From 8d10fed0f7bceac796cdfe2eba8d1fb60cb4a12c Mon Sep 17 00:00:00 2001 From: sangier <45793271+sangier@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:05:15 +0200 Subject: [PATCH 001/172] Cherry-pick: Add MsgRegisterCounterparty Struct and Handler from ibc-lite (#6982) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(lite): counterparty client logic (#6307) * imp: added counterparty client store * imp: added provide counterparty to proto * imp: ran 'make proto-all' * imp: added logic to counterparty client * imp: fix proto * imp: fix proto * imp: ran 'make proto-all' * feat: finished counterparty client logic * change counterparty to include custom prefix * fix imports * import fixes, review suggestions * rm lite comment * applying review suggestions * add creator tests * addressing aditya review * Update proto/ibc/core/client/v1/client.proto Co-authored-by: DimitrisJim * Update modules/core/02-client/types/msgs.go Co-authored-by: DimitrisJim * Update modules/core/keeper/msg_server.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * addressing jim review * refactor(proto): use counterparty type in MsgProvideCounterparty. Validate Counterparty type. * refactor(keys): move Counterparty key to 02-client keys.go * feat(core): delete creator after registering counterparty. * chore(core): make GetCreator return a boolean if not found. * tests(02-client): add tests for counterparty validation. * tests(02-client): add tests for msg_server provide counterparty handler. * nit(core): remove stale key for counterparty in host. * Update modules/core/02-client/keeper/keeper_test.go --------- Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com> Co-authored-by: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> Co-authored-by: Stefano Angieri Co-authored-by: DimitrisJim Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/core/02-client/keeper/keeper.go | 39 ++ modules/core/02-client/keeper/keeper_test.go | 37 ++ modules/core/02-client/types/client.go | 22 + modules/core/02-client/types/client.pb.go | 300 +++++++++-- modules/core/02-client/types/client_test.go | 45 ++ modules/core/02-client/types/codec.go | 1 + modules/core/02-client/types/errors.go | 1 + modules/core/02-client/types/keys.go | 10 + modules/core/02-client/types/msgs.go | 31 ++ modules/core/02-client/types/tx.pb.go | 535 +++++++++++++++++-- modules/core/keeper/msg_server.go | 27 +- modules/core/keeper/msg_server_test.go | 74 +++ proto/ibc/core/client/v1/client.proto | 9 + proto/ibc/core/client/v1/tx.proto | 22 + 14 files changed, 1064 insertions(+), 89 deletions(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 02bc0e9e18f..568143526c2 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -322,6 +322,45 @@ func (k *Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) return k.consensusHost.GetSelfConsensusState(ctx, height) } +// SetCounterparty sets the Counterparty for a given client identifier. +func (k *Keeper) SetCounterparty(ctx sdk.Context, clientID string, counterparty types.Counterparty) { + bz := k.cdc.MustMarshal(&counterparty) + k.ClientStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) +} + +// GetCounterparty gets the counterparty client's identifier for a given client identifier. +func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { + store := k.ClientStore(ctx, clientID) + bz := store.Get([]byte(types.CounterpartyKey)) + if len(bz) == 0 { + return types.Counterparty{}, false + } + + var counterparty types.Counterparty + k.cdc.MustUnmarshal(bz, &counterparty) + return counterparty, true +} + +// GetCreator returns the creator of the client. +func (k *Keeper) GetCreator(ctx sdk.Context, clientID string) (string, bool) { + bz := k.ClientStore(ctx, clientID).Get([]byte(types.CreatorKey)) + if len(bz) == 0 { + return "", false + } + + return string(bz), true +} + +// SetCreator sets the creator of the client. +func (k *Keeper) SetCreator(ctx sdk.Context, clientID, creator string) { + k.ClientStore(ctx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) +} + +// DeleteCreator deletes the creator associated with the client. +func (k *Keeper) DeleteCreator(ctx sdk.Context, clientID string) { + k.ClientStore(ctx, clientID).Delete([]byte(types.CreatorKey)) +} + // ValidateSelfClient validates the client parameters for a client of the running chain. // This function is only used to validate the client state the counterparty stores for this chain. // NOTE: If the client type is not of type Tendermint then delegate to a custom client validator function. diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 7e4005bda45..54b5698e1e6 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -129,6 +129,43 @@ func (suite *KeeperTestSuite) TestSetClientState() { suite.Require().Equal(clientState, retrievedState, "Client states are not equal") } +func (suite *KeeperTestSuite) TestSetCounterparty() { + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + counterparty := types.Counterparty{ + ClientId: testClientID, + MerklePathPrefix: &merklePathPrefix, + } + suite.keeper.SetCounterparty(suite.ctx, testClientID, counterparty) + + retrievedCounterparty, found := suite.keeper.GetCounterparty(suite.ctx, testClientID) + suite.Require().True(found, "GetCounterparty does not return counterparty") + suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") + + retrievedCounterparty, found = suite.keeper.GetCounterparty(suite.ctx, "client-0") + suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") + suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") +} + +func (suite *KeeperTestSuite) TestSetCreator() { + clientID := "test-client" + expectedCreator := "test-creator" + + // Set the creator for the client + suite.keeper.SetCreator(suite.ctx, clientID, expectedCreator) + + // Retrieve the creator from the store + retrievedCreator, found := suite.keeper.GetCreator(suite.ctx, clientID) + + // Verify that the retrieved creator matches the expected creator + suite.Require().True(found, "GetCreator did not return stored creator") + suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") + + // Verify non stored creator is not found + retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, "client-0") + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Equal(retrievedCreator, "", "Creator is not empty") +} + func (suite *KeeperTestSuite) TestSetClientConsensusState() { suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index 993f43d570a..e56e4517b34 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -13,6 +13,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -71,6 +72,27 @@ func (ics IdentifiedClientStates) Sort() IdentifiedClientStates { return ics } +// NewCounterparty creates a new Counterparty instance +func NewCounterparty(clientID string, merklePathPrefix *commitmenttypes.MerklePath) Counterparty { + return Counterparty{ + ClientId: clientID, + MerklePathPrefix: merklePathPrefix, + } +} + +// Validate validates the Counterparty +func (c Counterparty) Validate() error { + if err := host.ClientIdentifierValidator(c.ClientId); err != nil { + return err + } + + if c.MerklePathPrefix.Empty() { + return errorsmod.Wrap(ErrInvalidCounterparty, "counterparty prefix cannot be empty") + } + + return nil +} + // NewConsensusStateWithHeight creates a new ConsensusStateWithHeight instance func NewConsensusStateWithHeight(height Height, consensusState exported.ConsensusState) ConsensusStateWithHeight { msg, ok := consensusState.(proto.Message) diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 63653c7590a..df4d34a82b9 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -8,6 +8,7 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" io "io" math "math" math_bits "math/bits" @@ -192,6 +193,61 @@ func (m *ClientConsensusStates) GetConsensusStates() []ConsensusStateWithHeight return nil } +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +type Counterparty struct { + // the client identifier of the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the merkle path that all ICS24 paths will be stored under + MerklePathPrefix *v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix,omitempty"` +} + +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_b6bc4c8185546947, []int{3} +} +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 + +func (m *Counterparty) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *Counterparty) GetMerklePathPrefix() *v2.MerklePath { + if m != nil { + return m.MerklePathPrefix + } + return nil +} + // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients @@ -212,7 +268,7 @@ type Height struct { func (m *Height) Reset() { *m = Height{} } func (*Height) ProtoMessage() {} func (*Height) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{3} + return fileDescriptor_b6bc4c8185546947, []int{4} } func (m *Height) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -253,7 +309,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{4} + return fileDescriptor_b6bc4c8185546947, []int{5} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,6 +349,7 @@ func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") proto.RegisterType((*ClientConsensusStates)(nil), "ibc.core.client.v1.ClientConsensusStates") + proto.RegisterType((*Counterparty)(nil), "ibc.core.client.v1.Counterparty") proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height") proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params") } @@ -300,35 +357,39 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 439 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0xce, 0x74, 0x97, 0xb2, 0x9d, 0x4a, 0x2b, 0x61, 0x17, 0x62, 0x85, 0xb4, 0xe4, 0x62, 0x0e, - 0xee, 0x8c, 0x8d, 0x07, 0x57, 0xc1, 0x83, 0xbb, 0x17, 0xf7, 0x22, 0x12, 0x0f, 0x82, 0x20, 0x25, - 0x99, 0xcc, 0x26, 0x03, 0xc9, 0xcc, 0x92, 0x99, 0x44, 0xfa, 0x1f, 0x78, 0x14, 0xbc, 0x78, 0xdc, - 0x3f, 0x67, 0x8f, 0x3d, 0x7a, 0x12, 0x69, 0xff, 0x11, 0xc9, 0xcc, 0x14, 0x89, 0xbf, 0xf0, 0xf6, - 0xf2, 0xbd, 0x2f, 0xdf, 0xfb, 0xde, 0x37, 0x0f, 0xce, 0x59, 0x4a, 0x30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, 0x1c, 0x84, 0xe3, 0xe8, 0xe1, 0x9f, 0x9c, 0xff, 0x6d, 0x6f, 0xbb, 0xcb, 0xb4, 0x6f, 0x4a, - 0x06, 0x19, 0x1c, 0xda, 0x60, 0x1e, 0xc0, 0x69, 0x4d, 0x5b, 0x26, 0x99, 0xe0, 0x2b, 0xde, 0x54, - 0x29, 0xad, 0xb5, 0x97, 0xc3, 0x78, 0xb2, 0x87, 0x5f, 0x69, 0xb4, 0x47, 0xb4, 0x51, 0x0e, 0xfa, - 0x44, 0xa3, 0xf8, 0xec, 0xe8, 0xe3, 0xcd, 0xdc, 0xf9, 0x72, 0x33, 0x77, 0x82, 0x25, 0x1c, 0xbe, - 0x4e, 0xea, 0xa4, 0x92, 0xdd, 0xcf, 0x49, 0x59, 0x8a, 0x0f, 0x34, 0x5b, 0x19, 0xd3, 0xd2, 0x03, - 0x8b, 0x83, 0x70, 0x14, 0x4f, 0x2c, 0x6c, 0x22, 0x92, 0xe7, 0xf1, 0xed, 0xd6, 0x07, 0x9b, 0xad, - 0x0f, 0xbe, 0x6f, 0x7d, 0xf0, 0x69, 0xe7, 0x3b, 0x9b, 0x9d, 0xef, 0x7c, 0xdd, 0xf9, 0xce, 0xbb, - 0xb3, 0x9c, 0xa9, 0xa2, 0x49, 0x11, 0x11, 0x15, 0x26, 0x42, 0x56, 0x42, 0x62, 0x96, 0x92, 0xd3, - 0x5c, 0xe0, 0xf6, 0x29, 0xae, 0x44, 0xd6, 0x94, 0x54, 0x9a, 0x9b, 0x7e, 0x14, 0x9d, 0xda, 0xb3, - 0x56, 0xeb, 0x6b, 0x2a, 0xd3, 0xa1, 0x7e, 0xa0, 0xc7, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf5, - 0xca, 0xb7, 0xeb, 0xf6, 0x02, 0x00, 0x00, + // 510 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0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90, 0xdf, 0xf7, 0x06, 0x5b, 0xf8, 0x85, + 0x40, 0x5b, 0x44, 0x75, 0xc9, 0x4e, 0x9b, 0x28, 0x3b, 0x3e, 0x3e, 0xf8, 0x78, 0x35, 0xd6, 0xbe, + 0x5c, 0x8d, 0x35, 0x7b, 0x06, 0xba, 0x8b, 0xa0, 0x0c, 0x08, 0x6b, 0x8a, 0x83, 0x2c, 0xa3, 0xef, + 0x50, 0xec, 0xcb, 0xa9, 0x98, 0xa9, 0x4f, 0xf6, 0xa6, 0x3d, 0x6f, 0xa0, 0x60, 0x79, 0x21, 0x76, + 0xe1, 0x5d, 0xaf, 0x2d, 0xfd, 0x66, 0x6d, 0xe9, 0xdf, 0xd7, 0x96, 0xfe, 0x69, 0x63, 0x69, 0x37, + 0x1b, 0x4b, 0xfb, 0xba, 0xb1, 0xb4, 0xd7, 0xe7, 0x09, 0xe6, 0x69, 0x15, 0x36, 0x53, 0xc2, 0x88, + 0x32, 0x42, 0x19, 0xc4, 0x61, 0x74, 0x96, 0x50, 0x58, 0x3f, 0x82, 0x84, 0xc6, 0x55, 0x86, 0x98, + 0x7c, 0x15, 0xf7, 0xdd, 0x33, 0xf5, 0xfc, 0xf8, 0xaa, 0x40, 0x2c, 0xec, 0x8a, 0xff, 0xe3, 0xc1, + 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x53, 0xb6, 0xa5, 0x5c, 0x9e, 0x03, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -462,6 +523,48 @@ func (m *ClientConsensusStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 m.MerklePathPrefix != nil { + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintClient(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Height) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -589,6 +692,23 @@ func (m *ClientConsensusStates) Size() (n int) { 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 + sovClient(uint64(l)) + } + if m.MerklePathPrefix != nil { + l = m.MerklePathPrefix.Size() + n += 1 + l + sovClient(uint64(l)) + } + return n +} + func (m *Height) Size() (n int) { if m == nil { return 0 @@ -978,6 +1098,124 @@ func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowClient + } + 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 ErrIntOverflowClient + } + 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 ErrInvalidLengthClient + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + 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 MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MerklePathPrefix == nil { + m.MerklePathPrefix = &v2.MerklePath{} + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Height) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 43b5b1c7f58..21769232cb1 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -6,6 +6,8 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -86,3 +88,46 @@ func TestValidateClientType(t *testing.T) { } } } + +func TestValidateCounterparty(t *testing.T) { + testCases := []struct { + name string + clientID string + merklePathPrefix commitmenttypes.MerklePath + expError error + }{ + { + "success", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc")), + nil, + }, + { + "failure: invalid client id", + "", + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: empty merkle path prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath(), + types.ErrInvalidCounterparty, + }, + } + + for _, tc := range testCases { + tc := tc + + counterparty := types.NewCounterparty(tc.clientID, &tc.merklePathPrefix) + err := counterparty.Validate() + + expPass := tc.expError == nil + if expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + require.ErrorIs(t, err, tc.expError) + } + } +} diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index 082970cd598..9e239c83564 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -45,6 +45,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgRecoverClient{}, &MsgIBCSoftwareUpgrade{}, &MsgUpdateParams{}, + &MsgProvideCounterparty{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index 62d906bc40c..b3771efdd8e 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -38,4 +38,5 @@ var ( ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty identifier") ) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index e0c23c96aaa..29604c2816e 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -32,6 +32,16 @@ const ( // AllowAllClients is the value that if set in AllowedClients param // would allow any wired up light client modules to be allowed AllowAllClients = "*" + + // CreatorKey is the key used to store the client creator in the client store + // the creator key is imported from types instead of host because + // the creator key is not a part of the ics-24 host specification + CreatorKey = "creator" + + // CounterpartyKey is the key used to store counterparty in the client store. + // the counterparty key is imported from types instead of host because + // the counterparty key is not a part of the ics-24 host specification + CounterpartyKey = "counterparty" ) // FormatClientIdentifier returns the client identifier with the sequence appended. diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index e35b7bbbaad..e8e0d100555 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -7,6 +7,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -20,6 +21,7 @@ var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.Msg = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.Msg = (*MsgRecoverClient)(nil) + _ sdk.Msg = (*MsgProvideCounterparty)(nil) _ sdk.HasValidateBasic = (*MsgCreateClient)(nil) _ sdk.HasValidateBasic = (*MsgUpdateClient)(nil) @@ -28,6 +30,7 @@ var ( _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.HasValidateBasic = (*MsgRecoverClient)(nil) + _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -265,6 +268,34 @@ func (msg *MsgRecoverClient) ValidateBasic() error { return nil } +// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance +func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix *commitmenttypes.MerklePath) *MsgProvideCounterparty { + counterparty := NewCounterparty(counterpartyID, merklePathPrefix) + + return &MsgProvideCounterparty{ + Signer: signer, + ClientId: clientID, + Counterparty: counterparty, + } +} + +// ValidateBasic performs basic checks on a MsgProvideCounterparty. +func (msg *MsgProvideCounterparty) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + return err + } + + if err := msg.Counterparty.Validate(); err != nil { + return err + } + + return nil +} + // NewMsgIBCSoftwareUpgrade creates a new MsgIBCSoftwareUpgrade instance func NewMsgIBCSoftwareUpgrade(signer string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*MsgIBCSoftwareUpgrade, error) { anyClient, err := PackClientState(upgradedClientState) diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index 5a22491005e..fdca53cd3c9 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -448,6 +448,88 @@ func (m *MsgRecoverClientResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRecoverClientResponse proto.InternalMessageInfo +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +type MsgProvideCounterparty struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // counterparty client + Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } +func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterparty) ProtoMessage() {} +func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{10} +} +func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +} +func (m *MsgProvideCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +type MsgProvideCounterpartyResponse struct { +} + +func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } +func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterpartyResponse) ProtoMessage() {} +func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{11} +} +func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +} +func (m *MsgProvideCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo + // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal type MsgIBCSoftwareUpgrade struct { Plan types1.Plan `protobuf:"bytes,1,opt,name=plan,proto3" json:"plan"` @@ -468,7 +550,7 @@ func (m *MsgIBCSoftwareUpgrade) Reset() { *m = MsgIBCSoftwareUpgrade{} } func (m *MsgIBCSoftwareUpgrade) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgrade) ProtoMessage() {} func (*MsgIBCSoftwareUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{10} + return fileDescriptor_cb5dc4651eb49a04, []int{12} } func (m *MsgIBCSoftwareUpgrade) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -526,7 +608,7 @@ func (m *MsgIBCSoftwareUpgradeResponse) Reset() { *m = MsgIBCSoftwareUpg func (m *MsgIBCSoftwareUpgradeResponse) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgradeResponse) ProtoMessage() {} func (*MsgIBCSoftwareUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{11} + return fileDescriptor_cb5dc4651eb49a04, []int{13} } func (m *MsgIBCSoftwareUpgradeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -569,7 +651,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{12} + return fileDescriptor_cb5dc4651eb49a04, []int{14} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -606,7 +688,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{13} + return fileDescriptor_cb5dc4651eb49a04, []int{15} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -646,6 +728,8 @@ func init() { proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") proto.RegisterType((*MsgRecoverClient)(nil), "ibc.core.client.v1.MsgRecoverClient") proto.RegisterType((*MsgRecoverClientResponse)(nil), "ibc.core.client.v1.MsgRecoverClientResponse") + proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.client.v1.MsgProvideCounterparty") + proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.client.v1.MsgProvideCounterpartyResponse") proto.RegisterType((*MsgIBCSoftwareUpgrade)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgrade") proto.RegisterType((*MsgIBCSoftwareUpgradeResponse)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgradeResponse") proto.RegisterType((*MsgUpdateParams)(nil), "ibc.core.client.v1.MsgUpdateParams") @@ -655,59 +739,63 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 819 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0x8e, 0xd3, 0x34, 0xa2, 0xd7, 0xb4, 0xa1, 0x47, 0x4a, 0x53, 0x97, 0x26, 0x55, 0xe8, 0x50, - 0x0a, 0xb5, 0x9b, 0x22, 0x41, 0x29, 0x30, 0xb4, 0x59, 0xe8, 0x10, 0xa9, 0x72, 0xc5, 0xc2, 0x92, - 0xda, 0xce, 0xc5, 0x35, 0x8a, 0x7d, 0x96, 0xef, 0x1c, 0xe8, 0x86, 0x98, 0x18, 0x19, 0x58, 0xd8, - 0xf8, 0x09, 0x15, 0x3f, 0x80, 0x0d, 0xa9, 0x63, 0x47, 0x26, 0x84, 0xda, 0xa1, 0x12, 0xbf, 0x02, - 0xd9, 0x77, 0x49, 0x6d, 0x27, 0x36, 0x41, 0x6c, 0xb1, 0xdf, 0xf7, 0xee, 0x7d, 0xdf, 0xbb, 0xf7, - 0xbe, 0x18, 0x2c, 0x99, 0x9a, 0x2e, 0xeb, 0xd8, 0x45, 0xb2, 0xde, 0x35, 0x91, 0x4d, 0xe5, 0x5e, - 0x5d, 0xa6, 0x6f, 0x25, 0xc7, 0xc5, 0x14, 0x43, 0x68, 0x6a, 0xba, 0xe4, 0x07, 0x25, 0x16, 0x94, - 0x7a, 0x75, 0x71, 0x41, 0xc7, 0xc4, 0xc2, 0x44, 0xb6, 0x88, 0xe1, 0x63, 0x2d, 0x62, 0x30, 0xb0, - 0xb8, 0xca, 0x03, 0x9e, 0x63, 0xb8, 0x6a, 0x1b, 0xc9, 0xbd, 0xba, 0x86, 0xa8, 0x5a, 0xef, 0x3f, - 0x73, 0x54, 0xc9, 0xc0, 0x06, 0x0e, 0x7e, 0xca, 0xfe, 0x2f, 0xfe, 0x76, 0xd1, 0xc0, 0xd8, 0xe8, - 0x22, 0x39, 0x78, 0xd2, 0xbc, 0x8e, 0xac, 0xda, 0x27, 0x3c, 0x54, 0x1d, 0x41, 0x90, 0xb3, 0x09, - 0x00, 0xb5, 0xaf, 0x02, 0x28, 0x36, 0x89, 0xd1, 0x70, 0x91, 0x4a, 0x51, 0x23, 0x88, 0xc0, 0xc7, - 0xa0, 0xc0, 0x30, 0x2d, 0x42, 0x55, 0x8a, 0xca, 0xc2, 0x8a, 0xb0, 0x36, 0xbd, 0x55, 0x92, 0x58, - 0x19, 0xa9, 0x5f, 0x46, 0xda, 0xb5, 0x4f, 0x94, 0x69, 0x86, 0x3c, 0xf4, 0x81, 0xf0, 0x39, 0x28, - 0xea, 0xd8, 0x26, 0xc8, 0x26, 0x1e, 0xe1, 0xb9, 0xd9, 0x94, 0xdc, 0xd9, 0x01, 0x98, 0xa5, 0xdf, - 0x06, 0x79, 0x62, 0x1a, 0x36, 0x72, 0xcb, 0x13, 0x2b, 0xc2, 0xda, 0x94, 0xc2, 0x9f, 0x76, 0x8a, - 0x1f, 0xbe, 0x54, 0x33, 0xef, 0xaf, 0x4e, 0xd7, 0xf9, 0x8b, 0xda, 0x33, 0xb0, 0x10, 0xe3, 0xac, - 0x20, 0xe2, 0xf8, 0x87, 0xc1, 0x25, 0x30, 0xc5, 0xb9, 0x9b, 0xed, 0x80, 0xf8, 0x94, 0x72, 0x83, - 0xbd, 0xd8, 0x6f, 0xef, 0xe4, 0xfc, 0x83, 0x6a, 0x9f, 0x98, 0xe4, 0x97, 0x4e, 0xfb, 0x5a, 0x72, - 0x5a, 0x1a, 0x7c, 0x0a, 0x66, 0x79, 0xd0, 0x42, 0x84, 0xa8, 0x46, 0xba, 0xaa, 0x19, 0x86, 0x6d, - 0x32, 0xe8, 0xf8, 0xa2, 0x16, 0x03, 0x51, 0x61, 0x56, 0x7d, 0x51, 0xb5, 0xef, 0x59, 0x70, 0x33, - 0x88, 0x05, 0x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0x31, 0x7b, 0x94, 0xfa, 0x76, 0xc8, 0xed, - 0x51, 0x3a, 0xe8, 0xaa, 0xf6, 0x5e, 0xee, 0xec, 0x67, 0x35, 0xa3, 0x04, 0x78, 0xf8, 0x02, 0xcc, - 0x73, 0x4c, 0xbb, 0x35, 0xf6, 0x06, 0xdc, 0xea, 0xa7, 0x34, 0x42, 0x9b, 0x90, 0x24, 0x70, 0x3a, - 0x2c, 0x8e, 0xdd, 0xcc, 0x30, 0xff, 0x81, 0x42, 0x1a, 0xf2, 0x9a, 0x03, 0xd5, 0x55, 0x2d, 0x12, - 0x3a, 0x58, 0x08, 0x1f, 0x0c, 0xb7, 0x41, 0xde, 0x09, 0x10, 0x9c, 0xab, 0x28, 0x0d, 0xff, 0x81, - 0x48, 0xec, 0x0c, 0x2e, 0x99, 0xe3, 0xd3, 0xbd, 0x84, 0x65, 0xf4, 0x09, 0x6d, 0xfd, 0x9e, 0x04, - 0x13, 0x4d, 0x62, 0xc0, 0x23, 0x50, 0x88, 0x98, 0xfe, 0xdd, 0x51, 0xd5, 0x62, 0x2e, 0x2b, 0xde, - 0x1f, 0x03, 0x34, 0xb0, 0xe2, 0x23, 0x50, 0x88, 0x78, 0x6c, 0x52, 0x85, 0x30, 0x28, 0xb1, 0xc2, - 0x28, 0x5f, 0x84, 0x3a, 0x98, 0x89, 0x9a, 0xc9, 0x6a, 0x62, 0x76, 0x08, 0x25, 0x3e, 0x18, 0x07, - 0x35, 0x28, 0xe2, 0x02, 0x38, 0xc2, 0x14, 0xee, 0x25, 0x9c, 0x31, 0x0c, 0x15, 0xeb, 0x63, 0x43, - 0xc3, 0xc2, 0xa2, 0xbb, 0x9c, 0x24, 0x2c, 0x82, 0x4a, 0x14, 0x36, 0x72, 0xf9, 0x7c, 0x61, 0x23, - 0x16, 0x2f, 0x49, 0xd8, 0x30, 0x34, 0x51, 0x58, 0xf2, 0x3a, 0xc0, 0x0e, 0x80, 0xe1, 0x9b, 0xe4, - 0x1b, 0x91, 0x3e, 0x19, 0x0c, 0xf4, 0x97, 0xc9, 0x88, 0x4e, 0xb9, 0x38, 0xf9, 0xee, 0xea, 0x74, - 0x5d, 0xd8, 0x53, 0xce, 0x2e, 0x2a, 0xc2, 0xf9, 0x45, 0x45, 0xf8, 0x75, 0x51, 0x11, 0x3e, 0x5e, - 0x56, 0x32, 0xe7, 0x97, 0x95, 0xcc, 0x8f, 0xcb, 0x4a, 0xe6, 0xd5, 0xb6, 0x61, 0xd2, 0x63, 0x4f, - 0x93, 0x74, 0x6c, 0xc9, 0xfc, 0xd3, 0xcb, 0xd4, 0xf4, 0x0d, 0x03, 0xcb, 0xbd, 0x27, 0xb2, 0x85, - 0xdb, 0x5e, 0x17, 0x11, 0xf6, 0xe1, 0xb4, 0xb9, 0xb5, 0xc1, 0xbf, 0x9d, 0xe8, 0x89, 0x83, 0x88, - 0x96, 0x0f, 0xac, 0xe3, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xa7, 0x07, 0xfb, 0xfc, - 0x09, 0x00, 0x00, + // 886 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x73, 0xe3, 0x44, + 0x14, 0xb6, 0x1c, 0x9f, 0x87, 0x6c, 0x7c, 0x67, 0x6e, 0xcf, 0x77, 0xe7, 0xd3, 0x71, 0xb6, 0xc7, + 0x5c, 0x11, 0x0c, 0x91, 0x62, 0x33, 0x03, 0x21, 0x40, 0x91, 0xb8, 0x21, 0xcc, 0x78, 0x26, 0xa3, + 0x0c, 0x0d, 0x8d, 0x23, 0xc9, 0x6b, 0x45, 0x8c, 0xa5, 0xd5, 0x68, 0x57, 0x06, 0x77, 0x0c, 0x15, + 0x25, 0x05, 0x0d, 0x1d, 0x35, 0x55, 0x86, 0x1f, 0x40, 0xc7, 0x4c, 0xca, 0x94, 0x54, 0x0c, 0x24, + 0x45, 0xfe, 0x06,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0x46, 0x27, 0x90, 0xb9, 0x83, 0xf1, 0x38, 0xc5, 0xba, 0x2d, 0xf5, 0xbb, 0xe0, 0x55, 0x26, 0x35, + 0x91, 0x7c, 0x38, 0x20, 0x1a, 0x32, 0xf1, 0x12, 0xf9, 0xbc, 0xb3, 0x03, 0xf0, 0x98, 0x04, 0xc6, + 0x57, 0xc8, 0xa4, 0xd3, 0x34, 0xff, 0x26, 0x0f, 0x8c, 0xd7, 0x32, 0xf6, 0x41, 0x8b, 0x04, 0x06, + 0xa1, 0x36, 0x0d, 0x28, 0x12, 0xe0, 0xd5, 0x08, 0x0e, 0xef, 0x63, 0x71, 0x46, 0xe9, 0xb9, 0x66, + 0x4d, 0x4f, 0x50, 0x8b, 0x79, 0xff, 0x22, 0x81, 0x67, 0x13, 0x62, 0x9d, 0xfa, 0x78, 0x69, 0x87, + 0xdb, 0x1a, 0xb8, 0x14, 0xf9, 0x9e, 0xee, 0xd3, 0x55, 0x71, 0xd7, 0x3f, 0x07, 0x0d, 0x53, 0x00, + 0xf3, 0xae, 0xf7, 0x94, 0x4d, 0xc7, 0x55, 0xc4, 0xa2, 0xc7, 0xb5, 0xab, 0x3f, 0xbb, 0x15, 0x2d, + 0x91, 0x5b, 0x5e, 0x48, 0x0f, 0x74, 0xb2, 0xb9, 0xc6, 0x72, 0x7e, 0x63, 0x33, 0x74, 0x72, 0x3c, + 0x3e, 0xc3, 0x73, 0xfa, 0xb5, 0xee, 0x23, 0x3e, 0x6b, 0xf0, 0x03, 0x50, 0xf3, 0x16, 0xba, 0xcb, + 0xad, 0xf4, 0x2d, 0x85, 0xb9, 0xbd, 0xb2, 0x76, 0x77, 0xee, 0xf6, 0xca, 0xe9, 0x42, 0x77, 0x39, + 0xc9, 0x08, 0x0f, 0x3f, 0x03, 0x4f, 0x39, 0x66, 0x36, 0x2d, 0x7d, 0xa0, 0x9f, 0xac, 0x53, 0xc6, + 0xc2, 0xc1, 0xce, 0x93, 0xb9, 0x23, 0x4a, 0x64, 0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0xe9, + 0x48, 0x3f, 0xdc, 0x76, 0x2a, 0xd7, 0xb7, 0x9d, 0xca, 0x1f, 0xb7, 0x9d, 0xca, 0x97, 0x07, 0x96, + 0x4d, 0x2f, 0x02, 0x43, 0x31, 0xb1, 0xa3, 0xf2, 0x1f, 0x58, 0xdb, 0x30, 0xf7, 0x2c, 0xac, 0x2e, + 0x3f, 0x52, 0x1d, 0x3c, 0x0b, 0x16, 0x88, 0xb0, 0xdf, 0xcf, 0xfd, 0xd1, 0x1e, 0xff, 0x03, 0xa5, + 0x2b, 0x0f, 0x11, 0xa3, 0x1e, 0x39, 0xd6, 0xfb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xa4, + 0xb8, 0x24, 0x42, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -732,6 +820,8 @@ type MsgClient interface { SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(ctx context.Context, in *MsgRecoverClient, opts ...grpc.CallOption) (*MsgRecoverClientResponse, error) + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -791,6 +881,15 @@ func (c *msgClient) RecoverClient(ctx context.Context, in *MsgRecoverClient, opt return out, nil } +func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { + out := new(MsgProvideCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/ProvideCounterparty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) { out := new(MsgIBCSoftwareUpgradeResponse) err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/IBCSoftwareUpgrade", in, out, opts...) @@ -821,6 +920,8 @@ type MsgServer interface { SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(context.Context, *MsgRecoverClient) (*MsgRecoverClientResponse, error) + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(context.Context, *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -846,6 +947,9 @@ func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) RecoverClient(ctx context.Context, req *MsgRecoverClient) (*MsgRecoverClientResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecoverClient not implemented") } +func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") +} func (*UnimplementedMsgServer) IBCSoftwareUpgrade(ctx context.Context, req *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IBCSoftwareUpgrade not implemented") } @@ -947,6 +1051,24 @@ func _Msg_RecoverClient_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgProvideCounterparty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ProvideCounterparty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/ProvideCounterparty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_IBCSoftwareUpgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgIBCSoftwareUpgrade) if err := dec(in); err != nil { @@ -1007,6 +1129,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RecoverClient", Handler: _Msg_RecoverClient_Handler, }, + { + MethodName: "ProvideCounterparty", + Handler: _Msg_ProvideCounterparty_Handler, + }, { MethodName: "IBCSoftwareUpgrade", Handler: _Msg_IBCSoftwareUpgrade_Handler, @@ -1413,6 +1539,76 @@ func (m *MsgRecoverClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *MsgProvideCounterparty) 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 *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterparty) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgProvideCounterpartyResponse) 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 *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgIBCSoftwareUpgrade) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1728,6 +1924,34 @@ func (m *MsgRecoverClientResponse) Size() (n int) { return n } +func (m *MsgProvideCounterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgProvideCounterpartyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgIBCSoftwareUpgrade) Size() (n int) { if m == nil { return 0 @@ -2922,6 +3146,203 @@ func (m *MsgRecoverClientResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgProvideCounterparty) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterparty: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgProvideCounterpartyResponse) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterpartyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgIBCSoftwareUpgrade) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 173706e4b21..848f65c2ddd 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -43,7 +43,9 @@ func (k *Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateC return nil, err } - return &clienttypes.MsgCreateClientResponse{ClientId: clientID}, nil + k.ClientKeeper.SetCreator(ctx, clientID, msg.Signer) + + return &clienttypes.MsgCreateClientResponse{}, nil } // UpdateClient defines a rpc handler method for MsgUpdateClient. @@ -135,6 +137,29 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI return &clienttypes.MsgIBCSoftwareUpgradeResponse{}, nil } +// ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. +func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.MsgProvideCounterparty) (*clienttypes.MsgProvideCounterpartyResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) + if !found { + return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "expected client creator to have been set") + } + + if creator != msg.Signer { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected client creator %s to match signer %s", creator, msg.Signer) + } + + if _, ok := k.ClientKeeper.GetCounterparty(ctx, msg.ClientId); ok { + return nil, errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) + } + k.ClientKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) + // Delete client creator from state as it is not needed after this point. + k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) + + return &clienttypes.MsgProvideCounterpartyResponse{}, nil +} + // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. func (k *Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 68d354786d7..839e519414b 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -17,6 +17,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -777,6 +778,79 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { } } +func (suite *KeeperTestSuite) TestProvideCounterparty() { + var ( + path *ibctesting.Path + msg *clienttypes.MsgProvideCounterparty + ) + cases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: unknown client identifier", + func() { + msg.ClientId = ibctesting.InvalidID + }, + ibcerrors.ErrUnauthorized, + }, + { + "failure: signer does not match creator", + func() { + msg.Signer = ibctesting.TestAccAddress + }, + ibcerrors.ErrUnauthorized, + }, + { + "failure: counterparty already exists", + func() { + // set it before handler + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) + }, + clienttypes.ErrInvalidCounterparty, + }, + } + + for _, tc := range cases { + tc := tc + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupClients() + + signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() + merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) + msg = clienttypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, &merklePrefix) + + tc.malleate() + + ctx := suite.chainA.GetContext() + resp, err := suite.chainA.App.GetIBCKeeper().ProvideCounterparty(ctx, msg) + + expPass := tc.expError == nil + if expPass { + suite.Require().NotNil(resp) + suite.Require().Nil(err) + + // Assert counterparty set and creator deleted + counterparty, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(found) + suite.Require().Equal(counterparty, msg.Counterparty) + + _, found = suite.chainA.App.GetIBCKeeper().ClientKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().False(found) + } else { + suite.Require().Nil(resp) + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + } +} + func (suite *KeeperTestSuite) TestUpgradeClient() { var ( path *ibctesting.Path diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index cc245a4f98f..5adbdde55c4 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -6,6 +6,7 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; +import "ibc/core/commitment/v2/commitment.proto"; // IdentifiedClientState defines a client state with an additional client // identifier field. @@ -34,6 +35,14 @@ message ClientConsensusStates { repeated ConsensusStateWithHeight consensus_states = 2 [(gogoproto.nullable) = false]; } +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +message Counterparty { + // the client identifier of the counterparty chain + string client_id = 1; + // the merkle path that all ICS24 paths will be stored under + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2; +} + // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 1e9e4f47ada..357c5a7d0a1 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -29,6 +29,9 @@ service Msg { // RecoverClient defines a rpc handler method for MsgRecoverClient. rpc RecoverClient(MsgRecoverClient) returns (MsgRecoverClientResponse); + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); + // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. rpc IBCSoftwareUpgrade(MsgIBCSoftwareUpgrade) returns (MsgIBCSoftwareUpgradeResponse); @@ -140,6 +143,25 @@ message MsgRecoverClient { // MsgRecoverClientResponse defines the Msg/RecoverClient response type. message MsgRecoverClientResponse {} +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +message MsgProvideCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1; + // counterparty client + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +message MsgProvideCounterpartyResponse {} + // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal message MsgIBCSoftwareUpgrade { option (cosmos.msg.v1.signer) = "signer"; From 15f33681bdd0cfb3cacd50ab36191ec0308296ae Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 1 Aug 2024 15:51:47 +0300 Subject: [PATCH 002/172] chore: move status checks from connection verify_* functions to 02-client verify_* functions. (#7006) --- modules/core/02-client/keeper/keeper.go | 8 ++ modules/core/02-client/keeper/keeper_test.go | 128 +++++++++++++++++++ modules/core/03-connection/keeper/verify.go | 41 ------ 3 files changed, 136 insertions(+), 41 deletions(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 568143526c2..c317e02be15 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -376,6 +376,10 @@ func (k *Keeper) VerifyMembership(ctx sdk.Context, clientID string, height expor return err } + if status := clientModule.Status(ctx, clientID); status != exported.Active { + return errorsmod.Wrapf(types.ErrClientNotActive, "cannot call verify membership on client (%s) with status %s", clientID, status) + } + return clientModule.VerifyMembership(ctx, clientID, height, delayTimePeriod, delayBlockPeriod, proof, path, value) } @@ -386,6 +390,10 @@ func (k *Keeper) VerifyNonMembership(ctx sdk.Context, clientID string, height ex return err } + if status := clientModule.Status(ctx, clientID); status != exported.Active { + return errorsmod.Wrapf(types.ErrClientNotActive, "cannot call verify non membership on client (%s) with status %s", clientID, status) + } + return clientModule.VerifyNonMembership(ctx, clientID, height, delayTimePeriod, delayBlockPeriod, proof, path) } diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 54b5698e1e6..79595e5c12d 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -502,6 +502,134 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { } } +func (suite *KeeperTestSuite) TestVerifyMembership() { + var path *ibctesting.Path + + cases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "invalid client id", + func() { + path.EndpointA.ClientID = "" + }, + host.ErrInvalidID, + }, + { + "failure: client is frozen", + func() { + clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState) + suite.Require().True(ok) + clientState.FrozenHeight = types.NewHeight(0, 1) + path.EndpointA.SetClientState(clientState) + }, + types.ErrClientNotActive, + }, + } + + for _, tc := range cases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + // create default proof, merklePath, and value which passes + key := host.FullClientStateKey(path.EndpointB.ClientID) + merklePath := commitmenttypes.NewMerklePath(key) + merklePrefixPath, err := commitmenttypes.ApplyPrefix(suite.chainB.GetPrefix(), merklePath) + suite.Require().NoError(err) + + proof, proofHeight := suite.chainB.QueryProof(key) + + clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState) + suite.Require().True(ok) + value, err := suite.chainB.Codec.MarshalInterface(clientState) + suite.Require().NoError(err) + + tc.malleate() + + err = suite.chainA.App.GetIBCKeeper().ClientKeeper.VerifyMembership(suite.chainA.GetContext(), path.EndpointA.ClientID, proofHeight, 0, 0, proof, merklePrefixPath, value) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + } else { + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestVerifyNonMembership() { + var path *ibctesting.Path + + cases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "invalid client id", + func() { + path.EndpointA.ClientID = "" + }, + host.ErrInvalidID, + }, + { + "failure: client is frozen", + func() { + clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState) + suite.Require().True(ok) + clientState.FrozenHeight = types.NewHeight(0, 1) + path.EndpointA.SetClientState(clientState) + }, + types.ErrClientNotActive, + }, + } + + for _, tc := range cases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + // create default proof, merklePath, and value which passes + key := host.FullClientStateKey("invalid-client-id") + + merklePath := commitmenttypes.NewMerklePath(key) + merklePrefixPath, err := commitmenttypes.ApplyPrefix(suite.chainB.GetPrefix(), merklePath) + suite.Require().NoError(err) + + proof, proofHeight := suite.chainB.QueryProof(key) + + tc.malleate() + + err = suite.chainA.App.GetIBCKeeper().ClientKeeper.VerifyNonMembership(suite.chainA.GetContext(), path.EndpointA.ClientID, proofHeight, 0, 0, proof, merklePrefixPath) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + } else { + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + // TestDefaultSetParams tests the default params set are what is expected func (suite *KeeperTestSuite) TestDefaultSetParams() { expParams := types.DefaultParams() diff --git a/modules/core/03-connection/keeper/verify.go b/modules/core/03-connection/keeper/verify.go index 34db455dc10..efd3b5a99c4 100644 --- a/modules/core/03-connection/keeper/verify.go +++ b/modules/core/03-connection/keeper/verify.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -25,10 +24,6 @@ func (k *Keeper) VerifyClientState( clientState exported.ClientState, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.FullClientStateKey(connection.Counterparty.ClientId)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { @@ -62,10 +57,6 @@ func (k *Keeper) VerifyClientConsensusState( consensusState exported.ConsensusState, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.FullConsensusStateKey(connection.Counterparty.ClientId, consensusHeight)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { @@ -99,10 +90,6 @@ func (k *Keeper) VerifyConnectionState( counterpartyConnection types.ConnectionEnd, // opposite connection ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.ConnectionKey(connectionID)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { @@ -137,10 +124,6 @@ func (k *Keeper) VerifyChannelState( channel channeltypes.Channel, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.ChannelKey(portID, channelID)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { @@ -176,10 +159,6 @@ func (k *Keeper) VerifyPacketCommitment( commitmentBytes []byte, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - // get time and block delays timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) @@ -212,10 +191,6 @@ func (k *Keeper) VerifyPacketAcknowledgement( acknowledgement []byte, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - // get time and block delays timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) @@ -249,10 +224,6 @@ func (k *Keeper) VerifyPacketReceiptAbsence( sequence uint64, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - // get time and block delays timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) @@ -284,10 +255,6 @@ func (k *Keeper) VerifyNextSequenceRecv( nextSequenceRecv uint64, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - // get time and block delays timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) @@ -320,10 +287,6 @@ func (k *Keeper) VerifyChannelUpgradeError( errorReceipt channeltypes.ErrorReceipt, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeErrorKey(portID, channelID)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { @@ -357,10 +320,6 @@ func (k *Keeper) VerifyChannelUpgrade( upgrade channeltypes.Upgrade, ) error { clientID := connection.ClientId - if status := k.clientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeKey(portID, channelID)) merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) if err != nil { From 2ff4aa957c52ed32865da7707bfca951cfc2fbe2 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 1 Aug 2024 16:37:53 +0300 Subject: [PATCH 003/172] chore: split out packet handling rpcs (#7007) * chore: split out packet handling rpcs * add keeper, expected interfaces, merkle tweaks. * add verify functions of client keeper. * self review --- modules/core/04-channel/types/codec.go | 1 + modules/core/04-channel/types/tx.pb.go | 514 ++++++++++-------- modules/core/keeper/msg_server.go | 7 +- modules/core/module.go | 2 + modules/core/packet-server/keeper/keeper.go | 21 + .../packet-server/types/expected_keepers.go | 46 ++ modules/core/packet-server/types/merkle.go | 27 + proto/ibc/core/channel/v1/tx.proto | 23 +- 8 files changed, 390 insertions(+), 251 deletions(-) create mode 100644 modules/core/packet-server/keeper/keeper.go create mode 100644 modules/core/packet-server/types/expected_keepers.go create mode 100644 modules/core/packet-server/types/merkle.go diff --git a/modules/core/04-channel/types/codec.go b/modules/core/04-channel/types/codec.go index 1b4fbef1493..dbe7ac6934f 100644 --- a/modules/core/04-channel/types/codec.go +++ b/modules/core/04-channel/types/codec.go @@ -41,6 +41,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &_PacketMsg_serviceDesc) } // SubModuleCdc references the global x/ibc/core/04-channel module codec. Note, the codec should diff --git a/modules/core/04-channel/types/tx.pb.go b/modules/core/04-channel/types/tx.pb.go index 71157b18e4b..87a92a47a61 100644 --- a/modules/core/04-channel/types/tx.pb.go +++ b/modules/core/04-channel/types/tx.pb.go @@ -1675,131 +1675,131 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1975 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcf, 0x6f, 0xdb, 0xc8, - 0x15, 0x36, 0xf5, 0x33, 0x7e, 0x4e, 0xd6, 0x0a, 0xe5, 0xc4, 0x32, 0x6d, 0x4b, 0x8a, 0x5a, 0x6c, - 0xbc, 0x6e, 0x22, 0xad, 0xbd, 0x49, 0x81, 0x04, 0x0b, 0xb4, 0x8e, 0xaa, 0x74, 0x0d, 0xc4, 0xb1, - 0x41, 0x59, 0x45, 0xbb, 0x5b, 0x54, 0x90, 0xa9, 0x09, 0x45, 0x48, 0x22, 0xb9, 0x24, 0xa5, 0x5d, - 0x17, 0x68, 0xb1, 0xe8, 0x29, 0xc8, 0x61, 0xd1, 0x02, 0x7b, 0x0d, 0xd0, 0xa2, 0xff, 0xc0, 0x9e, - 0xfb, 0xe3, 0xd0, 0xdb, 0x9e, 0x8a, 0x3d, 0x2e, 0x0a, 0x74, 0x51, 0x24, 0x87, 0xbd, 0xf4, 0x2f, - 0x28, 0x50, 0xa0, 0xe0, 0xcc, 0x90, 0xa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x32, 0x65, 0x11, 0x49, 0xc3, 0x93, 0x96, 0xd4, - 0x45, 0x16, 0xff, 0x00, 0x52, 0x3a, 0xfe, 0x85, 0xb9, 0x5b, 0xd9, 0xdf, 0x64, 0x96, 0x69, 0x02, - 0xa6, 0x13, 0xa4, 0x03, 0xf8, 0xb7, 0x20, 0x43, 0x08, 0x92, 0xb4, 0x7e, 0x5f, 0xb1, 0xfa, 0x48, - 0xb5, 0x30, 0xc9, 0x57, 0xc5, 0x55, 0xdc, 0x5e, 0x75, 0x9b, 0x03, 0x5c, 0xc6, 0xe7, 0xe3, 0x32, - 0x31, 0x39, 0x95, 0x7e, 0x81, 0xd7, 0xef, 0x68, 0x92, 0x6e, 0xe5, 0xfd, 0x01, 0xa4, 0x0c, 0x64, - 0x0e, 0x7a, 0x64, 0xb2, 0x6f, 0xec, 0xdf, 0x66, 0x4e, 0xd6, 0x81, 0x8b, 0x18, 0x7a, 0x7a, 0xae, - 0x23, 0x91, 0x0e, 0xa3, 0x15, 0xf8, 0xd3, 0x18, 0xc0, 0x91, 0x29, 0x9f, 0x2a, 0x7d, 0xa4, 0x0d, - 0x16, 0x43, 0xe1, 0x40, 0x35, 0x90, 0x84, 0x94, 0x21, 0x6a, 0x8f, 0x51, 0xd8, 0x70, 0x9b, 0x17, - 0x43, 0xe1, 0x1d, 0xe0, 0x55, 0xf4, 0xb1, 0xe5, 0xa6, 0x59, 0xd3, 0x40, 0xd2, 0x10, 0xd3, 0x99, - 0x10, 0x33, 0x76, 0x8f, 0x93, 0x5c, 0x36, 0x79, 0xd1, 0x8b, 0xca, 0x07, 0x78, 0x0b, 0x45, 0xf9, - 0x58, 0x34, 0xdb, 0xff, 0x21, 0xef, 0x3b, 0x6a, 0xfd, 0x58, 0xc5, 0x89, 0x7d, 0x49, 0xa4, 0x17, - 0x60, 0x85, 0xa6, 0xb8, 0xed, 0x94, 0xd6, 0x08, 0x52, 0x35, 0x48, 0x18, 0x0b, 0x29, 0x12, 0x6c, - 0x55, 0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 0xea, 0x3d, 0x4d, 0x37, 0xf9, 0x0e, 0x6c, - 0x32, 0x0b, 0x02, 0x95, 0x2a, 0x31, 0xa3, 0x54, 0x1b, 0x8c, 0xc2, 0x41, 0x00, 0xd3, 0x4b, 0x4f, - 0x72, 0x6a, 0xe9, 0xe1, 0xbf, 0x03, 0xd7, 0x68, 0xa9, 0xa5, 0xc7, 0xc6, 0x14, 0x5e, 0x8b, 0x64, - 0xf5, 0x51, 0x76, 0x47, 0x20, 0x47, 0xe1, 0xb4, 0x07, 0x44, 0x2d, 0x06, 0x96, 0xec, 0x95, 0xf9, - 0x96, 0xec, 0xf2, 0xe4, 0x84, 0xfc, 0x3b, 0x07, 0x5b, 0x2c, 0xfd, 0x2f, 0x3d, 0x1f, 0x3d, 0xe5, - 0x21, 0x3e, 0x4f, 0x79, 0xf8, 0x67, 0x8c, 0x91, 0xd0, 0xf3, 0x1c, 0x31, 0x1b, 0xbe, 0xa3, 0xa2, - 0xc3, 0x46, 0x3c, 0x32, 0x1b, 0x59, 0x46, 0xe2, 0x04, 0x13, 0x26, 0x11, 0x25, 0x61, 0x92, 0x11, - 0x12, 0xe6, 0xff, 0x7b, 0xf6, 0x44, 0x8c, 0x7c, 0xf1, 0x1c, 0x3f, 0x17, 0x55, 0xe5, 0xff, 0x1c, - 0x87, 0x5c, 0xc0, 0xcf, 0xbc, 0x47, 0xa6, 0x9f, 0x82, 0xc0, 0xbc, 0x2d, 0x30, 0xad, 0x96, 0x85, - 0x68, 0xda, 0x09, 0xcc, 0x78, 0xeb, 0x36, 0x42, 0xcc, 0x31, 0x2e, 0x13, 0x70, 0x4f, 0x68, 0x92, - 0x24, 0x16, 0x9c, 0x24, 0xc9, 0x28, 0x49, 0x92, 0x8a, 0x90, 0x24, 0xe9, 0xf9, 0x92, 0xe4, 0xca, - 0xe4, 0x24, 0x51, 0xa0, 0x18, 0x26, 0xde, 0xa2, 0x13, 0xe5, 0x93, 0x38, 0x63, 0x3b, 0x70, 0xac, - 0x23,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0x9c, 0x49, 0x77, 0x65, 0xad, 0x32, 0x7c, 0x50, 0xe9, - 0x6b, 0xed, 0x41, 0x0f, 0x99, 0xe4, 0x7f, 0x4d, 0x6f, 0xdf, 0xbb, 0xeb, 0xfc, 0xb5, 0xc9, 0x3a, - 0xd7, 0x91, 0x79, 0x96, 0xc2, 0x7f, 0x6b, 0x7a, 0xe7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5b, - 0x64, 0x1e, 0xc4, 0xa1, 0x25, 0x00, 0x00, + // 1983 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x6f, 0xdb, 0xc8, + 0x15, 0x37, 0xf5, 0x19, 0x3d, 0x27, 0x91, 0x43, 0x39, 0xb1, 0x4c, 0xdb, 0x92, 0xa2, 0x16, 0x8d, + 0xd7, 0x4d, 0xa4, 0xb5, 0x37, 0x5b, 0x20, 0xc1, 0x02, 0xad, 0xa3, 0x2a, 0x5d, 0x03, 0x71, 0x6c, + 0x50, 0x56, 0xd1, 0xee, 0x16, 0x15, 0x64, 0x6a, 0x42, 0x11, 0x92, 0x48, 0x2e, 0x49, 0x69, 0xd7, + 0x05, 0x5a, 0x2c, 0x7a, 0x0a, 0x72, 0x58, 0xb4, 0xc0, 0x5e, 0x03, 0xb4, 0xe8, 0x3f, 0xb0, 0xe8, + 0xb1, 0x1f, 0x87, 0xde, 0xf6, 0x50, 0x14, 0x7b, 0x5c, 0x14, 0xe8, 0xa2, 0x48, 0x0e, 0xfb, 0x3f, + 0x14, 0x28, 0x50, 0x70, 0x66, 0x48, 0x51, 0xe4, 0x50, 0xa2, 0x2d, 0xd5, 0xd8, 0x9b, 0x38, 0xf3, + 0x9b, 0x37, 0xf3, 0x7e, 0xbf, 0x37, 0x6f, 0xbe, 0x04, 0x9b, 0xca, 0xa9, 0x54, 0x95, 0x34, 0x03, + 0x55, 0xa5, 0x6e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, 0x26, 0xf9, 0xb3, 0xd3, + 0x9b, 0xf7, 0xef, 0x39, 0xff, 0x77, 0xb2, 0xce, 0x74, 0x64, 0x9e, 0xa6, 0xf0, 0x7f, 0x9d, 0xde, + 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xdf, 0x5a, 0xd6, 0xb6, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1827,14 +1827,8 @@ type MsgClient interface { // ChannelCloseConfirm defines a rpc handler method for // MsgChannelCloseConfirm. ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. @@ -1917,24 +1911,6 @@ func (c *msgClient) ChannelCloseConfirm(ctx context.Context, in *MsgChannelClose return out, nil } -func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { - out := new(MsgRecvPacketResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/RecvPacket", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { - out := new(MsgTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { out := new(MsgTimeoutOnCloseResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) @@ -1944,15 +1920,6 @@ func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, o return out, nil } -func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { - out := new(MsgAcknowledgementResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Acknowledgement", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) { out := new(MsgChannelUpgradeInitResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeInit", in, out, opts...) @@ -2049,14 +2016,8 @@ type MsgServer interface { // ChannelCloseConfirm defines a rpc handler method for // MsgChannelCloseConfirm. ChannelCloseConfirm(context.Context, *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. ChannelUpgradeInit(context.Context, *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. @@ -2099,18 +2060,9 @@ func (*UnimplementedMsgServer) ChannelCloseInit(ctx context.Context, req *MsgCha func (*UnimplementedMsgServer) ChannelCloseConfirm(ctx context.Context, req *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseConfirm not implemented") } -func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") -} -func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") -} func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") } -func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") -} func (*UnimplementedMsgServer) ChannelUpgradeInit(ctx context.Context, req *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeInit not implemented") } @@ -2251,42 +2203,6 @@ func _Msg_ChannelCloseConfirm_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRecvPacket) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RecvPacket(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/RecvPacket", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeout) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Timeout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/Timeout", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgTimeoutOnClose) if err := dec(in); err != nil { @@ -2305,24 +2221,6 @@ func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Msg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAcknowledgement) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Acknowledgement(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/Acknowledgement", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_ChannelUpgradeInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgChannelUpgradeInit) if err := dec(in); err != nil { @@ -2513,22 +2411,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ChannelCloseConfirm", Handler: _Msg_ChannelCloseConfirm_Handler, }, - { - MethodName: "RecvPacket", - Handler: _Msg_RecvPacket_Handler, - }, - { - MethodName: "Timeout", - Handler: _Msg_Timeout_Handler, - }, { MethodName: "TimeoutOnClose", Handler: _Msg_TimeoutOnClose_Handler, }, - { - MethodName: "Acknowledgement", - Handler: _Msg_Acknowledgement_Handler, - }, { MethodName: "ChannelUpgradeInit", Handler: _Msg_ChannelUpgradeInit_Handler, @@ -2570,6 +2456,156 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/core/channel/v1/tx.proto", } +// PacketMsgClient is the client API for PacketMsg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type PacketMsgClient interface { + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) +} + +type packetMsgClient struct { + cc grpc1.ClientConn +} + +func NewPacketMsgClient(cc grpc1.ClientConn) PacketMsgClient { + return &packetMsgClient{cc} +} + +func (c *packetMsgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { + out := new(MsgRecvPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/RecvPacket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *packetMsgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { + out := new(MsgTimeoutResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/Timeout", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *packetMsgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { + out := new(MsgAcknowledgementResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/Acknowledgement", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PacketMsgServer is the server API for PacketMsg service. +type PacketMsgServer interface { + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) +} + +// UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. +type UnimplementedPacketMsgServer struct { +} + +func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") +} +func (*UnimplementedPacketMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") +} +func (*UnimplementedPacketMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") +} + +func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { + s.RegisterService(&_PacketMsg_serviceDesc, srv) +} + +func _PacketMsg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRecvPacket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).RecvPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.PacketMsg/RecvPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + } + return interceptor(ctx, in, info, handler) +} + +func _PacketMsg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeout) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).Timeout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.PacketMsg/Timeout", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).Timeout(ctx, req.(*MsgTimeout)) + } + return interceptor(ctx, in, info, handler) +} + +func _PacketMsg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAcknowledgement) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).Acknowledgement(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.PacketMsg/Acknowledgement", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) + } + return interceptor(ctx, in, info, handler) +} + +var _PacketMsg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.channel.v1.PacketMsg", + HandlerType: (*PacketMsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RecvPacket", + Handler: _PacketMsg_RecvPacket_Handler, + }, + { + MethodName: "Timeout", + Handler: _PacketMsg_Timeout_Handler, + }, + { + MethodName: "Acknowledgement", + Handler: _PacketMsg_Acknowledgement_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/channel/v1/tx.proto", +} + func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 848f65c2ddd..55621c4f619 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -19,9 +19,10 @@ import ( ) var ( - _ clienttypes.MsgServer = (*Keeper)(nil) - _ connectiontypes.MsgServer = (*Keeper)(nil) - _ channeltypes.MsgServer = (*Keeper)(nil) + _ clienttypes.MsgServer = (*Keeper)(nil) + _ connectiontypes.MsgServer = (*Keeper)(nil) + _ channeltypes.MsgServer = (*Keeper)(nil) + _ channeltypes.PacketMsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. diff --git a/modules/core/module.go b/modules/core/module.go index aeac13f2862..1dc35eec4a8 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -131,6 +131,8 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) + channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) + clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) channeltypes.RegisterQueryServer(cfg.QueryServer(), channelkeeper.NewQueryServer(am.keeper.ChannelKeeper)) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go new file mode 100644 index 00000000000..78ea2833ca2 --- /dev/null +++ b/modules/core/packet-server/keeper/keeper.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + channelKeeper types.ChannelKeeper + clientKeeper types.ClientKeeper +} + +func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { + return &Keeper{ + cdc: cdc, + channelKeeper: channelKeeper, + clientKeeper: clientKeeper, + } +} diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go new file mode 100644 index 00000000000..a4aa0904947 --- /dev/null +++ b/modules/core/packet-server/types/expected_keepers.go @@ -0,0 +1,46 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +type ChannelKeeper interface { + // SetPacketCommitment writes the commitment hash under the commitment path + // This is a public path that is standardized by the IBC specification + SetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64, commitment []byte) + + // GetPacketCommitment returns the packet commitment hash under the commitment path + GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte + + // DeletePacketCommitment deletes the packet commitment hash under the commitment path + DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) + + // SetNextSequenceSend writes the next send sequence under the sequence path + // This is a public path that is standardized by the IBC specification + SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) + + // GetNextSequenceSend returns the next send sequence from the sequence path + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + + // SetPacketReceipt writes the packet receipt under the receipt path + // This is a public path that is standardized by the IBC specification + SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) + + // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path + // This is a public path that is standardized by the IBC specification + SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) +} + +type ClientKeeper interface { + // VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height. + VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error + // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. + VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error + // GetCounterparty returns the counterparty client given the client ID on + // the executing chain + // This is a private path that is only used by the IBC lite module + GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool) +} diff --git a/modules/core/packet-server/types/merkle.go b/modules/core/packet-server/types/merkle.go new file mode 100644 index 00000000000..6c654677420 --- /dev/null +++ b/modules/core/packet-server/types/merkle.go @@ -0,0 +1,27 @@ +package types + +import ( + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" +) + +// BuildMerklePath takes the merkle path prefix and an ICS24 path +// and builds a new path by appending the ICS24 path to the last element of the merkle path prefix. +func BuildMerklePath(prefix *commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath { + if prefix == nil || len(prefix.KeyPath) == 0 { + return commitmenttypes.NewMerklePath(path) + } + prefixKeys := prefix.KeyPath + lastElement := prefixKeys[len(prefixKeys)-1] + // append path to last element + newLastElement := cloneAppend(lastElement, path) + prefixKeys[len(prefixKeys)-1] = newLastElement + return commitmenttypes.NewMerklePath(prefixKeys...) +} + +func cloneAppend(bz []byte, tail []byte) []byte { + res := make([]byte, len(bz)+len(tail)) + copy(res, bz) + copy(res[len(bz):], tail) + return res +} diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index 06e8523284a..729ffd09b28 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -33,18 +33,9 @@ service Msg { // MsgChannelCloseConfirm. rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse); - // RecvPacket defines a rpc handler method for MsgRecvPacket. - rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); - - // Timeout defines a rpc handler method for MsgTimeout. - rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); - // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. rpc ChannelUpgradeInit(MsgChannelUpgradeInit) returns (MsgChannelUpgradeInitResponse); @@ -73,6 +64,20 @@ service Msg { rpc PruneAcknowledgements(MsgPruneAcknowledgements) returns (MsgPruneAcknowledgementsResponse); } +// PacketMsg defines the ibc/channel PacketMsg service. +service PacketMsg { + option (cosmos.msg.v1.service) = true; + + // RecvPacket defines a rpc handler method for MsgRecvPacket. + rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); + + // Timeout defines a rpc handler method for MsgTimeout. + rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); + + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); +} + // ResponseResultType defines the possible outcomes of the execution of a message enum ResponseResultType { option (gogoproto.goproto_enum_prefix) = false; From 44215f71915bcb14cef7beef64b9e11ed3929727 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:38:56 +0200 Subject: [PATCH 004/172] Add versions to packet and create Eureka packet commitment (#6986) * add versions to packet and separate commitment function * use IBC Version to switch hashing * fix build and tests, found bug in switch logic * add documentation * improve code docstrings * address jim review * rename eureka to v2 --- modules/apps/29-fee/ica_test.go | 2 +- .../core/03-connection/keeper/verify_test.go | 2 +- modules/core/04-channel/keeper/packet.go | 6 +- modules/core/04-channel/keeper/packet_test.go | 2 +- modules/core/04-channel/keeper/timeout.go | 4 +- modules/core/04-channel/types/channel.pb.go | 235 +++++++++++++----- modules/core/04-channel/types/msgs_test.go | 1 + modules/core/04-channel/types/packet.go | 93 ++++++- modules/core/04-channel/types/packet_test.go | 26 +- .../light_client_module_test.go | 2 +- .../07-tendermint/light_client_module_test.go | 2 +- .../09-localhost/light_client_module_test.go | 2 +- proto/ibc/core/channel/v1/channel.proto | 19 ++ testing/path.go | 5 +- testing/solomachine.go | 2 +- 15 files changed, 315 insertions(+), 88 deletions(-) diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index dceb5ed938d..a90a18c58b1 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -166,7 +166,7 @@ func (suite *FeeTestSuite) TestFeeInterchainAccounts() { packet := buildInterchainAccountsPacket(path, icaPacketData.GetBytes(), 1) // write packet commitment to state on chainA and commit state - commitment := channeltypes.CommitPacket(suite.chainA.GetSimApp().AppCodec(), packet) + commitment := channeltypes.CommitPacket(packet) suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, 1, commitment) suite.chainA.NextBlock() diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index c3e2e02a2de..b3b8bdeaf1a 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -350,7 +350,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { suite.chainB.App.GetIBCKeeper().ConnectionKeeper.SetParams(suite.chainB.GetContext(), types.NewParams(timePerBlock)) } - commitment := channeltypes.CommitPacket(suite.chainB.App.GetIBCKeeper().Codec(), packet) + commitment := channeltypes.CommitPacket(packet) err = suite.chainB.App.GetIBCKeeper().ConnectionKeeper.VerifyPacketCommitment( suite.chainB.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), commitment, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index f56b578096f..96a9f22a2b8 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -84,7 +84,7 @@ func (k *Keeper) SendPacket( return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") } - commitment := types.CommitPacket(k.cdc, packet) + commitment := types.CommitPacket(packet) k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) @@ -177,7 +177,7 @@ func (k *Keeper) RecvPacket( return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") } - commitment := types.CommitPacket(k.cdc, packet) + commitment := types.CommitPacket(packet) // verify that the counterparty did commit to sending this packet if err := k.connectionKeeper.VerifyPacketCommitment( @@ -431,7 +431,7 @@ func (k *Keeper) AcknowledgePacket( return types.ErrNoOpMsg } - packetCommitment := types.CommitPacket(k.cdc, packet) + packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 97b6e5795bf..dc986bbe0c5 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -602,7 +602,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) // manually set packet commitment - suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, packet.GetSequence(), types.CommitPacket(suite.chainA.App.AppCodec(), packet)) + suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, packet.GetSequence(), types.CommitPacket(packet)) suite.chainB.CreateChannelCapability(suite.chainB.GetSimApp().ScopedIBCMockKeeper, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) channelCap = suite.chainB.GetChannelCapability(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 1f8649e0f7a..db41d4a0c83 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -84,7 +84,7 @@ func (k *Keeper) TimeoutPacket( return types.ErrNoOpMsg } - packetCommitment := types.CommitPacket(k.cdc, packet) + packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { @@ -247,7 +247,7 @@ func (k *Keeper) TimeoutOnClose( return types.ErrNoOpMsg } - packetCommitment := types.CommitPacket(k.cdc, packet) + packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index 2263ee69c4e..b4e1cafde7c 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -108,6 +108,41 @@ func (Order) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c3a07336710636a0, []int{1} } +// IBCVersion defines the version that the IBC packet intends to use. +// This allows asynchronous upgrades over time as unsupported IBC Versions +// will simply be rejected by the receiver and timed out on sender. +type IBCVersion int32 + +const ( + // zero-value for IBC version. + // This will be treated as a classic packet + IBC_VERSION_UNSPECIFIED IBCVersion = 0 + // IBC version 1 implements the Classic protocol + IBC_VERSION_1 IBCVersion = 1 + // IBC version 2 implements the Eureka protocol + IBC_VERSION_2 IBCVersion = 2 +) + +var IBCVersion_name = map[int32]string{ + 0: "IBC_VERSION_UNSPECIFIED", + 1: "IBC_VERSION_1", + 2: "IBC_VERSION_2", +} + +var IBCVersion_value = map[string]int32{ + "IBC_VERSION_UNSPECIFIED": 0, + "IBC_VERSION_1": 1, + "IBC_VERSION_2": 2, +} + +func (x IBCVersion) String() string { + return proto.EnumName(IBCVersion_name, int32(x)) +} + +func (IBCVersion) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{2} +} + // 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. @@ -278,6 +313,10 @@ type Packet struct { TimeoutHeight types.Height `protobuf:"bytes,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"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"` + // which IBC version to use to commit this packet + ProtocolVersion IBCVersion `protobuf:"varint,9,opt,name=protocol_version,json=protocolVersion,proto3,enum=ibc.core.channel.v1.IBCVersion" json:"protocol_version,omitempty"` + // version which application should use to process the packet data + AppVersion string `protobuf:"bytes,10,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` } func (m *Packet) Reset() { *m = Packet{} } @@ -606,6 +645,7 @@ func (m *Params) GetUpgradeTimeout() Timeout { func init() { proto.RegisterEnum("ibc.core.channel.v1.State", State_name, State_value) proto.RegisterEnum("ibc.core.channel.v1.Order", Order_name, Order_value) + proto.RegisterEnum("ibc.core.channel.v1.IBCVersion", IBCVersion_name, IBCVersion_value) proto.RegisterType((*Channel)(nil), "ibc.core.channel.v1.Channel") proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v1.IdentifiedChannel") proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v1.Counterparty") @@ -620,66 +660,71 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 937 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x6f, 0xe2, 0xc6, - 0x1b, 0xc6, 0xc4, 0xfc, 0x7b, 0x93, 0x80, 0x33, 0xf9, 0xfd, 0x52, 0xcb, 0x4a, 0xc1, 0x8b, 0x5a, - 0x95, 0x4d, 0xb5, 0xb0, 0xd9, 0x56, 0x55, 0xb7, 0xb7, 0x04, 0xbc, 0x8b, 0xb5, 0x14, 0x90, 0x81, - 0x43, 0xf7, 0x82, 0x8c, 0x3d, 0x05, 0x6b, 0xc1, 0x43, 0xed, 0x81, 0xd5, 0xaa, 0xe7, 0x4a, 0x2b, - 0x4e, 0xfd, 0x02, 0x48, 0x95, 0xfa, 0x15, 0xfa, 0x21, 0xf6, 0xb8, 0xc7, 0x3d, 0x55, 0x55, 0xf2, - 0x1d, 0x7a, 0xae, 0x3c, 0x33, 0x0e, 0x10, 0x45, 0x51, 0x55, 0xa9, 0xb7, 0x9e, 0x98, 0xf7, 0x79, - 0x9f, 0xf7, 0x7d, 0xde, 0x3f, 0xc3, 0xc8, 0xf0, 0xc0, 0x1b, 0x39, 0x35, 0x87, 0x04, 0xb8, 0xe6, - 0x4c, 0x6c, 0xdf, 0xc7, 0x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eb, 0x52, 0x45, 0xb6, 0x0a, 0x02, 0xef, - 0x09, 0xf8, 0x1b, 0xf9, 0xed, 0x2f, 0xa5, 0x44, 0xf9, 0xcf, 0x24, 0x1c, 0x99, 0x2e, 0xf6, 0xa9, - 0xf7, 0xbd, 0x87, 0xdd, 0xff, 0x06, 0xf8, 0x11, 0x64, 0xe6, 0x24, 0xa0, 0x43, 0xcf, 0x65, 0x73, - 0xcb, 0x59, 0xe9, 0xc8, 0x34, 0x5d, 0xf4, 0x31, 0x80, 0x28, 0x25, 0xf2, 0x65, 0x98, 0x2f, 0x27, - 0x10, 0xd3, 0xbd, 0x73, 0xf0, 0xd9, 0xfb, 0x06, 0xdf, 0x82, 0x83, 0xed, 0x7e, 0xb6, 0x85, 0xa5, - 0x7b, 0x84, 0x93, 0xb7, 0x84, 0x45, 0xb6, 0x0f, 0x49, 0x48, 0x77, 0x6d, 0xe7, 0x15, 0xa6, 0x48, - 0x83, 0xec, 0x4d, 0x05, 0x12, 0xab, 0xe0, 0xc6, 0x46, 0x25, 0xd8, 0x0f, 0xc9, 0x22, 0x70, 0xf0, - 0x30, 0x4a, 0x2e, 0x92, 0x01, 0x87, 0xba, 0x24, 0xa0, 0xe8, 0x53, 0xc8, 0x0b, 0x82, 0x50, 0x60, - 0x0b, 0xc9, 0x59, 0x87, 0x1c, 0x8d, 0xef, 0xc7, 0x43, 0x50, 0x5c, 0x1c, 0x52, 0xcf, 0xb7, 0xd9, - 0xa4, 0x59, 0x32, 0x99, 0x11, 0x0b, 0x5b, 0x38, 0xcb, 0x58, 0x83, 0xe3, 0x6d, 0x6a, 0x9c, 0x96, - 0x8f, 0x1d, 0x6d, 0xb9, 0xe2, 0xdc, 0x08, 0x64, 0xd7, 0xa6, 0x36, 0x1b, 0xff, 0x81, 0xc5, 0xce, - 0xe8, 0x39, 0xe4, 0xa9, 0x37, 0xc3, 0x64, 0x41, 0x87, 0x13, 0xec, 0x8d, 0x27, 0x94, 0x2d, 0x60, - 0x7f, 0x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0x19, 0xa2, 0x7d, 0x61, 0x72, - 0xe1, 0xcb, 0xde, 0xbb, 0xab, 0xa2, 0xf4, 0xfe, 0xaa, 0x28, 0xfd, 0x71, 0x55, 0x94, 0x7e, 0xbe, - 0x2e, 0x26, 0xde, 0x5f, 0x17, 0x13, 0x1f, 0xae, 0x8b, 0x89, 0x97, 0x4f, 0xc7, 0x1e, 0x9d, 0x2c, - 0x46, 0x55, 0x87, 0xcc, 0x6a, 0x0e, 0x09, 0x67, 0x24, 0xac, 0x79, 0x23, 0xe7, 0xd1, 0x98, 0xd4, - 0x96, 0x4f, 0x6b, 0x33, 0xe2, 0x2e, 0xa6, 0x38, 0xe4, 0x9f, 0x08, 0x8f, 0xbf, 0x7c, 0x14, 0x7f, - 0x73, 0xd0, 0x37, 0x73, 0x1c, 0x8e, 0xd2, 0xec, 0x1b, 0xe1, 0x8b, 0xbf, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x39, 0xda, 0x3d, 0x84, 0x94, 0x08, 0x00, 0x00, + // 1013 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x53, 0xe7, 0xeb, 0x6d, 0x93, 0xb8, 0x53, 0xe8, 0x5a, 0xa6, 0x24, 0xde, 0x0a, 0x44, + 0xb7, 0x68, 0x93, 0x6d, 0x41, 0x88, 0xe5, 0xd6, 0xa6, 0xde, 0xad, 0xd9, 0x92, 0x54, 0x4e, 0xb2, + 0x12, 0x7b, 0xb1, 0x5c, 0x7b, 0x48, 0xad, 0x4d, 0x3c, 0xc6, 0x9e, 0x74, 0xb5, 0xe2, 0x8c, 0xb4, + 0xca, 0x89, 0x3f, 0x10, 0x09, 0x89, 0xbf, 0xc0, 0x5f, 0x40, 0xda, 0xe3, 0x1e, 0x39, 0x21, 0xd4, + 0xfe, 0x07, 0xce, 0xc8, 0x33, 0xe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, 0x70, 0x14, 0xfb, + 0x24, 0x50, 0x73, 0xba, 0xb4, 0x57, 0xb2, 0x52, 0x13, 0x3d, 0x00, 0x65, 0x1c, 0x0e, 0x22, 0xc7, + 0xc3, 0x76, 0x8c, 0xbf, 0x1f, 0xe3, 0xc0, 0xc5, 0x6a, 0x5e, 0x97, 0xf6, 0x64, 0xab, 0x2a, 0xf0, + 0xae, 0x80, 0xbf, 0x92, 0xdf, 0xfc, 0x5c, 0xcf, 0xec, 0xfe, 0x95, 0x85, 0x4d, 0xd3, 0xc3, 0x01, + 0xf5, 0xbf, 0xf3, 0xb1, 0xf7, 0xff, 0x00, 0xef, 0x41, 0x21, 0x24, 0x11, 0xb5, 0x7d, 0x8f, 0xcd, + 0xad, 0x64, 0xe5, 0x13, 0xd3, 0xf4, 0xd0, 0x87, 0x00, 0xa2, 0x95, 0xc4, 0x57, 0x60, 0xbe, 0x92, + 0x40, 0x4c, 0x6f, 0xe5, 0xe0, 0x8b, 0x77, 0x0d, 0xfe, 0x0c, 0x36, 0x16, 0xf7, 0xb3, 0x58, 0x58, + 0xba, 0xa3, 0x70, 0xf6, 0x56, 0x61, 0x91, 0xed, 0xb7, 0x35, 0xc8, 0x9f, 0x3b, 0xee, 0x4b, 0x4c, + 0x91, 0x06, 0xc5, 0x59, 0x07, 0x12, 0xeb, 0x60, 0x66, 0xa3, 0x3a, 0xac, 0xc7, 0x64, 0x1c, 0xb9, + 0xd8, 0x4e, 0x92, 0x8b, 0x64, 0xc0, 0xa1, 0x73, 0x12, 0x51, 0xf4, 0x31, 0x54, 0x04, 0x41, 0x54, + 0x60, 0x07, 0x52, 0xb2, 0xca, 0x1c, 0x4d, 0xf5, 0xf1, 0x00, 0x14, 0x0f, 0xc7, 0xd4, 0x0f, 0x1c, + 0x36, 0x69, 0x96, 0x4c, 0x66, 0xc4, 0xea, 0x02, 0xce, 0x32, 0x36, 0x61, 0x6b, 0x91, 0x9a, 0xa6, + 0xe5, 0x63, 0x47, 0x0b, 0xae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0xe5, 0xb3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x70, 0x20, 0xe4, + 0xc3, 0x58, 0x09, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -881,6 +926,18 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AppVersion) > 0 { + i -= len(m.AppVersion) + copy(dAtA[i:], m.AppVersion) + i = encodeVarintChannel(dAtA, i, uint64(len(m.AppVersion))) + i-- + dAtA[i] = 0x52 + } + if m.ProtocolVersion != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.ProtocolVersion)) + i-- + dAtA[i] = 0x48 + } if m.TimeoutTimestamp != 0 { i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) i-- @@ -1297,6 +1354,13 @@ func (m *Packet) Size() (n int) { if m.TimeoutTimestamp != 0 { n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) } + if m.ProtocolVersion != 0 { + n += 1 + sovChannel(uint64(m.ProtocolVersion)) + } + l = len(m.AppVersion) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } return n } @@ -2257,6 +2321,57 @@ func (m *Packet) Unmarshal(dAtA []byte) error { break } } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolVersion", wireType) + } + m.ProtocolVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProtocolVersion |= IBCVersion(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipChannel(dAtA[iNdEx:]) diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index e660cf39bd4..173131d73df 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -64,6 +64,7 @@ var ( disabledTimeout = clienttypes.ZeroHeight() validPacketData = []byte("testdata") unknownPacketData = []byte("unknown") + validVersion = "ics-20" packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) invalidPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 0660a8f91c2..afc65a66eaf 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -5,7 +5,6 @@ import ( errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" @@ -13,11 +12,31 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// CommitPacket returns the packet commitment bytes. The commitment consists of: +// CommitPacket returns the packet commitment bytes based on +// the ProtocolVersion specified in the Packet. The commitment +// must commit to all fields in the packet apart from the source port +// source channel and sequence (which will be committed to in the packet commitment key path) +// and the ProtocolVersion which is defining how to hash the packet fields. +// NOTE: The commitment MUSTs be a fixed length preimage to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. +func CommitPacket(packet Packet) []byte { + switch packet.ProtocolVersion { + case IBC_VERSION_UNSPECIFIED, IBC_VERSION_1: + return commitV1Packet(packet) + case IBC_VERSION_2: + return commitV2Packet(packet) + default: + panic("unsupported version") + } +} + +// commitV1Packet returns the V1 packet commitment bytes. The commitment consists of: // sha256_hash(timeout_timestamp + timeout_height.RevisionNumber + timeout_height.RevisionHeight + sha256_hash(data)) // from a given packet. This results in a fixed length preimage. +// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. // NOTE: sdk.Uint64ToBigEndian sets the uint64 to a slice of length 8. -func CommitPacket(cdc codec.BinaryCodec, packet Packet) []byte { +func commitV1Packet(packet Packet) []byte { timeoutHeight := packet.GetTimeoutHeight() buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) @@ -35,6 +54,52 @@ func CommitPacket(cdc codec.BinaryCodec, packet Packet) []byte { return hash[:] } +// commitV2Packet returns the V2 packet commitment bytes. The commitment consists of: +// sha256_hash(timeout_timestamp + timeout_height.RevisionNumber + timeout_height.RevisionHeight) +// + sha256_hash(destPort) + sha256_hash(destChannel) + sha256_hash(version) + sha256_hash(data)) +// from a given packet. This results in a fixed length preimage. +// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. +// NOTE: sdk.Uint64ToBigEndian sets the uint64 to a slice of length 8. +func commitV2Packet(packet Packet) []byte { + timeoutHeight := packet.GetTimeoutHeight() + + timeoutBuf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) + + // only hash the timeout height if it is non-zero. This will allow us to remove it entirely in the future + if timeoutHeight.EQ(clienttypes.ZeroHeight()) { + revisionNumber := sdk.Uint64ToBigEndian(timeoutHeight.GetRevisionNumber()) + timeoutBuf = append(timeoutBuf, revisionNumber...) + + revisionHeight := sdk.Uint64ToBigEndian(timeoutHeight.GetRevisionHeight()) + timeoutBuf = append(timeoutBuf, revisionHeight...) + } + + // hash the timeout rather than using a fixed-size preimage directly + // this will allow more flexibility in the future with how timeouts are defined + timeoutHash := sha256.Sum256(timeoutBuf) + buf := timeoutHash[:] + + // hash the destination identifiers since we can no longer retrieve them from the channelEnd + portHash := sha256.Sum256([]byte(packet.GetDestPort())) + buf = append(buf, portHash[:]...) + destinationHash := sha256.Sum256([]byte(packet.GetDestChannel())) + buf = append(buf, destinationHash[:]...) + + // hash the version only if it is nonempty + if packet.AppVersion != "" { + versionHash := sha256.Sum256([]byte(packet.AppVersion)) + buf = append(buf, versionHash[:]...) + } + + // hash the data + dataHash := sha256.Sum256(packet.GetData()) + buf = append(buf, dataHash[:]...) + + hash := sha256.Sum256(buf) + return hash[:] +} + // CommitAcknowledgement returns the hash of commitment bytes func CommitAcknowledgement(data []byte) []byte { hash := sha256.Sum256(data) @@ -58,6 +123,28 @@ func NewPacket( DestinationChannel: destinationChannel, TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, + ProtocolVersion: IBC_VERSION_1, + } +} + +func NewPacketWithVersion( + data []byte, + sequence uint64, sourcePort, sourceChannel, + destinationPort, destinationChannel string, + timeoutHeight clienttypes.Height, timeoutTimestamp uint64, + appVersion string, +) Packet { + return Packet{ + Data: data, + Sequence: sequence, + SourcePort: sourcePort, + SourceChannel: sourceChannel, + DestinationPort: destinationPort, + DestinationChannel: destinationChannel, + TimeoutHeight: timeoutHeight, + TimeoutTimestamp: timeoutTimestamp, + ProtocolVersion: IBC_VERSION_2, + AppVersion: appVersion, } } diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index 1338f45c8d1..92fd9a5002f 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -5,24 +5,30 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) func TestCommitPacket(t *testing.T) { packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - registry := codectypes.NewInterfaceRegistry() - clienttypes.RegisterInterfaces(registry) - types.RegisterInterfaces(registry) + commitment1 := types.CommitPacket(packet) + require.NotNil(t, commitment1) + + packet2 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "") + commitment2 := types.CommitPacket(packet2) + require.NotNil(t, commitment2) + + // even though versions are same empty string, + // the commitment is different because we use + // Eureka protocol for packet2 + require.NotEqual(t, commitment1, commitment2) - cdc := codec.NewProtoCodec(registry) + packet3 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, validVersion) + commitment3 := types.CommitPacket(packet3) + require.NotNil(t, commitment3) - commitment := types.CommitPacket(cdc, packet) - require.NotNil(t, commitment) + require.NotEqual(t, commitment1, commitment3) + require.NotEqual(t, commitment2, commitment3) } func TestPacketValidateBasic(t *testing.T) { diff --git a/modules/light-clients/06-solomachine/light_client_module_test.go b/modules/light-clients/06-solomachine/light_client_module_test.go index b011d130931..7d4ad2e94c3 100644 --- a/modules/light-clients/06-solomachine/light_client_module_test.go +++ b/modules/light-clients/06-solomachine/light_client_module_test.go @@ -440,7 +440,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { 0, ) - commitmentBz := channeltypes.CommitPacket(suite.chainA.Codec, packet) + commitmentBz := channeltypes.CommitPacket(packet) path = sm.GetPacketCommitmentPath(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) merklePath, ok := path.(commitmenttypesv2.MerklePath) suite.Require().True(ok) diff --git a/modules/light-clients/07-tendermint/light_client_module_test.go b/modules/light-clients/07-tendermint/light_client_module_test.go index 87119309949..f196ac0aa3e 100644 --- a/modules/light-clients/07-tendermint/light_client_module_test.go +++ b/modules/light-clients/07-tendermint/light_client_module_test.go @@ -342,7 +342,7 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { proof, proofHeight = testingpath.EndpointB.QueryProof(key) - value = channeltypes.CommitPacket(suite.chainA.App.GetIBCKeeper().Codec(), packet) + value = channeltypes.CommitPacket(packet) }, nil, }, { diff --git a/modules/light-clients/09-localhost/light_client_module_test.go b/modules/light-clients/09-localhost/light_client_module_test.go index 108b52c8f99..79987c3bd89 100644 --- a/modules/light-clients/09-localhost/light_client_module_test.go +++ b/modules/light-clients/09-localhost/light_client_module_test.go @@ -150,7 +150,7 @@ func (suite *LocalhostTestSuite) TestVerifyMembership() { 0, ) - commitmentBz := channeltypes.CommitPacket(suite.chain.Codec, packet) + commitmentBz := channeltypes.CommitPacket(packet) suite.chain.GetSimApp().GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chain.GetContext(), mock.PortID, ibctesting.FirstChannelID, 1, commitmentBz) merklePath := commitmenttypes.NewMerklePath(host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())) diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index 78df62bdbb4..cf3ecbb61e0 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -90,6 +90,21 @@ enum Order { ORDER_ORDERED = 2 [(gogoproto.enumvalue_customname) = "ORDERED"]; } +// IBCVersion defines the version that the IBC packet intends to use. +// This allows asynchronous upgrades over time as unsupported IBC Versions +// will simply be rejected by the receiver and timed out on sender. +enum IBCVersion { + option (gogoproto.goproto_enum_prefix) = false; + + // zero-value for IBC version. + // This will be treated as a classic packet + IBC_VERSION_UNSPECIFIED = 0; + // IBC version 1 implements the Classic protocol + IBC_VERSION_1 = 1; + // IBC version 2 implements the Eureka protocol + IBC_VERSION_2 = 2; +} + // Counterparty defines a channel end counterparty message Counterparty { option (gogoproto.goproto_getters) = false; @@ -122,6 +137,10 @@ message Packet { ibc.core.client.v1.Height timeout_height = 7 [(gogoproto.nullable) = false]; // block timestamp (in nanoseconds) after which the packet times out uint64 timeout_timestamp = 8; + // which IBC version to use to commit this packet + IBCVersion protocol_version = 9; + // version which application should use to process the packet data + string app_version = 10; } // PacketState defines the generic type necessary to retrieve and store diff --git a/testing/path.go b/testing/path.go index 53c25467441..1a1c7c54574 100644 --- a/testing/path.go +++ b/testing/path.go @@ -89,7 +89,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error { // - An error if a relay step fails or the packet commitment does not exist on either endpoint. func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.ExecTxResult, []byte, error) { pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) { + if bytes.Equal(pc, channeltypes.CommitPacket(packet)) { // packet found, relay from A to B if err := path.EndpointB.UpdateClient(); err != nil { return nil, nil, err @@ -113,8 +113,7 @@ func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.Exec } pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointB.Chain.App.AppCodec(), packet)) { - + if bytes.Equal(pc, channeltypes.CommitPacket(packet)) { // packet found, relay B to A if err := path.EndpointA.UpdateClient(); err != nil { return nil, nil, err diff --git a/testing/solomachine.go b/testing/solomachine.go index 4b57ae2dac1..d986895ff8f 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -614,7 +614,7 @@ func (solo *Solomachine) GenerateChanClosedProof(portID, version, counterpartyCh // GenerateCommitmentProof generates a commitment proof for the provided packet. func (solo *Solomachine) GenerateCommitmentProof(packet channeltypes.Packet) []byte { - commitment := channeltypes.CommitPacket(solo.cdc, packet) + commitment := channeltypes.CommitPacket(packet) path := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) signBytes := &solomachine.SignBytes{ From dcff30b4d83c25b5b4a21a8b5dc2fa9ea60416c6 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 6 Aug 2024 07:42:52 +0300 Subject: [PATCH 005/172] feat(tests): add helper functions, keeper test suite. (#7052) * feat(tests): add helper functions, keeper test suite. * wire up packet server in app --------- Co-authored-by: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> --- modules/apps/callbacks/testing/simapp/app.go | 8 +++ modules/core/packet-server/keeper/keeper.go | 8 +-- .../core/packet-server/keeper/keeper_test.go | 50 +++++++++++++++++++ .../packet-server/types/expected_keepers.go | 2 +- .../08-wasm/testing/simapp/app.go | 10 ++++ testing/endpoint.go | 12 +++++ testing/path.go | 19 +++++++ testing/simapp/app.go | 10 ++++ testing/testing_app.go | 2 + 9 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 modules/core/packet-server/keeper/keeper_test.go diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 9a89526745e..932cc361d3f 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -123,6 +123,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -198,6 +199,7 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper CircuitKeeper circuitkeeper.Keeper + PacketServer *packetserverkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -407,6 +409,7 @@ func NewSimApp( app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), ibctm.NewConsensusHost(app.StakingKeeper), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) // NOTE: The mock ContractKeeper is only created for testing. // Real applications should not use the mock ContractKeeper @@ -1057,6 +1060,11 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } +// GetPacketServer implements the TestingApp interface +func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { + return app.PacketServer +} + // GetScopedIBCKeeper implements the TestingApp interface. func (app *SimApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { return app.ScopedIBCKeeper diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 78ea2833ca2..bc3223cae9d 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -8,14 +8,14 @@ import ( type Keeper struct { cdc codec.BinaryCodec - channelKeeper types.ChannelKeeper - clientKeeper types.ClientKeeper + ChannelKeeper types.ChannelKeeper + ClientKeeper types.ClientKeeper } func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { return &Keeper{ cdc: cdc, - channelKeeper: channelKeeper, - clientKeeper: clientKeeper, + ChannelKeeper: channelKeeper, + ClientKeeper: clientKeeper, } } diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go new file mode 100644 index 00000000000..c73615069ae --- /dev/null +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + testifysuite "github.com/stretchr/testify/suite" + + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +// KeeperTestSuite is a testing suite to test keeper functions. +type KeeperTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain +} + +// TestKeeperTestSuite runs all the tests within this package. +func TestKeeperTestSuite(t *testing.T) { + testifysuite.Run(t, new(KeeperTestSuite)) +} + +// SetupTest creates a coordinator with 2 test chains. +func (suite *KeeperTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + + // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) + suite.coordinator.CommitNBlocks(suite.chainA, 2) + suite.coordinator.CommitNBlocks(suite.chainB, 2) +} + +// TODO: Remove, just testing the testing setup. +func (suite *KeeperTestSuite) TestCreateEurekaClients() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // Assert counterparty set and creator deleted + _, found := suite.chainA.App.GetPacketServer().ClientKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(found) + + // Assert counterparty set and creator deleted + _, found = suite.chainB.App.GetPacketServer().ClientKeeper.GetCounterparty(suite.chainB.GetContext(), path.EndpointB.ClientID) + suite.Require().True(found) +} diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index a4aa0904947..7b4c6a03b1f 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -16,7 +16,7 @@ type ChannelKeeper interface { GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte // DeletePacketCommitment deletes the packet commitment hash under the commitment path - DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) + // DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) // SetNextSequenceSend writes the next send sequence under the sequence path // This is a public path that is standardized by the IBC specification diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 801b35a9ecc..5e7994e7fb4 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -131,6 +131,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -207,6 +208,7 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper CircuitKeeper circuitkeeper.Keeper + PacketServer *packetserverkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -415,6 +417,9 @@ func NewSimApp( appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), ibctm.NewConsensusHost(app.StakingKeeper), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + // setup packet server keeper for Eureka tests + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -1106,6 +1111,11 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } +// GetPacketServer implements the TestingApp interface +func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { + return app.PacketServer +} + // GetWasmKeeper implements the TestingApp interface. func (app *SimApp) GetWasmKeeper() wasmkeeper.Keeper { return app.WasmClientKeeper diff --git a/testing/endpoint.go b/testing/endpoint.go index a790cdd8be7..ea4b9c43a9a 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -165,6 +165,18 @@ func (endpoint *Endpoint) UpdateClient() (err error) { return endpoint.Chain.sendMsgs(msg) } +// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. +func (endpoint *Endpoint) ProvideCounterparty() (err error) { + merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + + msg := clienttypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, &merklePath) + + // setup counterparty + _, err = endpoint.Chain.SendMsgs(msg) + + return err +} + // UpgradeChain will upgrade a chain's chainID to the next revision number. // It will also update the counterparty client. // TODO: implement actual upgrade chain functionality via scheduling an upgrade diff --git a/testing/path.go b/testing/path.go index 1a1c7c54574..fc9c0aac564 100644 --- a/testing/path.go +++ b/testing/path.go @@ -148,6 +148,13 @@ func (path *Path) Setup() { path.CreateChannels() } +// SetupV2 constructs clients on both sides and then provides the counterparties for both sides +// This is all that is necessary for path setup with the Eureka (V2) protocol +func (path *Path) SetupV2() { + path.SetupClients() + path.SetupCounterparties() +} + // SetupClients is a helper function to create clients on both chains. It assumes the // caller does not anticipate any errors. func (path *Path) SetupClients() { @@ -162,6 +169,18 @@ func (path *Path) SetupClients() { } } +// SetupCounterparties is a helper function to set the counterparties supporting ibc-eureka on both +// chains. It assumes the caller does not anticipate any errors. +func (path *Path) SetupCounterparties() { + if err := path.EndpointB.ProvideCounterparty(); err != nil { + panic(err) + } + + if err := path.EndpointA.ProvideCounterparty(); err != nil { + panic(err) + } +} + // SetupConnections is a helper function to create clients and the appropriate // connections on both the source and counterparty chain. It assumes the caller does not // anticipate any errors. diff --git a/testing/simapp/app.go b/testing/simapp/app.go index dca117000b3..84d25b83495 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -110,6 +110,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -177,6 +178,7 @@ type SimApp struct { ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper + PacketServer *packetserverkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -370,6 +372,9 @@ func NewSimApp( appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), ibctm.NewConsensusHost(app.StakingKeeper), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + // Setup packet server to call on Eureka tests + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -979,6 +984,11 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } +// GetPacketServer implements the TestingApp interface +func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { + return app.PacketServer +} + // GetScopedIBCKeeper implements the TestingApp interface. func (app *SimApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { return app.ScopedIBCKeeper diff --git a/testing/testing_app.go b/testing/testing_app.go index 1a1ac564859..925c3df388c 100644 --- a/testing/testing_app.go +++ b/testing/testing_app.go @@ -29,6 +29,7 @@ import ( capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" "github.com/cosmos/ibc-go/v9/testing/simapp" ibctestingtypes "github.com/cosmos/ibc-go/v9/testing/types" ) @@ -44,6 +45,7 @@ type TestingApp interface { GetIBCKeeper() *keeper.Keeper GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper GetTxConfig() client.TxConfig + GetPacketServer() *packetserverkeeper.Keeper // Implemented by SimApp AppCodec() codec.Codec From 567e730d3edb9e9dae77554f6cbe9ecae9de7c6b Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:45:46 +0200 Subject: [PATCH 006/172] feat(core/eureka): add packet handler (#7048) * send packet eureka * test progress * add tests * lint * nit * lint moar * refactor tests --- modules/core/04-channel/keeper/events.go | 2 +- modules/core/04-channel/keeper/packet.go | 2 +- modules/core/packet-server/keeper/keeper.go | 80 ++++++++++++++++++ .../core/packet-server/keeper/keeper_test.go | 81 ++++++++++++++++--- .../packet-server/types/expected_keepers.go | 7 ++ 5 files changed, 160 insertions(+), 12 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index b93f3d0c3d2..136c382bb12 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -121,7 +121,7 @@ func emitChannelCloseConfirmEvent(ctx sdk.Context, portID string, channelID stri // emitSendPacketEvent emits an event with packet data along with other packet information for relayer // to pick up and relay to other chain -func emitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) { +func EmitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSendPacket, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 1ab81953cb9..0711722cc55 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -89,7 +89,7 @@ func (k *Keeper) SendPacket( k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - emitSendPacketEvent(ctx, packet, channel, timeoutHeight) + EmitSendPacketEvent(ctx, packet, channel, timeoutHeight) k.Logger(ctx).Info( "packet sent", diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index bc3223cae9d..49d6e9ed410 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,8 +1,16 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -19,3 +27,75 @@ func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientK ClientKeeper: clientKeeper, } } + +func (k Keeper) SendPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + sourceChannel string, + sourcePort string, + destPort string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + version string, + data []byte, +) (uint64, error) { + // Lookup counterparty associated with our source channel to retrieve the destination channel + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) + if !ok { + return 0, channeltypes.ErrChannelNotFound + } + destChannel := counterparty.ClientId + + // retrieve the sequence send for this channel + // if no packets have been sent yet, initialize the sequence to 1. + sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + sequence = 1 + } + + // construct packet from given fields and channel state + packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, + destPort, destChannel, timeoutHeight, timeoutTimestamp, version) + + if err := packet.ValidateBasic(); err != nil { + return 0, errorsmod.Wrap(err, "constructed packet failed basic validation") + } + + // check that the client of receiver chain is still active + if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client state is not active: %s", status) + } + + // retrieve latest height and timestamp of the client of receiver chain + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) + if latestHeight.IsZero() { + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) + } + + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) + if err != nil { + return 0, err + } + + // check if packet is timed out on the receiving chain + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(latestHeight, latestTimestamp) { + return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + } + + commitment := channeltypes.CommitPacket(packet) + + // bump the sequence and set the packet commitment so it is provable by the counterparty + k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) + k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) + + // create sentinel channel for events + channel := channeltypes.Channel{ + Ordering: channeltypes.ORDERED, + ConnectionHops: []string{sourceChannel}, + } + channelkeeper.EmitSendPacketEvent(ctx, packet, channel, timeoutHeight) + + // return the sequence + return sequence, nil +} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index c73615069ae..aae084891a8 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -1,11 +1,16 @@ package keeper_test import ( + "fmt" "testing" testifysuite "github.com/stretchr/testify/suite" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + tmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/ibc-go/v9/testing/mock" ) // KeeperTestSuite is a testing suite to test keeper functions. @@ -35,16 +40,72 @@ func (suite *KeeperTestSuite) SetupTest() { suite.coordinator.CommitNBlocks(suite.chainB, 2) } -// TODO: Remove, just testing the testing setup. -func (suite *KeeperTestSuite) TestCreateEurekaClients() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() +func (suite *KeeperTestSuite) TestSendPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + ) - // Assert counterparty set and creator deleted - _, found := suite.chainA.App.GetPacketServer().ClientKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) - suite.Require().True(found) + testCases := []struct { + name string + malleate func() + expError error + }{ + {"success", func() {}, nil}, + {"counterparty not found", func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, channeltypes.ErrChannelNotFound}, + {"packet failed basic validation", func() { + // invalid data + packet.Data = nil + }, channeltypes.ErrInvalidPacket}, + {"client status invalid", func() { + // make underlying client Frozen to get invalid client status + clientState, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(ok, "could not retrieve client state") + tmClientState, ok := clientState.(*tmtypes.ClientState) + suite.Require().True(ok, "client is not tendermint client") + tmClientState.FrozenHeight = clienttypes.NewHeight(0, 1) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClientState) + }, clienttypes.ErrClientNotActive}, + {"timeout elapsed", func() { + packet.TimeoutTimestamp = 1 + }, channeltypes.ErrTimeoutElapsed}, + } - // Assert counterparty set and creator deleted - _, found = suite.chainB.App.GetPacketServer().ClientKeeper.GetCounterparty(suite.chainB.GetContext(), path.EndpointB.ClientID) - suite.Require().True(found) + for i, tc := range testCases { + tc := tc + suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { + suite.SetupTest() // reset + + // create clients and set counterparties on both chains + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // create standard packet that can be malleated + packet = channeltypes.NewPacketWithVersion(mock.MockPacketData, 1, mock.PortID, + path.EndpointA.ClientID, mock.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(1, 100), 0, mock.Version) + + // malleate the test case + tc.malleate() + + // send packet + seq, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, + packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().Equal(uint64(1), seq) + expCommitment := channeltypes.CommitPacket(packet) + suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Equal(uint64(0), seq) + suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) + + } + }) + } } diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 7b4c6a03b1f..2e9a701e2c8 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -43,4 +43,11 @@ type ClientKeeper interface { // the executing chain // This is a private path that is only used by the IBC lite module GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool) + // GetClientStatus returns the status of a client given the client ID + GetClientStatus(ctx sdk.Context, clientID string) exported.Status + // GetClientLatestHeight returns the latest height of a client given the client ID + GetClientLatestHeight(ctx sdk.Context, clientID string) clienttypes.Height + // GetClientTimestampAtHeight returns the timestamp for a given height on the client + // given its client ID and height + GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) } From 94ad62a00f818fa57b8787b35e125f99b8cda119 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 6 Aug 2024 15:18:09 +0300 Subject: [PATCH 007/172] feat(core/eureka): add recv handler (#7041) * feat(core/eureka): add recv handler. * review: address feedback, self review. * tests(core/packet-server): add tests for recv. * chore: make lint-fix. * chore: address review nits. --- modules/core/04-channel/keeper/events.go | 4 +- modules/core/04-channel/keeper/packet.go | 6 +- modules/core/packet-server/keeper/keeper.go | 87 +++++++++++++ .../core/packet-server/keeper/keeper_test.go | 119 ++++++++++++++++++ .../packet-server/types/expected_keepers.go | 3 + 5 files changed, 214 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index 136c382bb12..9a5d6264bf8 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -146,9 +146,9 @@ func EmitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha }) } -// emitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet +// EmitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet // is received for a certain sequence and for all duplicate receives. -func emitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { +func EmitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 0711722cc55..cb886330bb5 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -203,7 +203,7 @@ func (k *Keeper) RecvPacket( ) // emit an event that the relayer can query for - emitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, channel) return channel.Version, nil } @@ -227,7 +227,7 @@ func (k *Keeper) applyReplayProtection(ctx sdk.Context, packet types.Packet, cha // by the increase of the recvStartSequence. _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { - emitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -251,7 +251,7 @@ func (k *Keeper) applyReplayProtection(ctx sdk.Context, packet types.Packet, cha } if packet.GetSequence() < nextSequenceRecv { - emitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 49d6e9ed410..d73501bf792 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,7 +1,10 @@ package keeper import ( + "strconv" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,6 +13,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -28,6 +32,12 @@ func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientK } } +// Logger returns a module-specific logger. +func (Keeper) Logger(ctx sdk.Context) log.Logger { + // TODO: prefix some submodule identifier? + return ctx.Logger().With("module", "x/"+exported.ModuleName) +} + func (k Keeper) SendPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -99,3 +109,80 @@ func (k Keeper) SendPacket( // return the sequence return sequence, nil } + +func (k Keeper) RecvPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, +) error { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + // Note: This can be implemented by the current keeper + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + if !ok { + return channeltypes.ErrChannelNotFound + } + if counterparty.ClientId != packet.SourceChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + // check if packet timed out by comparing it with the latest height of the chain + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(selfHeight, selfTimestamp) { + return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + } + + // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received + // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale + // by the increase of the recvStartSequence. + _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + if found { + channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) + // This error indicates that the packet has already been relayed. Core IBC will + // treat this error as a no-op in order to prevent an entire relay transaction + // from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + // create key/value pair for proof verification by appending the ICS24 path to the last element of the counterparty merklepath + // TODO: allow for custom prefix + path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + commitment := channeltypes.CommitPacket(packet) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + packet.DestinationChannel, + proofHeight, + 0, 0, + proof, + merklePath, + commitment, + ); err != nil { + return err + } + + // Set Packet Receipt to prevent timeout from occurring on counterparty + k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + + // log that a packet has been received & executed + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit the same events as receive packet without channel fields + channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) + + return nil +} + +// sentinelChannel creates a sentinel channel for use in events for Eureka protocol handlers. +func sentinelChannel(clientID string) channeltypes.Channel { + return channeltypes.Channel{Ordering: channeltypes.UNORDERED, ConnectionHops: []string{clientID}} +} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index aae084891a8..d2f58b93225 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -8,11 +8,18 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" tmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" ) +var ( + defaultTimeoutHeight = clienttypes.NewHeight(1, 100) + disabledTimeoutTimestamp = uint64(0) +) + // KeeperTestSuite is a testing suite to test keeper functions. type KeeperTestSuite struct { testifysuite.Suite @@ -109,3 +116,115 @@ func (suite *KeeperTestSuite) TestSendPacket() { }) } } + +func (suite *KeeperTestSuite) TestRecvPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not V2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrChannelNotFound, + }, + { + "failure: client is not active", + func() { + clientState, ok := suite.chainB.GetClientState(packet.DestinationChannel).(*tmtypes.ClientState) + suite.Require().True(ok) + clientState.FrozenHeight = clienttypes.NewHeight(0, 1) + suite.chainB.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainB.GetContext(), packet.DestinationChannel, clientState) + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has timed out", + func() { + packet.TimeoutHeight = clienttypes.ZeroHeight() + packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + }, + channeltypes.ErrTimeoutElapsed, + }, + { + "failure: packet already received", + func() { + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: verify membership failed", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, []byte("")) + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + + // For now, set packet commitment on A for each case and update clients. Use SendPacket after 7048. + suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, channeltypes.CommitPacket(packet)) + + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + + tc.malleate() + + // get proof of packet commitment from chainA + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + err := suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().True(found) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 2e9a701e2c8..c1c4879878c 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -29,6 +29,9 @@ type ChannelKeeper interface { // This is a public path that is standardized by the IBC specification SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) + // GetPacketReceipt returns the packet receipt from the packet receipt path + GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) + // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) From 8c3a9a4a37a164eea4c16ea286752df7fab1651c Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:47:14 +0200 Subject: [PATCH 008/172] feat(core/eureka): add timeout handler (#7060) * timeout eureka implementation * test progress * continued progress with tests * tests * cleanup and docs * use sentinel channel in sendPacket events * address review * test review fixes * lint --- modules/core/04-channel/keeper/events.go | 2 +- modules/core/04-channel/keeper/keeper.go | 2 +- modules/core/04-channel/keeper/packet.go | 2 +- modules/core/04-channel/keeper/timeout.go | 8 +- modules/core/packet-server/keeper/keeper.go | 88 ++++++++- .../core/packet-server/keeper/keeper_test.go | 181 ++++++++++++++++++ .../packet-server/types/expected_keepers.go | 2 +- 7 files changed, 271 insertions(+), 14 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index 9a5d6264bf8..be3a244a754 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -228,7 +228,7 @@ func emitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel ty // emitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet // is timed out for a certain sequence and for all duplicate timeouts. -func emitTimeoutPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { +func EmitTimeoutPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 33f9e6d2856..3c5e65b97f6 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -219,7 +219,7 @@ func (k *Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, store.Set(host.PacketCommitmentKey(portID, channelID, sequence), commitmentHash) } -func (k *Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) DeletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) store.Delete(host.PacketCommitmentKey(portID, channelID, sequence)) } diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index cb886330bb5..8873173199f 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -472,7 +472,7 @@ func (k *Keeper) AcknowledgePacket( } // Delete packet commitment, since the packet has been acknowledged, the commitement is no longer necessary - k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + k.DeletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // log that a packet has been acknowledged k.Logger(ctx).Info( diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index d788d647b1f..e834e5f8e82 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -76,7 +76,7 @@ func (k *Keeper) TimeoutPacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -148,7 +148,7 @@ func (k *Keeper) TimeoutExecuted( ) } - k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + k.DeletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING && channel.Ordering == types.UNORDERED { @@ -183,7 +183,7 @@ func (k *Keeper) TimeoutExecuted( ) // emit an event marking that we have processed the timeout - emitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, channel) return nil } @@ -236,7 +236,7 @@ func (k *Keeper) TimeoutOnClose( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index d73501bf792..a0d34ef70b1 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "bytes" "strconv" errorsmod "cosmossdk.io/errors" @@ -99,12 +100,10 @@ func (k Keeper) SendPacket( k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - // create sentinel channel for events - channel := channeltypes.Channel{ - Ordering: channeltypes.ORDERED, - ConnectionHops: []string{sourceChannel}, - } - channelkeeper.EmitSendPacketEvent(ctx, packet, channel, timeoutHeight) + // log that a packet has been sent + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitSendPacketEvent(ctx, packet, sentinelChannel(sourceChannel), timeoutHeight) // return the sequence return sequence, nil @@ -182,6 +181,83 @@ func (k Keeper) RecvPacket( return nil } +func (k Keeper) TimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, + _ uint64, +) error { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + // Lookup counterparty associated with our channel and ensure that destination channel + // is the expected counterparty + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return channeltypes.ErrChannelNotFound + } + + if counterparty.ClientId != packet.DestinationChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + // check that timeout height or timeout timestamp has passed on the other end + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) + if err != nil { + return err + } + + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { + return errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + } + + // check that the commitment has not been cleared and that it matches the packet sent by relayer + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + + if len(commitment) == 0 { + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + // This error indicates that the timeout has already been relayed + // or there is a misconfigured relayer attempting to prove a timeout + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + } + + // verify packet receipt absence + path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyNonMembership( + ctx, + packet.SourceChannel, + proofHeight, + 0, 0, + proof, + merklePath, + ); err != nil { + return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + } + + // delete packet commitment to prevent replay + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + // log that a packet has been timed out + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit timeout events + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + + return nil +} + // sentinelChannel creates a sentinel channel for use in events for Eureka protocol handlers. func sentinelChannel(clientID string) channeltypes.Channel { return channeltypes.Channel{Ordering: channeltypes.UNORDERED, ConnectionHops: []string{clientID}} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index d2f58b93225..3e43bb97a87 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -228,3 +228,184 @@ func (suite *KeeperTestSuite) TestRecvPacket() { }) } } + +func (suite *KeeperTestSuite) TestTimeoutPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success with timeout height", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + nil, + }, + { + "success with timeout timestamp", + func() { + // disable timeout height and set timeout timestamp to a past timestamp + packet.TimeoutHeight = clienttypes.Height{} + packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + nil, + }, + { + "failure: invalid protocol version", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + packet.AppVersion = "" + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrChannelNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has not timed out yet", + func() { + packet.TimeoutHeight = defaultTimeoutHeight + + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + channeltypes.ErrTimeoutNotReached, + }, + { + "failure: packet already timed out", + func() {}, // equivalent to not sending packet at all + channeltypes.ErrNoOpMsg, + }, + { + "failure: packet does not match commitment", + func() { + // send a different packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, []byte("different data")) + suite.Require().NoError(err, "send packet failed") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: client status invalid", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: verify non-membership failed", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + // set packet receipt to mock a valid past receive + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + // initialize freezeClient to false + freezeClient = false + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // create default packet with a timed out height + // test cases may mutate timeout values + timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, "") + + tc.malleate() + + // need to update chainA's client representing chainB to prove missing ack + // commit the changes and update the clients + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + // get proof of packet receipt absence from chainB + receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointB.QueryProof(receiptKey) + + if freezeClient { + // make underlying client Frozen to get invalid client status + clientState, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(ok, "could not retrieve client state") + tmClientState, ok := clientState.(*tmtypes.ClientState) + suite.Require().True(ok, "client is not tendermint client") + tmClientState.FrozenHeight = clienttypes.NewHeight(0, 1) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClientState) + } + + err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, 0) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().Nil(commitment, "packet commitment not deleted") + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index c1c4879878c..b08c4a1fd48 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -16,7 +16,7 @@ type ChannelKeeper interface { GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte // DeletePacketCommitment deletes the packet commitment hash under the commitment path - // DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) + DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) // SetNextSequenceSend writes the next send sequence under the sequence path // This is a public path that is standardized by the IBC specification From 2b8a96d8e9a1e42bc5d8994c40efe3ea1ec6b722 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 7 Aug 2024 09:43:56 +0300 Subject: [PATCH 009/172] feat(core/eureka): add writeack, ack handler. (#7049) * feat(core/eureka): add writeack, ack handler. * tests(core/packet-server): add tests for write acknowledgement. * chore: add packet protocol version checks to both. * fix: add check for packet receipt being present. * tests(core/packet-server): add tests for ack. * tests: address review, add FreezeClient helper to endpoint. --- modules/core/04-channel/keeper/events.go | 8 +- modules/core/04-channel/keeper/packet.go | 6 +- modules/core/packet-server/keeper/keeper.go | 122 +++++++++ .../core/packet-server/keeper/keeper_test.go | 255 ++++++++++++++++-- .../packet-server/types/expected_keepers.go | 3 + testing/endpoint.go | 10 + 6 files changed, 378 insertions(+), 26 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index be3a244a754..0aa087d534b 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -173,8 +173,8 @@ func EmitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha }) } -// emitWriteAcknowledgementEvent emits an event that the relayer can query for -func emitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) { +// EmitWriteAcknowledgementEvent emits an event that the relayer can query for +func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeWriteAck, @@ -200,9 +200,9 @@ func emitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel }) } -// emitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time +// EmitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time // a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. -func emitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { +func EmitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcknowledgePacket, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 8873173199f..cf4cd10c571 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -356,7 +356,7 @@ func (k *Keeper) WriteAcknowledgement( "dst_channel", packet.GetDestChannel(), ) - emitWriteAcknowledgementEvent(ctx, packet.(types.Packet), channel, bz) + EmitWriteAcknowledgementEvent(ctx, packet.(types.Packet), channel, bz) return nil } @@ -423,7 +423,7 @@ func (k *Keeper) AcknowledgePacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitAcknowledgePacketEvent(ctx, packet, channel) + EmitAcknowledgePacketEvent(ctx, packet, channel) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -485,7 +485,7 @@ func (k *Keeper) AcknowledgePacket( ) // emit an event marking that we have processed the acknowledgement - emitAcknowledgePacketEvent(ctx, packet, channel) + EmitAcknowledgePacketEvent(ctx, packet, channel) // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING { diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index a0d34ef70b1..975a1d0c018 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -181,6 +181,128 @@ func (k Keeper) RecvPacket( return nil } +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packetI exported.PacketI, + ack exported.Acknowledgement, +) error { + packet, ok := packetI.(channeltypes.Packet) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) + } + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + if !ok { + return channeltypes.ErrChannelNotFound + } + if counterparty.ClientId != packet.SourceChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + // NOTE: IBC app modules might have written the acknowledgement synchronously on + // the OnRecvPacket callback so we need to check if the acknowledgement is already + // set on the store and return an error if so. + if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { + return channeltypes.ErrAcknowledgementExists + } + + if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { + return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") + } + + if ack == nil { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") + } + + bz := ack.Acknowledgement() + if len(bz) == 0 { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") + } + + k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) + + // log that a packet acknowledgement has been written + k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit the same events as write acknowledgement without channel fields + channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, sentinelChannel(packet.DestinationChannel), bz) + + return nil +} + +func (k Keeper) AcknowledgePacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + acknowledgement []byte, + proofAcked []byte, + proofHeight exported.Height, +) error { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return channeltypes.ErrChannelNotFound + } + + if counterparty.ClientId != packet.DestinationChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + if len(commitment) == 0 { + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + + // This error indicates that the acknowledgement has already been relayed + // or there is a misconfigured relayer attempting to prove an acknowledgement + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + } + + path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + packet.SourceChannel, + proofHeight, + 0, 0, + proofAcked, + merklePath, + channeltypes.CommitAcknowledgement(acknowledgement), + ); err != nil { + return err + } + + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + // log that a packet has been acknowledged + k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) + + // emit the same events as acknowledge packet without channel fields + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + + return nil +} + func (k Keeper) TimeoutPacket( ctx sdk.Context, packet channeltypes.Packet, diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 3e43bb97a87..027301a9ee4 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -10,7 +10,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - tmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" + "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" ) @@ -67,13 +67,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { packet.Data = nil }, channeltypes.ErrInvalidPacket}, {"client status invalid", func() { - // make underlying client Frozen to get invalid client status - clientState, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) - suite.Require().True(ok, "could not retrieve client state") - tmClientState, ok := clientState.(*tmtypes.ClientState) - suite.Require().True(ok, "client is not tendermint client") - tmClientState.FrozenHeight = clienttypes.NewHeight(0, 1) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClientState) + path.EndpointA.FreezeClient() }, clienttypes.ErrClientNotActive}, {"timeout elapsed", func() { packet.TimeoutTimestamp = 1 @@ -150,10 +144,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { { "failure: client is not active", func() { - clientState, ok := suite.chainB.GetClientState(packet.DestinationChannel).(*tmtypes.ClientState) - suite.Require().True(ok) - clientState.FrozenHeight = clienttypes.NewHeight(0, 1) - suite.chainB.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainB.GetContext(), packet.DestinationChannel, clientState) + path.EndpointB.FreezeClient() }, clienttypes.ErrClientNotActive, }, @@ -229,6 +220,238 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } } +func (suite *KeeperTestSuite) TestWriteAcknowledgement() { + var ( + packet channeltypes.Packet + ack exported.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not IBC_VERSION_2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrChannelNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: ack already exists", + func() { + ackBz := channeltypes.CommitAcknowledgement(ack.Acknowledgement()) + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence, ackBz) + }, + channeltypes.ErrAcknowledgementExists, + }, + { + "failure: ack is nil", + func() { + ack = nil + }, + channeltypes.ErrInvalidAcknowledgement, + }, + { + "failure: empty ack", + func() { + ack = mock.NewEmptyAcknowledgement() + }, + channeltypes.ErrInvalidAcknowledgement, + }, + { + "failure: receipt not found for packet", + func() { + packet.Sequence = 2 + }, + channeltypes.ErrInvalidPacket, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + ack = mock.MockAcknowledgement + + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + + tc.malleate() + + err := suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), nil, packet, ack) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + ackCommitment, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().True(found) + suite.Require().Equal(channeltypes.CommitAcknowledgement(ack.Acknowledgement()), ackCommitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestAcknowledgePacket() { + var ( + packet channeltypes.Packet + ack exported.Acknowledgement + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not IBC_VERSION_2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrChannelNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet commitment doesn't exist.", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeper.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: client status invalid", + func() { + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: packet commitment bytes differ", + func() { + packet.Data = []byte("") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: verify membership fails", + func() { + ack = channeltypes.NewResultAcknowledgement([]byte("swapped acknowledgement")) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + freezeClient = false + + // create packet receipt and acknowledgement + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err) + + // TODO: Clean up code when msg server handler routes correctly. + + // need to update chainA's client representing chainB to prove missing ack + // commit the changes and update the clients + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + + // get proof of packet commitment from chainA + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) + suite.Require().NoError(err) + + ack = mock.MockAcknowledgement + err = suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), nil, packet, ack) + suite.Require().NoError(err) + + tc.malleate() + + // need to update chainA's client representing chainB to prove missing ack + // commit the changes and update the clients + suite.coordinator.CommitBlock(path.EndpointB.Chain) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + packetKey = host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight = path.EndpointB.QueryProof(packetKey) + + if freezeClient { + path.EndpointA.FreezeClient() + } + + err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), nil, packet, ack.Acknowledgement(), proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) + suite.Require().Empty(commitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + func (suite *KeeperTestSuite) TestTimeoutPacket() { var ( path *ibctesting.Path @@ -385,13 +608,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { proof, proofHeight := path.EndpointB.QueryProof(receiptKey) if freezeClient { - // make underlying client Frozen to get invalid client status - clientState, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID) - suite.Require().True(ok, "could not retrieve client state") - tmClientState, ok := clientState.(*tmtypes.ClientState) - suite.Require().True(ok, "client is not tendermint client") - tmClientState.FrozenHeight = clienttypes.NewHeight(0, 1) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClientState) + path.EndpointA.FreezeClient() } err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, 0) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index b08c4a1fd48..c3e23572228 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -32,6 +32,9 @@ type ChannelKeeper interface { // GetPacketReceipt returns the packet receipt from the packet receipt path GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) + // HasPacketAcknowledgement check if the packet ack hash is already on the store + HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool + // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) diff --git a/testing/endpoint.go b/testing/endpoint.go index ea4b9c43a9a..83d72fc425f 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -165,6 +165,16 @@ func (endpoint *Endpoint) UpdateClient() (err error) { return endpoint.Chain.sendMsgs(msg) } +// FreezeClient freezes the IBC client associated with the endpoint. +func (endpoint *Endpoint) FreezeClient() { + clientState := endpoint.Chain.GetClientState(endpoint.ClientID) + tmClientState, ok := clientState.(*ibctm.ClientState) + require.True(endpoint.Chain.TB, ok) + + tmClientState.FrozenHeight = clienttypes.NewHeight(0, 1) + endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, tmClientState) +} + // ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) From 366ab9d481512748b5349db6e8bdaeafe0ee262f Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 8 Aug 2024 17:09:10 +0300 Subject: [PATCH 010/172] feat(core): Wire packet handler to core message server (#7091) * chore: return app version in handlers * add expected keeper interface for packet handler functions. * add switch in msg_server to dispatch based on protocol version. * guard TimeoutExecuted with version check for time being. * rename interface. * inline timeoutExecuted * slipped WriteAck. * use msg-server entrypoints for packet flow in testing. * use endpoint.SendPacket in recv test. --- modules/core/04-channel/keeper/export_test.go | 6 ++ modules/core/04-channel/keeper/timeout.go | 15 ++- .../core/04-channel/keeper/timeout_test.go | 7 +- modules/core/keeper/expected_keeper.go | 43 ++++++++ modules/core/keeper/keeper.go | 24 +++-- modules/core/keeper/msg_server.go | 98 +++++++++++++------ modules/core/packet-server/keeper/keeper.go | 53 +++++----- .../core/packet-server/keeper/keeper_test.go | 48 +++------ testing/endpoint.go | 27 +++++ 9 files changed, 216 insertions(+), 105 deletions(-) create mode 100644 modules/core/keeper/expected_keeper.go diff --git a/modules/core/04-channel/keeper/export_test.go b/modules/core/04-channel/keeper/export_test.go index bbe084b15c5..24ac7f29061 100644 --- a/modules/core/04-channel/keeper/export_test.go +++ b/modules/core/04-channel/keeper/export_test.go @@ -7,6 +7,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) @@ -34,3 +35,8 @@ func (k *Keeper) SetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID strin func (k *Keeper) SetRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { k.setRecvStartSequence(ctx, portID, channelID, sequence) } + +// TimeoutExecuted is a wrapper around timeoutExecuted to allow the function to be directly called in tests. +func (k *Keeper) TimeoutExecuted(ctx sdk.Context, capability *capabilitytypes.Capability, packet types.Packet) error { + return k.timeoutExecuted(ctx, capability, packet) +} diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index e834e5f8e82..90eefdb61a6 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -24,6 +24,7 @@ import ( // ante handler. func (k *Keeper) TimeoutPacket( ctx sdk.Context, + chanCap *capabilitytypes.Capability, packet types.Packet, proof []byte, proofHeight exported.Height, @@ -119,18 +120,21 @@ func (k *Keeper) TimeoutPacket( return "", err } - // NOTE: the remaining code is located in the TimeoutExecuted function + if err = k.timeoutExecuted(ctx, chanCap, packet); err != nil { + return "", err + } + return channel.Version, nil } -// TimeoutExecuted deletes the commitment send from this chain after it verifies timeout. +// timeoutExecuted deletes the commitment send from this chain after it verifies timeout. // If the timed-out packet came from an ORDERED channel then this channel will be closed. // If the channel is in the FLUSHING state and there is a counterparty upgrade, then the // upgrade will be aborted if the upgrade has timed out. Otherwise, if there are no more inflight packets, // then the channel will be set to the FLUSHCOMPLETE state. // // CONTRACT: this function must be called in the IBC handler -func (k *Keeper) TimeoutExecuted( +func (k *Keeper) timeoutExecuted( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet types.Packet, @@ -298,6 +302,9 @@ func (k *Keeper) TimeoutOnClose( return "", err } - // NOTE: the remaining code is located in the TimeoutExecuted function + if err = k.timeoutExecuted(ctx, chanCap, packet); err != nil { + return "", err + } + return channel.Version, nil } diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 26b55158907..1c9f77fa4f9 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -27,6 +27,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { var ( path *ibctesting.Path packet types.Packet + chanCap *capabilitytypes.Capability nextSeqRecv uint64 ordered bool expError *errorsmod.Error @@ -47,6 +48,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // need to update chainA's client representing chainB to prove missing ack err = path.EndpointA.UpdateClient() suite.Require().NoError(err) + + chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) }, true}, {"success: UNORDERED", func() { ordered = false @@ -60,6 +63,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // need to update chainA's client representing chainB to prove missing ack err = path.EndpointA.UpdateClient() suite.Require().NoError(err) + chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) }, true}, {"packet already timed out: ORDERED", func() { expError = types.ErrNoOpMsg @@ -144,6 +148,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) + suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, timeoutTimestamp) err = path.EndpointA.UpdateClient() @@ -220,7 +225,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { } } - channelVersion, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, nextSeqRecv) + channelVersion, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.TimeoutPacket(suite.chainA.GetContext(), chanCap, packet, proof, proofHeight, nextSeqRecv) if tc.expPass { suite.Require().NoError(err) diff --git a/modules/core/keeper/expected_keeper.go b/modules/core/keeper/expected_keeper.go new file mode 100644 index 00000000000..31b2ca2cdb5 --- /dev/null +++ b/modules/core/keeper/expected_keeper.go @@ -0,0 +1,43 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +type PacketHandler interface { + RecvPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height) (string, error) + + WriteAcknowledgement( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet exported.PacketI, + acknowledgement exported.Acknowledgement, + ) error + + AcknowledgePacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet channeltypes.Packet, + acknowledgement []byte, + proof []byte, + proofHeight exported.Height, + ) (string, error) + + TimeoutPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, + nextSequenceRecv uint64, + ) (string, error) +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index fed78a94888..da389975107 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -16,15 +16,17 @@ import ( channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" portkeeper "github.com/cosmos/ibc-go/v9/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" "github.com/cosmos/ibc-go/v9/modules/core/types" ) // Keeper defines each ICS keeper for IBC type Keeper struct { - ClientKeeper *clientkeeper.Keeper - ConnectionKeeper *connectionkeeper.Keeper - ChannelKeeper *channelkeeper.Keeper - PortKeeper *portkeeper.Keeper + ClientKeeper *clientkeeper.Keeper + ConnectionKeeper *connectionkeeper.Keeper + ChannelKeeper *channelkeeper.Keeper + PacketServerKeeper *packetserver.Keeper + PortKeeper *portkeeper.Keeper cdc codec.BinaryCodec @@ -54,14 +56,16 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) + packetKeeper := packetserver.NewKeeper(cdc, channelKeeper, clientKeeper) return &Keeper{ - cdc: cdc, - ClientKeeper: clientKeeper, - ConnectionKeeper: connectionKeeper, - ChannelKeeper: channelKeeper, - PortKeeper: portKeeper, - authority: authority, + cdc: cdc, + ClientKeeper: clientKeeper, + ConnectionKeeper: connectionKeeper, + ChannelKeeper: channelKeeper, + PacketServerKeeper: packetKeeper, + PortKeeper: portKeeper, + authority: authority, } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 3e112779371..d8b4a295326 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -3,11 +3,13 @@ package keeper import ( "context" "errors" + "fmt" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" @@ -460,6 +462,11 @@ func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Ms // RecvPacket defines a rpc handler method for MsgRecvPacket. func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (*channeltypes.MsgRecvPacketResponse, error) { + var ( + packetHandler PacketHandler + module string + capability *capabilitytypes.Capability + ) ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -468,11 +475,22 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - // Lookup module by channel capability - module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) - if err != nil { - ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + switch msg.Packet.ProtocolVersion { + case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: + packetHandler = k.ChannelKeeper + + // Lookup module by channel capability + module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) + if err != nil { + ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + } + + case channeltypes.IBC_VERSION_2: + packetHandler = k.PacketServerKeeper + module = msg.Packet.DestinationPort + default: + panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) } // Retrieve callbacks from router @@ -487,7 +505,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // If the packet was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight) + channelVersion, err := packetHandler.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight) switch err { case nil: @@ -518,7 +536,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the // acknowledgement is nil. if ack != nil { - if err := k.ChannelKeeper.WriteAcknowledgement(ctx, capability, msg.Packet, ack); err != nil { + if err := packetHandler.WriteAcknowledgement(ctx, capability, msg.Packet, ack); err != nil { return nil, err } } @@ -532,6 +550,11 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // Timeout defines a rpc handler method for MsgTimeout. func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { + var ( + packetHandler PacketHandler + module string + capability *capabilitytypes.Capability + ) ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -540,11 +563,22 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - // Lookup module by channel capability - module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) - if err != nil { - ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + switch msg.Packet.ProtocolVersion { + case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: + packetHandler = k.ChannelKeeper + + // Lookup module by channel capability + module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) + if err != nil { + ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + } + + case channeltypes.IBC_VERSION_2: + packetHandler = k.PacketServerKeeper + module = msg.Packet.SourcePort + default: + panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) } // Retrieve callbacks from router @@ -559,7 +593,7 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* // If the timeout was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.TimeoutPacket(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) + channelVersion, err := packetHandler.TimeoutPacket(cacheCtx, capability, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) switch err { case nil: @@ -573,11 +607,6 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, errorsmod.Wrap(err, "timeout packet verification failed") } - // Delete packet commitment - if err = k.ChannelKeeper.TimeoutExecuted(ctx, capability, msg.Packet); err != nil { - return nil, err - } - // Perform application logic callback err = cbs.OnTimeoutPacket(ctx, channelVersion, msg.Packet, relayer) if err != nil { @@ -635,11 +664,6 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime return nil, errorsmod.Wrap(err, "timeout on close packet verification failed") } - // Delete packet commitment - if err = k.ChannelKeeper.TimeoutExecuted(ctx, capability, msg.Packet); err != nil { - return nil, err - } - // Perform application logic callback // // NOTE: MsgTimeout and MsgTimeoutOnClose use the same "OnTimeoutPacket" @@ -659,6 +683,11 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime // Acknowledgement defines a rpc handler method for MsgAcknowledgement. func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { + var ( + packetHandler PacketHandler + module string + capability *capabilitytypes.Capability + ) ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -667,11 +696,22 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - // Lookup module by channel capability - module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) - if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + switch msg.Packet.ProtocolVersion { + case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: + packetHandler = k.ChannelKeeper + + // Lookup module by channel capability + module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) + if err != nil { + ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + } + + case channeltypes.IBC_VERSION_2: + packetHandler = k.PacketServerKeeper + module = msg.Packet.SourcePort + default: + panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) } // Retrieve callbacks from router @@ -686,7 +726,7 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck // If the acknowledgement was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.AcknowledgePacket(cacheCtx, capability, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + channelVersion, err := packetHandler.AcknowledgePacket(cacheCtx, capability, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) switch err { case nil: diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 975a1d0c018..7e8d37a0659 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -115,9 +115,9 @@ func (k Keeper) RecvPacket( packet channeltypes.Packet, proof []byte, proofHeight exported.Height, -) error { +) (string, error) { if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket + return "", channeltypes.ErrInvalidPacket } // Lookup counterparty associated with our channel and ensure that it was packet was indeed @@ -125,17 +125,17 @@ func (k Keeper) RecvPacket( // Note: This can be implemented by the current keeper counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return channeltypes.ErrChannelNotFound + return "", channeltypes.ErrChannelNotFound } if counterparty.ClientId != packet.SourceChannel { - return channeltypes.ErrInvalidChannelIdentifier + return "", channeltypes.ErrInvalidChannelIdentifier } // check if packet timed out by comparing it with the latest height of the chain selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) if timeout.Elapsed(selfHeight, selfTimestamp) { - return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") } // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received @@ -147,7 +147,7 @@ func (k Keeper) RecvPacket( // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return "", channeltypes.ErrNoOpMsg } // create key/value pair for proof verification by appending the ICS24 path to the last element of the counterparty merklepath @@ -166,7 +166,7 @@ func (k Keeper) RecvPacket( merklePath, commitment, ); err != nil { - return err + return "", err } // Set Packet Receipt to prevent timeout from occurring on counterparty @@ -178,7 +178,7 @@ func (k Keeper) RecvPacket( // emit the same events as receive packet without channel fields channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) - return nil + return packet.AppVersion, nil } func (k Keeper) WriteAcknowledgement( @@ -243,20 +243,20 @@ func (k Keeper) AcknowledgePacket( acknowledgement []byte, proofAcked []byte, proofHeight exported.Height, -) error { +) (string, error) { if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket + return "", channeltypes.ErrInvalidPacket } // Lookup counterparty associated with our channel and ensure that it was packet was indeed // sent by our counterparty. counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return channeltypes.ErrChannelNotFound + return "", channeltypes.ErrChannelNotFound } if counterparty.ClientId != packet.DestinationChannel { - return channeltypes.ErrInvalidChannelIdentifier + return "", channeltypes.ErrInvalidChannelIdentifier } commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) @@ -267,14 +267,14 @@ func (k Keeper) AcknowledgePacket( // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to // prevent an entire relay transaction from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return "", channeltypes.ErrNoOpMsg } packetCommitment := channeltypes.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) } path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) @@ -289,7 +289,7 @@ func (k Keeper) AcknowledgePacket( merklePath, channeltypes.CommitAcknowledgement(acknowledgement), ); err != nil { - return err + return "", err } k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) @@ -300,39 +300,40 @@ func (k Keeper) AcknowledgePacket( // emit the same events as acknowledge packet without channel fields channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) - return nil + return packet.AppVersion, nil } func (k Keeper) TimeoutPacket( ctx sdk.Context, + _ *capabilitytypes.Capability, packet channeltypes.Packet, proof []byte, proofHeight exported.Height, _ uint64, -) error { +) (string, error) { if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket + return "", channeltypes.ErrInvalidPacket } // Lookup counterparty associated with our channel and ensure that destination channel // is the expected counterparty counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return channeltypes.ErrChannelNotFound + return "", channeltypes.ErrChannelNotFound } if counterparty.ClientId != packet.DestinationChannel { - return channeltypes.ErrInvalidChannelIdentifier + return "", channeltypes.ErrInvalidChannelIdentifier } // check that timeout height or timeout timestamp has passed on the other end proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) if err != nil { - return err + return "", err } timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { - return errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") } // check that the commitment has not been cleared and that it matches the packet sent by relayer @@ -344,13 +345,13 @@ func (k Keeper) TimeoutPacket( // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to // prevent an entire relay transaction from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return "", channeltypes.ErrNoOpMsg } packetCommitment := channeltypes.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) } // verify packet receipt absence @@ -365,7 +366,7 @@ func (k Keeper) TimeoutPacket( proof, merklePath, ); err != nil { - return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) } // delete packet commitment to prevent replay @@ -377,7 +378,7 @@ func (k Keeper) TimeoutPacket( // emit timeout events channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) - return nil + return packet.AppVersion, nil } // sentinelChannel creates a sentinel channel for use in events for Eureka protocol handlers. diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 027301a9ee4..513a5412dbb 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -190,13 +190,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") - - // For now, set packet commitment on A for each case and update clients. Use SendPacket after 7048. - suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, channeltypes.CommitPacket(packet)) + // send packet + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, "", ibctesting.MockPacketData) + suite.Require().NoError(err) - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") tc.malleate() @@ -204,7 +202,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := path.EndpointA.QueryProof(packetKey) - err := suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) + _, err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) expPass := tc.expError == nil if expPass { @@ -323,7 +321,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func (suite *KeeperTestSuite) TestAcknowledgePacket() { var ( packet channeltypes.Packet - ack exported.Acknowledgement + ack = mock.MockAcknowledgement freezeClient bool ) @@ -398,45 +396,25 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { freezeClient = false - // create packet receipt and acknowledgement - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, "", ibctesting.MockPacketData) suite.Require().NoError(err) - // TODO: Clean up code when msg server handler routes correctly. - - // need to update chainA's client representing chainB to prove missing ack - // commit the changes and update the clients - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") - // get proof of packet commitment from chainA - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointA.QueryProof(packetKey) - - err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) - suite.Require().NoError(err) - - ack = mock.MockAcknowledgement - err = suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), nil, packet, ack) + err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) tc.malleate() - // need to update chainA's client representing chainB to prove missing ack - // commit the changes and update the clients - suite.coordinator.CommitBlock(path.EndpointB.Chain) - suite.Require().NoError(path.EndpointA.UpdateClient()) - - packetKey = host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight = path.EndpointB.QueryProof(packetKey) + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointB.QueryProof(packetKey) if freezeClient { path.EndpointA.FreezeClient() } - err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), nil, packet, ack.Acknowledgement(), proof, proofHeight) + _, err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), nil, packet, ack.Acknowledgement(), proof, proofHeight) expPass := tc.expError == nil if expPass { @@ -611,7 +589,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { path.EndpointA.FreezeClient() } - err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, 0) + _, err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), nil, packet, proof, proofHeight, 0) expPass := tc.expError == nil if expPass { diff --git a/testing/endpoint.go b/testing/endpoint.go index 86af3897678..89b4125fb78 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -453,6 +453,33 @@ func (endpoint *Endpoint) ChanCloseInit() error { return endpoint.Chain.sendMsgs(msg) } +// SendPacketV2 sends a packet through the packet server using the associated endpoint +// The counterparty client is updated so proofs can be sent to the counterparty chain. +// The packet sequence generated for the packet to be sent is returned. An error +// is returned if one occurs. +func (endpoint *Endpoint) SendPacketV2( + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + version string, + data []byte, +) (uint64, error) { + // no need to send message, acting as a module + sequence, err := endpoint.Chain.App.GetPacketServer().SendPacket(endpoint.Chain.GetContext(), nil, endpoint.ClientID, endpoint.ChannelConfig.PortID, endpoint.Counterparty.ChannelConfig.PortID, timeoutHeight, timeoutTimestamp, version, data) + if err != nil { + return 0, err + } + + // commit changes since no message was sent + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) + + err = endpoint.Counterparty.UpdateClient() + if err != nil { + return 0, err + } + + return sequence, nil +} + // SendPacket sends a packet through the channel keeper using the associated endpoint // The counterparty client is updated so proofs can be sent to the counterparty chain. // The packet sequence generated for the packet to be sent is returned. An error From 2a07e6e060c8ba8778297528e9a826b6045e295e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 9 Aug 2024 09:06:25 +0200 Subject: [PATCH 011/172] feat(eureka): fix condition in commit packet, added test for zero timeout height (#7109) * fix condition in commit packet, added test for zero timeout height, change some error messages and add some more comments * error for verify functions --- modules/core/02-client/keeper/keeper.go | 2 +- modules/core/02-client/types/client.go | 2 +- modules/core/02-client/types/errors.go | 2 +- modules/core/04-channel/types/packet.go | 4 ++-- modules/core/04-channel/types/packet_test.go | 23 +++++++++++++++----- modules/core/keeper/msg_server.go | 7 ++++-- modules/core/packet-server/keeper/keeper.go | 17 ++++++++++----- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 6efdf45fcd5..94de6e8887c 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -310,7 +310,7 @@ func (k *Keeper) SetCounterparty(ctx sdk.Context, clientID string, counterparty k.ClientStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) } -// GetCounterparty gets the counterparty client's identifier for a given client identifier. +// GetCounterparty gets the Counterparty for a given client identifier. func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { store := k.ClientStore(ctx, clientID) bz := store.Get([]byte(types.CounterpartyKey)) diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index c4ee5d17b77..72e47ecf40b 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -80,7 +80,7 @@ func (c Counterparty) Validate() error { } if c.MerklePathPrefix.Empty() { - return errorsmod.Wrap(ErrInvalidCounterparty, "counterparty prefix cannot be empty") + return errorsmod.Wrap(ErrInvalidCounterparty, "prefix cannot be empty") } return nil diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index b3771efdd8e..116e322ac6d 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -38,5 +38,5 @@ var ( ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty identifier") + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty") ) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index afc65a66eaf..5cb91786aeb 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -17,7 +17,7 @@ import ( // must commit to all fields in the packet apart from the source port // source channel and sequence (which will be committed to in the packet commitment key path) // and the ProtocolVersion which is defining how to hash the packet fields. -// NOTE: The commitment MUSTs be a fixed length preimage to prevent relayers from being able +// NOTE: The commitment MUST be a fixed length preimage to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. func CommitPacket(packet Packet) []byte { switch packet.ProtocolVersion { @@ -67,7 +67,7 @@ func commitV2Packet(packet Packet) []byte { timeoutBuf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) // only hash the timeout height if it is non-zero. This will allow us to remove it entirely in the future - if timeoutHeight.EQ(clienttypes.ZeroHeight()) { + if !timeoutHeight.EQ(clienttypes.ZeroHeight()) { revisionNumber := sdk.Uint64ToBigEndian(timeoutHeight.GetRevisionNumber()) timeoutBuf = append(timeoutBuf, revisionNumber...) diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index 92fd9a5002f..ed64c1aa10d 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -5,30 +5,41 @@ import ( "github.com/stretchr/testify/require" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) func TestCommitPacket(t *testing.T) { - packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - - commitment1 := types.CommitPacket(packet) + // V1 packet1 commitment + packet1 := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + commitment1 := types.CommitPacket(packet1) require.NotNil(t, commitment1) + // V2 packet commitment with empty app version packet2 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "") commitment2 := types.CommitPacket(packet2) require.NotNil(t, commitment2) - // even though versions are same empty string, - // the commitment is different because we use - // Eureka protocol for packet2 + // even though app version is empty for both packet1 and packet2 + // the commitment is different because we use Eureka protocol for packet2 require.NotEqual(t, commitment1, commitment2) + // V2 packet commitment with non-empty app version packet3 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, validVersion) commitment3 := types.CommitPacket(packet3) require.NotNil(t, commitment3) require.NotEqual(t, commitment1, commitment3) require.NotEqual(t, commitment2, commitment3) + + // V2 packet commitment with non-empty app version and zero timeout height + packet4 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.ZeroHeight(), timeoutTimestamp, validVersion) + commitment4 := types.CommitPacket(packet4) + require.NotNil(t, commitment4) + + require.NotEqual(t, commitment1, commitment4) + require.NotEqual(t, commitment2, commitment4) + require.NotEqual(t, commitment3, commitment4) } func TestPacketValidateBasic(t *testing.T) { diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index d8b4a295326..5098d411f1e 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -28,6 +28,8 @@ var ( ) // CreateClient defines a rpc handler method for MsgCreateClient. +// It stores the signer of MsgCreateClient as the creator of the client, which is afterwards +// compared against the signer of MsgProvideCounterparty. // NOTE: The raw bytes of the concrete types encoded into protobuf.Any is passed to the client keeper. // The 02-client handler will route to the appropriate light client module based on client type and it is the responsibility // of the light client module to unmarshal and interpret the proto encoded bytes. @@ -146,16 +148,17 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.Msg creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) if !found { - return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "expected client creator to have been set") + return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "client creator must be set") } if creator != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected client creator %s to match signer %s", creator, msg.Signer) + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) } if _, ok := k.ClientKeeper.GetCounterparty(ctx, msg.ClientId); ok { return nil, errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) } + k.ClientKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) // Delete client creator from state as it is not needed after this point. k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 7e8d37a0659..330e13ed759 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -39,6 +39,7 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName) } +// TODO: add godoc func (k Keeper) SendPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -69,15 +70,15 @@ func (k Keeper) SendPacket( destPort, destChannel, timeoutHeight, timeoutTimestamp, version) if err := packet.ValidateBasic(); err != nil { - return 0, errorsmod.Wrap(err, "constructed packet failed basic validation") + return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) } - // check that the client of receiver chain is still active + // check that the client of counterparty chain is still active if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client state is not active: %s", status) + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) } - // retrieve latest height and timestamp of the client of receiver chain + // retrieve latest height and timestamp of the client of counterparty chain latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) if latestHeight.IsZero() { return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) @@ -109,6 +110,7 @@ func (k Keeper) SendPacket( return sequence, nil } +// TODO: add godoc func (k Keeper) RecvPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -166,7 +168,7 @@ func (k Keeper) RecvPacket( merklePath, commitment, ); err != nil { - return "", err + return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) } // Set Packet Receipt to prevent timeout from occurring on counterparty @@ -181,6 +183,7 @@ func (k Keeper) RecvPacket( return packet.AppVersion, nil } +// TODO: add godoc func (k Keeper) WriteAcknowledgement( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -236,6 +239,7 @@ func (k Keeper) WriteAcknowledgement( return nil } +// TODO: add godoc func (k Keeper) AcknowledgePacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -289,7 +293,7 @@ func (k Keeper) AcknowledgePacket( merklePath, channeltypes.CommitAcknowledgement(acknowledgement), ); err != nil { - return "", err + return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) } k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) @@ -303,6 +307,7 @@ func (k Keeper) AcknowledgePacket( return packet.AppVersion, nil } +// TODO: add godoc func (k Keeper) TimeoutPacket( ctx sdk.Context, _ *capabilitytypes.Capability, From 0743c090f7ff67dd73b691c5b70fd88de69c9aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:32:30 +0200 Subject: [PATCH 012/172] refactor: reduce channel lookup for timeout flow (#7149) --- modules/core/04-channel/keeper/export_test.go | 4 ++-- modules/core/04-channel/keeper/timeout.go | 10 +++------- modules/core/04-channel/keeper/timeout_test.go | 18 +----------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/modules/core/04-channel/keeper/export_test.go b/modules/core/04-channel/keeper/export_test.go index 24ac7f29061..b28e1db97d5 100644 --- a/modules/core/04-channel/keeper/export_test.go +++ b/modules/core/04-channel/keeper/export_test.go @@ -37,6 +37,6 @@ func (k *Keeper) SetRecvStartSequence(ctx sdk.Context, portID, channelID string, } // TimeoutExecuted is a wrapper around timeoutExecuted to allow the function to be directly called in tests. -func (k *Keeper) TimeoutExecuted(ctx sdk.Context, capability *capabilitytypes.Capability, packet types.Packet) error { - return k.timeoutExecuted(ctx, capability, packet) +func (k *Keeper) TimeoutExecuted(ctx sdk.Context, channel types.Channel, capability *capabilitytypes.Capability, packet types.Packet) error { + return k.timeoutExecuted(ctx, channel, capability, packet) } diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 90eefdb61a6..84b797b975e 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -120,7 +120,7 @@ func (k *Keeper) TimeoutPacket( return "", err } - if err = k.timeoutExecuted(ctx, chanCap, packet); err != nil { + if err = k.timeoutExecuted(ctx, channel, chanCap, packet); err != nil { return "", err } @@ -136,14 +136,10 @@ func (k *Keeper) TimeoutPacket( // CONTRACT: this function must be called in the IBC handler func (k *Keeper) timeoutExecuted( ctx sdk.Context, + channel types.Channel, chanCap *capabilitytypes.Capability, packet types.Packet, ) error { - channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", packet.GetSourcePort(), packet.GetSourceChannel()) - } - capName := host.ChannelCapabilityPath(packet.GetSourcePort(), packet.GetSourceChannel()) if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, capName) { return errorsmod.Wrapf( @@ -302,7 +298,7 @@ func (k *Keeper) TimeoutOnClose( return "", err } - if err = k.timeoutExecuted(ctx, chanCap, packet); err != nil { + if err = k.timeoutExecuted(ctx, channel, chanCap, packet); err != nil { return "", err } diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 1c9f77fa4f9..a5516b58221 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -283,22 +283,6 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { }, nil, }, - { - "channel not found", - func() { - // use wrong channel naming - path.Setup() - packet = types.NewPacket(ibctesting.MockPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, - func(packetCommitment []byte, err error) { - suite.Require().Error(err) - suite.Require().ErrorIs(err, types.ErrChannelNotFound) - - // packet never sent. - suite.Require().Nil(packetCommitment) - }, - nil, - }, { "incorrect capability ORDERED", func() { @@ -528,7 +512,7 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { tc.malleate() - err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.TimeoutExecuted(ctx, chanCap, packet) + err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.TimeoutExecuted(ctx, path.EndpointA.GetChannel(), chanCap, packet) pc := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) tc.expResult(pc, err) From 6efbdec71c27961c89908195f16226b411d44832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:48:53 +0200 Subject: [PATCH 013/172] imp: require stricter usage of app version in packet (#7146) * fix: add validation of protocol version and app version to packet validatebasic * Update modules/core/04-channel/types/packet_test.go * Update modules/core/04-channel/types/packet.go Co-authored-by: Carlos Rodriguez --------- Co-authored-by: Carlos Rodriguez --- modules/core/04-channel/types/packet.go | 4 ++++ modules/core/04-channel/types/packet_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 5cb91786aeb..549e8c975aa 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -2,6 +2,7 @@ package types import ( "crypto/sha256" + "slices" errorsmod "cosmossdk.io/errors" @@ -195,6 +196,9 @@ func (p Packet) ValidateBasic() error { if len(p.Data) == 0 { return errorsmod.Wrap(ErrInvalidPacket, "packet data bytes cannot be empty") } + if p.AppVersion != "" && slices.Contains([]IBCVersion{IBC_VERSION_UNSPECIFIED, IBC_VERSION_1}, p.ProtocolVersion) { + return errorsmod.Wrapf(ErrInvalidPacket, "app version cannot be specified when packet does not use protocol %s", IBC_VERSION_2) + } return nil } diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index ed64c1aa10d..412dcad5078 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -57,6 +57,9 @@ func TestPacketValidateBasic(t *testing.T) { {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), false, "disabled both timeout height and timestamp"}, {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), true, "disabled timeout timestamp, valid timeout height"}, + {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "version"), true, "valid v2 packet"}, + {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_1, "version"}, false, "invalid specifying of app version with protocol version 1"}, + {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_UNSPECIFIED, "version"}, false, "invalid specifying of app version with unspecified protocol version"}, {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, } From eb2830fd0605a16241b9fdac01059dbc4936c834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:00:07 +0200 Subject: [PATCH 014/172] chore: remove unnecessary comments (#7155) --- modules/core/packet-server/keeper/keeper.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 330e13ed759..43a12ac937a 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -152,8 +152,6 @@ func (k Keeper) RecvPacket( return "", channeltypes.ErrNoOpMsg } - // create key/value pair for proof verification by appending the ICS24 path to the last element of the counterparty merklepath - // TODO: allow for custom prefix path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) From 0a9b7995270e8ead4036adda3f991fbfdee2c38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Sun, 18 Aug 2024 22:30:16 +0200 Subject: [PATCH 015/172] imp: add tests for BuildMerklePath, make merkle path non-nullable in counterparty (#7160) * refactor: regenerate merkle path as non-nullable + add tests to build merkle path * fix: avoid mutating prefix provided * fix test build --------- Co-authored-by: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> --- modules/core/02-client/keeper/keeper_test.go | 2 +- modules/core/02-client/types/client.go | 2 +- modules/core/02-client/types/client.pb.go | 101 ++++++++---------- modules/core/02-client/types/client_test.go | 2 +- modules/core/02-client/types/msgs.go | 2 +- modules/core/keeper/msg_server_test.go | 2 +- modules/core/packet-server/types/merkle.go | 10 +- .../core/packet-server/types/merkle_test.go | 86 +++++++++++++++ proto/ibc/core/client/v1/client.proto | 2 +- testing/endpoint.go | 2 +- 10 files changed, 147 insertions(+), 64 deletions(-) create mode 100644 modules/core/packet-server/types/merkle_test.go diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 79595e5c12d..320debeab56 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -133,7 +133,7 @@ func (suite *KeeperTestSuite) TestSetCounterparty() { merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) counterparty := types.Counterparty{ ClientId: testClientID, - MerklePathPrefix: &merklePathPrefix, + MerklePathPrefix: merklePathPrefix, } suite.keeper.SetCounterparty(suite.ctx, testClientID, counterparty) diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index 72e47ecf40b..d2887878248 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -66,7 +66,7 @@ func (ics IdentifiedClientStates) Sort() IdentifiedClientStates { } // NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID string, merklePathPrefix *commitmenttypes.MerklePath) Counterparty { +func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { return Counterparty{ ClientId: clientID, MerklePathPrefix: merklePathPrefix, diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 12a978e9e33..738feab14fd 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -198,7 +198,7 @@ type Counterparty struct { // the client identifier of the counterparty chain ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // the merkle path that all ICS24 paths will be stored under - MerklePathPrefix *v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix,omitempty"` + MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` } func (m *Counterparty) Reset() { *m = Counterparty{} } @@ -241,11 +241,11 @@ func (m *Counterparty) GetClientId() string { return "" } -func (m *Counterparty) GetMerklePathPrefix() *v2.MerklePath { +func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { if m != nil { return m.MerklePathPrefix } - return nil + return v2.MerklePath{} } // Height is a monotonically increasing data type @@ -360,40 +360,40 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 523 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xb6, 0xdb, 0x2a, 0x6a, 0x2e, 0x55, 0x52, 0x99, 0x56, 0x0a, 0x41, 0x72, 0x22, 0x2f, 0xcd, - 0x40, 0x7d, 0xc4, 0x0c, 0x14, 0x04, 0x03, 0xc9, 0x42, 0x07, 0x50, 0x64, 0x06, 0x24, 0x24, 0x64, - 0xf9, 0xc7, 0xc5, 0x3e, 0xe1, 0xf3, 0x59, 0xbe, 0xb3, 0x21, 0x03, 0x3b, 0x13, 0x42, 0x62, 0x61, - 0xec, 0x9f, 0xd3, 0xb1, 0x23, 0x53, 0x85, 0x92, 0x8d, 0xbf, 0x02, 0xf9, 0xee, 0x42, 0x9a, 0x52, - 0x2a, 0xb6, 0xf7, 0xe3, 0x7b, 0xfe, 0xbe, 0xf7, 0x3d, 0x1f, 0xe8, 0xe3, 0x20, 0x84, 0x21, 0x2d, - 0x10, 0x0c, 0x53, 0x8c, 0x32, 0x0e, 0xab, 0x91, 0x8a, 0xec, 0xbc, 0xa0, 0x9c, 0x1a, 0x06, 0x0e, - 0x42, 0xbb, 0x06, 0xd8, 0xaa, 0x5c, 0x8d, 0x7a, 0x07, 0x31, 0x8d, 0xa9, 0x68, 0xc3, 0x3a, 0x92, - 0xc8, 0xde, 0xdd, 0x98, 0xd2, 0x38, 0x45, 0x50, 0x64, 0x41, 0x39, 0x83, 0x7e, 0x36, 0x57, 0xad, - 0xa3, 0x35, 0x0b, 0x25, 0x04, 0x73, 0x22, 0x98, 0x9c, 0x2b, 0x99, 0x04, 0x5a, 0x04, 0x1c, 0x9e, - 0x46, 0x28, 0xe3, 0x78, 0x86, 0x51, 0x34, 0x11, 0x84, 0xaf, 0xb9, 0xcf, 0x91, 0x71,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, 0xcc, 0x5a, 0x5f, 0x74, 0xd0, 0x50, 0x87, 0x79, 0x0a, 0x3a, 0x05, - 0xaa, 0x30, 0xc3, 0x34, 0xf3, 0xb2, 0x92, 0x04, 0xa8, 0x10, 0xfc, 0x3b, 0xe3, 0x3b, 0xbf, 0x2e, - 0xfb, 0xd7, 0x5b, 0x6e, 0x7b, 0x55, 0x78, 0x25, 0xf2, 0x8d, 0x69, 0x75, 0xdf, 0xad, 0x1b, 0xa6, - 0x65, 0x6b, 0x3d, 0x2d, 0xb9, 0x9f, 0xec, 0x7e, 0x3e, 0xeb, 0x6b, 0xdf, 0xcf, 0xfa, 0x9a, 0x35, - 0x02, 0x8d, 0xa9, 0x5f, 0xf8, 0x84, 0x19, 0x47, 0xa0, 0xe3, 0xa7, 0x29, 0xfd, 0x80, 0x22, 0x4f, - 0x1a, 0xc0, 0xba, 0xfa, 0x60, 0x7b, 0xd8, 0x74, 0xdb, 0xaa, 0x2c, 0x8f, 0xc9, 0xc6, 0xee, 0xf9, - 0xc2, 0xd4, 0x2f, 0x16, 0xa6, 0xfe, 0x73, 0x61, 0xea, 0x5f, 0x97, 0xa6, 0x76, 0xb1, 0x34, 0xb5, - 0x1f, 0x4b, 0x53, 0x7b, 0x7b, 0x12, 0x63, 0x9e, 0x94, 0x41, 0x6d, 0x08, 0x0c, 0x29, 0x23, 0x94, - 0x41, 0x1c, 0x84, 0xc7, 0x31, 0x85, 0xd5, 0x63, 0x48, 0x68, 0x54, 0xa6, 0x88, 0xc9, 0x07, 0xf4, - 0xc0, 0x39, 0x56, 0x2f, 0x95, 0xcf, 0x73, 0xc4, 0x82, 0x86, 0xf8, 0x95, 0x1e, 0xfe, 0x0e, 0x00, - 0x00, 0xff, 0xff, 0xa8, 0xfc, 0xb8, 0x84, 0xc9, 0x03, 0x00, 0x00, + // 528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 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 0x2b, 0x68, 0x80, 0x73, 0x49, 0xb1, + 0x3d, 0xb8, 0xf3, 0xfb, 0xa2, 0x73, 0x35, 0xe5, 0x35, 0x56, 0x81, 0x57, 0x72, 0xbf, 0x51, 0xad, + 0xc7, 0x5c, 0xb9, 0xa6, 0x5a, 0xa5, 0xd6, 0xd5, 0xca, 0xfb, 0xc9, 0xce, 0x97, 0xd3, 0x8e, 0xf1, + 0xe3, 0xb4, 0x63, 0xd8, 0x7d, 0x58, 0x1d, 0xf9, 0xb9, 0x4f, 0xb9, 0x79, 0x08, 0x9b, 0x7e, 0x9a, + 0xb2, 0x8f, 0x38, 0x1a, 0xab, 0x36, 0xf0, 0x16, 0xe8, 0x6e, 0xf5, 0x6a, 0x5e, 0x43, 0x87, 0xd5, + 0x4c, 0xf9, 0xc0, 0x3b, 0x5b, 0x58, 0xe0, 0x7c, 0x61, 0x81, 0x5f, 0x0b, 0x0b, 0x7c, 0x5b, 0x5a, + 0xc6, 0xf9, 0xd2, 0x32, 0x7e, 0x2e, 0x2d, 0xe3, 0xdd, 0x71, 0x4c, 0x44, 0x52, 0x04, 0x65, 0x5b, + 0x50, 0xc8, 0x38, 0x65, 0x1c, 0x91, 0x20, 0x3c, 0x8a, 0x19, 0x9a, 0x3d, 0x46, 0x94, 0x45, 0x45, + 0x8a, 0xb9, 0xfa, 0x47, 0x0f, 0xdc, 0x23, 0xfd, 0x61, 0xc5, 0x7c, 0x8a, 0x79, 0x50, 0x95, 0x2f, + 0xea, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xcb, 0x7d, 0x43, 0xd0, 0x03, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -547,18 +547,16 @@ func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MerklePathPrefix != nil { - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintClient(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) @@ -706,10 +704,8 @@ func (m *Counterparty) Size() (n int) { if l > 0 { n += 1 + l + sovClient(uint64(l)) } - if m.MerklePathPrefix != nil { - l = m.MerklePathPrefix.Size() - n += 1 + l + sovClient(uint64(l)) - } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovClient(uint64(l)) return n } @@ -1192,9 +1188,6 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.MerklePathPrefix == nil { - m.MerklePathPrefix = &v2.MerklePath{} - } if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 21769232cb1..f8e40fdaf24 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -119,7 +119,7 @@ func TestValidateCounterparty(t *testing.T) { for _, tc := range testCases { tc := tc - counterparty := types.NewCounterparty(tc.clientID, &tc.merklePathPrefix) + counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) err := counterparty.Validate() expPass := tc.expError == nil diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index e8e0d100555..b0442e4a62b 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -269,7 +269,7 @@ func (msg *MsgRecoverClient) ValidateBasic() error { } // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix *commitmenttypes.MerklePath) *MsgProvideCounterparty { +func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { counterparty := NewCounterparty(counterpartyID, merklePathPrefix) return &MsgProvideCounterparty{ diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 839e519414b..73bcb53dd65 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -824,7 +824,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = clienttypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, &merklePrefix) + msg = clienttypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) tc.malleate() diff --git a/modules/core/packet-server/types/merkle.go b/modules/core/packet-server/types/merkle.go index 6c654677420..59be153c960 100644 --- a/modules/core/packet-server/types/merkle.go +++ b/modules/core/packet-server/types/merkle.go @@ -7,11 +7,15 @@ import ( // BuildMerklePath takes the merkle path prefix and an ICS24 path // and builds a new path by appending the ICS24 path to the last element of the merkle path prefix. -func BuildMerklePath(prefix *commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath { - if prefix == nil || len(prefix.KeyPath) == 0 { +func BuildMerklePath(prefix commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath { + if prefix.Empty() { return commitmenttypes.NewMerklePath(path) } - prefixKeys := prefix.KeyPath + + // avoid mutating the provided prefix + prefixKeys := make([][]byte, len(prefix.KeyPath)) + copy(prefixKeys, prefix.KeyPath) + lastElement := prefixKeys[len(prefixKeys)-1] // append path to last element newLastElement := cloneAppend(lastElement, path) diff --git a/modules/core/packet-server/types/merkle_test.go b/modules/core/packet-server/types/merkle_test.go new file mode 100644 index 00000000000..46c75dd2303 --- /dev/null +++ b/modules/core/packet-server/types/merkle_test.go @@ -0,0 +1,86 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +type TypesTestSuite struct { + suite.Suite + + coordinator *ibctesting.Coordinator + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain +} + +func (s *TypesTestSuite) SetupTest() { + s.coordinator = ibctesting.NewCoordinator(s.T(), 2) + s.chainA = s.coordinator.GetChain(ibctesting.GetChainID(1)) + s.chainB = s.coordinator.GetChain(ibctesting.GetChainID(2)) +} + +func TestTypesTestSuite(t *testing.T) { + suite.Run(t, new(TypesTestSuite)) +} + +func (s *TypesTestSuite) TestBuildMerklePath() { + path := ibctesting.NewPath(s.chainA, s.chainB) + path.SetupV2() + + prefixPath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + packetCommitmentKey := host.PacketCommitmentKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, 1) + + testCases := []struct { + name string + prefix commitmenttypesv2.MerklePath + path []byte + expPath commitmenttypesv2.MerklePath + }{ + { + name: "standard ibc path", + prefix: prefixPath, + path: packetCommitmentKey, + expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), packetCommitmentKey), + }, + { + name: "non-empty last element prefix path", + prefix: commitmenttypes.NewMerklePath([]byte("ibc"), []byte("abc")), + path: packetCommitmentKey, + expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), append([]byte("abc"), packetCommitmentKey...)), + }, + { + name: "many elements in prefix path", + prefix: commitmenttypes.NewMerklePath([]byte("ibc"), []byte("a"), []byte("b"), []byte("c"), []byte("d")), + path: packetCommitmentKey, + expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), []byte("a"), []byte("b"), []byte("c"), append([]byte("d"), packetCommitmentKey...)), + }, + { + name: "empty prefix", + prefix: commitmenttypesv2.MerklePath{}, + path: packetCommitmentKey, + expPath: commitmenttypesv2.NewMerklePath(packetCommitmentKey), + }, + { + name: "empty path", + prefix: prefixPath, + path: []byte{}, + expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), []byte("")), + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + merklePath := types.BuildMerklePath(tc.prefix, tc.path) + s.Require().Equal(tc.expPath, merklePath) + }) + } +} diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index 08c9591e26b..a6d5530c369 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -40,7 +40,7 @@ message Counterparty { // the client identifier of the counterparty chain string client_id = 1; // the merkle path that all ICS24 paths will be stored under - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2; + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; } // Height is a monotonically increasing data type diff --git a/testing/endpoint.go b/testing/endpoint.go index 89b4125fb78..4ce12cb675f 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -179,7 +179,7 @@ func (endpoint *Endpoint) FreezeClient() { func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - msg := clienttypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, &merklePath) + msg := clienttypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) From 1971ad5f3488e1729b97932ec35f33e4e5e2e12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:25:57 +0200 Subject: [PATCH 016/172] chore: add godoc to packet server handlers (#7156) * chore: add godoc * Apply suggestions from code review --------- Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- modules/core/packet-server/keeper/keeper.go | 48 ++++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 43a12ac937a..926905228b9 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -19,12 +19,15 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) +// Keeper defines the packet keeper. It wraps the client and channel keepers. +// It does not manage its own store. type Keeper struct { cdc codec.BinaryCodec ChannelKeeper types.ChannelKeeper ClientKeeper types.ClientKeeper } +// NewKeeper creates a new packet keeper func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { return &Keeper{ cdc: cdc, @@ -39,7 +42,10 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName) } -// TODO: add godoc +// SendPacket implements the packet sending logic required by a packet handler. +// It will generate a packet and store the commitment hash if all arguments provided are valid. +// The destination channel will be filled in using the counterparty information. +// The next sequence send will be initialized if this is the first packet sent for the given client. func (k Keeper) SendPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -101,16 +107,20 @@ func (k Keeper) SendPacket( k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - // log that a packet has been sent k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) channelkeeper.EmitSendPacketEvent(ctx, packet, sentinelChannel(sourceChannel), timeoutHeight) - // return the sequence return sequence, nil } -// TODO: add godoc +// RecvPacket implements the packet receiving logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If the packet has already been received a no-op error is returned. +// The packet handler will verify that the packet has not timed out and that the +// counterparty stored a packet commitment. If successful, a packet receipt is stored +// to indicate to the counterparty successful delivery. func (k Keeper) RecvPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -124,7 +134,6 @@ func (k Keeper) RecvPacket( // Lookup counterparty associated with our channel and ensure that it was packet was indeed // sent by our counterparty. - // Note: This can be implemented by the current keeper counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) if !ok { return "", channeltypes.ErrChannelNotFound @@ -172,16 +181,18 @@ func (k Keeper) RecvPacket( // Set Packet Receipt to prevent timeout from occurring on counterparty k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - // log that a packet has been received & executed k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - // emit the same events as receive packet without channel fields channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) return packet.AppVersion, nil } -// TODO: add godoc +// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement +// is written into state. func (k Keeper) WriteAcknowledgement( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -228,16 +239,19 @@ func (k Keeper) WriteAcknowledgement( k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) - // log that a packet acknowledgement has been written k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - // emit the same events as write acknowledgement without channel fields channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, sentinelChannel(packet.DestinationChannel), bz) return nil } -// TODO: add godoc +// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// the acknowledgement provided is verified to have been stored by the counterparty. +// If successful, the packet commitment is deleted and the packet has completed its lifecycle. func (k Keeper) AcknowledgePacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -296,16 +310,20 @@ func (k Keeper) AcknowledgePacket( k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - // log that a packet has been acknowledged k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) - // emit the same events as acknowledge packet without channel fields channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) return packet.AppVersion, nil } -// TODO: add godoc +// TimeoutPacket implements the timeout logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// an absence proof of the packet receipt is performed to ensure that the packet +// was never delivered to the counterparty. If successful, the packet commitment +// is deleted and the packet has completed its lifecycle. func (k Keeper) TimeoutPacket( ctx sdk.Context, _ *capabilitytypes.Capability, @@ -375,10 +393,8 @@ func (k Keeper) TimeoutPacket( // delete packet commitment to prevent replay k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - // log that a packet has been timed out k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - // emit timeout events channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) return packet.AppVersion, nil From a7c3de464b985056fba645dff3c4b61943c05883 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Tue, 20 Aug 2024 11:58:15 +0200 Subject: [PATCH 017/172] feat(eureka): add tests for `MsgProvideCounterparty` (#7179) * add tests for MsgProvideCounterparty ValidateBasic * address review comments --- modules/core/02-client/keeper/keeper_test.go | 12 +++- modules/core/02-client/types/msgs_test.go | 65 +++++++++++++++++++- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 320debeab56..607fbf37fd2 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestSetCounterparty() { } func (suite *KeeperTestSuite) TestSetCreator() { - clientID := "test-client" + clientID := ibctesting.FirstClientID expectedCreator := "test-creator" // Set the creator for the client @@ -161,9 +161,15 @@ func (suite *KeeperTestSuite) TestSetCreator() { suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") // Verify non stored creator is not found - retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, "client-0") + retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, ibctesting.SecondClientID) suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Equal(retrievedCreator, "", "Creator is not empty") + suite.Require().Empty(retrievedCreator, "Creator is not empty") + + // Verify that the creator is deleted from the store + suite.keeper.DeleteCreator(suite.ctx, clientID) + retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, clientID) + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Empty(retrievedCreator, "Creator is not empty") } func (suite *KeeperTestSuite) TestSetClientConsensusState() { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 6440ddabc8a..cfc73cc8578 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -681,7 +681,70 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { if expPass { suite.Require().NoError(err, "valid case %s failed", tc.name) } else { - suite.Require().Error(err, "invalid case %s passed", tc.name) + suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) + } + } +} + +// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty +func (suite *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { + var msg *types.MsgProvideCounterparty + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: invalid signer address", + func() { + msg.Signer = "invalid" + }, + ibcerrors.ErrInvalidAddress, + }, + { + "failure: invalid client ID", + func() { + msg.ClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid counterparty client ID", + func() { + msg.Counterparty.ClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: empty key path of counterparty of merkle path prefix", + func() { + msg.Counterparty.MerklePathPrefix.KeyPath = nil + }, + types.ErrInvalidCounterparty, + }, + } + + for _, tc := range testCases { + msg = types.NewMsgProvideCounterparty( + ibctesting.TestAccAddress, + ibctesting.FirstClientID, + ibctesting.SecondClientID, + commitmenttypes.NewMerklePath([]byte("key")), + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err, "valid case %s failed", tc.name) + } else { suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) } } From 88f6a3ff6203eb4803d0b53a5cf476574a7f2275 Mon Sep 17 00:00:00 2001 From: chandiniv1 <117723967+chandiniv1@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:54:20 +0530 Subject: [PATCH 018/172] add submodule to logger (#7196) * add submodule for logger * add submodule in keys.go --- modules/core/packet-server/keeper/keeper.go | 3 +-- modules/core/packet-server/types/keys.go | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 modules/core/packet-server/types/keys.go diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 926905228b9..b816df12fd8 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -38,8 +38,7 @@ func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientK // Logger returns a module-specific logger. func (Keeper) Logger(ctx sdk.Context) log.Logger { - // TODO: prefix some submodule identifier? - return ctx.Logger().With("module", "x/"+exported.ModuleName) + return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } // SendPacket implements the packet sending logic required by a packet handler. diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go new file mode 100644 index 00000000000..1dbfabd45e8 --- /dev/null +++ b/modules/core/packet-server/types/keys.go @@ -0,0 +1,3 @@ +package types + +const SubModuleName = "packetserver" From ad5748eaf27a02d8d9f4db7aaca2aa58f8670808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:23:16 +0200 Subject: [PATCH 019/172] tests: msg server tests for eureka (#7162) * test: TestAcknowledgePacketV2 * fix up recv tests * add timeout v2 tests * imp: use expErr instead of expPass --------- Co-authored-by: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> Co-authored-by: Carlos Rodriguez --- modules/core/keeper/msg_server_test.go | 437 +++++++++++++++++++++++++ 1 file changed, 437 insertions(+) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 73bcb53dd65..43e59b1c130 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -223,6 +223,179 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { } } +// tests the IBC handler receiving a packet using V2 protocol +func (suite *KeeperTestSuite) TestRecvPacketV2() { + var ( + packet channeltypes.Packet + path *ibctesting.Path + ) + + testCases := []struct { + name string + malleate func() + expErr error + expRevert bool + async bool // indicate no ack written + replay bool // indicate replay (no-op) + }{ + { + "success", + func() { + path.SetupV2() + + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + }, + nil, + false, + false, + false, + }, + { + "success: OnRecvPacket callback returns error acknowledgement", + func() { + path.SetupV2() + + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockFailPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + }, + nil, + true, + false, + false, + }, + { + "success: async acknowledgement", + func() { + path.SetupV2() + + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibcmock.MockAsyncPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + }, + nil, + false, + true, + false, + }, + { + "success no-op: packet already received (replay)", + func() { + // mock will panic if application callback is called twice on the same packet + path.SetupV2() + + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + err = path.EndpointB.RecvPacket(packet) + suite.Require().NoError(err) + }, + nil, + false, + false, + true, + }, + { + "channel does not exist", + func() { + // any non-nil value of packet is valid + suite.Require().NotNil(packet) + }, + channeltypes.ErrChannelNotFound, + false, + false, + false, + }, + { + "packet not sent", + func() { + path.SetupV2() + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + }, + fmt.Errorf("receive packet verification failed"), + false, + false, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + path = ibctesting.NewPath(suite.chainA, suite.chainB) + + tc.malleate() + + var ( + proof []byte + proofHeight clienttypes.Height + ) + // get proof of packet commitment from chainA + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + if path.EndpointA.ClientID != "" { + proof, proofHeight = path.EndpointA.QueryProof(packetKey) + } + + ctx := suite.chainB.GetContext() + msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) + res, err := suite.chainB.App.GetIBCKeeper().RecvPacket(ctx, msg) + + events := ctx.EventManager().Events() + + if tc.expErr == nil { + suite.Require().NoError(err) + + // replay should not fail since it will be treated as a no-op + _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) + suite.Require().NoError(err) + + // check that callback state was handled correctly + _, exists := suite.chainB.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainB.GetContext(), ibcmock.GetMockRecvCanaryCapabilityName(packet)) + if tc.expRevert { + suite.Require().False(exists, "capability exists in store even after callback reverted") + + // context events should contain error events + suite.Require().Contains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) + } else { + suite.Require().True(exists, "callback state not persisted when revert is false") + + if tc.replay { + // context should not contain application events + suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) + suite.Require().NotContains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + } else { + // context events should contain application events + suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) + } + } + + // verify if ack was written + ack, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + + if tc.async { + suite.Require().Nil(ack) + suite.Require().False(found) + } else { + suite.Require().NotNil(ack) + suite.Require().True(found) + } + } else { + suite.Require().ErrorContains(err, tc.expErr.Error()) + suite.Require().Nil(res) + } + }) + } +} + func (suite *KeeperTestSuite) TestRecoverClient() { var msg *clienttypes.MsgRecoverClient @@ -456,6 +629,133 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { } } +// tests the IBC handler acknowledgement of a packet using protocol version V2 +func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { + var ( + packet channeltypes.Packet + signer string + path *ibctesting.Path + ) + + testCases := []struct { + name string + malleate func() + expError error + replay bool // indicate replay (no-op) + }{ + { + "success", + func() {}, + nil, + false, + }, + { + "invalid signer", + func() { + signer = "invalid-signer" + }, + errors.New("Invalid address for msg Signer"), + false, + }, + { + "port route does not exist", + func() { + packet.SourcePort = "invalid-port" + }, + porttypes.ErrInvalidRoute, + false, + }, + { + "acknowledge packet fails in packet handler", + func() { + packet.SourceChannel = "invalid-client" + }, + channeltypes.ErrChannelNotFound, + false, + }, + { + "successful no-op: - packet already acknowledged (replay)", + func() { + err := path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) + suite.Require().NoError(err) + }, + nil, + true, + }, + { + "application callback returns error", + func() { + suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnAcknowledgementPacket = func(ctx sdk.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error { + return fmt.Errorf("mock app callback failed") + } + }, + fmt.Errorf("mock app callback failed"), + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + signer = suite.chainA.SenderAccount.GetAddress().String() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + err = path.EndpointB.RecvPacket(packet) + suite.Require().NoError(err) + + tc.malleate() + + var ( + proof []byte + proofHeight clienttypes.Height + ) + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight = path.EndpointB.QueryProof(packetKey) + + msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement.Acknowledgement(), proof, proofHeight, signer) + + ctx := suite.chainA.GetContext() + res, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(ctx, msg) + + events := ctx.EventManager().Events() + + if tc.expError == nil { + suite.Require().NoError(err) + + // verify packet commitment was deleted on source chain + has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + suite.Require().False(has) + + if tc.replay { + // context should not contain application events + suite.Require().NotContains(events, ibcmock.NewMockAckPacketEvent()) + suite.Require().Equal(channeltypes.NOOP, res.Result) + } else { + // context events should contain application events + suite.Require().Contains(events, ibcmock.NewMockAckPacketEvent()) + suite.Require().Equal(channeltypes.SUCCESS, res.Result) + + // replay should not error as it is treated as a no-op + res, err = suite.chainA.App.GetIBCKeeper().Acknowledgement(suite.chainA.GetContext(), msg) + suite.Require().NoError(err) + suite.Require().Equal(channeltypes.NOOP, res.Result) + } + } else { + suite.Require().ErrorContains(err, tc.expError.Error()) + suite.Require().Nil(res) + } + }) + } +} + // tests the IBC handler timing out a packet on ordered and unordered channels. // It verifies that the deletion of a packet commitment occurs. It tests // high level properties like ordering and basic sanity checks. More @@ -614,6 +914,143 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { } } +// tests the IBC handler timing out a packet for the V2 protocol. +// It verifies that the deletion of a packet commitment occurs. More +// rigorous testing of 'TimeoutPacket' and 'TimeoutExecuted' can be found in +// the packet-server/keeper/keeper_test.go. +func (suite *KeeperTestSuite) TestTimeoutPacketV2() { + var ( + packet channeltypes.Packet + packetKey []byte + path *ibctesting.Path + ) + + testCases := []struct { + name string + malleate func() + expErr error + noop bool // indicate no-op + }{ + { + "success", + func() { + path.SetupV2() + + timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + + // create packet commitment + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, "", ibctesting.MockPacketData) + suite.Require().NoError(err) + + // need to update chainA client to prove missing ack + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, timeoutTimestamp, "") + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + }, + nil, + false, + }, + { + "success: timeout out of order packet", + func() { + // setup uses an UNORDERED channel + path.SetupV2() + + // attempts to timeout the last packet sent without timing out the first packet + // packet sequences begin at 1 + for i := uint64(1); i < maxSequence; i++ { + timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) + + // create packet commitment + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + } + + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + }, + nil, + false, + }, + { + "success no-op: packet not sent", func() { + path.SetupV2() + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(0, 1), 0, "") + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + }, + nil, + true, + }, + { + "channel does not exist", + func() { + // any non-nil value of packet is valid + suite.Require().NotNil(packet) + + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + }, + channeltypes.ErrChannelNotFound, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + path = ibctesting.NewPath(suite.chainA, suite.chainB) + + tc.malleate() + + var ( + proof []byte + proofHeight clienttypes.Height + ) + if path.EndpointB.ClientID != "" { + proof, proofHeight = path.EndpointB.QueryProof(packetKey) + } + + ctx := suite.chainA.GetContext() + msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) + res, err := suite.chainA.App.GetIBCKeeper().Timeout(ctx, msg) + + events := ctx.EventManager().Events() + + if tc.expErr == nil { + suite.Require().NoError(err) + + // replay should not return an error as it is treated as a no-op + _, err := suite.chainA.App.GetIBCKeeper().Timeout(suite.chainA.GetContext(), msg) + suite.Require().NoError(err) + + // verify packet commitment was deleted on source chain + has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + suite.Require().False(has) + + if tc.noop { + // context should not contain application events + suite.Require().NotContains(events, ibcmock.NewMockTimeoutPacketEvent()) + } else { + // context should contain application events + suite.Require().Contains(events, ibcmock.NewMockTimeoutPacketEvent()) + } + + } else { + suite.Require().ErrorIs(err, tc.expErr) + suite.Require().Nil(res) + } + }) + } +} + // tests the IBC handler timing out a packet via channel closure on ordered // and unordered channels. It verifies that the deletion of a packet // commitment occurs. It tests high level properties like ordering and basic From 1c5e886ebf265be15dd5f3217531b1f1f20572ec Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:16:58 +0200 Subject: [PATCH 020/172] Validate MerklePathPrefix and Path (#7193) * merkle validation funcs * add merkle prefix validation and testing * address comments --------- Co-authored-by: Carlos Rodriguez --- modules/core/02-client/types/client.go | 4 +- modules/core/02-client/types/client_test.go | 24 +++++++ modules/core/23-commitment/types/v2/merkle.go | 34 ++++++++++ .../23-commitment/types/v2/merkle_test.go | 64 +++++++++++++++++++ 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 modules/core/23-commitment/types/v2/merkle_test.go diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index d2887878248..5346f2726c0 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -79,8 +79,8 @@ func (c Counterparty) Validate() error { return err } - if c.MerklePathPrefix.Empty() { - return errorsmod.Wrap(ErrInvalidCounterparty, "prefix cannot be empty") + if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { + return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) } return nil diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index f8e40fdaf24..2eabd3681f2 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -102,6 +102,24 @@ func TestValidateCounterparty(t *testing.T) { commitmenttypes.NewMerklePath([]byte("ibc")), nil, }, + { + "success with multiple element prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), + nil, + }, + { + "success with multiple element prefix, last prefix empty", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), + nil, + }, + { + "success with single empty key prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("")), + nil, + }, { "failure: invalid client id", "", @@ -114,6 +132,12 @@ func TestValidateCounterparty(t *testing.T) { commitmenttypes.NewMerklePath(), types.ErrInvalidCounterparty, }, + { + "failure: empty key in merkle path prefix first element", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), + types.ErrInvalidCounterparty, + }, } for _, tc := range testCases { diff --git a/modules/core/23-commitment/types/v2/merkle.go b/modules/core/23-commitment/types/v2/merkle.go index 08293709684..7cdccc1f39d 100644 --- a/modules/core/23-commitment/types/v2/merkle.go +++ b/modules/core/23-commitment/types/v2/merkle.go @@ -1,6 +1,7 @@ package v2 import ( + "errors" "fmt" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -28,3 +29,36 @@ func (mp MerklePath) GetKey(i uint64) ([]byte, error) { func (mp MerklePath) Empty() bool { return len(mp.KeyPath) == 0 } + +// ValidateAsPrefix validates the MerklePath to ensure it is a valid prefix +// Thus every element of the merkle path must be non-empty except for the last element +// which may be empty. In this case, the ICS24 path will be appended to the last element +// to form the full path. +func (mp MerklePath) ValidateAsPrefix() error { + if mp.Empty() { + return errors.New("path cannot have length 0") + } + + for i, key := range mp.KeyPath { + if len(key) == 0 && i != len(mp.KeyPath)-1 { + return fmt.Errorf("key at index %d cannot be empty", i) + } + } + return nil +} + +// ValidateAsPath validates the MerklePath as a fully constructed path. +// Here every element must be non-empty since the MerklePath is no longer +// acting as a prefix but is instead the full path intended for verification. +func (mp MerklePath) ValidateAsPath() error { + if mp.Empty() { + return errors.New("path cannot have length 0") + } + + for i, key := range mp.KeyPath { + if len(key) == 0 { + return fmt.Errorf("key at index %d cannot be empty", i) + } + } + return nil +} diff --git a/modules/core/23-commitment/types/v2/merkle_test.go b/modules/core/23-commitment/types/v2/merkle_test.go new file mode 100644 index 00000000000..f0701bd10f9 --- /dev/null +++ b/modules/core/23-commitment/types/v2/merkle_test.go @@ -0,0 +1,64 @@ +package v2 + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestMerklePathValidation(t *testing.T) { + cases := []struct { + name string + path MerklePath + expPrefixErr error + expPathErr error + }{ + { + "success: prefix and path", + NewMerklePath([]byte("key1"), []byte("key2")), + nil, + nil, + }, + { + "prefix with empty last key", + NewMerklePath([]byte("key1"), []byte("")), + nil, + errors.New("key at index 1 cannot be empty"), + }, + { + "prefix with single empty key", + NewMerklePath([]byte("")), + nil, + errors.New("key at index 0 cannot be empty"), + }, + { + "failure: empty path", + NewMerklePath(), + errors.New("path cannot have length 0"), + errors.New("path cannot have length 0"), + }, + { + "failure: prefix with empty first key", + NewMerklePath([]byte(""), []byte("key2")), + errors.New("key at index 0 cannot be empty"), + errors.New("key at index 0 cannot be empty"), + }, + } + + for _, tc := range cases { + err := tc.path.ValidateAsPrefix() + if tc.expPrefixErr == nil { + require.NoError(t, err, tc.name) + } else { + require.ErrorContains(t, err, tc.expPrefixErr.Error(), tc.name) + } + + err = tc.path.ValidateAsPath() + if tc.expPathErr == nil { + require.NoError(t, err, tc.name) + } else { + require.ErrorContains(t, err, tc.expPathErr.Error(), tc.name) + } + } +} From e66223ca519c01a2ca6e458b2c12a70d833c6aa3 Mon Sep 17 00:00:00 2001 From: chandiniv1 <117723967+chandiniv1@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:43:07 +0530 Subject: [PATCH 021/172] add helper to retrieve handler and module based on protocol version (#7198) * add helper to retrieve handler and module based on protocol version * address self review comments * returning values instead of binding vars * chore: clean up case for v1. --------- Co-authored-by: Carlos Rodriguez Co-authored-by: DimitrisJim --- modules/core/keeper/msg_server.go | 86 ++++++++++++++----------------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 5098d411f1e..30d5c9cf36d 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -478,22 +478,10 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - switch msg.Packet.ProtocolVersion { - case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: - packetHandler = k.ChannelKeeper - - // Lookup module by channel capability - module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) - if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - - case channeltypes.IBC_VERSION_2: - packetHandler = k.PacketServerKeeper - module = msg.Packet.DestinationPort - default: - panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) + packetHandler, module, capability, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) + if err != nil { + ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.DestinationPort, "channel-id", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } // Retrieve callbacks from router @@ -566,22 +554,10 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - switch msg.Packet.ProtocolVersion { - case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: - packetHandler = k.ChannelKeeper - - // Lookup module by channel capability - module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) - if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - - case channeltypes.IBC_VERSION_2: - packetHandler = k.PacketServerKeeper - module = msg.Packet.SourcePort - default: - panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) + packetHandler, module, capability, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.SourcePort, msg.Packet.SourceChannel) + if err != nil { + ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } // Retrieve callbacks from router @@ -699,22 +675,10 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - switch msg.Packet.ProtocolVersion { - case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: - packetHandler = k.ChannelKeeper - - // Lookup module by channel capability - module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) - if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - - case channeltypes.IBC_VERSION_2: - packetHandler = k.PacketServerKeeper - module = msg.Packet.SourcePort - default: - panic(fmt.Errorf("unsupported protocol version %d", msg.Packet.ProtocolVersion)) + packetHandler, module, capability, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.SourcePort, msg.Packet.SourceChannel) + if err != nil { + ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } // Retrieve callbacks from router @@ -1178,3 +1142,29 @@ func convertToErrorEvents(events sdk.Events) sdk.Events { return newEvents } + +// getPacketHandlerAndModule returns the appropriate packet handler, module name, and capability +// given the provided port and channel identifiers. The packet handler is determined by the +// provided protocol version. An error is returned if the module cannot be found or if the protocol +// version is not supported. +func (k *Keeper) getPacketHandlerAndModule(ctx sdk.Context, protocolVersion channeltypes.IBCVersion, port, channel string) (PacketHandler, string, *capabilitytypes.Capability, error) { + var ( + module string + capability *capabilitytypes.Capability + err error + ) + + switch protocolVersion { + case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: + // Lookup module by channel capability + module, capability, err = k.ChannelKeeper.LookupModuleByChannel(ctx, port, channel) + if err != nil { + return nil, "", nil, err + } + return k.ChannelKeeper, module, capability, nil + case channeltypes.IBC_VERSION_2: + return k.PacketServerKeeper, port, nil, nil + default: + return nil, "", nil, fmt.Errorf("unsupported protocol %s", protocolVersion) + } +} From 5d62925b5456c3aac2a9575d095c532dcca6fbb5 Mon Sep 17 00:00:00 2001 From: Vishal Potpelliwar <71565171+vishal-kanna@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:37:15 +0530 Subject: [PATCH 022/172] feat(eureka): Add gRPC query for Counterparty for a given client identifier (#7120) * chore: add grpc query for counterParty * chpre: made changes to the proto * chore: updated goDoc * chore: added creator to the respone * fix: fixes in the grpc_query * fixes * improve implementation and add tests * trying to fix weird linter error * fix build * chore: make counterparty field of response a non pointer. * chore: simplify logic, remove uneeded ifs * chore(tests): use expError pattern. --------- Co-authored-by: Carlos Rodriguez Co-authored-by: DimitrisJim --- modules/core/02-client/keeper/grpc_query.go | 22 + .../core/02-client/keeper/grpc_query_test.go | 96 +++ modules/core/02-client/types/query.pb.go | 597 +++++++++++++++--- modules/core/02-client/types/query.pb.gw.go | 101 +++ proto/ibc/core/client/v1/query.proto | 18 +- 5 files changed, 753 insertions(+), 81 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index b8d742ba838..995df5e02df 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -410,3 +410,25 @@ func (q *queryServer) VerifyMembership(c context.Context, req *types.QueryVerify Success: true, }, nil } + +// Client implements the Query/Client gRPC method +func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) (*types.QueryClientResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + res := types.QueryClientResponse{} + + sdkCtx := sdk.UnwrapSDKContext(ctx) + creator, _ := q.GetCreator(sdkCtx, req.ClientId) + res.Creator = creator + + counterparty, _ := q.GetCounterparty(sdkCtx, req.ClientId) + res.Counterparty = counterparty + + return &res, nil +} diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 5d37a0fdae0..c3d69c52779 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -954,3 +954,99 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { }) } } + +func (suite *KeeperTestSuite) TestQueryClient() { + var ( + req *types.QueryClientRequest + expCreator string + expCounterparty types.Counterparty + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + ctx := suite.chainA.GetContext() + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "success: no creator", + func() { + expCreator = "" + + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "success: no counterparty", + func() { + expCounterparty = types.Counterparty{} + + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "req is nil", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid clientID", + func() { + req = &types.QueryClientRequest{} + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + expCreator = ibctesting.TestAccAddress + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) + expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} + + tc.malleate() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) + res, err := queryServer.Client(suite.chainA.GetContext(), req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCreator, res.Creator) + suite.Require().Equal(expCounterparty, res.Counterparty) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/02-client/types/query.pb.go b/modules/core/02-client/types/query.pb.go index 2585a9a8988..b0eb1eea77a 100644 --- a/modules/core/02-client/types/query.pb.go +++ b/modules/core/02-client/types/query.pb.go @@ -1107,6 +1107,104 @@ func (m *QueryVerifyMembershipResponse) GetSuccess() bool { return false } +// QueryClientRequest is the request type for the Query/Client RPC method +type QueryClientRequest struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *QueryClientRequest) Reset() { *m = QueryClientRequest{} } +func (m *QueryClientRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClientRequest) ProtoMessage() {} +func (*QueryClientRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{20} +} +func (m *QueryClientRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientRequest.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 *QueryClientRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientRequest.Merge(m, src) +} +func (m *QueryClientRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClientRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo + +func (m *QueryClientRequest) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +// QueryClientRequest is the response type for the Query/Client RPC method +type QueryClientResponse struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` +} + +func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } +func (m *QueryClientResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClientResponse) ProtoMessage() {} +func (*QueryClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{21} +} +func (m *QueryClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientResponse.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 *QueryClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientResponse.Merge(m, src) +} +func (m *QueryClientResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientResponse proto.InternalMessageInfo + +func (m *QueryClientResponse) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *QueryClientResponse) GetCounterparty() Counterparty { + if m != nil { + return m.Counterparty + } + return Counterparty{} +} + func init() { proto.RegisterType((*QueryClientStateRequest)(nil), "ibc.core.client.v1.QueryClientStateRequest") proto.RegisterType((*QueryClientStateResponse)(nil), "ibc.core.client.v1.QueryClientStateResponse") @@ -1128,91 +1226,97 @@ func init() { proto.RegisterType((*QueryUpgradedConsensusStateResponse)(nil), "ibc.core.client.v1.QueryUpgradedConsensusStateResponse") proto.RegisterType((*QueryVerifyMembershipRequest)(nil), "ibc.core.client.v1.QueryVerifyMembershipRequest") proto.RegisterType((*QueryVerifyMembershipResponse)(nil), "ibc.core.client.v1.QueryVerifyMembershipResponse") + proto.RegisterType((*QueryClientRequest)(nil), "ibc.core.client.v1.QueryClientRequest") + proto.RegisterType((*QueryClientResponse)(nil), "ibc.core.client.v1.QueryClientResponse") } func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) } var fileDescriptor_dc42cdfd1d52d76e = []byte{ - // 1250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x4f, 0x1b, 0x47, - 0x1b, 0x67, 0x08, 0x10, 0x78, 0xec, 0x00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0xd7, 0x2d, 0x57, - 0x89, 0xce, 0xbe, 0x8a, 0xfe, 0xa1, 0x6e, 0x38, 0x61, 0x92, 0x39, 0xa1, 0x32, 0x6a, 0x96, 0x6e, - 0x38, 0x8e, 0xeb, 0x31, 0x78, 0x54, 0x68, 0xa7, 0xca, 0x6e, 0xd9, 0x65, 0x3f, 0xf5, 0xe0, 0x17, - 0x97, 0xaa, 0xdb, 0x70, 0xe5, 0x83, 0x00, 0xe7, 0x6d, 0x06, 0xe6, 0x43, 0xcf, 0xf0, 0x48, 0x9e, - 0x3c, 0xf4, 0x09, 0xf5, 0xf0, 0x2c, 0x8c, 0x71, 0x88, 0x05, 0xab, 0x94, 0x41, 0x0b, 0x68, 0x65, - 0x2c, 0x3f, 0xca, 0x05, 0xfb, 0x25, 0xf5, 0x09, 0x82, 0x4c, 0xa7, 0x23, 0xad, 0xb9, 0x0e, 0x25, - 0x78, 0x07, 0xd2, 0xc2, 0x93, 0x06, 0x72, 0xe6, 0x9c, 0xca, 0x4d, 0x69, 0x1c, 0x9f, 0x16, 0x42, - 0xd7, 0xde, 0x76, 0x8e, 0xf2, 0x29, 0xb3, 0x15, 0x00, 0x4f, 0xc1, 0x70, 0xad, 0xee, 0xba, 0x87, - 0x99, 0xc1, 0x05, 0xb4, 0x92, 0xce, 0xf3, 0x0f, 0x7c, 0x1b, 0xd2, 0xec, 0x47, 0xa1, 0x42, 0xac, - 0x72, 0xc5, 0xcb, 0x5c, 0x60, 0xe1, 0x14, 0xad, 0x73, 0x60, 0xda, 0x5d, 0x66, 0xb1, 0x37, 0x74, - 0xfa, 0xc7, 0xfc, 0x40, 0x3e, 0xc5, 0xbc, 0xb8, 0x48, 0x2d, 0x76, 0xe2, 0xa5, 0x61, 0xa5, 0x77, - 0x00, 0x5a, 0xe3, 0x14, 0x68, 0x5f, 0xd3, 0xf8, 0x3c, 0xb5, 0x60, 0xf6, 0x1a, 0x9f, 0xa5, 0x98, - 0xbd, 0x76, 0x60, 0x94, 0xc3,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0x7a, 0x75, 0x97, 0x68, 0x10, 0xba, 0x61, 0x54, 0x7d, 0x92, 0x19, 0xe6, 0xa1, 0xd9, - 0x07, 0xbe, 0x06, 0xe0, 0x59, 0x36, 0x29, 0x94, 0x48, 0xd5, 0x38, 0xca, 0x8c, 0x30, 0x76, 0x19, - 0x0b, 0x24, 0xef, 0x04, 0x02, 0x3c, 0x0f, 0xa9, 0x62, 0xd5, 0x35, 0x1f, 0x08, 0xfd, 0x45, 0xa6, - 0x07, 0x26, 0xe2, 0x06, 0xfb, 0x90, 0xb2, 0x49, 0xfd, 0x41, 0x95, 0x14, 0x6a, 0x86, 0x57, 0xc9, - 0x8c, 0x32, 0x64, 0x6a, 0x04, 0x59, 0xeb, 0xad, 0xd6, 0xc8, 0x69, 0xf7, 0x98, 0xe9, 0x81, 0xe1, - 0x55, 0x04, 0x42, 0xb0, 0x9b, 0x92, 0xf7, 0x86, 0x46, 0x87, 0x26, 0x87, 0xd5, 0x9b, 0x70, 0xad, - 0x4b, 0xfb, 0xc4, 0xc0, 0x32, 0x70, 0x91, 0xfa, 0xa6, 0x49, 0x28, 0xdf, 0xe1, 0xd1, 0x7c, 0xf8, - 0x99, 0x3b, 0x19, 0x87, 0x61, 0xe6, 0x8b, 0xbf, 0x41, 0x90, 0x8a, 0x6c, 0x0c, 0x7e, 0x5d, 0xd6, - 0xaa, 0x2e, 0x6f, 0x3c, 0x65, 0x2d, 0x99, 0x31, 0x87, 0xa3, 0xde, 0x38, 0xf9, 0xf5, 0xaf, 0xaf, - 0x06, 0x75, 0xbc, 0xae, 0x77, 0x7d, 0xce, 0x0a, 0x32, 0xd0, 0x1f, 0x35, 0xe7, 0x7e, 0x8c, 0xbf, - 0x46, 0x90, 0x8e, 0xbe, 0x53, 0x70, 0xa2, 0xac, 0xe1, 0x21, 0x57, 0xd6, 0x13, 0x5a, 0x0b, 0x90, - 0xd7, 0x19, 0xc8, 0x25, 0xbc, 0xd8, 0x13, 0x24, 0x7e, 0x8e, 0x60, 0x3c, 0xbe, 0xd2, 0x58, 0xeb, - 0x9e, 0x4c, 0x76, 0xf2, 0x14, 0x3d, 0xb1, 0xbd, 0x80, 0x57, 0x65, 0xf0, 0x0e, 0x71, 0x49, 0x0a, - 0xaf, 0x8d, 0x53, 0xa3, 0x6d, 0xd4, 0xc3, 0x77, 0x90, 0xfe, 0xa8, 0xed, 0x45, 0x75, 0xac, 0xf3, - 0xb3, 0x12, 0x51, 0x70, 0xc1, 0x31, 0x7e, 0x82, 0x60, 0xa2, 0x8d, 0xc3, 0x71, 0x52, 0xc8, 0xcd, - 0x01, 0x6c, 0x24, 0x77, 0x10, 0x45, 0xee, 0xb2, 0x22, 0x73, 0x78, 0xa3, 0xdf, 0x22, 0xf1, 0x29, - 0x82, 0x69, 0x29, 0x41, 0xe2, 0x1b, 0x09, 0x51, 0xc4, 0xb9, 0x5d, 0xd9, 0xee, 0xd7, 0x4d, 0x94, - 0xf0, 0x16, 0x2b, 0xe1, 0x16, 0xde, 0xed, 0x7b, 0x4e, 0x82, 0xae, 0xf1, 0xb7, 0xb1, 0xb5, 0xf7, - 0x93, 0xad, 0xbd, 0xdf, 0xd7, 0xda, 0xb7, 0xe8, 0x33, 0xf1, 0xd9, 0xf4, 0xe3, 0xfd, 0xfe, 0xa2, - 0x09, 0x92, 0x33, 0x61, 0x4f, 0x90, 0x31, 0x02, 0xee, 0x09, 0x32, 0x4e, 0xc9, 0xaa, 0xca, 0x40, - 0xce, 0x61, 0x45, 0x06, 0x92, 0x53, 0x30, 0xfe, 0x1e, 0xc1, 0x65, 0x09, 0xb7, 0xe2, 0xad, 0xae, - 0xa9, 0xba, 0x93, 0xb5, 0xf2, 0x46, 0x7f, 0x4e, 0x02, 0x66, 0x8e, 0xc1, 0x5c, 0xc3, 0xab, 0x32, - 0x98, 0x52, 0x62, 0xa7, 0xf8, 0x27, 0x04, 0x33, 0x72, 0xfa, 0xc5, 0xdb, 0xbd, 0x41, 0x48, 0xef, - 0x96, 0x9d, 0xbe, 0xfd, 0x92, 0xec, 0x42, 0xb7, 0x17, 0x00, 0x0d, 0x2e, 0x8b, 0xc9, 0x76, 0x2a, - 0xc2, 0xdd, 0x0f, 0x7f, 0x17, 0xd2, 0x57, 0x36, 0xfb, 0xf0, 0x08, 0x01, 0x3f, 0xfe, 0xfb, 0xe9, - 0x2a, 0x62, 0xa8, 0x57, 0x6f, 0xa1, 0x55, 0xf5, 0xff, 0x32, 0xe0, 0x0d, 0xe6, 0x5d, 0xb0, 0x9b, - 0xee, 0x7b, 0xf9, 0xd3, 0xb3, 0x2c, 0x7a, 0x76, 0x96, 0x45, 0x7f, 0x9e, 0x65, 0xd1, 0x97, 0xe7, - 0xd9, 0x81, 0x67, 0xe7, 0xd9, 0x81, 0xdf, 0xcf, 0xb3, 0x03, 0x9f, 0xed, 0x96, 0x2d, 0xaf, 0xe2, - 0x17, 0x03, 0x4a, 0xd6, 0xc5, 0xff, 0x32, 0x56, 0xd1, 0x5c, 0x2f, 0xbb, 0x7a, 0xe3, 0xa6, 0x6e, - 0xbb, 0x25, 0xbf, 0x4a, 0x28, 0x8f, 0xbf, 0x91, 0x5b, 0x17, 0x29, 0xbc, 0xa3, 0x1a, 0xa1, 0xc5, - 0x11, 0xf6, 0xf2, 0xd9, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x00, 0x51, 0xed, 0x2f, 0x12, - 0x00, 0x00, + // 1327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6b, 0x1b, 0x47, + 0x1b, 0xf7, 0x38, 0xb6, 0xe3, 0x3c, 0x52, 0xe2, 0x30, 0x49, 0x1c, 0x65, 0x93, 0xc8, 0xf2, 0xfa, + 0x7d, 0xe3, 0x8f, 0xda, 0xbb, 0x96, 0xdc, 0xd8, 0x4e, 0xa0, 0xd0, 0x3a, 0x25, 0x8d, 0x03, 0x49, + 0x5d, 0x95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, 0xea, 0xc5, 0x6c, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1249,6 +1353,8 @@ type QueryClient interface { UpgradedConsensusState(ctx context.Context, in *QueryUpgradedConsensusStateRequest, opts ...grpc.CallOption) (*QueryUpgradedConsensusStateResponse, error) // VerifyMembership queries an IBC light client for proof verification of a value at a given key path. VerifyMembership(ctx context.Context, in *QueryVerifyMembershipRequest, opts ...grpc.CallOption) (*QueryVerifyMembershipResponse, error) + // Client queries the counterparty of an IBC client. + Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) } type queryClient struct { @@ -1349,6 +1455,15 @@ func (c *queryClient) VerifyMembership(ctx context.Context, in *QueryVerifyMembe return out, nil } +func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) { + out := new(QueryClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/Client", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ClientState queries an IBC light client. @@ -1373,6 +1488,8 @@ type QueryServer interface { UpgradedConsensusState(context.Context, *QueryUpgradedConsensusStateRequest) (*QueryUpgradedConsensusStateResponse, error) // VerifyMembership queries an IBC light client for proof verification of a value at a given key path. VerifyMembership(context.Context, *QueryVerifyMembershipRequest) (*QueryVerifyMembershipResponse, error) + // Client queries the counterparty of an IBC client. + Client(context.Context, *QueryClientRequest) (*QueryClientResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1409,6 +1526,9 @@ func (*UnimplementedQueryServer) UpgradedConsensusState(ctx context.Context, req func (*UnimplementedQueryServer) VerifyMembership(ctx context.Context, req *QueryVerifyMembershipRequest) (*QueryVerifyMembershipResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VerifyMembership not implemented") } +func (*UnimplementedQueryServer) Client(ctx context.Context, req *QueryClientRequest) (*QueryClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Client not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1594,6 +1714,24 @@ func _Query_VerifyMembership_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClientRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Client(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Query/Client", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Client(ctx, req.(*QueryClientRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.client.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1638,6 +1776,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "VerifyMembership", Handler: _Query_VerifyMembership_Handler, }, + { + MethodName: "Client", + Handler: _Query_Client_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/client/v1/query.proto", @@ -2434,6 +2576,76 @@ func (m *QueryVerifyMembershipResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryClientRequest) 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 *QueryClientRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryClientResponse) 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 *QueryClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2757,6 +2969,34 @@ func (m *QueryVerifyMembershipResponse) Size() (n int) { return n } +func (m *QueryClientRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4869,6 +5109,203 @@ func (m *QueryVerifyMembershipResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryClientRequest) 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 ErrIntOverflowQuery + } + 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: QueryClientRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientRequest: 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryClientResponse) 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 ErrIntOverflowQuery + } + 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: QueryClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/query.pb.gw.go b/modules/core/02-client/types/query.pb.gw.go index 70d1ac22c2f..408a0a1057b 100644 --- a/modules/core/02-client/types/query.pb.gw.go +++ b/modules/core/02-client/types/query.pb.gw.go @@ -525,6 +525,60 @@ func local_request_Query_VerifyMembership_0(ctx context.Context, marshaler runti } +func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + msg, err := client.Client(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + msg, err := server.Client(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -761,6 +815,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Client_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1002,6 +1079,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Client_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1025,6 +1122,8 @@ var ( pattern_Query_UpgradedConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "client", "v1", "upgraded_consensus_states"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_VerifyMembership_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "client", "v1", "verify_membership"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Client_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "clients", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1047,4 +1146,6 @@ var ( forward_Query_UpgradedConsensusState_0 = runtime.ForwardResponseMessage forward_Query_VerifyMembership_0 = runtime.ForwardResponseMessage + + forward_Query_Client_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto index 1cc773e5990..7bf5e4f70de 100644 --- a/proto/ibc/core/client/v1/query.proto +++ b/proto/ibc/core/client/v1/query.proto @@ -71,6 +71,11 @@ service Query { body: "*" }; } + + // Client queries the counterparty of an IBC client. + rpc Client(QueryClientRequest) returns (QueryClientResponse) { + option (google.api.http).get = "/ibc/core/client/v1/clients/{client_id}"; + } } // QueryClientStateRequest is the request type for the Query/ClientState RPC @@ -241,4 +246,15 @@ message QueryVerifyMembershipRequest { message QueryVerifyMembershipResponse { // boolean indicating success or failure of proof verification. bool success = 1; -} \ No newline at end of file +} + +// QueryClientRequest is the request type for the Query/Client RPC method +message QueryClientRequest { + string client_id = 1; +} + +// QueryClientRequest is the response type for the Query/Client RPC method +message QueryClientResponse { + string creator = 1; + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; +} From ed164c3b77d228d676d8c78c91cb8998d62d29b7 Mon Sep 17 00:00:00 2001 From: Vishal Potpelliwar <71565171+vishal-kanna@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:44:50 +0530 Subject: [PATCH 023/172] feat(eureka): add CLI to submit `MsgProvideCounterparty` (#7118) * wip * wip * chore: added description * fix: fixed lint issues * address my self-review * lint * accept hex-encoded strings for merkle path prefix * fix build error --------- Co-authored-by: Carlos Rodriguez --- modules/core/02-client/client/cli/cli.go | 1 + modules/core/02-client/client/cli/tx.go | 54 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index 2490668f122..4b05f4dbac0 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -50,6 +50,7 @@ func NewTxCmd() *cobra.Command { newUpgradeClientCmd(), newSubmitRecoverClientProposalCmd(), newScheduleIBCUpgradeProposalCmd(), + newProvideCounterpartyCmd(), ) return txCmd diff --git a/modules/core/02-client/client/cli/tx.go b/modules/core/02-client/client/cli/tx.go index 223343dbfd9..8f4242ec6ca 100644 --- a/modules/core/02-client/client/cli/tx.go +++ b/modules/core/02-client/client/cli/tx.go @@ -1,9 +1,11 @@ package cli import ( + "encoding/hex" "fmt" "os" "strconv" + "strings" "github.com/spf13/cobra" @@ -20,6 +22,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -450,3 +453,54 @@ func newScheduleIBCUpgradeProposalCmd() *cobra.Command { return cmd } + +// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. +func newProvideCounterpartyCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "provide-counterparty [client-identifier] [counterparty-client-identifier] [counterparty-merkle-path-prefix]", + Args: cobra.ExactArgs(3), + Short: "provide the counterparty to an IBC client", + Long: `Provide the counterparty to an IBC client specified by its client ID. +The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, + Example: fmt.Sprintf("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + clientIdentifier := args[0] + counterpartyClientIdentifier := args[1] + counterpartyMerklePathPrefix, err := parseMerklePathPrefix(args[2]) + if err != nil { + return err + } + + counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) + msg := types.MsgProvideCounterparty{ + ClientId: clientIdentifier, + Counterparty: counterparty, + Signer: clientCtx.GetFromAddress().String(), + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. +func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { + var keyPath [][]byte + hexPrefixes := strings.Split(merklePathPrefixString, ",") + for _, hexPrefix := range hexPrefixes { + prefix, err := hex.DecodeString(hexPrefix) + if err != nil { + return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) + } + keyPath = append(keyPath, prefix) + } + + return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil +} From f4783d1e9a805c8fe64e171089c9f778a83165a2 Mon Sep 17 00:00:00 2001 From: chandiniv1 <117723967+chandiniv1@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:13:13 +0530 Subject: [PATCH 024/172] Use client and counterparty terminology in packet server (#7195) * Use client and counterparty terminology in packet server rather than channel * add counterparty not found error * add ErrCounterpartyNotFound * improve comment --------- Co-authored-by: Carlos Rodriguez --- modules/core/02-client/types/errors.go | 1 + modules/core/keeper/msg_server_test.go | 6 +- modules/core/packet-server/keeper/keeper.go | 26 ++++----- .../core/packet-server/keeper/keeper_test.go | 55 +++++++++++++------ 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index 116e322ac6d..f663019ab0f 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -39,4 +39,5 @@ var ( ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty") + ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 35, "counterparty not found") ) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 43e59b1c130..4a87d594d09 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -307,7 +307,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // any non-nil value of packet is valid suite.Require().NotNil(packet) }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, false, false, false, @@ -670,7 +670,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { func() { packet.SourceChannel = "invalid-client" }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, false, }, { @@ -996,7 +996,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, false, }, } diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index b816df12fd8..894ebb59b4a 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -59,7 +59,7 @@ func (k Keeper) SendPacket( // Lookup counterparty associated with our source channel to retrieve the destination channel counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) if !ok { - return 0, channeltypes.ErrChannelNotFound + return 0, errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, sourceChannel) } destChannel := counterparty.ClientId @@ -131,11 +131,11 @@ func (k Keeper) RecvPacket( return "", channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure that it was packet was indeed - // sent by our counterparty. + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return "", channeltypes.ErrChannelNotFound + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) } if counterparty.ClientId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier @@ -206,11 +206,11 @@ func (k Keeper) WriteAcknowledgement( return channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure that it was packet was indeed - // sent by our counterparty. + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return channeltypes.ErrChannelNotFound + return errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) } if counterparty.ClientId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier @@ -263,11 +263,11 @@ func (k Keeper) AcknowledgePacket( return "", channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure that it was packet was indeed - // sent by our counterparty. + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return "", channeltypes.ErrChannelNotFound + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) } if counterparty.ClientId != packet.DestinationChannel { @@ -334,11 +334,11 @@ func (k Keeper) TimeoutPacket( if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { return "", channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure that destination channel - // is the expected counterparty + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return "", channeltypes.ErrChannelNotFound + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) } if counterparty.ClientId != packet.DestinationChannel { diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 513a5412dbb..183f32a6be4 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -58,20 +58,39 @@ func (suite *KeeperTestSuite) TestSendPacket() { malleate func() expError error }{ - {"success", func() {}, nil}, - {"counterparty not found", func() { - packet.SourceChannel = ibctesting.FirstChannelID - }, channeltypes.ErrChannelNotFound}, - {"packet failed basic validation", func() { - // invalid data - packet.Data = nil - }, channeltypes.ErrInvalidPacket}, - {"client status invalid", func() { - path.EndpointA.FreezeClient() - }, clienttypes.ErrClientNotActive}, - {"timeout elapsed", func() { - packet.TimeoutTimestamp = 1 - }, channeltypes.ErrTimeoutElapsed}, + { + "success", + func() {}, + nil, + }, + { + "counterparty not found", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + clienttypes.ErrCounterpartyNotFound, + }, + { + "packet failed basic validation", + func() { + // invalid data + packet.Data = nil + }, + channeltypes.ErrInvalidPacket, + }, + { + "client status invalid", + func() { + path.EndpointA.FreezeClient() + }, + clienttypes.ErrClientNotActive, + }, + { + "timeout elapsed", func() { + packet.TimeoutTimestamp = 1 + }, + channeltypes.ErrTimeoutElapsed, + }, } for i, tc := range testCases { @@ -139,7 +158,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { func() { packet.DestinationChannel = ibctesting.FirstChannelID }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "failure: client is not active", @@ -246,7 +265,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { packet.DestinationChannel = ibctesting.FirstChannelID }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -347,7 +366,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { func() { packet.SourceChannel = ibctesting.FirstChannelID }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -489,7 +508,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.SourceChannel = ibctesting.FirstChannelID }, - channeltypes.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", From 8a324c290a1bef69e6fa3f650fa4597cf8e3c8dd Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 27 Aug 2024 13:05:17 +0300 Subject: [PATCH 025/172] chore: require app version be non-empty when protocol version is version 2 (#7209) * chore: require app version be non-empty when protocol version is version 2. * chore(tests): use constructor instead of direct struct initialization. * chore(tests): update usages in msg_server, packet_server tests to use non-empty app version. --- modules/core/04-channel/types/packet.go | 13 +++++--- modules/core/04-channel/types/packet_test.go | 4 ++- modules/core/keeper/msg_server_test.go | 32 +++++++++---------- .../core/packet-server/keeper/keeper_test.go | 12 +++---- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 549e8c975aa..49b569af9b2 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -3,6 +3,7 @@ package types import ( "crypto/sha256" "slices" + "strings" errorsmod "cosmossdk.io/errors" @@ -87,11 +88,9 @@ func commitV2Packet(packet Packet) []byte { destinationHash := sha256.Sum256([]byte(packet.GetDestChannel())) buf = append(buf, destinationHash[:]...) - // hash the version only if it is nonempty - if packet.AppVersion != "" { - versionHash := sha256.Sum256([]byte(packet.AppVersion)) - buf = append(buf, versionHash[:]...) - } + // hash the app version. + versionHash := sha256.Sum256([]byte(packet.AppVersion)) + buf = append(buf, versionHash[:]...) // hash the data dataHash := sha256.Sum256(packet.GetData()) @@ -199,6 +198,10 @@ func (p Packet) ValidateBasic() error { if p.AppVersion != "" && slices.Contains([]IBCVersion{IBC_VERSION_UNSPECIFIED, IBC_VERSION_1}, p.ProtocolVersion) { return errorsmod.Wrapf(ErrInvalidPacket, "app version cannot be specified when packet does not use protocol %s", IBC_VERSION_2) } + if strings.TrimSpace(p.AppVersion) == "" && p.ProtocolVersion == IBC_VERSION_2 { + return errorsmod.Wrapf(ErrInvalidPacket, "app version must be specified when packet uses protocol %s", IBC_VERSION_2) + } + return nil } diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index 412dcad5078..c688e44f29a 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -49,6 +49,7 @@ func TestPacketValidateBasic(t *testing.T) { errMsg string }{ {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"}, {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"}, {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"}, @@ -60,7 +61,8 @@ func TestPacketValidateBasic(t *testing.T) { {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "version"), true, "valid v2 packet"}, {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_1, "version"}, false, "invalid specifying of app version with protocol version 1"}, {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_UNSPECIFIED, "version"}, false, "invalid specifying of app version with unspecified protocol version"}, - {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, ""), false, "app version must be specified when packet uses protocol version 2"}, + {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, " "), false, "app version must be specified when packet uses protocol version 2"}, } for i, tc := range testCases { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 4a87d594d09..dafd0bd0609 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -243,10 +243,10 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { func() { path.SetupV2() - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) }, nil, false, @@ -258,10 +258,10 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { func() { path.SetupV2() - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockFailPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockFailPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) }, nil, true, @@ -273,10 +273,10 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { func() { path.SetupV2() - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibcmock.MockAsyncPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibcmock.MockAsyncPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) }, nil, false, @@ -289,10 +289,10 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // mock will panic if application callback is called twice on the same packet path.SetupV2() - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) }, @@ -316,7 +316,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { "packet not sent", func() { path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) }, fmt.Errorf("receive packet verification failed"), false, @@ -704,10 +704,10 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) @@ -940,14 +940,14 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) // create packet commitment - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) // need to update chainA client to prove missing ack err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, timeoutTimestamp, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, timeoutTimestamp, ibcmock.Version) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, nil, @@ -965,10 +965,10 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) // create packet commitment - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) } err := path.EndpointA.UpdateClient() @@ -982,7 +982,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { { "success no-op: packet not sent", func() { path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(0, 1), 0, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, nil, diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 183f32a6be4..03e107e3c1a 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -210,10 +210,10 @@ func (suite *KeeperTestSuite) TestRecvPacket() { path.SetupV2() // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) tc.malleate() @@ -313,7 +313,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) ack = mock.MockAcknowledgement suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) @@ -416,10 +416,10 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { freezeClient = false // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, "", ibctesting.MockPacketData) + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) @@ -590,7 +590,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // create default packet with a timed out height // test cases may mutate timeout values timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, "") + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) tc.malleate() From d98549bd6961752567048f69dde230441b4c096d Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 27 Aug 2024 17:42:31 +0300 Subject: [PATCH 026/172] chore(tests): add case for latest height err case. (#7212) --- modules/core/packet-server/keeper/keeper_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 03e107e3c1a..7de9f82a0da 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -11,6 +11,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" ) @@ -85,6 +86,21 @@ func (suite *KeeperTestSuite) TestSendPacket() { }, clienttypes.ErrClientNotActive, }, + { + "client state zero height", func() { + clientState := path.EndpointA.GetClientState() + cs, ok := clientState.(*ibctm.ClientState) + suite.Require().True(ok) + + // force a consensus state into the store at height zero to allow client status check to pass. + consensusState := path.EndpointA.GetConsensusState(cs.LatestHeight) + path.EndpointA.SetConsensusState(consensusState, clienttypes.ZeroHeight()) + + cs.LatestHeight = clienttypes.ZeroHeight() + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, cs) + }, + clienttypes.ErrInvalidHeight, + }, { "timeout elapsed", func() { packet.TimeoutTimestamp = 1 From d4d1dc6dfd3370b6ff1fb4a1d79c5a0c9bc28a00 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 2 Sep 2024 11:20:23 +0300 Subject: [PATCH 027/172] feat(events): dont emit channel information for eureka handlers) (#7230) --- modules/core/04-channel/keeper/events.go | 160 +++++++++++++------- modules/core/04-channel/keeper/packet.go | 14 +- modules/core/04-channel/keeper/timeout.go | 6 +- modules/core/packet-server/keeper/keeper.go | 21 +-- 4 files changed, 120 insertions(+), 81 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index 4683ed90da9..89aa79a652c 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -121,23 +121,32 @@ func emitChannelCloseConfirmEvent(ctx sdk.Context, portID string, channelID stri // emitSendPacketEvent emits an event with packet data along with other packet information for relayer // to pick up and relay to other chain -func EmitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeSendPacket, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), +func EmitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel *types.Channel, timeoutHeight exported.Height) { + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + } + + if channel != nil { + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSendPacket, + eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -148,23 +157,32 @@ func EmitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha // EmitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet // is received for a certain sequence and for all duplicate receives. -func EmitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRecvPacket, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), +func EmitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel *types.Channel) { + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + } + + if channel != nil { + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRecvPacket, + eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -174,24 +192,33 @@ func EmitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha } // EmitWriteAcknowledgementEvent emits an event that the relayer can query for -func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeWriteAck, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), +func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel *types.Channel, acknowledgement []byte) { + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), + } + + if channel != nil { + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeWriteAck, + eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -202,22 +229,31 @@ func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel // EmitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time // a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. -func EmitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAcknowledgePacket, - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), +func EmitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel *types.Channel) { + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + } + + if channel != nil { + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ) + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAcknowledgePacket, + eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -228,19 +264,27 @@ func EmitAcknowledgePacketEvent(ctx sdk.Context, packet types.Packet, channel ty // emitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet // is timed out for a certain sequence and for all duplicate timeouts. -func EmitTimeoutPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { +func EmitTimeoutPacketEvent(ctx sdk.Context, packet types.Packet, channel *types.Channel) { + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + } + + if channel != nil { + eventAttributes = append(eventAttributes, + sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + ) + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index cf4cd10c571..d3187727c56 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -89,7 +89,7 @@ func (k *Keeper) SendPacket( k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - EmitSendPacketEvent(ctx, packet, channel, timeoutHeight) + EmitSendPacketEvent(ctx, packet, &channel, timeoutHeight) k.Logger(ctx).Info( "packet sent", @@ -203,7 +203,7 @@ func (k *Keeper) RecvPacket( ) // emit an event that the relayer can query for - EmitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, &channel) return channel.Version, nil } @@ -227,7 +227,7 @@ func (k *Keeper) applyReplayProtection(ctx sdk.Context, packet types.Packet, cha // by the increase of the recvStartSequence. _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { - EmitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, &channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -251,7 +251,7 @@ func (k *Keeper) applyReplayProtection(ctx sdk.Context, packet types.Packet, cha } if packet.GetSequence() < nextSequenceRecv { - EmitRecvPacketEvent(ctx, packet, channel) + EmitRecvPacketEvent(ctx, packet, &channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -356,7 +356,7 @@ func (k *Keeper) WriteAcknowledgement( "dst_channel", packet.GetDestChannel(), ) - EmitWriteAcknowledgementEvent(ctx, packet.(types.Packet), channel, bz) + EmitWriteAcknowledgementEvent(ctx, packet.(types.Packet), &channel, bz) return nil } @@ -423,7 +423,7 @@ func (k *Keeper) AcknowledgePacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitAcknowledgePacketEvent(ctx, packet, channel) + EmitAcknowledgePacketEvent(ctx, packet, &channel) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -485,7 +485,7 @@ func (k *Keeper) AcknowledgePacket( ) // emit an event marking that we have processed the acknowledgement - EmitAcknowledgePacketEvent(ctx, packet, channel) + EmitAcknowledgePacketEvent(ctx, packet, &channel) // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING { diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 84b797b975e..bc7c6252409 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -77,7 +77,7 @@ func (k *Keeper) TimeoutPacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, &channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -183,7 +183,7 @@ func (k *Keeper) timeoutExecuted( ) // emit an event marking that we have processed the timeout - EmitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, &channel) return nil } @@ -236,7 +236,7 @@ func (k *Keeper) TimeoutOnClose( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, channel) + EmitTimeoutPacketEvent(ctx, packet, &channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 894ebb59b4a..5e4aaa1db4a 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -108,7 +108,7 @@ func (k Keeper) SendPacket( k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - channelkeeper.EmitSendPacketEvent(ctx, packet, sentinelChannel(sourceChannel), timeoutHeight) + channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) return sequence, nil } @@ -153,7 +153,7 @@ func (k Keeper) RecvPacket( // by the increase of the recvStartSequence. _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) if found { - channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -182,7 +182,7 @@ func (k Keeper) RecvPacket( k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - channelkeeper.EmitRecvPacketEvent(ctx, packet, sentinelChannel(packet.DestinationChannel)) + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) return packet.AppVersion, nil } @@ -240,7 +240,7 @@ func (k Keeper) WriteAcknowledgement( k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, sentinelChannel(packet.DestinationChannel), bz) + channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) return nil } @@ -276,7 +276,7 @@ func (k Keeper) AcknowledgePacket( commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement @@ -311,7 +311,7 @@ func (k Keeper) AcknowledgePacket( k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) return packet.AppVersion, nil } @@ -360,7 +360,7 @@ func (k Keeper) TimeoutPacket( commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -394,12 +394,7 @@ func (k Keeper) TimeoutPacket( k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, sentinelChannel(packet.SourceChannel)) + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) return packet.AppVersion, nil } - -// sentinelChannel creates a sentinel channel for use in events for Eureka protocol handlers. -func sentinelChannel(clientID string) channeltypes.Channel { - return channeltypes.Channel{Ordering: channeltypes.UNORDERED, ConnectionHops: []string{clientID}} -} From 463893335cc9a9fc3a1f15c732f4989a07efded9 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 4 Sep 2024 12:18:35 +0300 Subject: [PATCH 028/172] feat(02-client/cli): add query for client counterparty. (#7235) * feat(02-client/cli): add query for client counterparty. * chore: mirror grpc name. * Apply suggestions from code review Co-authored-by: Carlos Rodriguez --------- Co-authored-by: Carlos Rodriguez --- modules/core/02-client/client/cli/cli.go | 1 + modules/core/02-client/client/cli/query.go | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index 4b05f4dbac0..545dafda7db 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -26,6 +26,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryConsensusStateHeights(), GetCmdQueryConsensusState(), GetCmdQueryHeader(), + GetCmdQueryClient(), GetCmdSelfConsensusState(), GetCmdClientParams(), ) diff --git a/modules/core/02-client/client/cli/query.go b/modules/core/02-client/client/cli/query.go index 082fc2004bf..05a5e79acd7 100644 --- a/modules/core/02-client/client/cli/query.go +++ b/modules/core/02-client/client/cli/query.go @@ -210,6 +210,38 @@ func GetCmdQueryConsensusStateHeights() *cobra.Command { return cmd } +// GetCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID. +func GetCmdQueryClient() *cobra.Command { + cmd := &cobra.Command{ + Use: "client [client-id]", + Short: "Query the information of a client.", + Long: "Query the client information (creator and counterparty) for the provided client ID.", + Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, ibcexported.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + clientID := args[0] + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryClientRequest{ClientId: clientID} + + res, err := queryClient.Client(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // GetCmdQueryConsensusState defines the command to query the consensus state of // the chain as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#query func GetCmdQueryConsensusState() *cobra.Command { From 70ceada131d7e188c3d5863b1c40c0c1b2f6a6bd Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 10 Sep 2024 13:45:15 +0300 Subject: [PATCH 029/172] chore: move handler implementations into a relay.go file. (#7271) Co-authored-by: Aditya --- modules/core/packet-server/keeper/keeper.go | 367 ----------------- modules/core/packet-server/keeper/relay.go | 376 ++++++++++++++++++ .../keeper/{keeper_test.go => relay_test.go} | 0 3 files changed, 376 insertions(+), 367 deletions(-) create mode 100644 modules/core/packet-server/keeper/relay.go rename modules/core/packet-server/keeper/{keeper_test.go => relay_test.go} (100%) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 5e4aaa1db4a..411d3e9414b 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,20 +1,11 @@ package keeper import ( - "bytes" - "strconv" - - errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -40,361 +31,3 @@ func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientK func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } - -// SendPacket implements the packet sending logic required by a packet handler. -// It will generate a packet and store the commitment hash if all arguments provided are valid. -// The destination channel will be filled in using the counterparty information. -// The next sequence send will be initialized if this is the first packet sent for the given client. -func (k Keeper) SendPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - sourceChannel string, - sourcePort string, - destPort string, - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, - version string, - data []byte, -) (uint64, error) { - // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) - if !ok { - return 0, errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, sourceChannel) - } - destChannel := counterparty.ClientId - - // retrieve the sequence send for this channel - // if no packets have been sent yet, initialize the sequence to 1. - sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) - if !found { - sequence = 1 - } - - // construct packet from given fields and channel state - packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, - destPort, destChannel, timeoutHeight, timeoutTimestamp, version) - - if err := packet.ValidateBasic(); err != nil { - return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) - } - - // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) - } - - // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) - if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) - } - - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) - if err != nil { - return 0, err - } - - // check if packet is timed out on the receiving chain - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(latestHeight, latestTimestamp) { - return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") - } - - commitment := channeltypes.CommitPacket(packet) - - // bump the sequence and set the packet commitment so it is provable by the counterparty - k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) - k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - - k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) - - return sequence, nil -} - -// RecvPacket implements the packet receiving logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If the packet has already been received a no-op error is returned. -// The packet handler will verify that the packet has not timed out and that the -// counterparty stored a packet commitment. If successful, a packet receipt is stored -// to indicate to the counterparty successful delivery. -func (k Keeper) RecvPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) - } - if counterparty.ClientId != packet.SourceChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - // check if packet timed out by comparing it with the latest height of the chain - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(selfHeight, selfTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") - } - - // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received - // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale - // by the increase of the recvStartSequence. - _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - if found { - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - // This error indicates that the packet has already been relayed. Core IBC will - // treat this error as a no-op in order to prevent an entire relay transaction - // from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - commitment := channeltypes.CommitPacket(packet) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - packet.DestinationChannel, - proofHeight, - 0, 0, - proof, - merklePath, - commitment, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) - } - - // Set Packet Receipt to prevent timeout from occurring on counterparty - k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - - k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} - -// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement -// is written into state. -func (k Keeper) WriteAcknowledgement( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packetI exported.PacketI, - ack exported.Acknowledgement, -) error { - packet, ok := packetI.(channeltypes.Packet) - if !ok { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) - } - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) - if !ok { - return errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) - } - if counterparty.ClientId != packet.SourceChannel { - return channeltypes.ErrInvalidChannelIdentifier - } - - // NOTE: IBC app modules might have written the acknowledgement synchronously on - // the OnRecvPacket callback so we need to check if the acknowledgement is already - // set on the store and return an error if so. - if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { - return channeltypes.ErrAcknowledgementExists - } - - if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { - return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") - } - - if ack == nil { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") - } - - bz := ack.Acknowledgement() - if len(bz) == 0 { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") - } - - k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) - - k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) - - return nil -} - -// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// the acknowledgement provided is verified to have been stored by the counterparty. -// If successful, the packet commitment is deleted and the packet has completed its lifecycle. -func (k Keeper) AcknowledgePacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - acknowledgement []byte, - proofAcked []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) - } - - if counterparty.ClientId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - if len(commitment) == 0 { - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - // This error indicates that the acknowledgement has already been relayed - // or there is a misconfigured relayer attempting to prove an acknowledgement - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) - } - - path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - packet.SourceChannel, - proofHeight, - 0, 0, - proofAcked, - merklePath, - channeltypes.CommitAcknowledgement(acknowledgement), - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) - } - - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) - - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} - -// TimeoutPacket implements the timeout logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// an absence proof of the packet receipt is performed to ensure that the packet -// was never delivered to the counterparty. If successful, the packet commitment -// is deleted and the packet has completed its lifecycle. -func (k Keeper) TimeoutPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, - _ uint64, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) - } - - if counterparty.ClientId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) - if err != nil { - return "", err - } - - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") - } - - // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - - if len(commitment) == 0 { - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - // This error indicates that the timeout has already been relayed - // or there is a misconfigured relayer attempting to prove a timeout - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) - } - - // verify packet receipt absence - path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyNonMembership( - ctx, - packet.SourceChannel, - proofHeight, - 0, 0, - proof, - merklePath, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) - } - - // delete packet commitment to prevent replay - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go new file mode 100644 index 00000000000..9a20b806cd2 --- /dev/null +++ b/modules/core/packet-server/keeper/relay.go @@ -0,0 +1,376 @@ +package keeper + +import ( + "bytes" + "strconv" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// SendPacket implements the packet sending logic required by a packet handler. +// It will generate a packet and store the commitment hash if all arguments provided are valid. +// The destination channel will be filled in using the counterparty information. +// The next sequence send will be initialized if this is the first packet sent for the given client. +func (k Keeper) SendPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + sourceChannel string, + sourcePort string, + destPort string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + version string, + data []byte, +) (uint64, error) { + // Lookup counterparty associated with our source channel to retrieve the destination channel + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) + if !ok { + return 0, errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, sourceChannel) + } + destChannel := counterparty.ClientId + + // retrieve the sequence send for this channel + // if no packets have been sent yet, initialize the sequence to 1. + sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + sequence = 1 + } + + // construct packet from given fields and channel state + packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, + destPort, destChannel, timeoutHeight, timeoutTimestamp, version) + + if err := packet.ValidateBasic(); err != nil { + return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) + } + + // check that the client of counterparty chain is still active + if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) + } + + // retrieve latest height and timestamp of the client of counterparty chain + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) + if latestHeight.IsZero() { + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) + } + + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) + if err != nil { + return 0, err + } + + // check if packet is timed out on the receiving chain + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(latestHeight, latestTimestamp) { + return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + } + + commitment := channeltypes.CommitPacket(packet) + + // bump the sequence and set the packet commitment so it is provable by the counterparty + k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) + k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) + + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) + + return sequence, nil +} + +// RecvPacket implements the packet receiving logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If the packet has already been received a no-op error is returned. +// The packet handler will verify that the packet has not timed out and that the +// counterparty stored a packet commitment. If successful, a packet receipt is stored +// to indicate to the counterparty successful delivery. +func (k Keeper) RecvPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + if !ok { + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) + } + if counterparty.ClientId != packet.SourceChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + + // check if packet timed out by comparing it with the latest height of the chain + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(selfHeight, selfTimestamp) { + return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + } + + // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received + // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale + // by the increase of the recvStartSequence. + _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + if found { + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) + // This error indicates that the packet has already been relayed. Core IBC will + // treat this error as a no-op in order to prevent an entire relay transaction + // from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + commitment := channeltypes.CommitPacket(packet) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + packet.DestinationChannel, + proofHeight, + 0, 0, + proof, + merklePath, + commitment, + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) + } + + // Set Packet Receipt to prevent timeout from occurring on counterparty + k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} + +// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement +// is written into state. +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packetI exported.PacketI, + ack exported.Acknowledgement, +) error { + packet, ok := packetI.(channeltypes.Packet) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) + } + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + if !ok { + return errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) + } + if counterparty.ClientId != packet.SourceChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + // NOTE: IBC app modules might have written the acknowledgement synchronously on + // the OnRecvPacket callback so we need to check if the acknowledgement is already + // set on the store and return an error if so. + if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { + return channeltypes.ErrAcknowledgementExists + } + + if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { + return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") + } + + if ack == nil { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") + } + + bz := ack.Acknowledgement() + if len(bz) == 0 { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") + } + + k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) + + k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) + + return nil +} + +// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// the acknowledgement provided is verified to have been stored by the counterparty. +// If successful, the packet commitment is deleted and the packet has completed its lifecycle. +func (k Keeper) AcknowledgePacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + acknowledgement []byte, + proofAcked []byte, + proofHeight exported.Height, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) + } + + if counterparty.ClientId != packet.DestinationChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + if len(commitment) == 0 { + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) + + // This error indicates that the acknowledgement has already been relayed + // or there is a misconfigured relayer attempting to prove an acknowledgement + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + } + + path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + packet.SourceChannel, + proofHeight, + 0, 0, + proofAcked, + merklePath, + channeltypes.CommitAcknowledgement(acknowledgement), + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) + } + + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) + + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} + +// TimeoutPacket implements the timeout logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// an absence proof of the packet receipt is performed to ensure that the packet +// was never delivered to the counterparty. If successful, the packet commitment +// is deleted and the packet has completed its lifecycle. +func (k Keeper) TimeoutPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, + _ uint64, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) + } + + if counterparty.ClientId != packet.DestinationChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + + // check that timeout height or timeout timestamp has passed on the other end + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) + if err != nil { + return "", err + } + + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { + return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + } + + // check that the commitment has not been cleared and that it matches the packet sent by relayer + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + + if len(commitment) == 0 { + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) + // This error indicates that the timeout has already been relayed + // or there is a misconfigured relayer attempting to prove a timeout + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + } + + // verify packet receipt absence + path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyNonMembership( + ctx, + packet.SourceChannel, + proofHeight, + 0, 0, + proof, + merklePath, + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + } + + // delete packet commitment to prevent replay + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/relay_test.go similarity index 100% rename from modules/core/packet-server/keeper/keeper_test.go rename to modules/core/packet-server/keeper/relay_test.go From 37d3d39e7af9234a8f9b9bc5e077d0e47b74e9eb Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 11 Sep 2024 14:36:41 +0300 Subject: [PATCH 030/172] refactor: Move Counterparty to packet server (#7280) * refactor: move Counterparty to packet-server Co-authored-by: Aditya * chore: remove old structs/impls Co-authored-by: Aditya * nit(tests): use second client id to check counterparty isn't found. --------- Co-authored-by: Aditya --- e2e/testsuite/codec.go | 2 + modules/apps/callbacks/testing/simapp/app.go | 2 +- modules/core/02-client/client/cli/cli.go | 2 - modules/core/02-client/client/cli/query.go | 32 - modules/core/02-client/client/cli/tx.go | 54 -- modules/core/02-client/keeper/grpc_query.go | 22 - .../core/02-client/keeper/grpc_query_test.go | 96 --- modules/core/02-client/keeper/keeper.go | 19 - modules/core/02-client/keeper/keeper_test.go | 17 - modules/core/02-client/types/client.go | 22 - modules/core/02-client/types/client.pb.go | 295 +-------- modules/core/02-client/types/client_test.go | 69 -- modules/core/02-client/types/codec.go | 1 - modules/core/02-client/types/errors.go | 2 - modules/core/02-client/types/msgs.go | 31 - modules/core/02-client/types/msgs_test.go | 64 -- modules/core/02-client/types/query.pb.go | 597 +++-------------- modules/core/02-client/types/query.pb.gw.go | 101 --- modules/core/02-client/types/tx.pb.go | 535 ++------------- modules/core/24-host/channel_keys.go | 2 + modules/core/keeper/keeper.go | 2 +- modules/core/keeper/msg_server.go | 12 +- modules/core/keeper/msg_server_test.go | 17 +- modules/core/module.go | 2 + modules/core/packet-server/keeper/keeper.go | 33 +- .../core/packet-server/keeper/keeper_test.go | 27 + modules/core/packet-server/keeper/relay.go | 20 +- .../core/packet-server/keeper/relay_test.go | 11 +- modules/core/packet-server/types/codec.go | 14 + .../core/packet-server/types/counterparty.go | 29 + .../packet-server/types/counterparty.pb.go | 382 +++++++++++ .../packet-server/types/counterparty_test.go | 79 +++ modules/core/packet-server/types/errors.go | 10 + .../packet-server/types/expected_keepers.go | 4 - modules/core/packet-server/types/keys.go | 10 +- modules/core/packet-server/types/msgs.go | 44 ++ modules/core/packet-server/types/msgs_test.go | 73 ++ modules/core/packet-server/types/tx.pb.go | 624 ++++++++++++++++++ modules/core/types/codec.go | 2 + .../08-wasm/testing/simapp/app.go | 2 +- proto/ibc/core/client/v1/client.proto | 9 - proto/ibc/core/client/v1/query.proto | 16 - proto/ibc/core/client/v1/tx.proto | 22 - .../core/packetserver/v1/counterparty.proto | 16 + proto/ibc/core/packetserver/v1/tx.proto | 37 ++ testing/endpoint.go | 3 +- testing/simapp/app.go | 2 +- 47 files changed, 1591 insertions(+), 1876 deletions(-) create mode 100644 modules/core/packet-server/keeper/keeper_test.go create mode 100644 modules/core/packet-server/types/codec.go create mode 100644 modules/core/packet-server/types/counterparty.go create mode 100644 modules/core/packet-server/types/counterparty.pb.go create mode 100644 modules/core/packet-server/types/counterparty_test.go create mode 100644 modules/core/packet-server/types/errors.go create mode 100644 modules/core/packet-server/types/msgs.go create mode 100644 modules/core/packet-server/types/msgs_test.go create mode 100644 modules/core/packet-server/types/tx.pb.go create mode 100644 proto/ibc/core/packetserver/v1/counterparty.proto create mode 100644 proto/ibc/core/packetserver/v1/tx.proto diff --git a/e2e/testsuite/codec.go b/e2e/testsuite/codec.go index adcd74c67e5..5de0570cd18 100644 --- a/e2e/testsuite/codec.go +++ b/e2e/testsuite/codec.go @@ -32,6 +32,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -69,6 +70,7 @@ func codecAndEncodingConfig() (*codec.ProtoCodec, testutil.TestEncodingConfig) { connectiontypes.RegisterInterfaces(cfg.InterfaceRegistry) ibctmtypes.RegisterInterfaces(cfg.InterfaceRegistry) wasmtypes.RegisterInterfaces(cfg.InterfaceRegistry) + packetservertypes.RegisterInterfaces(cfg.InterfaceRegistry) // all other types upgradetypes.RegisterInterfaces(cfg.InterfaceRegistry) diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 2a4e28925a9..5b536c2626b 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -409,7 +409,7 @@ func NewSimApp( app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) // NOTE: The mock ContractKeeper is only created for testing. // Real applications should not use the mock ContractKeeper diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index 545dafda7db..2490668f122 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -26,7 +26,6 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryConsensusStateHeights(), GetCmdQueryConsensusState(), GetCmdQueryHeader(), - GetCmdQueryClient(), GetCmdSelfConsensusState(), GetCmdClientParams(), ) @@ -51,7 +50,6 @@ func NewTxCmd() *cobra.Command { newUpgradeClientCmd(), newSubmitRecoverClientProposalCmd(), newScheduleIBCUpgradeProposalCmd(), - newProvideCounterpartyCmd(), ) return txCmd diff --git a/modules/core/02-client/client/cli/query.go b/modules/core/02-client/client/cli/query.go index 05a5e79acd7..082fc2004bf 100644 --- a/modules/core/02-client/client/cli/query.go +++ b/modules/core/02-client/client/cli/query.go @@ -210,38 +210,6 @@ func GetCmdQueryConsensusStateHeights() *cobra.Command { return cmd } -// GetCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID. -func GetCmdQueryClient() *cobra.Command { - cmd := &cobra.Command{ - Use: "client [client-id]", - Short: "Query the information of a client.", - Long: "Query the client information (creator and counterparty) for the provided client ID.", - Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, ibcexported.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - clientID := args[0] - - queryClient := types.NewQueryClient(clientCtx) - - req := &types.QueryClientRequest{ClientId: clientID} - - res, err := queryClient.Client(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - // GetCmdQueryConsensusState defines the command to query the consensus state of // the chain as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#query func GetCmdQueryConsensusState() *cobra.Command { diff --git a/modules/core/02-client/client/cli/tx.go b/modules/core/02-client/client/cli/tx.go index 8f4242ec6ca..223343dbfd9 100644 --- a/modules/core/02-client/client/cli/tx.go +++ b/modules/core/02-client/client/cli/tx.go @@ -1,11 +1,9 @@ package cli import ( - "encoding/hex" "fmt" "os" "strconv" - "strings" "github.com/spf13/cobra" @@ -22,7 +20,6 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -453,54 +450,3 @@ func newScheduleIBCUpgradeProposalCmd() *cobra.Command { return cmd } - -// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. -func newProvideCounterpartyCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "provide-counterparty [client-identifier] [counterparty-client-identifier] [counterparty-merkle-path-prefix]", - Args: cobra.ExactArgs(3), - Short: "provide the counterparty to an IBC client", - Long: `Provide the counterparty to an IBC client specified by its client ID. -The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, - Example: fmt.Sprintf("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - clientIdentifier := args[0] - counterpartyClientIdentifier := args[1] - counterpartyMerklePathPrefix, err := parseMerklePathPrefix(args[2]) - if err != nil { - return err - } - - counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) - msg := types.MsgProvideCounterparty{ - ClientId: clientIdentifier, - Counterparty: counterparty, - Signer: clientCtx.GetFromAddress().String(), - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. -func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { - var keyPath [][]byte - hexPrefixes := strings.Split(merklePathPrefixString, ",") - for _, hexPrefix := range hexPrefixes { - prefix, err := hex.DecodeString(hexPrefix) - if err != nil { - return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) - } - keyPath = append(keyPath, prefix) - } - - return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil -} diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 995df5e02df..b8d742ba838 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -410,25 +410,3 @@ func (q *queryServer) VerifyMembership(c context.Context, req *types.QueryVerify Success: true, }, nil } - -// Client implements the Query/Client gRPC method -func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) (*types.QueryClientResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if err := host.ClientIdentifierValidator(req.ClientId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - res := types.QueryClientResponse{} - - sdkCtx := sdk.UnwrapSDKContext(ctx) - creator, _ := q.GetCreator(sdkCtx, req.ClientId) - res.Creator = creator - - counterparty, _ := q.GetCounterparty(sdkCtx, req.ClientId) - res.Counterparty = counterparty - - return &res, nil -} diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index c3d69c52779..5d37a0fdae0 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -954,99 +954,3 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { }) } } - -func (suite *KeeperTestSuite) TestQueryClient() { - var ( - req *types.QueryClientRequest - expCreator string - expCounterparty types.Counterparty - ) - - testCases := []struct { - msg string - malleate func() - expError error - }{ - { - "success", - func() { - ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) - - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, - } - }, - nil, - }, - { - "success: no creator", - func() { - expCreator = "" - - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) - - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, - } - }, - nil, - }, - { - "success: no counterparty", - func() { - expCounterparty = types.Counterparty{} - - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) - - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, - } - }, - nil, - }, - { - "req is nil", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid clientID", - func() { - req = &types.QueryClientRequest{} - }, - status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - expCreator = ibctesting.TestAccAddress - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) - expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} - - tc.malleate() - - queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) - res, err := queryServer.Client(suite.chainA.GetContext(), req) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(expCreator, res.Creator) - suite.Require().Equal(expCounterparty, res.Counterparty) - } else { - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Nil(res) - } - }) - } -} diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 94de6e8887c..dd5fb094657 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -304,25 +304,6 @@ func (k *Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) return k.GetClientConsensusState(ctx, clientID, clientModule.LatestHeight(ctx, clientID)) } -// SetCounterparty sets the Counterparty for a given client identifier. -func (k *Keeper) SetCounterparty(ctx sdk.Context, clientID string, counterparty types.Counterparty) { - bz := k.cdc.MustMarshal(&counterparty) - k.ClientStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) -} - -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { - store := k.ClientStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) - if len(bz) == 0 { - return types.Counterparty{}, false - } - - var counterparty types.Counterparty - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true -} - // GetCreator returns the creator of the client. func (k *Keeper) GetCreator(ctx sdk.Context, clientID string) (string, bool) { bz := k.ClientStore(ctx, clientID).Get([]byte(types.CreatorKey)) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 607fbf37fd2..adf412a9459 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -129,23 +129,6 @@ func (suite *KeeperTestSuite) TestSetClientState() { suite.Require().Equal(clientState, retrievedState, "Client states are not equal") } -func (suite *KeeperTestSuite) TestSetCounterparty() { - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - counterparty := types.Counterparty{ - ClientId: testClientID, - MerklePathPrefix: merklePathPrefix, - } - suite.keeper.SetCounterparty(suite.ctx, testClientID, counterparty) - - retrievedCounterparty, found := suite.keeper.GetCounterparty(suite.ctx, testClientID) - suite.Require().True(found, "GetCounterparty does not return counterparty") - suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") - - retrievedCounterparty, found = suite.keeper.GetCounterparty(suite.ctx, "client-0") - suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") - suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") -} - func (suite *KeeperTestSuite) TestSetCreator() { clientID := ibctesting.FirstClientID expectedCreator := "test-creator" diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index 5346f2726c0..6e3df24694e 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -12,7 +12,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -65,27 +64,6 @@ func (ics IdentifiedClientStates) Sort() IdentifiedClientStates { return ics } -// NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { - return Counterparty{ - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, - } -} - -// Validate validates the Counterparty -func (c Counterparty) Validate() error { - if err := host.ClientIdentifierValidator(c.ClientId); err != nil { - return err - } - - if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) - } - - return nil -} - // NewConsensusStateWithHeight creates a new ConsensusStateWithHeight instance func NewConsensusStateWithHeight(height Height, consensusState exported.ConsensusState) ConsensusStateWithHeight { msg, ok := consensusState.(proto.Message) diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 738feab14fd..0a61762a377 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -8,7 +8,6 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" io "io" math "math" math_bits "math/bits" @@ -193,61 +192,6 @@ func (m *ClientConsensusStates) GetConsensusStates() []ConsensusStateWithHeight return nil } -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -type Counterparty struct { - // the client identifier of the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the merkle path that all ICS24 paths will be stored under - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_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_b6bc4c8185546947, []int{3} -} -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 - -func (m *Counterparty) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { - if m != nil { - return m.MerklePathPrefix - } - return v2.MerklePath{} -} - // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients @@ -271,7 +215,7 @@ type Height struct { func (m *Height) Reset() { *m = Height{} } func (*Height) ProtoMessage() {} func (*Height) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{4} + return fileDescriptor_b6bc4c8185546947, []int{3} } func (m *Height) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -312,7 +256,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{5} + return fileDescriptor_b6bc4c8185546947, []int{4} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -352,7 +296,6 @@ func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") proto.RegisterType((*ClientConsensusStates)(nil), "ibc.core.client.v1.ClientConsensusStates") - proto.RegisterType((*Counterparty)(nil), "ibc.core.client.v1.Counterparty") proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height") proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params") } @@ -360,40 +303,36 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xbf, 0x6f, 0x13, 0x31, - 0x14, 0xc7, 0xcf, 0x69, 0x15, 0x35, 0x4e, 0x95, 0x54, 0x47, 0x2b, 0x85, 0x20, 0x5d, 0xa2, 0x5b, - 0x9a, 0x81, 0x9e, 0xc9, 0x31, 0x50, 0x10, 0x0c, 0x24, 0x0b, 0x1d, 0x40, 0xd1, 0x21, 0x81, 0x84, - 0x84, 0xa2, 0xfb, 0xe1, 0xdc, 0x59, 0x9c, 0xcf, 0xd1, 0xd9, 0x17, 0xc8, 0xcc, 0xc2, 0x84, 0x90, - 0x58, 0x18, 0xfb, 0xe7, 0x74, 0xec, 0xc8, 0x54, 0xa1, 0x64, 0xe3, 0xaf, 0x40, 0x67, 0x3b, 0xa4, - 0x29, 0x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 0x87, 0xd5, - 0x4c, 0xf9, 0xc0, 0x3b, 0x5b, 0x58, 0xe0, 0x7c, 0x61, 0x81, 0x5f, 0x0b, 0x0b, 0x7c, 0x5b, 0x5a, - 0xc6, 0xf9, 0xd2, 0x32, 0x7e, 0x2e, 0x2d, 0xe3, 0xdd, 0x71, 0x4c, 0x44, 0x52, 0x04, 0x65, 0x5b, - 0x50, 0xc8, 0x38, 0x65, 0x1c, 0x91, 0x20, 0x3c, 0x8a, 0x19, 0x9a, 0x3d, 0x46, 0x94, 0x45, 0x45, - 0x8a, 0xb9, 0xfa, 0x47, 0x0f, 0xdc, 0x23, 0xfd, 0x61, 0xc5, 0x7c, 0x8a, 0x79, 0x50, 0x95, 0x2f, - 0xea, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xcb, 0x7d, 0x43, 0xd0, 0x03, 0x00, 0x00, + // 456 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0xa5, 0x55, 0xd4, 0x5c, 0x50, 0x82, 0x4c, 0x2b, 0x99, 0x20, 0xd9, 0x51, 0x16, 0x32, + 0xd0, 0x3b, 0x12, 0x06, 0x0a, 0x82, 0x81, 0x74, 0xa1, 0x0b, 0x42, 0x66, 0x40, 0x42, 0x42, 0x91, + 0x7d, 0xbe, 0xda, 0x27, 0xd9, 0x77, 0x95, 0xef, 0x6c, 0x94, 0x7f, 0xc0, 0x84, 0x90, 0x58, 0x18, + 0xfb, 0x73, 0x3a, 0x76, 0x64, 0xaa, 0x50, 0xb2, 0xf1, 0x2b, 0x90, 0xef, 0x2e, 0xaa, 0x5c, 0x0a, + 0x62, 0x7b, 0xf7, 0xbe, 0xef, 0xbd, 0xef, 0xfb, 0x5e, 0x62, 0x18, 0xb0, 0x98, 0x60, 0x22, 0x4a, + 0x8a, 0x49, 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 0x39, 0xff, 0x5b, 0x6e, 0x9b, 0x65, 0xd8, + 0x36, 0x25, 0x27, 0x5f, 0x00, 0xec, 0xda, 0xcb, 0xbc, 0x80, 0xc3, 0x92, 0xd6, 0x4c, 0x32, 0xc1, + 0x97, 0xbc, 0x2a, 0x62, 0x5a, 0x6a, 0x33, 0xbb, 0x8b, 0x7b, 0xbf, 0xae, 0x82, 0x9b, 0x50, 0x38, + 0xd8, 0x36, 0xde, 0xe8, 0x77, 0x6b, 0xda, 0x1e, 0xb8, 0x73, 0xcb, 0xb4, 0x81, 0xae, 0xa7, 0x8d, + 0xf6, 0xf3, 0xbd, 0xcf, 0xe7, 0x81, 0xf3, 0xfd, 0x3c, 0x70, 0x26, 0x33, 0xd8, 0x7d, 0x1b, 0x95, + 0x51, 0x21, 0xdd, 0x87, 0x70, 0x18, 0xe5, 0xb9, 0xf8, 0x44, 0x93, 0xa5, 0xc9, 0x27, 0x3d, 0x30, + 0xde, 0x99, 0xf6, 0xc2, 0x81, 0x6d, 0x9b, 0x6b, 0xca, 0x45, 0x78, 0xb1, 0xf6, 0xc1, 0xe5, 0xda, + 0x07, 0x3f, 0xd7, 0x3e, 0xf8, 0xba, 0xf1, 0x9d, 0xcb, 0x8d, 0xef, 0xfc, 0xd8, 0xf8, 0xce, 0x87, + 0xa3, 0x94, 0xa9, 0xac, 0x8a, 0x11, 0x11, 0x05, 0x26, 0x42, 0x16, 0x42, 0x62, 0x16, 0x93, 0xc3, + 0x54, 0xe0, 0xfa, 0x19, 0x2e, 0x44, 0x52, 0xe5, 0x54, 0x9a, 0xbf, 0xff, 0xe3, 0xf9, 0xa1, 0xfd, + 0x02, 0xd4, 0xea, 0x8c, 0xca, 0xb8, 0xab, 0x7f, 0xcb, 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x94, 0x27, 0x25, 0x2c, 0x21, 0x03, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -527,46 +466,6 @@ func (m *ClientConsensusStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *Height) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -694,21 +593,6 @@ func (m *ClientConsensusStates) Size() (n int) { 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 + sovClient(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovClient(uint64(l)) - return n -} - func (m *Height) Size() (n int) { if m == nil { return 0 @@ -1098,121 +982,6 @@ func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowClient - } - 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 ErrIntOverflowClient - } - 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 ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - 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 MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Height) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 2eabd3681f2..43b5b1c7f58 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -88,70 +86,3 @@ func TestValidateClientType(t *testing.T) { } } } - -func TestValidateCounterparty(t *testing.T) { - testCases := []struct { - name string - clientID string - merklePathPrefix commitmenttypes.MerklePath - expError error - }{ - { - "success", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc")), - nil, - }, - { - "success with multiple element prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), - nil, - }, - { - "success with multiple element prefix, last prefix empty", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), - nil, - }, - { - "success with single empty key prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("")), - nil, - }, - { - "failure: invalid client id", - "", - commitmenttypes.NewMerklePath([]byte("ibc")), - host.ErrInvalidID, - }, - { - "failure: empty merkle path prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath(), - types.ErrInvalidCounterparty, - }, - { - "failure: empty key in merkle path prefix first element", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), - types.ErrInvalidCounterparty, - }, - } - - for _, tc := range testCases { - tc := tc - - counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) - err := counterparty.Validate() - - expPass := tc.expError == nil - if expPass { - require.NoError(t, err, tc.name) - } else { - require.Error(t, err, tc.name) - require.ErrorIs(t, err, tc.expError) - } - } -} diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index 9e239c83564..082970cd598 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -45,7 +45,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgRecoverClient{}, &MsgIBCSoftwareUpgrade{}, &MsgUpdateParams{}, - &MsgProvideCounterparty{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index f663019ab0f..62d906bc40c 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -38,6 +38,4 @@ var ( ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty") - ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 35, "counterparty not found") ) diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index b0442e4a62b..e35b7bbbaad 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -7,7 +7,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -21,7 +20,6 @@ var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.Msg = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.Msg = (*MsgRecoverClient)(nil) - _ sdk.Msg = (*MsgProvideCounterparty)(nil) _ sdk.HasValidateBasic = (*MsgCreateClient)(nil) _ sdk.HasValidateBasic = (*MsgUpdateClient)(nil) @@ -30,7 +28,6 @@ var ( _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.HasValidateBasic = (*MsgRecoverClient)(nil) - _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -268,34 +265,6 @@ func (msg *MsgRecoverClient) ValidateBasic() error { return nil } -// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { - counterparty := NewCounterparty(counterpartyID, merklePathPrefix) - - return &MsgProvideCounterparty{ - Signer: signer, - ClientId: clientID, - Counterparty: counterparty, - } -} - -// ValidateBasic performs basic checks on a MsgProvideCounterparty. -func (msg *MsgProvideCounterparty) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { - return err - } - - if err := msg.Counterparty.Validate(); err != nil { - return err - } - - return nil -} - // NewMsgIBCSoftwareUpgrade creates a new MsgIBCSoftwareUpgrade instance func NewMsgIBCSoftwareUpgrade(signer string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*MsgIBCSoftwareUpgrade, error) { anyClient, err := PackClientState(upgradedClientState) diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index cfc73cc8578..4dc9acb4dfd 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -686,70 +686,6 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { } } -// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty -func (suite *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { - var msg *types.MsgProvideCounterparty - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: invalid signer address", - func() { - msg.Signer = "invalid" - }, - ibcerrors.ErrInvalidAddress, - }, - { - "failure: invalid client ID", - func() { - msg.ClientId = "" - }, - host.ErrInvalidID, - }, - { - "failure: invalid counterparty client ID", - func() { - msg.Counterparty.ClientId = "" - }, - host.ErrInvalidID, - }, - { - "failure: empty key path of counterparty of merkle path prefix", - func() { - msg.Counterparty.MerklePathPrefix.KeyPath = nil - }, - types.ErrInvalidCounterparty, - }, - } - - for _, tc := range testCases { - msg = types.NewMsgProvideCounterparty( - ibctesting.TestAccAddress, - ibctesting.FirstClientID, - ibctesting.SecondClientID, - commitmenttypes.NewMerklePath([]byte("key")), - ) - - tc.malleate() - - err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err, "valid case %s failed", tc.name) - } else { - suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) - } - } -} - // TestMsgRecoverClientGetSigners tests GetSigners for MsgRecoverClient func TestMsgRecoverClientGetSigners(t *testing.T) { testCases := []struct { diff --git a/modules/core/02-client/types/query.pb.go b/modules/core/02-client/types/query.pb.go index b0eb1eea77a..2585a9a8988 100644 --- a/modules/core/02-client/types/query.pb.go +++ b/modules/core/02-client/types/query.pb.go @@ -1107,104 +1107,6 @@ func (m *QueryVerifyMembershipResponse) GetSuccess() bool { return false } -// QueryClientRequest is the request type for the Query/Client RPC method -type QueryClientRequest struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` -} - -func (m *QueryClientRequest) Reset() { *m = QueryClientRequest{} } -func (m *QueryClientRequest) String() string { return proto.CompactTextString(m) } -func (*QueryClientRequest) ProtoMessage() {} -func (*QueryClientRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{20} -} -func (m *QueryClientRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryClientRequest.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 *QueryClientRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientRequest.Merge(m, src) -} -func (m *QueryClientRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryClientRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo - -func (m *QueryClientRequest) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -// QueryClientRequest is the response type for the Query/Client RPC method -type QueryClientResponse struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` -} - -func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } -func (m *QueryClientResponse) String() string { return proto.CompactTextString(m) } -func (*QueryClientResponse) ProtoMessage() {} -func (*QueryClientResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{21} -} -func (m *QueryClientResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryClientResponse.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 *QueryClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientResponse.Merge(m, src) -} -func (m *QueryClientResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryClientResponse proto.InternalMessageInfo - -func (m *QueryClientResponse) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *QueryClientResponse) GetCounterparty() Counterparty { - if m != nil { - return m.Counterparty - } - return Counterparty{} -} - func init() { proto.RegisterType((*QueryClientStateRequest)(nil), "ibc.core.client.v1.QueryClientStateRequest") proto.RegisterType((*QueryClientStateResponse)(nil), "ibc.core.client.v1.QueryClientStateResponse") @@ -1226,97 +1128,91 @@ func init() { proto.RegisterType((*QueryUpgradedConsensusStateResponse)(nil), "ibc.core.client.v1.QueryUpgradedConsensusStateResponse") proto.RegisterType((*QueryVerifyMembershipRequest)(nil), "ibc.core.client.v1.QueryVerifyMembershipRequest") proto.RegisterType((*QueryVerifyMembershipResponse)(nil), "ibc.core.client.v1.QueryVerifyMembershipResponse") - proto.RegisterType((*QueryClientRequest)(nil), "ibc.core.client.v1.QueryClientRequest") - proto.RegisterType((*QueryClientResponse)(nil), "ibc.core.client.v1.QueryClientResponse") } func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) } var fileDescriptor_dc42cdfd1d52d76e = []byte{ - // 1327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6b, 0x1b, 0x47, - 0x1b, 0xf7, 0x38, 0xb6, 0xe3, 0x3c, 0x52, 0xe2, 0x30, 0x49, 0x1c, 0x65, 0x93, 0xc8, 0xf2, 0xfa, - 0x7d, 0xe3, 0x8f, 0xda, 0xbb, 0x96, 0xdc, 0xd8, 0x4e, 0xa0, 0xd0, 0x3a, 0x25, 0x8d, 0x03, 0x49, - 0x5d, 0x95, 0x7e, 0x50, 0x28, 0x62, 0xb5, 0x1a, 0x4b, 0x4b, 0xa4, 0x5d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06, 0x73, 0x19, 0x2f, - 0xc9, 0x60, 0x4a, 0x17, 0x11, 0x8a, 0x7f, 0x42, 0x30, 0x2d, 0x5f, 0x17, 0xf0, 0xfa, 0x60, 0x10, - 0xd2, 0xd9, 0xb2, 0x31, 0xb4, 0x5e, 0x92, 0x5e, 0xe8, 0xb7, 0xb1, 0xd0, 0x60, 0x58, 0x9c, 0xed, - 0x7e, 0x3a, 0x71, 0xff, 0xcb, 0xdf, 0x67, 0x49, 0x51, 0xf2, 0x43, 0x68, 0x84, 0x80, 0x1f, 0xff, - 0xfd, 0x6c, 0x09, 0x31, 0xd4, 0x4b, 0x37, 0xd1, 0x92, 0xfa, 0x7f, 0x19, 0xf0, 0x16, 0xd3, 0x2e, - 0x35, 0x3a, 0xd8, 0xbe, 0x40, 0x30, 0xc1, 0xeb, 0x87, 0xaf, 0x0d, 0x68, 0xc4, 0x10, 0xdc, 0xfc, - 0x40, 0x39, 0x01, 0x49, 0x67, 0x68, 0x16, 0xf1, 0x7c, 0xff, 0xfb, 0x14, 0xbb, 0x49, 0x5b, 0xc5, - 0x83, 0xc3, 0x2c, 0x7a, 0x7e, 0x98, 0x45, 0x7f, 0x1e, 0x66, 0xd1, 0x97, 0x47, 0xd9, 0x91, 0xe7, - 0x47, 0xd9, 0x91, 0xdf, 0x8f, 0xb2, 0x23, 0x9f, 0x6d, 0x56, 0x2d, 0xaf, 0xe6, 0x97, 0x83, 0x7d, - 0x46, 0x17, 0x3f, 0xb5, 0xac, 0xb2, 0xb9, 0x52, 0x75, 0xf4, 0xd6, 0x0d, 0xbd, 0xe1, 0x54, 0xfc, - 0x3a, 0xa1, 0xdc, 0xc3, 0x6a, 0x61, 0x45, 0x38, 0xf1, 0xda, 0x4d, 0x42, 0xcb, 0x13, 0x6c, 0x6d, - 0x5c, 0xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xa1, 0xea, 0xc5, 0x6c, 0x13, 0x00, 0x00, + // 1250 bytes of a gzipped FileDescriptorProto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, 0xc3, 0xab, 0x32, + 0x98, 0x52, 0x62, 0xa7, 0xf8, 0x27, 0x04, 0x33, 0x72, 0xfa, 0xc5, 0xdb, 0xbd, 0x41, 0x48, 0xef, + 0x96, 0x9d, 0xbe, 0xfd, 0x92, 0xec, 0x42, 0xb7, 0x17, 0x00, 0x0d, 0x2e, 0x8b, 0xc9, 0x76, 0x2a, + 0xc2, 0xdd, 0x0f, 0x7f, 0x17, 0xd2, 0x57, 0x36, 0xfb, 0xf0, 0x08, 0x01, 0x3f, 0xfe, 0xfb, 0xe9, + 0x2a, 0x62, 0xa8, 0x57, 0x6f, 0xa1, 0x55, 0xf5, 0xff, 0x32, 0xe0, 0x0d, 0xe6, 0x5d, 0xb0, 0x9b, + 0xee, 0x7b, 0xf9, 0xd3, 0xb3, 0x2c, 0x7a, 0x76, 0x96, 0x45, 0x7f, 0x9e, 0x65, 0xd1, 0x97, 0xe7, + 0xd9, 0x81, 0x67, 0xe7, 0xd9, 0x81, 0xdf, 0xcf, 0xb3, 0x03, 0x9f, 0xed, 0x96, 0x2d, 0xaf, 0xe2, + 0x17, 0x03, 0x4a, 0xd6, 0xc5, 0xff, 0x32, 0x56, 0xd1, 0x5c, 0x2f, 0xbb, 0x7a, 0xe3, 0xa6, 0x6e, + 0xbb, 0x25, 0xbf, 0x4a, 0x28, 0x8f, 0xbf, 0x91, 0x5b, 0x17, 0x29, 0xbc, 0xa3, 0x1a, 0xa1, 0xc5, + 0x11, 0xf6, 0xf2, 0xd9, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x00, 0x51, 0xed, 0x2f, 0x12, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1353,8 +1249,6 @@ type QueryClient interface { UpgradedConsensusState(ctx context.Context, in *QueryUpgradedConsensusStateRequest, opts ...grpc.CallOption) (*QueryUpgradedConsensusStateResponse, error) // VerifyMembership queries an IBC light client for proof verification of a value at a given key path. VerifyMembership(ctx context.Context, in *QueryVerifyMembershipRequest, opts ...grpc.CallOption) (*QueryVerifyMembershipResponse, error) - // Client queries the counterparty of an IBC client. - Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) } type queryClient struct { @@ -1455,15 +1349,6 @@ func (c *queryClient) VerifyMembership(ctx context.Context, in *QueryVerifyMembe return out, nil } -func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) { - out := new(QueryClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/Client", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // ClientState queries an IBC light client. @@ -1488,8 +1373,6 @@ type QueryServer interface { UpgradedConsensusState(context.Context, *QueryUpgradedConsensusStateRequest) (*QueryUpgradedConsensusStateResponse, error) // VerifyMembership queries an IBC light client for proof verification of a value at a given key path. VerifyMembership(context.Context, *QueryVerifyMembershipRequest) (*QueryVerifyMembershipResponse, error) - // Client queries the counterparty of an IBC client. - Client(context.Context, *QueryClientRequest) (*QueryClientResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1526,9 +1409,6 @@ func (*UnimplementedQueryServer) UpgradedConsensusState(ctx context.Context, req func (*UnimplementedQueryServer) VerifyMembership(ctx context.Context, req *QueryVerifyMembershipRequest) (*QueryVerifyMembershipResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VerifyMembership not implemented") } -func (*UnimplementedQueryServer) Client(ctx context.Context, req *QueryClientRequest) (*QueryClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Client not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1714,24 +1594,6 @@ func _Query_VerifyMembership_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Query_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryClientRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Client(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Query/Client", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Client(ctx, req.(*QueryClientRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.client.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1776,10 +1638,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "VerifyMembership", Handler: _Query_VerifyMembership_Handler, }, - { - MethodName: "Client", - Handler: _Query_Client_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/client/v1/query.proto", @@ -2576,76 +2434,6 @@ func (m *QueryVerifyMembershipResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryClientRequest) 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 *QueryClientRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryClientRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryClientResponse) 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 *QueryClientResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryClientResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2969,34 +2757,6 @@ func (m *QueryVerifyMembershipResponse) Size() (n int) { return n } -func (m *QueryClientRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryClientResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.Counterparty.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5109,203 +4869,6 @@ func (m *QueryVerifyMembershipResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryClientRequest) 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 ErrIntOverflowQuery - } - 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: QueryClientRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientRequest: 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryClientResponse) 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 ErrIntOverflowQuery - } - 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: QueryClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - 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 := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/query.pb.gw.go b/modules/core/02-client/types/query.pb.gw.go index 408a0a1057b..70d1ac22c2f 100644 --- a/modules/core/02-client/types/query.pb.gw.go +++ b/modules/core/02-client/types/query.pb.gw.go @@ -525,60 +525,6 @@ func local_request_Query_VerifyMembership_0(ctx context.Context, marshaler runti } -func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["client_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") - } - - protoReq.ClientId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) - } - - msg, err := client.Client(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["client_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") - } - - protoReq.ClientId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) - } - - msg, err := server.Client(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -815,29 +761,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Client_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -1079,26 +1002,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Client_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -1122,8 +1025,6 @@ var ( pattern_Query_UpgradedConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "client", "v1", "upgraded_consensus_states"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_VerifyMembership_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "client", "v1", "verify_membership"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Client_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "clients", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1146,6 +1047,4 @@ var ( forward_Query_UpgradedConsensusState_0 = runtime.ForwardResponseMessage forward_Query_VerifyMembership_0 = runtime.ForwardResponseMessage - - forward_Query_Client_0 = runtime.ForwardResponseMessage ) diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index fdca53cd3c9..5a22491005e 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -448,88 +448,6 @@ func (m *MsgRecoverClientResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRecoverClientResponse proto.InternalMessageInfo -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -type MsgProvideCounterparty struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // counterparty client - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } -func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterparty) ProtoMessage() {} -func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{10} -} -func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) -} -func (m *MsgProvideCounterparty) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -type MsgProvideCounterpartyResponse struct { -} - -func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } -func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterpartyResponse) ProtoMessage() {} -func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{11} -} -func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) -} -func (m *MsgProvideCounterpartyResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo - // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal type MsgIBCSoftwareUpgrade struct { Plan types1.Plan `protobuf:"bytes,1,opt,name=plan,proto3" json:"plan"` @@ -550,7 +468,7 @@ func (m *MsgIBCSoftwareUpgrade) Reset() { *m = MsgIBCSoftwareUpgrade{} } func (m *MsgIBCSoftwareUpgrade) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgrade) ProtoMessage() {} func (*MsgIBCSoftwareUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{12} + return fileDescriptor_cb5dc4651eb49a04, []int{10} } func (m *MsgIBCSoftwareUpgrade) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -608,7 +526,7 @@ func (m *MsgIBCSoftwareUpgradeResponse) Reset() { *m = MsgIBCSoftwareUpg func (m *MsgIBCSoftwareUpgradeResponse) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgradeResponse) ProtoMessage() {} func (*MsgIBCSoftwareUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{13} + return fileDescriptor_cb5dc4651eb49a04, []int{11} } func (m *MsgIBCSoftwareUpgradeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,7 +569,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{14} + return fileDescriptor_cb5dc4651eb49a04, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -688,7 +606,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{15} + return fileDescriptor_cb5dc4651eb49a04, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -728,8 +646,6 @@ func init() { proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") proto.RegisterType((*MsgRecoverClient)(nil), "ibc.core.client.v1.MsgRecoverClient") proto.RegisterType((*MsgRecoverClientResponse)(nil), "ibc.core.client.v1.MsgRecoverClientResponse") - proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.client.v1.MsgProvideCounterparty") - proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.client.v1.MsgProvideCounterpartyResponse") proto.RegisterType((*MsgIBCSoftwareUpgrade)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgrade") proto.RegisterType((*MsgIBCSoftwareUpgradeResponse)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgradeResponse") proto.RegisterType((*MsgUpdateParams)(nil), "ibc.core.client.v1.MsgUpdateParams") @@ -739,63 +655,59 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 886 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x73, 0xe3, 0x44, - 0x14, 0xb6, 0x1c, 0x9f, 0x87, 0x6c, 0x7c, 0x67, 0x6e, 0xcf, 0x77, 0xe7, 0xd3, 0x71, 0xb6, 0xc7, - 0x5c, 0x11, 0x0c, 0x91, 0x62, 0x33, 0x03, 0x21, 0x40, 0x91, 0xb8, 0x21, 0xcc, 0x78, 0x26, 0xa3, - 0x0c, 0x0d, 0x8d, 0x23, 0xc9, 0x6b, 0x45, 0x8c, 0xa5, 0xd5, 0x68, 0x57, 0x06, 0x77, 0x0c, 0x15, - 0x25, 0x05, 0x0d, 0x1d, 0x35, 0x55, 0x86, 0x1f, 0x40, 0xc7, 0x4c, 0xca, 0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e, 0x74, 0x7d, 0xd3, 0x91, 0xfe, 0xba, 0xe9, - 0x48, 0x3f, 0xdc, 0x76, 0x2a, 0xd7, 0xb7, 0x9d, 0xca, 0x1f, 0xb7, 0x9d, 0xca, 0x97, 0x07, 0x96, - 0x4d, 0x2f, 0x02, 0x43, 0x31, 0xb1, 0xa3, 0xf2, 0x1f, 0x58, 0xdb, 0x30, 0xf7, 0x2c, 0xac, 0x2e, - 0x3f, 0x52, 0x1d, 0x3c, 0x0b, 0x16, 0x88, 0xb0, 0xdf, 0xcf, 0xfd, 0xd1, 0x1e, 0xff, 0x03, 0xa5, - 0x2b, 0x0f, 0x11, 0xa3, 0x1e, 0x39, 0xd6, 0xfb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xa4, - 0xb8, 0x24, 0x42, 0x0b, 0x00, 0x00, + // 819 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0xd3, 0x34, 0xa2, 0xd7, 0xb4, 0xa1, 0x47, 0x4a, 0x53, 0x97, 0x26, 0x55, 0xe8, 0x50, + 0x0a, 0xb5, 0x9b, 0x22, 0x41, 0x29, 0x30, 0xb4, 0x59, 0xe8, 0x10, 0xa9, 0x72, 0xc5, 0xc2, 0x92, + 0xda, 0xce, 0xc5, 0x35, 0x8a, 0x7d, 0x96, 0xef, 0x1c, 0xe8, 0x86, 0x98, 0x18, 0x19, 0x58, 0xd8, + 0xf8, 0x09, 0x15, 0x3f, 0x80, 0x0d, 0xa9, 0x63, 0x47, 0x26, 0x84, 0xda, 0xa1, 0x12, 0xbf, 0x02, + 0xd9, 0x77, 0x49, 0x6d, 0x27, 0x36, 0x41, 0x6c, 0xb1, 0xdf, 0xf7, 0xee, 0x7d, 0xdf, 0xbb, 0xf7, + 0xbe, 0x18, 0x2c, 0x99, 0x9a, 0x2e, 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 0xe3, 0xac, + 0x20, 0xe2, 0xf8, 0x87, 0xc1, 0x25, 0x30, 0xc5, 0xb9, 0x9b, 0xed, 0x80, 0xf8, 0x94, 0x72, 0x83, + 0xbd, 0xd8, 0x6f, 0xef, 0xe4, 0xfc, 0x83, 0x6a, 0x9f, 0x98, 0xe4, 0x97, 0x4e, 0xfb, 0x5a, 0x72, + 0x5a, 0x1a, 0x7c, 0x0a, 0x66, 0x79, 0xd0, 0x42, 0x84, 0xa8, 0x46, 0xba, 0xaa, 0x19, 0x86, 0x6d, + 0x32, 0xe8, 0xf8, 0xa2, 0x16, 0x03, 0x51, 0x61, 0x56, 0x7d, 0x51, 0xb5, 0xef, 0x59, 0x70, 0x33, + 0x88, 0x05, 0xb3, 0x30, 0x0e, 0xe5, 0xf8, 0x15, 0x66, 0xff, 0xe3, 0x0a, 0x27, 0xfe, 0xe1, 0x0a, + 0x37, 0x41, 0xc9, 0x71, 0x31, 0xee, 0xb4, 0xf8, 0xdc, 0xb6, 0xd8, 0xd9, 0xe5, 0xdc, 0x8a, 0xb0, + 0x56, 0x50, 0x60, 0x10, 0x8b, 0xca, 0xd8, 0x05, 0xcb, 0xb1, 0x8c, 0x58, 0xf9, 0xc9, 0x20, 0x55, + 0x8c, 0xa4, 0x26, 0xcd, 0x4d, 0x3e, 0xbd, 0xc5, 0x22, 0x28, 0xc7, 0xdb, 0x38, 0xe8, 0xf1, 0x67, + 0x01, 0xcc, 0x37, 0x89, 0x71, 0xe8, 0x69, 0x96, 0x49, 0x9b, 0x26, 0xd1, 0xd0, 0xb1, 0xda, 0x33, + 0xb1, 0xe7, 0xa6, 0x37, 0x7a, 0x1b, 0x14, 0xac, 0x10, 0x38, 0xb5, 0xd1, 0x11, 0x64, 0xe2, 0x60, + 0xcc, 0xc5, 0x58, 0x97, 0x85, 0x5a, 0x15, 0x2c, 0x8f, 0xa4, 0x16, 0x26, 0xef, 0x0f, 0x88, 0x82, + 0x74, 0xdc, 0x43, 0x2e, 0xef, 0xec, 0x3a, 0x98, 0x23, 0x9e, 0xf6, 0x1a, 0xe9, 0xb4, 0x15, 0xe7, + 0x5f, 0xe4, 0x81, 0x46, 0x5f, 0xc6, 0x26, 0x28, 0x11, 0x4f, 0x23, 0xd4, 0xa4, 0x1e, 0x45, 0x21, + 0x78, 0x36, 0x80, 0xc3, 0xeb, 0xd8, 0x20, 0x63, 0xec, 0xb9, 0x66, 0x4d, 0x8f, 0x50, 0x1b, 0xf0, + 0xfe, 0xc6, 0x9a, 0xbe, 0xbf, 0xd7, 0x38, 0xc4, 0x1d, 0xfa, 0x46, 0x75, 0x11, 0xbf, 0x1c, 0xf8, + 0x08, 0xe4, 0x9c, 0xae, 0x6a, 0x73, 0xef, 0xb9, 0x23, 0x31, 0x7b, 0x94, 0xfa, 0x76, 0xc8, 0xed, + 0x51, 0x3a, 0xe8, 0xaa, 0xf6, 0x5e, 0xee, 0xec, 0x67, 0x35, 0xa3, 0x04, 0x78, 0xf8, 0x02, 0xcc, + 0x73, 0x4c, 0xbb, 0x35, 0xf6, 0x06, 0xdc, 0xea, 0xa7, 0x34, 0x42, 0x9b, 0x90, 0x24, 0x70, 0x3a, + 0x2c, 0x8e, 0xdd, 0xcc, 0x30, 0xff, 0x81, 0x42, 0x1a, 0xf2, 0x9a, 0x03, 0xd5, 0x55, 0x2d, 0x12, + 0x3a, 0x58, 0x08, 0x1f, 0x0c, 0xb7, 0x41, 0xde, 0x09, 0x10, 0x9c, 0xab, 0x28, 0x0d, 0xff, 0x81, + 0x48, 0xec, 0x0c, 0x2e, 0x99, 0xe3, 0xd3, 0xbd, 0x84, 0x65, 0xf4, 0x09, 0x6d, 0xfd, 0x9e, 0x04, + 0x13, 0x4d, 0x62, 0xc0, 0x23, 0x50, 0x88, 0x98, 0xfe, 0xdd, 0x51, 0xd5, 0x62, 0x2e, 0x2b, 0xde, + 0x1f, 0x03, 0x34, 0xb0, 0xe2, 0x23, 0x50, 0x88, 0x78, 0x6c, 0x52, 0x85, 0x30, 0x28, 0xb1, 0xc2, + 0x28, 0x5f, 0x84, 0x3a, 0x98, 0x89, 0x9a, 0xc9, 0x6a, 0x62, 0x76, 0x08, 0x25, 0x3e, 0x18, 0x07, + 0x35, 0x28, 0xe2, 0x02, 0x38, 0xc2, 0x14, 0xee, 0x25, 0x9c, 0x31, 0x0c, 0x15, 0xeb, 0x63, 0x43, + 0xc3, 0xc2, 0xa2, 0xbb, 0x9c, 0x24, 0x2c, 0x82, 0x4a, 0x14, 0x36, 0x72, 0xf9, 0x7c, 0x61, 0x23, + 0x16, 0x2f, 0x49, 0xd8, 0x30, 0x34, 0x51, 0x58, 0xf2, 0x3a, 0xc0, 0x0e, 0x80, 0xe1, 0x9b, 0xe4, + 0x1b, 0x91, 0x3e, 0x19, 0x0c, 0xf4, 0x97, 0xc9, 0x88, 0x4e, 0xb9, 0x38, 0xf9, 0xee, 0xea, 0x74, + 0x5d, 0xd8, 0x53, 0xce, 0x2e, 0x2a, 0xc2, 0xf9, 0x45, 0x45, 0xf8, 0x75, 0x51, 0x11, 0x3e, 0x5e, + 0x56, 0x32, 0xe7, 0x97, 0x95, 0xcc, 0x8f, 0xcb, 0x4a, 0xe6, 0xd5, 0xb6, 0x61, 0xd2, 0x63, 0x4f, + 0x93, 0x74, 0x6c, 0xc9, 0xfc, 0xd3, 0xcb, 0xd4, 0xf4, 0x0d, 0x03, 0xcb, 0xbd, 0x27, 0xb2, 0x85, + 0xdb, 0x5e, 0x17, 0x11, 0xf6, 0xe1, 0xb4, 0xb9, 0xb5, 0xc1, 0xbf, 0x9d, 0xe8, 0x89, 0x83, 0x88, + 0x96, 0x0f, 0xac, 0xe3, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xa7, 0x07, 0xfb, 0xfc, + 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -820,8 +732,6 @@ type MsgClient interface { SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(ctx context.Context, in *MsgRecoverClient, opts ...grpc.CallOption) (*MsgRecoverClientResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -881,15 +791,6 @@ func (c *msgClient) RecoverClient(ctx context.Context, in *MsgRecoverClient, opt return out, nil } -func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { - out := new(MsgProvideCounterpartyResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/ProvideCounterparty", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) { out := new(MsgIBCSoftwareUpgradeResponse) err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/IBCSoftwareUpgrade", in, out, opts...) @@ -920,8 +821,6 @@ type MsgServer interface { SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(context.Context, *MsgRecoverClient) (*MsgRecoverClientResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(context.Context, *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -947,9 +846,6 @@ func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) RecoverClient(ctx context.Context, req *MsgRecoverClient) (*MsgRecoverClientResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecoverClient not implemented") } -func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") -} func (*UnimplementedMsgServer) IBCSoftwareUpgrade(ctx context.Context, req *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IBCSoftwareUpgrade not implemented") } @@ -1051,24 +947,6 @@ func _Msg_RecoverClient_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgProvideCounterparty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ProvideCounterparty(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/ProvideCounterparty", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_IBCSoftwareUpgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgIBCSoftwareUpgrade) if err := dec(in); err != nil { @@ -1129,10 +1007,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RecoverClient", Handler: _Msg_RecoverClient_Handler, }, - { - MethodName: "ProvideCounterparty", - Handler: _Msg_ProvideCounterparty_Handler, - }, { MethodName: "IBCSoftwareUpgrade", Handler: _Msg_IBCSoftwareUpgrade_Handler, @@ -1539,76 +1413,6 @@ func (m *MsgRecoverClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgProvideCounterparty) 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 *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterparty) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgProvideCounterpartyResponse) 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 *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgIBCSoftwareUpgrade) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1924,34 +1728,6 @@ func (m *MsgRecoverClientResponse) Size() (n int) { return n } -func (m *MsgProvideCounterparty) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Counterparty.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgProvideCounterpartyResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgIBCSoftwareUpgrade) Size() (n int) { if m == nil { return 0 @@ -3146,203 +2922,6 @@ func (m *MsgRecoverClientResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterparty) 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 ErrIntOverflowTx - } - 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: MsgProvideCounterparty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterparty: 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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 Counterparty", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgProvideCounterpartyResponse) 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 ErrIntOverflowTx - } - 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: MsgProvideCounterpartyResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgIBCSoftwareUpgrade) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index a6d3cee060c..2edf9a9ea9e 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -2,6 +2,8 @@ package host import "fmt" +var KeyChannelStorePrefix = []byte("channels") + const ( KeyChannelEndPrefix = "channelEnds" KeyChannelPrefix = "channels" diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index da389975107..49b6009ea79 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -56,7 +56,7 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) - packetKeeper := packetserver.NewKeeper(cdc, channelKeeper, clientKeeper) + packetKeeper := packetserver.NewKeeper(cdc, key, channelKeeper, clientKeeper) return &Keeper{ cdc: cdc, diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 30d5c9cf36d..b80ed4d9493 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -17,6 +17,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/telemetry" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -25,6 +26,7 @@ var ( _ connectiontypes.MsgServer = (*Keeper)(nil) _ channeltypes.MsgServer = (*Keeper)(nil) _ channeltypes.PacketMsgServer = (*Keeper)(nil) + _ packetservertypes.MsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. @@ -143,7 +145,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI } // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. -func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.MsgProvideCounterparty) (*clienttypes.MsgProvideCounterpartyResponse, error) { +func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) @@ -155,15 +157,15 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.Msg return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) } - if _, ok := k.ClientKeeper.GetCounterparty(ctx, msg.ClientId); ok { - return nil, errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) + if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ClientId); ok { + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) } - k.ClientKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) + k.PacketServerKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) // Delete client creator from state as it is not needed after this point. k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) - return &clienttypes.MsgProvideCounterpartyResponse{}, nil + return &packetservertypes.MsgProvideCounterpartyResponse{}, nil } // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index dafd0bd0609..cbed627f0b1 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -22,6 +22,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -307,7 +308,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // any non-nil value of packet is valid suite.Require().NotNil(packet) }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, false, false, @@ -670,7 +671,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { func() { packet.SourceChannel = "invalid-client" }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, }, { @@ -996,7 +997,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, }, } @@ -1218,7 +1219,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { func (suite *KeeperTestSuite) TestProvideCounterparty() { var ( path *ibctesting.Path - msg *clienttypes.MsgProvideCounterparty + msg *packetservertypes.MsgProvideCounterparty ) cases := []struct { name string @@ -1248,9 +1249,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "failure: counterparty already exists", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) }, - clienttypes.ErrInvalidCounterparty, + packetservertypes.ErrInvalidCounterparty, }, } @@ -1261,7 +1262,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = clienttypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) + msg = packetservertypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) tc.malleate() @@ -1274,7 +1275,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty set and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) suite.Require().Equal(counterparty, msg.Counterparty) diff --git a/modules/core/module.go b/modules/core/module.go index 1dc35eec4a8..f81c9f54bda 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" "github.com/cosmos/ibc-go/v9/modules/core/simulation" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -132,6 +133,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) + packetservertypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 411d3e9414b..b881500de58 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,11 +1,16 @@ package keeper import ( + "fmt" + "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -14,14 +19,16 @@ import ( // It does not manage its own store. type Keeper struct { cdc codec.BinaryCodec + storeKey storetypes.StoreKey ChannelKeeper types.ChannelKeeper ClientKeeper types.ClientKeeper } // NewKeeper creates a new packet keeper -func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { return &Keeper{ cdc: cdc, + storeKey: storeKey, ChannelKeeper: channelKeeper, ClientKeeper: clientKeeper, } @@ -31,3 +38,27 @@ func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientK func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } + +func (k Keeper) ChannelStore(ctx sdk.Context, channelID string) storetypes.KVStore { + channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelStorePrefix, channelID)) + return prefix.NewStore(ctx.KVStore(k.storeKey), channelPrefix) +} + +// SetCounterparty sets the Counterparty for a given client identifier. +func (k *Keeper) SetCounterparty(ctx sdk.Context, clientID string, counterparty types.Counterparty) { + bz := k.cdc.MustMarshal(&counterparty) + k.ChannelStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) +} + +// GetCounterparty gets the Counterparty for a given client identifier. +func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { + store := k.ChannelStore(ctx, clientID) + bz := store.Get([]byte(types.CounterpartyKey)) + if len(bz) == 0 { + return types.Counterparty{}, false + } + + var counterparty types.Counterparty + k.cdc.MustUnmarshal(bz, &counterparty) + return counterparty, true +} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go new file mode 100644 index 00000000000..47e3f2e3f3b --- /dev/null +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -0,0 +1,27 @@ +package keeper_test + +import ( + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +const testClientID = "tendermint-0" + +func (suite *KeeperTestSuite) TestSetCounterparty() { + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + counterparty := types.Counterparty{ + ClientId: testClientID, + MerklePathPrefix: merklePathPrefix, + } + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), testClientID, counterparty) + + retrievedCounterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), testClientID) + suite.Require().True(found, "GetCounterparty does not return counterparty") + suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") + + // Counterparty not yet stored for another client. + retrievedCounterparty, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") + suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") +} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 9a20b806cd2..9cc41a23904 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -33,9 +33,9 @@ func (k Keeper) SendPacket( data []byte, ) (uint64, error) { // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) + counterparty, ok := k.GetCounterparty(ctx, sourceChannel) if !ok { - return 0, errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, sourceChannel) + return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) } destChannel := counterparty.ClientId @@ -109,9 +109,9 @@ func (k Keeper) RecvPacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } if counterparty.ClientId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier @@ -184,9 +184,9 @@ func (k Keeper) WriteAcknowledgement( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) + counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } if counterparty.ClientId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier @@ -241,9 +241,9 @@ func (k Keeper) AcknowledgePacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) } if counterparty.ClientId != packet.DestinationChannel { @@ -312,9 +312,9 @@ func (k Keeper) TimeoutPacket( } // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) } if counterparty.ClientId != packet.DestinationChannel { diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go index 7de9f82a0da..4aa13de9c42 100644 --- a/modules/core/packet-server/keeper/relay_test.go +++ b/modules/core/packet-server/keeper/relay_test.go @@ -11,6 +11,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" @@ -69,7 +70,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { func() { packet.SourceChannel = ibctesting.FirstChannelID }, - clienttypes.ErrCounterpartyNotFound, + types.ErrCounterpartyNotFound, }, { "packet failed basic validation", @@ -174,7 +175,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { func() { packet.DestinationChannel = ibctesting.FirstChannelID }, - clienttypes.ErrCounterpartyNotFound, + types.ErrCounterpartyNotFound, }, { "failure: client is not active", @@ -281,7 +282,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { packet.DestinationChannel = ibctesting.FirstChannelID }, - clienttypes.ErrCounterpartyNotFound, + types.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -382,7 +383,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { func() { packet.SourceChannel = ibctesting.FirstChannelID }, - clienttypes.ErrCounterpartyNotFound, + types.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -524,7 +525,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.SourceChannel = ibctesting.FirstChannelID }, - clienttypes.ErrCounterpartyNotFound, + types.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", diff --git a/modules/core/packet-server/types/codec.go b/modules/core/packet-server/types/codec.go new file mode 100644 index 00000000000..e2eb9996bc7 --- /dev/null +++ b/modules/core/packet-server/types/codec.go @@ -0,0 +1,14 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterInterfaces registers the client interfaces to protobuf Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgProvideCounterparty{}, + ) +} diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/counterparty.go new file mode 100644 index 00000000000..09fda058b43 --- /dev/null +++ b/modules/core/packet-server/types/counterparty.go @@ -0,0 +1,29 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" +) + +// NewCounterparty creates a new Counterparty instance +func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { + return Counterparty{ + ClientId: clientID, + MerklePathPrefix: merklePathPrefix, + } +} + +// Validate validates the Counterparty +func (c Counterparty) Validate() error { + if err := host.ClientIdentifierValidator(c.ClientId); err != nil { + return err + } + + if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { + return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) + } + + return nil +} diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/counterparty.pb.go new file mode 100644 index 00000000000..d8612d6a3f9 --- /dev/null +++ b/modules/core/packet-server/types/counterparty.pb.go @@ -0,0 +1,382 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/packetserver/v1/counterparty.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + 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 + +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +type Counterparty struct { + // the client identifier of the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the merkle path that all ICS24 paths will be stored under + MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_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_e0c60a0709a0040c, []int{0} +} +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 + +func (m *Counterparty) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { + if m != nil { + return m.MerklePathPrefix + } + return v2.MerklePath{} +} + +func init() { + proto.RegisterType((*Counterparty)(nil), "ibc.core.packetserver.v1.Counterparty") +} + +func init() { + proto.RegisterFile("ibc/core/packetserver/v1/counterparty.proto", fileDescriptor_e0c60a0709a0040c) +} + +var fileDescriptor_e0c60a0709a0040c = []byte{ + // 286 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4b, 0xc3, 0x40, + 0x14, 0xc6, 0x73, 0x22, 0x62, 0xa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 0xf8, 0xb9, 0x75, 0x36, + 0x57, 0xa2, 0x57, 0xd6, 0xad, 0xc3, 0x6a, 0x7b, 0xa8, 0x30, 0x3a, 0x56, 0x18, 0xfd, 0x56, 0x18, + 0x7d, 0xd5, 0xd8, 0x39, 0xd6, 0xd8, 0xf9, 0xae, 0xb1, 0xf3, 0xf6, 0x94, 0x70, 0x93, 0x96, 0x51, + 0x63, 0x49, 0x99, 0x2c, 0x84, 0x2c, 0x28, 0x8f, 0xd8, 0x22, 0x91, 0xd4, 0x3e, 0x52, 0x21, 0xe3, + 0x32, 0x83, 0x62, 0xd8, 0xe2, 0xe2, 0xbf, 0x46, 0xb3, 0x57, 0x50, 0x44, 0x67, 0xed, 0x91, 0x0f, + 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x87, 0x96, 0x5e, 0x91, 0x6c, 0x01, 0x00, 0x00, +} + +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.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCounterparty(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { + offset -= sovCounterparty(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +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 + sovCounterparty(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovCounterparty(uint64(l)) + return n +} + +func sovCounterparty(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCounterparty(x uint64) (n int) { + return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowCounterparty + } + 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 ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + 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 MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCounterparty(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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrInvalidLengthCounterparty + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCounterparty + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCounterparty + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/counterparty_test.go new file mode 100644 index 00000000000..20772bd7598 --- /dev/null +++ b/modules/core/packet-server/types/counterparty_test.go @@ -0,0 +1,79 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func TestValidateCounterparty(t *testing.T) { + testCases := []struct { + name string + clientID string + merklePathPrefix commitmenttypes.MerklePath + expError error + }{ + { + "success", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc")), + nil, + }, + { + "success with multiple element prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), + nil, + }, + { + "success with multiple element prefix, last prefix empty", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), + nil, + }, + { + "success with single empty key prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("")), + nil, + }, + { + "failure: invalid client id", + "", + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: empty merkle path prefix", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath(), + types.ErrInvalidCounterparty, + }, + { + "failure: empty key in merkle path prefix first element", + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), + types.ErrInvalidCounterparty, + }, + } + + for _, tc := range testCases { + tc := tc + + counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) + err := counterparty.Validate() + + expPass := tc.expError == nil + if expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + require.ErrorIs(t, err, tc.expError) + } + } +} diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go new file mode 100644 index 00000000000..a38e7eaa18f --- /dev/null +++ b/modules/core/packet-server/types/errors.go @@ -0,0 +1,10 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +var ( + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") + ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") +) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index c3e23572228..f74b6df031e 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -45,10 +45,6 @@ type ClientKeeper interface { VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error - // GetCounterparty returns the counterparty client given the client ID on - // the executing chain - // This is a private path that is only used by the IBC lite module - GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool) // GetClientStatus returns the status of a client given the client ID GetClientStatus(ctx sdk.Context, clientID string) exported.Status // GetClientLatestHeight returns the latest height of a client given the client ID diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index 1dbfabd45e8..34c291f67af 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -1,3 +1,11 @@ package types -const SubModuleName = "packetserver" +const ( + // SubModuleName defines the IBC packet server name. + SubModuleName = "packetserver" + + // CounterpartyKey is the key used to store counterparty in the client store. + // the counterparty key is imported from types instead of host because + // the counterparty key is not a part of the ics-24 host specification + CounterpartyKey = "counterparty" +) diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go new file mode 100644 index 00000000000..f8c55ad8a72 --- /dev/null +++ b/modules/core/packet-server/types/msgs.go @@ -0,0 +1,44 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" +) + +var ( + _ sdk.Msg = (*MsgProvideCounterparty)(nil) + _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) +) + +// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance +func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { + counterparty := NewCounterparty(counterpartyID, merklePathPrefix) + + return &MsgProvideCounterparty{ + Signer: signer, + ClientId: clientID, + Counterparty: counterparty, + } +} + +// ValidateBasic performs basic checks on a MsgProvideCounterparty. +func (msg *MsgProvideCounterparty) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + return err + } + + if err := msg.Counterparty.Validate(); err != nil { + return err + } + + return nil +} diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go new file mode 100644 index 00000000000..50e8848ae7c --- /dev/null +++ b/modules/core/packet-server/types/msgs_test.go @@ -0,0 +1,73 @@ +package types_test + +import ( + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty +func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { + var msg *types.MsgProvideCounterparty + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: invalid signer address", + func() { + msg.Signer = "invalid" + }, + ibcerrors.ErrInvalidAddress, + }, + { + "failure: invalid client ID", + func() { + msg.ClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid counterparty client ID", + func() { + msg.Counterparty.ClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: empty key path of counterparty of merkle path prefix", + func() { + msg.Counterparty.MerklePathPrefix.KeyPath = nil + }, + types.ErrInvalidCounterparty, + }, + } + + for _, tc := range testCases { + msg = types.NewMsgProvideCounterparty( + ibctesting.TestAccAddress, + ibctesting.FirstClientID, + ibctesting.SecondClientID, + commitmenttypes.NewMerklePath([]byte("key")), + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err, "valid case %s failed", tc.name) + } else { + s.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) + } + } +} diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go new file mode 100644 index 00000000000..8350e3a7fd0 --- /dev/null +++ b/modules/core/packet-server/types/tx.pb.go @@ -0,0 +1,624 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/packetserver/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +type MsgProvideCounterparty struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // counterparty client + Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } +func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterparty) ProtoMessage() {} +func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{0} +} +func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +} +func (m *MsgProvideCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +type MsgProvideCounterpartyResponse struct { +} + +func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } +func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterpartyResponse) ProtoMessage() {} +func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{1} +} +func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +} +func (m *MsgProvideCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.packetserver.v1.MsgProvideCounterparty") + proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.packetserver.v1.MsgProvideCounterpartyResponse") +} + +func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } + +var fileDescriptor_3c556aec8b7966db = []byte{ + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0x29, 0x4e, 0x2d, 0x2a, 0x4b, + 0x2d, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xc8, + 0x4c, 0x4a, 0xd6, 0x03, 0x29, 0xd1, 0x43, 0x56, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, + 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x4b, 0x69, 0xe3, 0x34, 0x32, 0x39, 0xbf, 0x34, + 0xaf, 0x24, 0xb5, 0xa8, 0x20, 0xb1, 0xa8, 0xa4, 0x12, 0xaa, 0x58, 0x3c, 0x39, 0xbf, 0x38, 0x37, + 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x22, 0xb7, 0x38, 0x1d, 0x22, 0xa1, 0xb4, 0x81, 0x91, + 0x4b, 0xcc, 0xb7, 0x38, 0x3d, 0xa0, 0x28, 0xbf, 0x2c, 0x33, 0x25, 0xd5, 0x19, 0x49, 0xa7, 0x90, + 0x34, 0x17, 0x67, 0x72, 0x4e, 0x66, 0x6a, 0x5e, 0x49, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3, + 0x06, 0x67, 0x10, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x1a, 0x09, 0x26, + 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0x9e, 0xd0, 0x43, 0x36, 0xda, 0x89, 0xe5, 0xc4, + 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, 0x8b, + 0x24, 0x98, 0xc1, 0x76, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, 0xd0, + 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x71, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, + 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, 0x3e, + 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, 0x86, + 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4b, 0x99, + 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, + 0xc8, 0xf1, 0xac, 0x0b, 0x8d, 0xe8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x34, 0x1a, + 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x61, 0x52, 0xe3, 0xab, 0x61, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { + out := new(MsgProvideCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgProvideCounterparty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ProvideCounterparty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.packetserver.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ProvideCounterparty", + Handler: _Msg_ProvideCounterparty_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/packetserver/v1/tx.proto", +} + +func (m *MsgProvideCounterparty) 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 *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterparty) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgProvideCounterpartyResponse) 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 *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgProvideCounterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgProvideCounterpartyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgProvideCounterparty) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterparty: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgProvideCounterpartyResponse) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterpartyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index 270096bc88d..28b008ce3f6 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -7,6 +7,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // RegisterInterfaces registers ibc types against interfaces using the global InterfaceRegistry. @@ -15,5 +16,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { clienttypes.RegisterInterfaces(registry) connectiontypes.RegisterInterfaces(registry) channeltypes.RegisterInterfaces(registry) + packetservertypes.RegisterInterfaces(registry) commitmenttypes.RegisterInterfaces(registry) } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 5f09c0a47cc..583cb82e709 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -418,7 +418,7 @@ func NewSimApp( ) // setup packet server keeper for Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) govConfig := govtypes.DefaultConfig() /* diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index a6d5530c369..d2ff2a2801c 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -6,7 +6,6 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -import "ibc/core/commitment/v2/commitment.proto"; // IdentifiedClientState defines a client state with an additional client // identifier field. @@ -35,14 +34,6 @@ message ClientConsensusStates { repeated ConsensusStateWithHeight consensus_states = 2 [(gogoproto.nullable) = false]; } -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -message Counterparty { - // the client identifier of the counterparty chain - string client_id = 1; - // the merkle path that all ICS24 paths will be stored under - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; -} - // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto index 7bf5e4f70de..02c3f4b1eeb 100644 --- a/proto/ibc/core/client/v1/query.proto +++ b/proto/ibc/core/client/v1/query.proto @@ -71,11 +71,6 @@ service Query { body: "*" }; } - - // Client queries the counterparty of an IBC client. - rpc Client(QueryClientRequest) returns (QueryClientResponse) { - option (google.api.http).get = "/ibc/core/client/v1/clients/{client_id}"; - } } // QueryClientStateRequest is the request type for the Query/ClientState RPC @@ -247,14 +242,3 @@ message QueryVerifyMembershipResponse { // boolean indicating success or failure of proof verification. bool success = 1; } - -// QueryClientRequest is the request type for the Query/Client RPC method -message QueryClientRequest { - string client_id = 1; -} - -// QueryClientRequest is the response type for the Query/Client RPC method -message QueryClientResponse { - string creator = 1; - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; -} diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 357c5a7d0a1..1e9e4f47ada 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -29,9 +29,6 @@ service Msg { // RecoverClient defines a rpc handler method for MsgRecoverClient. rpc RecoverClient(MsgRecoverClient) returns (MsgRecoverClientResponse); - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); - // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. rpc IBCSoftwareUpgrade(MsgIBCSoftwareUpgrade) returns (MsgIBCSoftwareUpgradeResponse); @@ -143,25 +140,6 @@ message MsgRecoverClient { // MsgRecoverClientResponse defines the Msg/RecoverClient response type. message MsgRecoverClientResponse {} -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -message MsgProvideCounterparty { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1; - // counterparty client - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; - // signer address - string signer = 3; -} - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -message MsgProvideCounterpartyResponse {} - // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal message MsgIBCSoftwareUpgrade { option (cosmos.msg.v1.signer) = "signer"; diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/counterparty.proto new file mode 100644 index 00000000000..906c0db3fa2 --- /dev/null +++ b/proto/ibc/core/packetserver/v1/counterparty.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package ibc.core.packetserver.v1; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/commitment/v2/commitment.proto"; + +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +message Counterparty { + // the client identifier of the counterparty chain + string client_id = 1; + // the merkle path that all ICS24 paths will be stored under + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; +} diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto new file mode 100644 index 00000000000..dec4a17f42c --- /dev/null +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -0,0 +1,37 @@ + +syntax = "proto3"; + +package ibc.core.packetserver.v1; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/packetserver/v1/counterparty.proto"; +import "cosmos/msg/v1/msg.proto"; + +// Msg defines the ibc/packetserver Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); +} + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +message MsgProvideCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1; + // counterparty client + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +message MsgProvideCounterpartyResponse {} diff --git a/testing/endpoint.go b/testing/endpoint.go index 4ce12cb675f..9a398b8e3ff 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -19,6 +19,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ) @@ -179,7 +180,7 @@ func (endpoint *Endpoint) FreezeClient() { func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - msg := clienttypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 87c5f1c7b43..cb5a7d3745e 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -373,7 +373,7 @@ func NewSimApp( ) // Setup packet server to call on Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) govConfig := govtypes.DefaultConfig() /* From 5c951b2b46e623844e413774cff752525b2a4761 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 12 Sep 2024 11:31:54 +0300 Subject: [PATCH 031/172] chore(packet-server): add queryServer to packet-server (#7283) * chore(packet-server): add queryServer to packet-server * chore(packet-server): return error if non of creator/counterparty is stored. --- modules/core/module.go | 6 + .../core/packet-server/keeper/grpc_query.go | 59 ++ .../packet-server/keeper/grpc_query_test.go | 118 ++++ .../packet-server/types/expected_keepers.go | 3 + modules/core/packet-server/types/query.pb.go | 643 ++++++++++++++++++ .../core/packet-server/types/query.pb.gw.go | 189 +++++ proto/ibc/core/packetserver/v1/query.proto | 28 + 7 files changed, 1046 insertions(+) create mode 100644 modules/core/packet-server/keeper/grpc_query.go create mode 100644 modules/core/packet-server/keeper/grpc_query_test.go create mode 100644 modules/core/packet-server/types/query.pb.go create mode 100644 modules/core/packet-server/types/query.pb.gw.go create mode 100644 proto/ibc/core/packetserver/v1/query.proto diff --git a/modules/core/module.go b/modules/core/module.go index f81c9f54bda..e0b7baf4a67 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" "github.com/cosmos/ibc-go/v9/modules/core/simulation" "github.com/cosmos/ibc-go/v9/modules/core/types" @@ -92,6 +93,10 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r if err != nil { panic(err) } + err = packetservertypes.RegisterQueryHandlerClient(context.Background(), mux, packetservertypes.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the ibc module. @@ -138,6 +143,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) channeltypes.RegisterQueryServer(cfg.QueryServer(), channelkeeper.NewQueryServer(am.keeper.ChannelKeeper)) + packetservertypes.RegisterQueryServer(cfg.QueryServer(), packetserverkeeper.NewQueryServer(am.keeper.PacketServerKeeper)) clientMigrator := clientkeeper.NewMigrator(am.keeper.ClientKeeper) if err := cfg.RegisterMigration(exported.ModuleName, 2, clientMigrator.Migrate2to3); err != nil { diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/packet-server/keeper/grpc_query.go new file mode 100644 index 00000000000..2632ea1dc4b --- /dev/null +++ b/modules/core/packet-server/keeper/grpc_query.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +var _ types.QueryServer = (*queryServer)(nil) + +// queryServer implements the packet-server types.QueryServer interface. +type queryServer struct { + *Keeper +} + +// NewQueryServer returns a new types.QueryServer implementation. +func NewQueryServer(k *Keeper) types.QueryServer { + return &queryServer{ + Keeper: k, + } +} + +// Client implements the Query/Client gRPC method +func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) (*types.QueryClientResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + res := types.QueryClientResponse{} + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + creator, foundCreator := q.ClientKeeper.GetCreator(sdkCtx, req.ClientId) + counterparty, foundCounterparty := q.GetCounterparty(sdkCtx, req.ClientId) + + if !foundCreator && !foundCounterparty { + return nil, status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrCounterpartyNotFound, "client-id: %s", req.ClientId).Error(), + ) + } + + res.Counterparty = counterparty + res.Creator = creator + + return &res, nil +} diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/packet-server/keeper/grpc_query_test.go new file mode 100644 index 00000000000..014efa8cf59 --- /dev/null +++ b/modules/core/packet-server/keeper/grpc_query_test.go @@ -0,0 +1,118 @@ +package keeper_test + +import ( + "fmt" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func (suite *KeeperTestSuite) TestQueryClient() { + var ( + req *types.QueryClientRequest + expCreator string + expCounterparty types.Counterparty + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + ctx := suite.chainA.GetContext() + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "success: no creator", + func() { + expCreator = "" + + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "success: no counterparty", + func() { + expCounterparty = types.Counterparty{} + + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) + + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + nil, + }, + { + "req is nil", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "no creator and no counterparty", + func() { + req = &types.QueryClientRequest{ + ClientId: ibctesting.FirstClientID, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: counterparty not found", ibctesting.FirstClientID)), + }, + { + "invalid clientID", + func() { + req = &types.QueryClientRequest{} + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + expCreator = ibctesting.TestAccAddress + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) + expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} + + tc.malleate() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.PacketServerKeeper) + res, err := queryServer.Client(suite.chainA.GetContext(), req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCreator, res.Creator) + suite.Require().Equal(expCounterparty, res.Counterparty) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index f74b6df031e..7134ab5495f 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -52,4 +52,7 @@ type ClientKeeper interface { // GetClientTimestampAtHeight returns the timestamp for a given height on the client // given its client ID and height GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) + + // GetCreator returns the creator of the client denoted by the clientID. + GetCreator(ctx sdk.Context, clientID string) (string, bool) } diff --git a/modules/core/packet-server/types/query.pb.go b/modules/core/packet-server/types/query.pb.go new file mode 100644 index 00000000000..02d3e24447a --- /dev/null +++ b/modules/core/packet-server/types/query.pb.go @@ -0,0 +1,643 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/packetserver/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryClientRequest is the request type for the Query/Client RPC method +type QueryClientRequest struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *QueryClientRequest) Reset() { *m = QueryClientRequest{} } +func (m *QueryClientRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClientRequest) ProtoMessage() {} +func (*QueryClientRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7ac0ae50eee8e6db, []int{0} +} +func (m *QueryClientRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientRequest.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 *QueryClientRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientRequest.Merge(m, src) +} +func (m *QueryClientRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClientRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo + +func (m *QueryClientRequest) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +// QueryClientRequest is the response type for the Query/Client RPC method +type QueryClientResponse struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` +} + +func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } +func (m *QueryClientResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClientResponse) ProtoMessage() {} +func (*QueryClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7ac0ae50eee8e6db, []int{1} +} +func (m *QueryClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientResponse.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 *QueryClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientResponse.Merge(m, src) +} +func (m *QueryClientResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientResponse proto.InternalMessageInfo + +func (m *QueryClientResponse) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *QueryClientResponse) GetCounterparty() Counterparty { + if m != nil { + return m.Counterparty + } + return Counterparty{} +} + +func init() { + proto.RegisterType((*QueryClientRequest)(nil), "ibc.core.packetserver.v1.QueryClientRequest") + proto.RegisterType((*QueryClientResponse)(nil), "ibc.core.packetserver.v1.QueryClientResponse") +} + +func init() { + proto.RegisterFile("ibc/core/packetserver/v1/query.proto", fileDescriptor_7ac0ae50eee8e6db) +} + +var fileDescriptor_7ac0ae50eee8e6db = []byte{ + // 362 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3d, 0x4b, 0x2b, 0x41, + 0x14, 0xdd, 0x09, 0xef, 0xe5, 0xbd, 0xcc, 0x7b, 0xd5, 0x68, 0xb1, 0x44, 0x59, 0x43, 0x10, 0x8d, + 0x68, 0x76, 0x48, 0xac, 0x04, 0xab, 0xa4, 0xb2, 0xd3, 0x14, 0x16, 0x36, 0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57, 0xc5, 0xb6, 0xbb, 0x05, 0x74, 0xe7, 0xd7, 0xe4, 0x6d, 0xcb, 0xe8, 0x2d, + 0x29, 0xb4, 0x9f, 0x09, 0xfd, 0x9d, 0x7a, 0x60, 0x4f, 0x84, 0x96, 0x33, 0x23, 0xec, 0x60, 0xb5, + 0xe0, 0xf7, 0x8c, 0xd5, 0xe6, 0x0f, 0xd1, 0x59, 0xba, 0x3a, 0xbf, 0x7f, 0xf9, 0x78, 0x2c, 0xed, + 0xb1, 0x5d, 0xbe, 0xa8, 0x24, 0xbb, 0x48, 0x5a, 0x46, 0x3a, 0x29, 0x7e, 0xb3, 0xb8, 0xda, 0x6d, + 0xe7, 0x7c, 0x32, 0xb3, 0xc8, 0x74, 0x66, 0x91, 0xf7, 0x99, 0x45, 0x1e, 0xe6, 0x96, 0x31, 0x9d, + 0x5b, 0xc6, 0xeb, 0xdc, 0x32, 0x2e, 0x8e, 0x3d, 0x5f, 0x5f, 0x45, 0xae, 0x2d, 0x70, 0xc8, 0x05, + 0xaa, 0x21, 0xaa, 0x44, 0xb3, 0xe9, 0x21, 0x8f, 0x8f, 0xf8, 0x10, 0xfb, 0xd1, 0x00, 0x54, 0xb1, + 0xf4, 0x66, 0xde, 0xba, 0x1e, 0x87, 0xa0, 0xdc, 0x72, 0x5a, 0xdc, 0xe1, 0x67, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x90, 0xb9, 0x8b, 0xca, 0x5b, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Client queries the counterparty of an IBC client. + Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) { + out := new(QueryClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Client", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Client queries the counterparty of an IBC client. + Client(context.Context, *QueryClientRequest) (*QueryClientResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Client(ctx context.Context, req *QueryClientRequest) (*QueryClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Client not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClientRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Client(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.packetserver.v1.Query/Client", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Client(ctx, req.(*QueryClientRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.packetserver.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Client", + Handler: _Query_Client_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/packetserver/v1/query.proto", +} + +func (m *QueryClientRequest) 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 *QueryClientRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryClientResponse) 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 *QueryClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryClientRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryClientRequest) 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 ErrIntOverflowQuery + } + 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: QueryClientRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientRequest: 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryClientResponse) 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 ErrIntOverflowQuery + } + 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: QueryClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/packet-server/types/query.pb.gw.go b/modules/core/packet-server/types/query.pb.gw.go new file mode 100644 index 00000000000..dbe2224a7b8 --- /dev/null +++ b/modules/core/packet-server/types/query.pb.gw.go @@ -0,0 +1,189 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: ibc/core/packetserver/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + msg, err := client.Client(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + msg, err := server.Client(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Client_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Client_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Client_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "clients", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Client_0 = runtime.ForwardResponseMessage +) diff --git a/proto/ibc/core/packetserver/v1/query.proto b/proto/ibc/core/packetserver/v1/query.proto new file mode 100644 index 00000000000..f056da89c32 --- /dev/null +++ b/proto/ibc/core/packetserver/v1/query.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package ibc.core.packetserver.v1; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; + +import "ibc/core/packetserver/v1/counterparty.proto"; +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; + +// Query provides defines the gRPC querier service +service Query { + // Client queries the counterparty of an IBC client. + rpc Client(QueryClientRequest) returns (QueryClientResponse) { + option (google.api.http).get = "/ibc/core/client/v1/clients/{client_id}"; + } +} + +// QueryClientRequest is the request type for the Query/Client RPC method +message QueryClientRequest { + string client_id = 1; +} + +// QueryClientRequest is the response type for the Query/Client RPC method +message QueryClientResponse { + string creator = 1; + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; +} From a432b0edd4fdb0e8001963ca654fe6b474799557 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 12 Sep 2024 12:19:50 +0300 Subject: [PATCH 032/172] feat(packet-server): add client. (#7284) --- modules/core/client/cli/cli.go | 3 + modules/core/packet-server/client/cli/cli.go | 43 ++++++++++++ .../core/packet-server/client/cli/query.go | 46 +++++++++++++ modules/core/packet-server/client/cli/tx.go | 69 +++++++++++++++++++ modules/core/packet-server/module.go | 23 +++++++ 5 files changed, 184 insertions(+) create mode 100644 modules/core/packet-server/client/cli/cli.go create mode 100644 modules/core/packet-server/client/cli/query.go create mode 100644 modules/core/packet-server/client/cli/tx.go create mode 100644 modules/core/packet-server/module.go diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index ef28df054a6..56f3ff765d3 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -9,6 +9,7 @@ import ( connection "github.com/cosmos/ibc-go/v9/modules/core/03-connection" channel "github.com/cosmos/ibc-go/v9/modules/core/04-channel" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server" ) // GetTxCmd returns the transaction commands for this module @@ -24,6 +25,7 @@ func GetTxCmd() *cobra.Command { ibcTxCmd.AddCommand( ibcclient.GetTxCmd(), channel.GetTxCmd(), + packetserver.GetTxCmd(), ) return ibcTxCmd @@ -44,6 +46,7 @@ func GetQueryCmd() *cobra.Command { ibcclient.GetQueryCmd(), connection.GetQueryCmd(), channel.GetQueryCmd(), + packetserver.GetQueryCmd(), ) return ibcQueryCmd diff --git a/modules/core/packet-server/client/cli/cli.go b/modules/core/packet-server/client/cli/cli.go new file mode 100644 index 00000000000..eff92825a94 --- /dev/null +++ b/modules/core/packet-server/client/cli/cli.go @@ -0,0 +1,43 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// GetQueryCmd returns the query commands for the IBC packet-server. +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.SubModuleName, + Short: "IBC packet-server query subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + queryCmd.AddCommand( + getCmdQueryClient(), + ) + + return queryCmd +} + +// NewTxCmd returns the command to submit transactions defined for the IBC packet-server. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.SubModuleName, + Short: "IBC packet-server transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + newProvideCounterpartyCmd(), + ) + + return txCmd +} diff --git a/modules/core/packet-server/client/cli/query.go b/modules/core/packet-server/client/cli/query.go new file mode 100644 index 00000000000..7cebadf9a4d --- /dev/null +++ b/modules/core/packet-server/client/cli/query.go @@ -0,0 +1,46 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// getCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID. +func getCmdQueryClient() *cobra.Command { + cmd := &cobra.Command{ + Use: "client [client-id]", + Short: "Query the information of a client.", + Long: "Query the client information (creator and counterparty) for the provided client ID.", + Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, exported.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + clientID := args[0] + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryClientRequest{ClientId: clientID} + + res, err := queryClient.Client(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go new file mode 100644 index 00000000000..45485e804a6 --- /dev/null +++ b/modules/core/packet-server/client/cli/tx.go @@ -0,0 +1,69 @@ +package cli + +import ( + "encoding/hex" + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. +func newProvideCounterpartyCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "provide-counterparty [client-identifier] [counterparty-client-identifier] [counterparty-merkle-path-prefix]", + Args: cobra.ExactArgs(3), + Short: "provide the counterparty to an IBC client", + Long: `Provide the counterparty to an IBC client specified by its client ID. +The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, + Example: fmt.Sprintf("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + clientIdentifier := args[0] + counterpartyClientIdentifier := args[1] + counterpartyMerklePathPrefix, err := parseMerklePathPrefix(args[2]) + if err != nil { + return err + } + + counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) + msg := types.MsgProvideCounterparty{ + ClientId: clientIdentifier, + Counterparty: counterparty, + Signer: clientCtx.GetFromAddress().String(), + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. +func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { + var keyPath [][]byte + hexPrefixes := strings.Split(merklePathPrefixString, ",") + for _, hexPrefix := range hexPrefixes { + prefix, err := hex.DecodeString(hexPrefix) + if err != nil { + return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) + } + keyPath = append(keyPath, prefix) + } + + return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil +} diff --git a/modules/core/packet-server/module.go b/modules/core/packet-server/module.go new file mode 100644 index 00000000000..c695542ca50 --- /dev/null +++ b/modules/core/packet-server/module.go @@ -0,0 +1,23 @@ +package client + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/client/cli" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// Name returns the IBC client name +func Name() string { + return types.SubModuleName +} + +// GetQueryCmd returns no root query command for the IBC client +func GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// GetTxCmd returns the root tx command for 02-client. +func GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} From b52a4388ed831d8a168bfeb3e3b00c0e1cc120c5 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 16 Sep 2024 08:43:22 +0100 Subject: [PATCH 033/172] Add PacketV2 Protos and CommitmentV2 function (#7287) * chore: adding proto for packetV2 * chore: adding commitV2 hash fn * chore: addressing PR feedback * chore: removed accidental comment --- modules/core/04-channel/types/channel.pb.go | 1080 +++++++++++++++++-- modules/core/04-channel/types/packet.go | 37 + proto/ibc/core/channel/v1/channel.proto | 36 + 3 files changed, 1076 insertions(+), 77 deletions(-) diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index b4e1cafde7c..0b6d4306164 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -445,6 +445,218 @@ func (m *PacketId) XXX_DiscardUnknown() { var xxx_messageInfo_PacketId proto.InternalMessageInfo +// PacketV2 defines a type that carries data across different chains through IBC +type PacketV2 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 sending chain. + SourceId string `protobuf:"bytes,2,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + // identifies the receiving chain. + DestinationId string `protobuf:"bytes,3,opt,name=destination_id,json=destinationId,proto3" json:"destination_id,omitempty"` + // timeout timestamp after which the packet times out. + TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` + // a list of packet data, each one for a specific application. + Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` +} + +func (m *PacketV2) Reset() { *m = PacketV2{} } +func (m *PacketV2) String() string { return proto.CompactTextString(m) } +func (*PacketV2) ProtoMessage() {} +func (*PacketV2) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{6} +} +func (m *PacketV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketV2.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 *PacketV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketV2.Merge(m, src) +} +func (m *PacketV2) XXX_Size() int { + return m.Size() +} +func (m *PacketV2) XXX_DiscardUnknown() { + xxx_messageInfo_PacketV2.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketV2 proto.InternalMessageInfo + +func (m *PacketV2) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *PacketV2) GetSourceId() string { + if m != nil { + return m.SourceId + } + return "" +} + +func (m *PacketV2) GetDestinationId() string { + if m != nil { + return m.DestinationId + } + return "" +} + +func (m *PacketV2) GetTimeoutTimestamp() uint64 { + if m != nil { + return m.TimeoutTimestamp + } + return 0 +} + +func (m *PacketV2) GetData() []PacketData { + if m != nil { + return m.Data + } + return nil +} + +// PacketData contains the source and destination ports and payload for the application +type PacketData struct { + // specifies the source port of the packet. + SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // specifies the destination port of the packet. + DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` + // the payload to be sent to the application. + Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` +} + +func (m *PacketData) Reset() { *m = PacketData{} } +func (m *PacketData) String() string { return proto.CompactTextString(m) } +func (*PacketData) ProtoMessage() {} +func (*PacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{7} +} +func (m *PacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketData.Merge(m, src) +} +func (m *PacketData) XXX_Size() int { + return m.Size() +} +func (m *PacketData) XXX_DiscardUnknown() { + xxx_messageInfo_PacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketData proto.InternalMessageInfo + +func (m *PacketData) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *PacketData) GetDestinationPort() string { + if m != nil { + return m.DestinationPort + } + return "" +} + +func (m *PacketData) GetPayload() Payload { + if m != nil { + return m.Payload + } + return Payload{} +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +type Payload struct { + // version of the specified application. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // the encoding used for the provided value. + Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` + // the raw bytes for the payload. + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *Payload) Reset() { *m = Payload{} } +func (m *Payload) String() string { return proto.CompactTextString(m) } +func (*Payload) ProtoMessage() {} +func (*Payload) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{8} +} +func (m *Payload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Payload.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 *Payload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Payload.Merge(m, src) +} +func (m *Payload) XXX_Size() int { + return m.Size() +} +func (m *Payload) XXX_DiscardUnknown() { + xxx_messageInfo_Payload.DiscardUnknown(m) +} + +var xxx_messageInfo_Payload proto.InternalMessageInfo + +func (m *Payload) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Payload) GetEncoding() string { + if m != nil { + return m.Encoding + } + return "" +} + +func (m *Payload) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental @@ -456,6 +668,7 @@ type Acknowledgement struct { // response contains either a result or an error and must be non-empty // // Types that are valid to be assigned to Response: + // // *Acknowledgement_Result // *Acknowledgement_Error Response isAcknowledgement_Response `protobuf_oneof:"response"` @@ -465,7 +678,7 @@ func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } func (*Acknowledgement) ProtoMessage() {} func (*Acknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{6} + return fileDescriptor_c3a07336710636a0, []int{9} } func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -553,7 +766,7 @@ func (m *Timeout) Reset() { *m = Timeout{} } func (m *Timeout) String() string { return proto.CompactTextString(m) } func (*Timeout) ProtoMessage() {} func (*Timeout) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{7} + return fileDescriptor_c3a07336710636a0, []int{10} } func (m *Timeout) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -606,7 +819,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{8} + return fileDescriptor_c3a07336710636a0, []int{11} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -652,6 +865,9 @@ func init() { proto.RegisterType((*Packet)(nil), "ibc.core.channel.v1.Packet") proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v1.PacketState") proto.RegisterType((*PacketId)(nil), "ibc.core.channel.v1.PacketId") + proto.RegisterType((*PacketV2)(nil), "ibc.core.channel.v1.PacketV2") + proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v1.PacketData") + proto.RegisterType((*Payload)(nil), "ibc.core.channel.v1.Payload") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement") proto.RegisterType((*Timeout)(nil), "ibc.core.channel.v1.Timeout") proto.RegisterType((*Params)(nil), "ibc.core.channel.v1.Params") @@ -660,71 +876,79 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 1013 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0x8e, 0x53, 0xe7, 0xeb, 0x6d, 0x93, 0xb8, 0x53, 0xe8, 0x5a, 0xa6, 0x24, 0xde, 0x0a, 0x44, - 0xb7, 0x68, 0x93, 0x6d, 0x41, 0x88, 0xe5, 0xd6, 0xa6, 0xde, 0xad, 0xd9, 0x92, 0x54, 0x4e, 0xb2, - 0x12, 0x7b, 0xb1, 0x5c, 0x7b, 0x48, 0xad, 0x4d, 0x3c, 0xc6, 0x9e, 0x74, 0xb5, 0xe2, 0x8c, 0xb4, - 0xca, 0x89, 0x3f, 0x10, 0x09, 0x89, 0xbf, 0xc0, 0x5f, 0x40, 0xda, 0xe3, 0x1e, 0x39, 0x21, 0xd4, - 0xfe, 0x07, 0xce, 0xc8, 0x33, 0xe3, 0x7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 0x14, 0xfb, - 0x24, 0x50, 0x73, 0xba, 0xb4, 0x57, 0xb2, 0x52, 0x13, 0x3d, 0x00, 0x65, 0x1c, 0x0e, 0x22, 0xc7, - 0xc3, 0x76, 0x8c, 0xbf, 0x1f, 0xe3, 0xc0, 0xc5, 0x6a, 0x5e, 0x97, 0xf6, 0x64, 0xab, 0x2a, 0xf0, - 0xae, 0x80, 0xbf, 0x92, 0xdf, 0xfc, 0x5c, 0xcf, 0xec, 0xfe, 0x95, 0x85, 0x4d, 0xd3, 0xc3, 0x01, - 0xf5, 0xbf, 0xf3, 0xb1, 0xf7, 0xff, 0x00, 0xef, 0x41, 0x21, 0x24, 0x11, 0xb5, 0x7d, 0x8f, 0xcd, - 0xad, 0x64, 0xe5, 0x13, 0xd3, 0xf4, 0xd0, 0x87, 0x00, 0xa2, 0x95, 0xc4, 0x57, 0x60, 0xbe, 0x92, - 0x40, 0x4c, 0x6f, 0xe5, 0xe0, 0x8b, 0x77, 0x0d, 0xfe, 0x0c, 0x36, 0x16, 0xf7, 0xb3, 0x58, 0x58, - 0xba, 0xa3, 0x70, 0xf6, 0x56, 0x61, 0x91, 0xed, 0xb7, 0x35, 0xc8, 0x9f, 0x3b, 0xee, 0x4b, 0x4c, - 0x91, 0x06, 0xc5, 0x59, 0x07, 0x12, 0xeb, 0x60, 0x66, 0xa3, 0x3a, 0xac, 0xc7, 0x64, 0x1c, 0xb9, - 0xd8, 0x4e, 0x92, 0x8b, 0x64, 0xc0, 0xa1, 0x73, 0x12, 0x51, 0xf4, 0x31, 0x54, 0x04, 0x41, 0x54, - 0x60, 0x07, 0x52, 0xb2, 0xca, 0x1c, 0x4d, 0xf5, 0xf1, 0x00, 0x14, 0x0f, 0xc7, 0xd4, 0x0f, 0x1c, - 0x36, 0x69, 0x96, 0x4c, 0x66, 0xc4, 0xea, 0x02, 0xce, 0x32, 0x36, 0x61, 0x6b, 0x91, 0x9a, 0xa6, - 0xe5, 0x63, 0x47, 0x0b, 0xae, 0x34,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0xb3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x70, 0x20, 0xe4, - 0xc3, 0x58, 0x09, 0x00, 0x00, + // 1143 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xf3, 0x9d, 0x97, 0x2f, 0x77, 0x76, 0xd9, 0x8d, 0xbc, 0x25, 0xf1, 0x46, 0x20, 0xb2, + 0x45, 0x9b, 0x6c, 0x0b, 0x42, 0x14, 0x71, 0x69, 0x13, 0xef, 0xd6, 0x6c, 0x49, 0x2a, 0x27, 0xa9, + 0xc4, 0x5e, 0x22, 0xd7, 0x1e, 0x52, 0x6b, 0x13, 0x8f, 0xb1, 0x9d, 0xac, 0x2a, 0xce, 0x48, 0xab, + 0x9c, 0x38, 0x71, 0x8b, 0x84, 0xc4, 0xbf, 0xc0, 0xbf, 0x80, 0xb4, 0xc7, 0x15, 0x27, 0x4e, 0x08, + 0xb5, 0xff, 0x03, 0x67, 0xe4, 0x99, 0x71, 0x3e, 0x4a, 0x5a, 0x21, 0x24, 0x6e, 0x9c, 0x32, 0xef, + 0xf7, 0x7e, 0xef, 0x63, 0xde, 0x7b, 0xf3, 0x1c, 0x78, 0x68, 0x9d, 0x19, 0x0d, 0x83, 0xb8, 0xb8, + 0x61, 0x9c, 0xeb, 0xb6, 0x8d, 0x47, 0x8d, 0xe9, 0x6e, 0x78, 0xac, 0x3b, 0x2e, 0xf1, 0x09, 0xba, + 0x63, 0x9d, 0x19, 0xf5, 0x80, 0x52, 0x0f, 0xf1, 0xe9, 0xae, 0x74, 0x77, 0x48, 0x86, 0x84, 0xea, + 0x1b, 0xc1, 0x89, 0x51, 0xa5, 0xca, 0xd2, 0xdb, 0xc8, 0xc2, 0xb6, 0x4f, 0x9d, 0xd1, 0x13, 0x23, + 0x54, 0x7f, 0x8e, 0x42, 0xaa, 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7e, 0xbb, 0x2a, 0x47, 0x5e, 0xec, 0x0f, 0x2d, 0xff, 0x7c, 0x72, 0x56, 0x37, + 0xc8, 0xb8, 0x61, 0x10, 0x6f, 0x4c, 0xbc, 0x86, 0x75, 0x66, 0x3c, 0x1e, 0x92, 0xc6, 0x74, 0xbf, + 0x31, 0x26, 0xe6, 0x64, 0x84, 0x3d, 0xf6, 0x5f, 0xf5, 0xc9, 0xc7, 0x8f, 0xc3, 0x3f, 0xbf, 0xfe, + 0x85, 0x83, 0xbd, 0xb3, 0x24, 0xfd, 0x2e, 0x7c, 0xf4, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, + 0x0e, 0x9c, 0xc5, 0x1d, 0x0b, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -1087,6 +1311,158 @@ func (m *PacketId) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PacketV2) 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 *PacketV2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.TimeoutTimestamp != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.DestinationId) > 0 { + i -= len(m.DestinationId) + copy(dAtA[i:], m.DestinationId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationId))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourceId) > 0 { + i -= len(m.SourceId) + copy(dAtA[i:], m.SourceId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceId))) + i-- + dAtA[i] = 0x12 + } + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x12 + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Payload) 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 *Payload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Encoding) > 0 { + i -= len(m.Encoding) + copy(dAtA[i:], m.Encoding) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Acknowledgement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1408,21 +1784,90 @@ func (m *PacketId) Size() (n int) { return n } -func (m *Acknowledgement) Size() (n int) { +func (m *PacketV2) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Response != nil { - n += m.Response.Size() + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) } - return n -} - -func (m *Acknowledgement_Result) Size() (n int) { - if m == nil { - return 0 + l = len(m.SourceId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) + } + if len(m.Data) > 0 { + for _, e := range m.Data { + l = e.Size() + n += 1 + l + sovChannel(uint64(l)) + } + } + return n +} + +func (m *PacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationPort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = m.Payload.Size() + n += 1 + l + sovChannel(uint64(l)) + return n +} + +func (m *Payload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.Encoding) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + +func (m *Acknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Response != nil { + n += m.Response.Size() + } + return n +} + +func (m *Acknowledgement_Result) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -2693,6 +3138,487 @@ func (m *PacketId) Unmarshal(dAtA []byte) error { } return nil } +func (m *PacketV2) 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 ErrIntOverflowChannel + } + 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: PacketV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketV2: 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 ErrIntOverflowChannel + } + 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 SourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data, PacketData{}) + if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketData) 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 ErrIntOverflowChannel + } + 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: PacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketData: 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 ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + 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 DestinationPort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationPort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Payload) 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 ErrIntOverflowChannel + } + 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: Payload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Encoding = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Acknowledgement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 49b569af9b2..7b4a5262313 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -26,6 +26,7 @@ func CommitPacket(packet Packet) []byte { case IBC_VERSION_UNSPECIFIED, IBC_VERSION_1: return commitV1Packet(packet) case IBC_VERSION_2: + // TODO: convert to PacketV2 and commit. return commitV2Packet(packet) default: panic("unsupported version") @@ -100,6 +101,42 @@ func commitV2Packet(packet Packet) []byte { return hash[:] } +// CommitPacketV2 returns the V2 packet commitment bytes. The commitment consists of: +// sha256_hash(timeout) + sha256_hash(destinationID) + sha256_hash(packetData) from a given packet. +// This results in a fixed length preimage. +// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. +func CommitPacketV2(packet PacketV2) []byte { + buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) + + destIDHash := sha256.Sum256([]byte(packet.DestinationId)) + buf = append(buf, destIDHash[:]...) + + for _, data := range packet.Data { + buf = append(buf, hashPacketData(data)...) + } + + hash := sha256.Sum256(buf) + return hash[:] +} + +// hashPacketData returns the hash of the packet data. +func hashPacketData(data PacketData) []byte { + var buf []byte + sourceHash := sha256.Sum256([]byte(data.SourcePort)) + buf = append(buf, sourceHash[:]...) + destHash := sha256.Sum256([]byte(data.DestinationPort)) + buf = append(buf, destHash[:]...) + payloadValueHash := sha256.Sum256(data.Payload.Value) + buf = append(buf, payloadValueHash[:]...) + payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) + buf = append(buf, payloadEncodingHash[:]...) + payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) + buf = append(buf, payloadVersionHash[:]...) + hash := sha256.Sum256(buf) + return hash[:] +} + // CommitAcknowledgement returns the hash of commitment bytes func CommitAcknowledgement(data []byte) []byte { hash := sha256.Sum256(data) diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index cf3ecbb61e0..969f18e6d97 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -174,6 +174,42 @@ message PacketId { uint64 sequence = 3; } +// PacketV2 defines a type that carries data across different chains through IBC +message PacketV2 { + // 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 sending chain. + string source_id = 2; + // identifies the receiving chain. + string destination_id = 3; + // timeout timestamp after which the packet times out. + uint64 timeout_timestamp = 4; + // a list of packet data, each one for a specific application. + repeated PacketData data = 5 [(gogoproto.nullable) = false]; +} + +// PacketData contains the source and destination ports and payload for the application +message PacketData { + // specifies the source port of the packet. + string source_port = 1; + // specifies the destination port of the packet. + string destination_port = 2; + // the payload to be sent to the application. + Payload payload = 3 [(gogoproto.nullable) = false]; +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +message Payload { + // version of the specified application. + string version = 1; + // the encoding used for the provided value. + string encoding = 2; + // the raw bytes for the payload. + bytes value = 3; +} + // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental From 5f07393fc678bd139a64e33fd6f5766933702d5f Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 16 Sep 2024 09:05:37 +0100 Subject: [PATCH 034/172] chore: add conversion function from PacketV1 to PacketV2 (#7292) * chore: adding proto for packetV2 * chore: adding commitV2 hash fn * chore: addressing PR feedback * chore: add conversion function from PacketV1 to PacketV2 * chore: added check for protocol version * go mod tidy and remove function * chore: default to json encoding in conversion * pr feedback --------- Co-authored-by: chatton --- e2e/go.mod | 12 +- e2e/go.sum | 24 +-- go.mod | 12 +- go.sum | 24 +-- modules/apps/callbacks/go.mod | 12 +- modules/apps/callbacks/go.sum | 24 +-- modules/core/04-channel/types/channel.pb.go | 191 ++++++++++++------- modules/core/04-channel/types/packet.go | 31 +++ modules/core/04-channel/types/packet_test.go | 4 +- modules/core/packet-server/keeper/relay.go | 2 + modules/light-clients/08-wasm/go.mod | 12 +- modules/light-clients/08-wasm/go.sum | 24 +-- proto/ibc/core/channel/v1/channel.proto | 2 + simapp/go.mod | 12 +- simapp/go.sum | 24 +-- 15 files changed, 245 insertions(+), 165 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index 50f7d32d120..63ce73e7f7f 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -236,13 +236,13 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/api v0.186.0 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 27883a64447..29683521456 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -1163,8 +1163,8 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1265,8 +1265,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1308,8 +1308,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1405,13 +1405,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1422,8 +1422,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/go.mod b/go.mod index 629fdd2616c..ef5351de673 100644 --- a/go.mod +++ b/go.mod @@ -177,14 +177,14 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/go.sum b/go.sum index 24afccc55ea..c307af1d3c1 100644 --- a/go.sum +++ b/go.sum @@ -1037,8 +1037,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1137,8 +1137,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1180,8 +1180,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1276,13 +1276,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1293,8 +1293,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 94c37bf511d..665e6a69b76 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -184,14 +184,14 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.23.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index b14e3de9111..631b8a8a8ef 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -1049,8 +1049,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1149,8 +1149,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1192,8 +1192,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1288,13 +1288,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1305,8 +1305,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index 0b6d4306164..ab3af424662 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -317,6 +317,8 @@ type Packet struct { ProtocolVersion IBCVersion `protobuf:"varint,9,opt,name=protocol_version,json=protocolVersion,proto3,enum=ibc.core.channel.v1.IBCVersion" json:"protocol_version,omitempty"` // version which application should use to process the packet data AppVersion string `protobuf:"bytes,10,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` + // encoding to be used TODO clearer message + Encoding string `protobuf:"bytes,11,opt,name=encoding,proto3" json:"encoding,omitempty"` } func (m *Packet) Reset() { *m = Packet{} } @@ -876,79 +878,79 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 1143 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x6f, 0xe3, 0x44, - 0x14, 0x8f, 0xf3, 0x9d, 0x97, 0x2f, 0x77, 0x76, 0xd9, 0x8d, 0xbc, 0x25, 0xf1, 0x46, 0x20, 0xb2, - 0x45, 0x9b, 0x6c, 0x0b, 0x42, 0x14, 0x71, 0x69, 0x13, 0xef, 0xd6, 0x6c, 0x49, 0x2a, 0x27, 0xa9, - 0xc4, 0x5e, 0x22, 0xd7, 0x1e, 0x52, 0x6b, 0x13, 0x8f, 0xb1, 0x9d, 0xac, 0x2a, 0xce, 0x48, 0xab, - 0x9c, 0x38, 0x71, 0x8b, 0x84, 0xc4, 0xbf, 0xc0, 0xbf, 0x80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 0x4e, 0x5b, 0xb9, 0x76, 0x7b, 0x9a, 0x60, - 0x80, 0xa3, 0x2a, 0x14, 0x19, 0xab, 0xdf, 0xa6, 0xbf, 0x4a, 0x4b, 0x14, 0xa4, 0xfc, 0x6c, 0x2e, - 0x67, 0x16, 0x40, 0x70, 0x7d, 0xc6, 0x09, 0x19, 0xfc, 0xfa, 0x5c, 0xe4, 0x81, 0xfb, 0x00, 0xcb, - 0xcd, 0x8b, 0x1e, 0xc0, 0x7d, 0xf5, 0xb0, 0x39, 0x38, 0x55, 0xb4, 0xae, 0xda, 0x69, 0xaf, 0x87, - 0x47, 0x5b, 0x90, 0x5f, 0x55, 0xee, 0x8a, 0xc2, 0x75, 0x68, 0x4f, 0x8c, 0x32, 0xb7, 0x87, 0xdd, - 0x37, 0x97, 0x65, 0xe1, 0xed, 0x65, 0x59, 0xf8, 0xe3, 0xb2, 0x2c, 0x7c, 0x7f, 0x55, 0x8e, 0xbc, - 0xbd, 0x2a, 0x47, 0x7e, 0xbb, 0x2a, 0x47, 0x5e, 0xec, 0x0f, 0x2d, 0xff, 0x7c, 0x72, 0x56, 0x37, - 0xc8, 0xb8, 0x61, 0x10, 0x6f, 0x4c, 0xbc, 0x86, 0x75, 0x66, 0x3c, 0x1e, 0x92, 0xc6, 0x74, 0xbf, - 0x31, 0x26, 0xe6, 0x64, 0x84, 0x3d, 0xf6, 0x5f, 0xf5, 0xc9, 0xc7, 0x8f, 0xc3, 0x3f, 0xbf, 0xfe, - 0x85, 0x83, 0xbd, 0xb3, 0x24, 0xfd, 0x2e, 0x7c, 0xf4, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, - 0x0e, 0x9c, 0xc5, 0x1d, 0x0b, 0x00, 0x00, + // 1149 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x8f, 0xdb, 0x54, + 0x10, 0x8f, 0xf3, 0x3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x3c, 0x88, 0x69, + 0xdc, 0x46, 0xb7, 0x20, 0x85, 0x5d, 0x97, 0xb8, 0x95, 0x5b, 0x41, 0xee, 0x83, 0x98, 0xc6, 0xcc, + 0x7d, 0x80, 0xac, 0x8b, 0x3d, 0x87, 0xd8, 0x1e, 0xae, 0xeb, 0x90, 0x19, 0xb0, 0x79, 0xa0, 0x4f, + 0x21, 0xcd, 0x17, 0x80, 0xf0, 0x0f, 0x17, 0x00, 0xe7, 0xa3, 0xbb, 0x90, 0x5b, 0x4f, 0x39, 0x4e, + 0xa7, 0xbc, 0x06, 0xea, 0xc3, 0x60, 0x7d, 0xba, 0xfa, 0xd4, 0x43, 0xcf, 0x21, 0x5c, 0xd8, 0x23, + 0x2e, 0x02, 0x5e, 0x6a, 0x7b, 0x6b, 0xf9, 0xc1, 0x78, 0xb1, 0x12, 0x0f, 0xe5, 0xe8, 0x83, 0xef, + 0xe2, 0x90, 0xea, 0xf3, 0xef, 0x63, 0xad, 0x3f, 0x78, 0x32, 0x50, 0x46, 0xc3, 0xae, 0xda, 0x55, + 0x07, 0xea, 0x93, 0x43, 0xf5, 0x85, 0xd2, 0x19, 0x0d, 0xbb, 0xfd, 0x23, 0xa5, 0xad, 0x3e, 0x55, + 0x95, 0x8e, 0x18, 0x93, 0x76, 0x16, 0x4b, 0xb9, 0xb8, 0x41, 0x40, 0x15, 0x00, 0x16, 0x17, 0x80, + 0xa2, 0x20, 0x65, 0x17, 0x4b, 0x39, 0x19, 0x3c, 0xa3, 0x2a, 0x14, 0x99, 0x67, 0xa0, 0x7d, 0xd5, + 0x3b, 0x52, 0xba, 0x62, 0x5c, 0xca, 0x2f, 0x96, 0x72, 0x86, 0x9b, 0xeb, 0x48, 0xea, 0x4c, 0xb0, + 0x48, 0xea, 0xb9, 0x0b, 0x05, 0xe6, 0x69, 0x1f, 0xf6, 0xfa, 0x4a, 0x47, 0x4c, 0x4a, 0xb0, 0x58, + 0xca, 0x69, 0x66, 0x21, 0x19, 0x4a, 0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x3d, 0xf6, 0x3f, 0xf6, 0xd1, + 0xc7, 0x0f, 0xc3, 0x3f, 0xc6, 0xfe, 0x99, 0x83, 0xbd, 0x93, 0x34, 0xfd, 0x66, 0x7c, 0xf4, 0x57, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x8e, 0x64, 0x83, 0x39, 0x0b, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -1150,6 +1152,13 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Encoding) > 0 { + i -= len(m.Encoding) + copy(dAtA[i:], m.Encoding) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) + i-- + dAtA[i] = 0x5a + } if len(m.AppVersion) > 0 { i -= len(m.AppVersion) copy(dAtA[i:], m.AppVersion) @@ -1737,6 +1746,10 @@ func (m *Packet) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } + l = len(m.Encoding) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } return n } @@ -2817,6 +2830,38 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } m.AppVersion = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Encoding = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipChannel(dAtA[iNdEx:]) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 7b4a5262313..85bc7352a4e 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -161,6 +161,7 @@ func NewPacket( TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, ProtocolVersion: IBC_VERSION_1, + Encoding: "json", } } @@ -263,3 +264,33 @@ func (p PacketId) Validate() error { func NewPacketID(portID, channelID string, seq uint64) PacketId { return PacketId{PortId: portID, ChannelId: channelID, Sequence: seq} } + +// ConvertPacketV1toV2 constructs a PacketV2 from a Packet. +func ConvertPacketV1toV2(packet Packet) (PacketV2, error) { + if packet.ProtocolVersion != IBC_VERSION_2 { + return PacketV2{}, errorsmod.Wrapf(ErrInvalidPacket, "expected protocol version %s, got %s instead", IBC_VERSION_2, packet.ProtocolVersion) + } + + encoding := strings.TrimSpace(packet.Encoding) + if encoding == "" { + encoding = "json" + } + + return PacketV2{ + Sequence: packet.Sequence, + SourceId: packet.SourceChannel, + DestinationId: packet.DestinationChannel, + TimeoutTimestamp: packet.TimeoutTimestamp, + Data: []PacketData{ + { + SourcePort: packet.SourcePort, + DestinationPort: packet.DestinationPort, + Payload: Payload{ + Version: packet.AppVersion, + Encoding: encoding, + Value: packet.Data, + }, + }, + }, + }, nil +} diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index c688e44f29a..a030f813375 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -59,8 +59,8 @@ func TestPacketValidateBasic(t *testing.T) { {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), true, "disabled timeout timestamp, valid timeout height"}, {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "version"), true, "valid v2 packet"}, - {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_1, "version"}, false, "invalid specifying of app version with protocol version 1"}, - {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_UNSPECIFIED, "version"}, false, "invalid specifying of app version with unspecified protocol version"}, + {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_1, "version", "json"}, false, "invalid specifying of app version with protocol version 1"}, + {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_UNSPECIFIED, "version", "json"}, false, "invalid specifying of app version with unspecified protocol version"}, {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, ""), false, "app version must be specified when packet uses protocol version 2"}, {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, " "), false, "app version must be specified when packet uses protocol version 2"}, } diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 9cc41a23904..7836b9c98d3 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -107,6 +107,8 @@ func (k Keeper) RecvPacket( return "", channeltypes.ErrInvalidPacket } + // packetv2 := convert(packet) + // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 828ab27d0ed..281eea13ded 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -188,14 +188,14 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 677c3713dcb..dc93577c717 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -1053,8 +1053,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1153,8 +1153,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1196,8 +1196,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1292,13 +1292,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1309,8 +1309,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index 969f18e6d97..5c10d0a2e6b 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -141,6 +141,8 @@ message Packet { IBCVersion protocol_version = 9; // version which application should use to process the packet data string app_version = 10; + // encoding to be used TODO clearer message + string encoding = 11; } // PacketState defines the generic type necessary to retrieve and store diff --git a/simapp/go.mod b/simapp/go.mod index 0e580f421c6..df4443c1e09 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -185,14 +185,14 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 6283843c20b..440b60a2718 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -1047,8 +1047,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1147,8 +1147,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1190,8 +1190,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1286,13 +1286,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1303,8 +1303,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From f2f46bc1906125eda3d31104f3a31e6f0c3deae6 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 30 Sep 2024 14:05:31 +0300 Subject: [PATCH 035/172] refactor: change counterparty structure. (#7328) * refactor: change counterparty structure. * refactor: add channel id to Counterparty. * refactor: use client identifier in relay functions. * chore: suffix _id to identifier. --- modules/core/keeper/msg_server.go | 10 +- modules/core/keeper/msg_server_test.go | 4 +- modules/core/packet-server/client/cli/tx.go | 4 +- modules/core/packet-server/keeper/relay.go | 31 +++--- .../core/packet-server/types/counterparty.go | 11 +- .../packet-server/types/counterparty.pb.go | 102 ++++++++++++++---- .../packet-server/types/counterparty_test.go | 17 ++- modules/core/packet-server/types/msgs.go | 8 +- modules/core/packet-server/types/msgs_test.go | 2 +- modules/core/packet-server/types/tx.pb.go | 50 ++++----- .../core/packetserver/v1/counterparty.proto | 10 +- proto/ibc/core/packetserver/v1/tx.proto | 4 +- 12 files changed, 169 insertions(+), 84 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 29f0ad19597..390c719b271 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -148,7 +148,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) + creator, found := k.ClientKeeper.GetCreator(ctx, msg.Counterparty.ClientId) if !found { return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "client creator must be set") } @@ -157,13 +157,13 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) } - if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ClientId); ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) + if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId); ok { + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ChannelId) } - k.PacketServerKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) + k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, msg.Counterparty) // Delete client creator from state as it is not needed after this point. - k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) + k.ClientKeeper.DeleteCreator(ctx, msg.Counterparty.ClientId) return &packetservertypes.MsgProvideCounterpartyResponse{}, nil } diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 7f352c689eb..1e54f08eecd 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1222,7 +1222,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { { "failure: unknown client identifier", func() { - msg.ClientId = ibctesting.InvalidID + msg.Counterparty.ClientId = ibctesting.InvalidID }, ibcerrors.ErrUnauthorized, }, @@ -1237,7 +1237,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "failure: counterparty already exists", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) }, packetservertypes.ErrInvalidCounterparty, }, diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 45485e804a6..0482ba21e30 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -39,9 +39,9 @@ The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded s return err } - counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) + counterparty := types.NewCounterparty(clientIdentifier, counterpartyClientIdentifier, counterpartyMerklePathPrefix) msg := types.MsgProvideCounterparty{ - ClientId: clientIdentifier, + ChannelId: clientIdentifier, Counterparty: counterparty, Signer: clientCtx.GetFromAddress().String(), } diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 50553fd454d..eaa16b9f80f 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -36,7 +36,8 @@ func (k Keeper) SendPacket( if !ok { return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) } - destChannel := counterparty.ClientId + destChannel := counterparty.CounterpartyChannelId + clientID := counterparty.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -54,17 +55,17 @@ func (k Keeper) SendPacket( } // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) + if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) } - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) if err != nil { return 0, err } @@ -113,9 +114,11 @@ func (k Keeper) RecvPacket( if !ok { return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } - if counterparty.ClientId != packet.SourceChannel { + + if counterparty.CounterpartyChannelId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 @@ -144,14 +147,14 @@ func (k Keeper) RecvPacket( if err := k.ClientKeeper.VerifyMembership( ctx, - packet.DestinationChannel, + clientID, proofHeight, 0, 0, proof, merklePath, commitment, ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) + return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", clientID) } // Set Packet Receipt to prevent timeout from occurring on counterparty @@ -248,6 +251,7 @@ func (k Keeper) AcknowledgePacket( if counterparty.ClientId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { @@ -272,14 +276,14 @@ func (k Keeper) AcknowledgePacket( if err := k.ClientKeeper.VerifyMembership( ctx, - packet.SourceChannel, + clientID, proofHeight, 0, 0, proofAcked, merklePath, channeltypes.CommitAcknowledgement(acknowledgement), ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) + return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) } k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) @@ -318,6 +322,7 @@ func (k Keeper) TimeoutPacket( if counterparty.ClientId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId // check that timeout height or timeout timestamp has passed on the other end proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) @@ -354,13 +359,13 @@ func (k Keeper) TimeoutPacket( if err := k.ClientKeeper.VerifyNonMembership( ctx, - packet.SourceChannel, + clientID, proofHeight, 0, 0, proof, merklePath, ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", clientID) } // delete packet commitment to prevent replay diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/counterparty.go index 09fda058b43..d63a92da3e8 100644 --- a/modules/core/packet-server/types/counterparty.go +++ b/modules/core/packet-server/types/counterparty.go @@ -8,10 +8,11 @@ import ( ) // NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { +func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { return Counterparty{ - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, + ClientId: clientID, + CounterpartyChannelId: counterpartyChannelID, + MerklePathPrefix: merklePathPrefix, } } @@ -21,6 +22,10 @@ func (c Counterparty) Validate() error { return err } + if err := host.ChannelIdentifierValidator(c.CounterpartyChannelId); err != nil { + return err + } + if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) } diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/counterparty.pb.go index d8612d6a3f9..2358d3b8213 100644 --- a/modules/core/packet-server/types/counterparty.pb.go +++ b/modules/core/packet-server/types/counterparty.pb.go @@ -26,10 +26,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Counterparty defines the counterparty for a light client to implement IBC eureka protocol type Counterparty struct { - // the client identifier of the counterparty chain + // the client identifier of the light client representing the counterparty chain ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the merkle path that all ICS24 paths will be stored under - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` + // the counterparty identifier that must be used by the packet + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` } func (m *Counterparty) Reset() { *m = Counterparty{} } @@ -72,6 +76,13 @@ func (m *Counterparty) GetClientId() string { return "" } +func (m *Counterparty) GetCounterpartyChannelId() string { + if m != nil { + return m.CounterpartyChannelId + } + return "" +} + func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { if m != nil { return m.MerklePathPrefix @@ -88,25 +99,27 @@ func init() { } var fileDescriptor_e0c60a0709a0040c = []byte{ - // 286 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4b, 0xc3, 0x40, - 0x14, 0xc6, 0x73, 0x22, 0x62, 0xa3, 0x83, 0x04, 0x87, 0x52, 0xe1, 0x2c, 0x5d, 0x2c, 0x48, 0xef, - 0x68, 0x9c, 0x04, 0xa7, 0x3a, 0x39, 0x08, 0xa5, 0x43, 0x07, 0x97, 0x90, 0x5c, 0x9e, 0xc9, 0xd1, - 0x5c, 0xee, 0xb8, 0x5c, 0x0e, 0x3b, 0xfb, 0x0f, 0xf8, 0x67, 0x75, 0xec, 0xe8, 0x24, 0x92, 0xfc, - 0x23, 0x92, 0x44, 0x42, 0xb6, 0xbb, 0x8f, 0xdf, 0xfb, 0xbe, 0xf7, 0x3e, 0xf7, 0x9e, 0x47, 0x8c, - 0x32, 0xa9, 0x81, 0xaa, 0x90, 0xed, 0xc0, 0x14, 0xa0, 0x2d, 0x68, 0x6a, 0x97, 0x94, 0xc9, 0x32, - 0x37, 0xa0, 0x55, 0xa8, 0xcd, 0x9e, 0x28, 0x2d, 0x8d, 0xf4, 0xc6, 0x3c, 0x62, 0xa4, 0x81, 0xc9, - 0x10, 0x26, 0x76, 0x39, 0xb9, 0x4e, 0x64, 0x22, 0x5b, 0x88, 0x36, 0xaf, 0x8e, 0x9f, 0xdc, 0xf5, - 0xe6, 0x4c, 0x0a, 0xc1, 0x8d, 0x80, 0xdc, 0x50, 0xeb, 0x0f, 0x7e, 0x1d, 0x38, 0xfb, 0x44, 0xee, - 0xe5, 0xf3, 0x20, 0xcf, 0xbb, 0x71, 0x47, 0x2c, 0xe3, 0x90, 0x9b, 0x80, 0xc7, 0x63, 0x34, 0x45, - 0xf3, 0xd1, 0xe6, 0xbc, 0x13, 0x5e, 0x62, 0x6f, 0xeb, 0x7a, 0x02, 0xf4, 0x2e, 0x83, 0x40, 0x85, - 0x26, 0x0d, 0x94, 0x86, 0x77, 0xfe, 0x31, 0x3e, 0x99, 0xa2, 0xf9, 0x85, 0x3f, 0x23, 0xfd, 0x8e, - 0x83, 0x14, 0xeb, 0x93, 0xd7, 0x76, 0x62, 0x1d, 0x9a, 0x74, 0x75, 0x7a, 0xf8, 0xb9, 0x75, 0x36, - 0x57, 0xa2, 0x57, 0xd6, 0xad, 0xc3, 0x6a, 0x7b, 0xa8, 0x30, 0x3a, 0x56, 0x18, 0xfd, 0x56, 0x18, - 0x7d, 0xd5, 0xd8, 0x39, 0xd6, 0xd8, 0xf9, 0xae, 0xb1, 0xf3, 0xf6, 0x94, 0x70, 0x93, 0x96, 0x51, - 0x63, 0x49, 0x99, 0x2c, 0x84, 0x2c, 0x28, 0x8f, 0xd8, 0x22, 0x91, 0xd4, 0x3e, 0x52, 0x21, 0xe3, - 0x32, 0x83, 0x62, 0xd8, 0xe2, 0xe2, 0xbf, 0x46, 0xb3, 0x57, 0x50, 0x44, 0x67, 0xed, 0x91, 0x0f, - 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x87, 0x96, 0x5e, 0x91, 0x6c, 0x01, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0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a8, 0xd3, 0x24, 0x58, 0xf8, + 0x81, 0x00, 0xbd, 0xcc, 0x21, 0x54, 0x91, 0xc9, 0x42, 0xa5, 0xe1, 0x9d, 0x7f, 0xb4, 0x8f, 0xbb, + 0xa8, 0x7f, 0x3e, 0xea, 0x91, 0xc3, 0x6e, 0x4e, 0x3a, 0x3b, 0x22, 0xaf, 0xf5, 0x8b, 0x59, 0x64, + 0xb2, 0xf1, 0xc9, 0xe6, 0xe7, 0xce, 0x9b, 0x5f, 0x8a, 0xc3, 0x64, 0x56, 0x3b, 0x8c, 0x17, 0x9b, + 0x1d, 0x46, 0xdb, 0x1d, 0x46, 0xbf, 0x3b, 0x8c, 0x3e, 0xf7, 0xd8, 0xdb, 0xee, 0xb1, 0xf7, 0xbd, + 0xc7, 0xde, 0xdb, 0x4b, 0xca, 0x4d, 0xb6, 0x8a, 0x2b, 0x4b, 0xca, 0x64, 0x29, 0x64, 0x49, 0x79, + 0xcc, 0x06, 0xa9, 0xa4, 0xf6, 0x99, 0x0a, 0x99, 0xac, 0x72, 0x28, 0xdd, 0xf6, 0x07, 0xff, 0xf5, + 0x9b, 0xb5, 0x82, 0x32, 0x3e, 0xad, 0xcb, 0x79, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x34, 0xa3, + 0x29, 0x7a, 0xa4, 0x01, 0x00, 0x00, } func (m *Counterparty) Marshal() (dAtA []byte, err error) { @@ -138,7 +151,14 @@ func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintCounterparty(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 + } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) @@ -170,6 +190,10 @@ func (m *Counterparty) Size() (n int) { if l > 0 { n += 1 + l + sovCounterparty(uint64(l)) } + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } l = m.MerklePathPrefix.Size() n += 1 + l + sovCounterparty(uint64(l)) return n @@ -243,6 +267,38 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) } diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/counterparty_test.go index 20772bd7598..462861a211d 100644 --- a/modules/core/packet-server/types/counterparty_test.go +++ b/modules/core/packet-server/types/counterparty_test.go @@ -15,48 +15,63 @@ func TestValidateCounterparty(t *testing.T) { testCases := []struct { name string clientID string + channelID string merklePathPrefix commitmenttypes.MerklePath expError error }{ { "success", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc")), nil, }, { "success with multiple element prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), nil, }, { "success with multiple element prefix, last prefix empty", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), nil, }, { "success with single empty key prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("")), nil, }, { "failure: invalid client id", "", + ibctesting.FirstChannelID, + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: invalid channel id", + ibctesting.FirstClientID, + "", commitmenttypes.NewMerklePath([]byte("ibc")), host.ErrInvalidID, }, { "failure: empty merkle path prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath(), types.ErrInvalidCounterparty, }, { "failure: empty key in merkle path prefix first element", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), types.ErrInvalidCounterparty, }, @@ -65,7 +80,7 @@ func TestValidateCounterparty(t *testing.T) { for _, tc := range testCases { tc := tc - counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) + counterparty := types.NewCounterparty(tc.clientID, tc.channelID, tc.merklePathPrefix) err := counterparty.Validate() expPass := tc.expError == nil diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go index f8c55ad8a72..3ecdaa5326e 100644 --- a/modules/core/packet-server/types/msgs.go +++ b/modules/core/packet-server/types/msgs.go @@ -16,12 +16,12 @@ var ( ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { - counterparty := NewCounterparty(counterpartyID, merklePathPrefix) +func NewMsgProvideCounterparty(signer, clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { + counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) return &MsgProvideCounterparty{ Signer: signer, - ClientId: clientID, + ChannelId: clientID, Counterparty: counterparty, } } @@ -32,7 +32,7 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) } - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { return err } diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index 50e8848ae7c..e3ad1c6b99b 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -32,7 +32,7 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { { "failure: invalid client ID", func() { - msg.ClientId = "" + msg.ChannelId = "" }, host.ErrInvalidID, }, diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index 8350e3a7fd0..46212f381ec 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -33,8 +33,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty // client identifier was not provided in the initial MsgCreateClient message. type MsgProvideCounterparty struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // unique identifier we will use to write all packet messages sent to counterparty + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` // counterparty client Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` // signer address @@ -119,29 +119,29 @@ func init() { func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } var fileDescriptor_3c556aec8b7966db = []byte{ - // 350 bytes of a gzipped FileDescriptorProto + // 351 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x4c, 0x4a, 0xd6, 0x4f, 0xce, 0x2f, 0x4a, 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3, 0xf3, 0x52, 0x8b, - 0x24, 0x98, 0xc1, 0x76, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, 0xd0, - 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x71, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, - 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, 0x3e, - 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, 0x86, - 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, - 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, - 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4b, 0x99, - 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, - 0xc8, 0xf1, 0xac, 0x0b, 0x8d, 0xe8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x34, 0x1a, - 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x61, 0x52, 0xe3, 0xab, 0x61, 0x02, 0x00, 0x00, + 0x2c, 0x17, 0x57, 0x72, 0x46, 0x62, 0x5e, 0x5e, 0x6a, 0x4e, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x67, 0x10, 0x27, 0x54, 0xc4, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x22, 0x09, + 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0xde, 0xd0, 0x43, 0x36, 0xdc, 0x89, 0xe5, + 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, + 0x8b, 0x24, 0x98, 0xc1, 0x96, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, + 0xd0, 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x73, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, + 0x71, 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, + 0x7e, 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, + 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, + 0x21, 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4f, + 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, + 0xc5, 0xc8, 0x31, 0xad, 0x0b, 0x8d, 0xea, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x44, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, 0x6d, 0x15, 0x38, 0x63, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -263,10 +263,10 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) } i-- dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) i-- dAtA[i] = 0xa } @@ -313,7 +313,7 @@ func (m *MsgProvideCounterparty) Size() (n int) { } var l int _ = l - l = len(m.ClientId) + l = len(m.ChannelId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -372,7 +372,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -400,7 +400,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/counterparty.proto index 906c0db3fa2..f708694b21e 100644 --- a/proto/ibc/core/packetserver/v1/counterparty.proto +++ b/proto/ibc/core/packetserver/v1/counterparty.proto @@ -9,8 +9,12 @@ import "ibc/core/commitment/v2/commitment.proto"; // Counterparty defines the counterparty for a light client to implement IBC eureka protocol message Counterparty { - // the client identifier of the counterparty chain + // the client identifier of the light client representing the counterparty chain string client_id = 1; - // the merkle path that all ICS24 paths will be stored under - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; + // the counterparty identifier that must be used by the packet + string counterparty_channel_id = 2; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto index dec4a17f42c..2a0b835a179 100644 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -25,8 +25,8 @@ message MsgProvideCounterparty { option (gogoproto.goproto_getters) = false; - // client unique identifier - string client_id = 1; + // unique identifier we will use to write all packet messages sent to counterparty + string channel_id = 1; // counterparty client Counterparty counterparty = 2 [(gogoproto.nullable) = false]; // signer address From a42e1c750c82943568beccd9149d3d721ac4a625 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 1 Oct 2024 13:41:30 +0100 Subject: [PATCH 036/172] chore: move PacketV2 to channel/v2 proto and rename it to Packet (#7357) * chore: move PacketV2 to channel/v2 * remove file accidentally added * chore: created packet.go for v2 * rename --- modules/core/04-channel/types/channel.pb.go | 1068 ++-------------- modules/core/04-channel/types/packet.go | 66 - .../core/04-channel/v2/types/channel.pb.go | 1078 +++++++++++++++++ modules/core/04-channel/v2/types/packet.go | 43 + proto/ibc/core/channel/v1/channel.proto | 36 - proto/ibc/core/channel/v2/channel.proto | 44 + 6 files changed, 1236 insertions(+), 1099 deletions(-) create mode 100644 modules/core/04-channel/v2/types/channel.pb.go create mode 100644 modules/core/04-channel/v2/types/packet.go create mode 100644 proto/ibc/core/channel/v2/channel.proto diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index ab3af424662..636f44c2bf1 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -447,218 +447,6 @@ func (m *PacketId) XXX_DiscardUnknown() { var xxx_messageInfo_PacketId proto.InternalMessageInfo -// PacketV2 defines a type that carries data across different chains through IBC -type PacketV2 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 sending chain. - SourceId string `protobuf:"bytes,2,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` - // identifies the receiving chain. - DestinationId string `protobuf:"bytes,3,opt,name=destination_id,json=destinationId,proto3" json:"destination_id,omitempty"` - // timeout timestamp after which the packet times out. - TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` - // a list of packet data, each one for a specific application. - Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` -} - -func (m *PacketV2) Reset() { *m = PacketV2{} } -func (m *PacketV2) String() string { return proto.CompactTextString(m) } -func (*PacketV2) ProtoMessage() {} -func (*PacketV2) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{6} -} -func (m *PacketV2) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PacketV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PacketV2.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 *PacketV2) XXX_Merge(src proto.Message) { - xxx_messageInfo_PacketV2.Merge(m, src) -} -func (m *PacketV2) XXX_Size() int { - return m.Size() -} -func (m *PacketV2) XXX_DiscardUnknown() { - xxx_messageInfo_PacketV2.DiscardUnknown(m) -} - -var xxx_messageInfo_PacketV2 proto.InternalMessageInfo - -func (m *PacketV2) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - -func (m *PacketV2) GetSourceId() string { - if m != nil { - return m.SourceId - } - return "" -} - -func (m *PacketV2) GetDestinationId() string { - if m != nil { - return m.DestinationId - } - return "" -} - -func (m *PacketV2) GetTimeoutTimestamp() uint64 { - if m != nil { - return m.TimeoutTimestamp - } - return 0 -} - -func (m *PacketV2) GetData() []PacketData { - if m != nil { - return m.Data - } - return nil -} - -// PacketData contains the source and destination ports and payload for the application -type PacketData struct { - // specifies the source port of the packet. - SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` - // specifies the destination port of the packet. - DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` - // the payload to be sent to the application. - Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` -} - -func (m *PacketData) Reset() { *m = PacketData{} } -func (m *PacketData) String() string { return proto.CompactTextString(m) } -func (*PacketData) ProtoMessage() {} -func (*PacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{7} -} -func (m *PacketData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PacketData.Merge(m, src) -} -func (m *PacketData) XXX_Size() int { - return m.Size() -} -func (m *PacketData) XXX_DiscardUnknown() { - xxx_messageInfo_PacketData.DiscardUnknown(m) -} - -var xxx_messageInfo_PacketData proto.InternalMessageInfo - -func (m *PacketData) GetSourcePort() string { - if m != nil { - return m.SourcePort - } - return "" -} - -func (m *PacketData) GetDestinationPort() string { - if m != nil { - return m.DestinationPort - } - return "" -} - -func (m *PacketData) GetPayload() Payload { - if m != nil { - return m.Payload - } - return Payload{} -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -type Payload struct { - // version of the specified application. - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - // the encoding used for the provided value. - Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` - // the raw bytes for the payload. - Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *Payload) Reset() { *m = Payload{} } -func (m *Payload) String() string { return proto.CompactTextString(m) } -func (*Payload) ProtoMessage() {} -func (*Payload) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{8} -} -func (m *Payload) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Payload.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 *Payload) XXX_Merge(src proto.Message) { - xxx_messageInfo_Payload.Merge(m, src) -} -func (m *Payload) XXX_Size() int { - return m.Size() -} -func (m *Payload) XXX_DiscardUnknown() { - xxx_messageInfo_Payload.DiscardUnknown(m) -} - -var xxx_messageInfo_Payload proto.InternalMessageInfo - -func (m *Payload) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *Payload) GetEncoding() string { - if m != nil { - return m.Encoding - } - return "" -} - -func (m *Payload) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental @@ -670,7 +458,6 @@ type Acknowledgement struct { // response contains either a result or an error and must be non-empty // // Types that are valid to be assigned to Response: - // // *Acknowledgement_Result // *Acknowledgement_Error Response isAcknowledgement_Response `protobuf_oneof:"response"` @@ -680,7 +467,7 @@ func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } func (*Acknowledgement) ProtoMessage() {} func (*Acknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{9} + return fileDescriptor_c3a07336710636a0, []int{6} } func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -768,7 +555,7 @@ func (m *Timeout) Reset() { *m = Timeout{} } func (m *Timeout) String() string { return proto.CompactTextString(m) } func (*Timeout) ProtoMessage() {} func (*Timeout) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{10} + return fileDescriptor_c3a07336710636a0, []int{7} } func (m *Timeout) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -821,7 +608,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{11} + return fileDescriptor_c3a07336710636a0, []int{8} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -867,9 +654,6 @@ func init() { proto.RegisterType((*Packet)(nil), "ibc.core.channel.v1.Packet") proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v1.PacketState") proto.RegisterType((*PacketId)(nil), "ibc.core.channel.v1.PacketId") - proto.RegisterType((*PacketV2)(nil), "ibc.core.channel.v1.PacketV2") - proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v1.PacketData") - proto.RegisterType((*Payload)(nil), "ibc.core.channel.v1.Payload") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement") proto.RegisterType((*Timeout)(nil), "ibc.core.channel.v1.Timeout") proto.RegisterType((*Params)(nil), "ibc.core.channel.v1.Params") @@ -878,79 +662,71 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 1149 bytes of a gzipped FileDescriptorProto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bc, 0x9a, 0x60, 0x73, 0x8c, 0xa7, - 0xd8, 0xf6, 0x51, 0x05, 0xd2, 0x2e, 0xf6, 0x66, 0x13, 0xbf, 0xf2, 0x4e, 0xc0, 0x3c, 0x88, 0x69, - 0xdc, 0x46, 0xb7, 0x20, 0x85, 0x5d, 0x97, 0xb8, 0x95, 0x5b, 0x41, 0xee, 0x83, 0x98, 0xc6, 0xcc, - 0x7d, 0x80, 0xac, 0x8b, 0x3d, 0x87, 0xd8, 0x1e, 0xae, 0xeb, 0x90, 0x19, 0xb0, 0x79, 0xa0, 0x4f, - 0x21, 0xcd, 0x17, 0x80, 0xf0, 0x0f, 0x17, 0x00, 0xe7, 0xa3, 0xbb, 0x90, 0x5b, 0x4f, 0x39, 0x4e, - 0xa7, 0xbc, 0x06, 0xea, 0xc3, 0x60, 0x7d, 0xba, 0xfa, 0xd4, 0x43, 0xcf, 0x21, 0x5c, 0xd8, 0x23, - 0x2e, 0x02, 0x5e, 0x6a, 0x7b, 0x6b, 0xf9, 0xc1, 0x78, 0xb1, 0x12, 0x0f, 0xe5, 0xe8, 0x83, 0xef, - 0xe2, 0x90, 0xea, 0xf3, 0xef, 0x63, 0xad, 0x3f, 0x78, 0x32, 0x50, 0x46, 0xc3, 0xae, 0xda, 0x55, - 0x07, 0xea, 0x93, 0x43, 0xf5, 0x85, 0xd2, 0x19, 0x0d, 0xbb, 0xfd, 0x23, 0xa5, 0xad, 0x3e, 0x55, - 0x95, 0x8e, 0x18, 0x93, 0x76, 0x16, 0x4b, 0xb9, 0xb8, 0x41, 0x40, 0x15, 0x00, 0x16, 0x17, 0x80, - 0xa2, 0x20, 0x65, 0x17, 0x4b, 0x39, 0x19, 0x3c, 0xa3, 0x2a, 0x14, 0x99, 0x67, 0xa0, 0x7d, 0xd5, - 0x3b, 0x52, 0xba, 0x62, 0x5c, 0xca, 0x2f, 0x96, 0x72, 0x86, 0x9b, 0xeb, 0x48, 0xea, 0x4c, 0xb0, - 0x48, 0xea, 0xb9,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 0x32, 0x88, 0x37, 0x25, 0x5e, 0xcb, 0x3a, 0x31, - 0x1e, 0x8e, 0x49, 0x6b, 0xfe, 0xb8, 0x35, 0x25, 0xe6, 0x6c, 0x82, 0x3d, 0xf6, 0x3f, 0xf6, 0xd1, - 0xc7, 0x0f, 0xc3, 0x3f, 0xc6, 0xfe, 0x99, 0x83, 0xbd, 0x93, 0x34, 0xfd, 0x66, 0x7c, 0xf4, 0x57, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x8e, 0x64, 0x83, 0x39, 0x0b, 0x00, 0x00, + // 1024 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x53, 0xe7, 0xeb, 0x4d, 0x93, 0xb8, 0x53, 0xe8, 0x5a, 0xa6, 0x24, 0xde, 0x0a, 0x44, + 0xb7, 0x68, 0x93, 0x6d, 0x41, 0x88, 0xe5, 0xd6, 0xa6, 0xde, 0xad, 0xd9, 0x92, 0x54, 0x4e, 0xb2, + 0x12, 0x7b, 0xb1, 0x5c, 0x7b, 0x48, 0xad, 0x4d, 0x3c, 0xc6, 0x9e, 0x74, 0xb5, 0xe2, 0x8c, 0xb4, + 0xca, 0x89, 0x3f, 0x10, 0x09, 0x89, 0xbf, 0xc0, 0x8f, 0xd8, 0xe3, 0x1e, 0x39, 0x21, 0x68, 0xff, + 0x03, 0x67, 0xe4, 0x99, 0x71, 0x3e, 0xaa, 0xaa, 0x42, 0x48, 0xdc, 0x38, 0x65, 0xde, 0xe7, 0x7d, + 0xde, 0x8f, 0x79, 0xe7, 0x99, 0x89, 0xe1, 0xbe, 0x7f, 0xee, 0xb6, 0x5c, 0x12, 0xe1, 0x96, 0x7b, + 0xe1, 0x04, 0x01, 0x1e, 0xb5, 0x2e, 0xf7, 0xd3, 0x65, 0x33, 0x8c, 0x08, 0x25, 0x68, 0x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0x0c, 0xf4, 0x11, 0x6c, 0x75, 0xad, 0x63, 0xc3, + 0xb2, 0x3b, 0xdd, 0x8e, 0x71, 0x63, 0xf7, 0xac, 0xc1, 0x04, 0x47, 0x3b, 0x50, 0xe3, 0xac, 0x41, + 0x87, 0xfd, 0x1a, 0xc7, 0x8a, 0xa4, 0x55, 0xa6, 0x33, 0xbd, 0x34, 0x07, 0x92, 0xed, 0x73, 0x4e, + 0xca, 0x10, 0xdb, 0x17, 0xa6, 0x28, 0x3c, 0x00, 0x58, 0x5c, 0x68, 0xf4, 0x01, 0xdc, 0x33, 0x8f, + 0xda, 0xf6, 0x73, 0xc3, 0xea, 0x99, 0xdd, 0xce, 0x6a, 0x79, 0xb4, 0x01, 0x95, 0x65, 0xe7, 0xbe, + 0x22, 0xdd, 0x84, 0x0e, 0x94, 0x2c, 0x4f, 0x7b, 0xd4, 0x7b, 0x7b, 0x55, 0x97, 0xde, 0x5d, 0xd5, + 0xa5, 0x3f, 0xae, 0xea, 0xd2, 0x4f, 0xd7, 0xf5, 0xcc, 0xbb, 0xeb, 0x7a, 0xe6, 0xb7, 0xeb, 0x7a, + 0xe6, 0xc5, 0xe3, 0xa1, 0x4f, 0x2f, 0x26, 0xe7, 0x4d, 0x97, 0x8c, 0x5b, 0x2e, 0x89, 0xc7, 0x24, + 0x6e, 0xf9, 0xe7, 0xee, 0xc3, 0x21, 0x69, 0x5d, 0x3e, 0x6e, 0x8d, 0x89, 0x37, 0x19, 0xe1, 0x98, + 0x7f, 0x02, 0x3d, 0xfa, 0xfc, 0x61, 0xfa, 0x4d, 0x45, 0x5f, 0x87, 0x38, 0x3e, 0xcf, 0xb3, 0xe7, + 0xe6, 0xb3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x19, 0x54, 0x78, 0x4b, 0x74, 0x09, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -1320,158 +1096,6 @@ func (m *PacketId) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PacketV2) 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 *PacketV2) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PacketV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.TimeoutTimestamp != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) - i-- - dAtA[i] = 0x20 - } - if len(m.DestinationId) > 0 { - i -= len(m.DestinationId) - copy(dAtA[i:], m.DestinationId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationId))) - i-- - dAtA[i] = 0x1a - } - if len(m.SourceId) > 0 { - i -= len(m.SourceId) - copy(dAtA[i:], m.SourceId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceId))) - i-- - dAtA[i] = 0x12 - } - if m.Sequence != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.DestinationPort) > 0 { - i -= len(m.DestinationPort) - copy(dAtA[i:], m.DestinationPort) - i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationPort))) - i-- - dAtA[i] = 0x12 - } - if len(m.SourcePort) > 0 { - i -= len(m.SourcePort) - copy(dAtA[i:], m.SourcePort) - i = encodeVarintChannel(dAtA, i, uint64(len(m.SourcePort))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Payload) 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 *Payload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x1a - } - if len(m.Encoding) > 0 { - i -= len(m.Encoding) - copy(dAtA[i:], m.Encoding) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) - i-- - dAtA[i] = 0x12 - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *Acknowledgement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1797,83 +1421,14 @@ func (m *PacketId) Size() (n int) { return n } -func (m *PacketV2) Size() (n int) { +func (m *Acknowledgement) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Sequence != 0 { - n += 1 + sovChannel(uint64(m.Sequence)) - } - l = len(m.SourceId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.DestinationId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - if m.TimeoutTimestamp != 0 { - n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) - } - if len(m.Data) > 0 { - for _, e := range m.Data { - l = e.Size() - n += 1 + l + sovChannel(uint64(l)) - } - } - return n -} - -func (m *PacketData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SourcePort) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.DestinationPort) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = m.Payload.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - -func (m *Payload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Version) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.Encoding) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - return n -} - -func (m *Acknowledgement) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Response != nil { - n += m.Response.Size() + if m.Response != nil { + n += m.Response.Size() } return n } @@ -3183,487 +2738,6 @@ func (m *PacketId) Unmarshal(dAtA []byte) error { } return nil } -func (m *PacketV2) 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 ErrIntOverflowChannel - } - 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: PacketV2: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PacketV2: 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 ErrIntOverflowChannel - } - 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 SourceId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourceId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - 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 ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeoutTimestamp |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data, PacketData{}) - if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PacketData) 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 ErrIntOverflowChannel - } - 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: PacketData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PacketData: 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - 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 DestinationPort", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationPort = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Payload) 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 ErrIntOverflowChannel - } - 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: Payload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Encoding = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Acknowledgement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 85bc7352a4e..71ff5bd62e9 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -101,42 +101,6 @@ func commitV2Packet(packet Packet) []byte { return hash[:] } -// CommitPacketV2 returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout) + sha256_hash(destinationID) + sha256_hash(packetData) from a given packet. -// This results in a fixed length preimage. -// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able -// to malleate the packet fields and create a commitment hash that matches the original packet. -func CommitPacketV2(packet PacketV2) []byte { - buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) - - destIDHash := sha256.Sum256([]byte(packet.DestinationId)) - buf = append(buf, destIDHash[:]...) - - for _, data := range packet.Data { - buf = append(buf, hashPacketData(data)...) - } - - hash := sha256.Sum256(buf) - return hash[:] -} - -// hashPacketData returns the hash of the packet data. -func hashPacketData(data PacketData) []byte { - var buf []byte - sourceHash := sha256.Sum256([]byte(data.SourcePort)) - buf = append(buf, sourceHash[:]...) - destHash := sha256.Sum256([]byte(data.DestinationPort)) - buf = append(buf, destHash[:]...) - payloadValueHash := sha256.Sum256(data.Payload.Value) - buf = append(buf, payloadValueHash[:]...) - payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) - buf = append(buf, payloadEncodingHash[:]...) - payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) - buf = append(buf, payloadVersionHash[:]...) - hash := sha256.Sum256(buf) - return hash[:] -} - // CommitAcknowledgement returns the hash of commitment bytes func CommitAcknowledgement(data []byte) []byte { hash := sha256.Sum256(data) @@ -264,33 +228,3 @@ func (p PacketId) Validate() error { func NewPacketID(portID, channelID string, seq uint64) PacketId { return PacketId{PortId: portID, ChannelId: channelID, Sequence: seq} } - -// ConvertPacketV1toV2 constructs a PacketV2 from a Packet. -func ConvertPacketV1toV2(packet Packet) (PacketV2, error) { - if packet.ProtocolVersion != IBC_VERSION_2 { - return PacketV2{}, errorsmod.Wrapf(ErrInvalidPacket, "expected protocol version %s, got %s instead", IBC_VERSION_2, packet.ProtocolVersion) - } - - encoding := strings.TrimSpace(packet.Encoding) - if encoding == "" { - encoding = "json" - } - - return PacketV2{ - Sequence: packet.Sequence, - SourceId: packet.SourceChannel, - DestinationId: packet.DestinationChannel, - TimeoutTimestamp: packet.TimeoutTimestamp, - Data: []PacketData{ - { - SourcePort: packet.SourcePort, - DestinationPort: packet.DestinationPort, - Payload: Payload{ - Version: packet.AppVersion, - Encoding: encoding, - Value: packet.Data, - }, - }, - }, - }, nil -} diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go new file mode 100644 index 00000000000..52cbc2a2dee --- /dev/null +++ b/modules/core/04-channel/v2/types/channel.pb.go @@ -0,0 +1,1078 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/channel/v2/channel.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// 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 sending chain. + SourceId string `protobuf:"bytes,2,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + // identifies the receiving chain. + DestinationId string `protobuf:"bytes,3,opt,name=destination_id,json=destinationId,proto3" json:"destination_id,omitempty"` + // timeout timestamp after which the packet times out. + TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` + // a list of packet data, each one for a specific application. + Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` +} + +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_7e9b57d8f218397d, []int{0} +} +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 (m *Packet) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *Packet) GetSourceId() string { + if m != nil { + return m.SourceId + } + return "" +} + +func (m *Packet) GetDestinationId() string { + if m != nil { + return m.DestinationId + } + return "" +} + +func (m *Packet) GetTimeoutTimestamp() uint64 { + if m != nil { + return m.TimeoutTimestamp + } + return 0 +} + +func (m *Packet) GetData() []PacketData { + if m != nil { + return m.Data + } + return nil +} + +// PacketData contains the source and destination ports and payload for the application +type PacketData struct { + // specifies the source port of the packet. + SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // specifies the destination port of the packet. + DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` + // the payload to be sent to the application. + Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` +} + +func (m *PacketData) Reset() { *m = PacketData{} } +func (m *PacketData) String() string { return proto.CompactTextString(m) } +func (*PacketData) ProtoMessage() {} +func (*PacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{1} +} +func (m *PacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketData.Merge(m, src) +} +func (m *PacketData) XXX_Size() int { + return m.Size() +} +func (m *PacketData) XXX_DiscardUnknown() { + xxx_messageInfo_PacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketData proto.InternalMessageInfo + +func (m *PacketData) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *PacketData) GetDestinationPort() string { + if m != nil { + return m.DestinationPort + } + return "" +} + +func (m *PacketData) GetPayload() Payload { + if m != nil { + return m.Payload + } + return Payload{} +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +type Payload struct { + // version of the specified application. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // the encoding used for the provided value. + Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` + // the raw bytes for the payload. + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *Payload) Reset() { *m = Payload{} } +func (m *Payload) String() string { return proto.CompactTextString(m) } +func (*Payload) ProtoMessage() {} +func (*Payload) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{2} +} +func (m *Payload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Payload.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 *Payload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Payload.Merge(m, src) +} +func (m *Payload) XXX_Size() int { + return m.Size() +} +func (m *Payload) XXX_DiscardUnknown() { + xxx_messageInfo_Payload.DiscardUnknown(m) +} + +var xxx_messageInfo_Payload proto.InternalMessageInfo + +func (m *Payload) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Payload) GetEncoding() string { + if m != nil { + return m.Encoding + } + return "" +} + +func (m *Payload) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func init() { + proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") + proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v2.PacketData") + proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } + +var fileDescriptor_7e9b57d8f218397d = []byte{ + // 405 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x3d, 0x6f, 0xd4, 0x30, + 0x18, 0x3e, 0xd3, 0x6b, 0xaf, 0xf7, 0x1e, 0x1f, 0xc5, 0x74, 0x88, 0x0a, 0xca, 0x1d, 0x27, 0x21, + 0x1d, 0x42, 0x8d, 0xd1, 0xc1, 0x52, 0xa9, 0x53, 0xc5, 0xd2, 0xad, 0x8a, 0x80, 0x81, 0xa5, 0x72, + 0x1c, 0x2b, 0xb5, 0x48, 0xfc, 0x86, 0xd8, 0x89, 0xd4, 0x7f, 0xc1, 0xc4, 0x6f, 0xea, 0x78, 0x23, + 0x13, 0x42, 0x77, 0x7f, 0x04, 0xc5, 0x4e, 0x20, 0x03, 0x9d, 0xe2, 0xe7, 0xc3, 0x7a, 0x9f, 0x27, + 0x7e, 0xe1, 0xa5, 0x4a, 0x04, 0x13, 0x58, 0x49, 0x26, 0x6e, 0xb8, 0xd6, 0x32, 0x67, 0xcd, 0xba, + 0x3f, 0x46, 0x65, 0x85, 0x16, 0xe9, 0x33, 0x95, 0x88, 0xa8, 0xb5, 0x44, 0x3d, 0xdf, 0xac, 0x4f, + 0x8e, 0x33, 0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49, 0x23, 0x2b, 0xa3, 0x50, 0x77, 0x81, 0x7a, 0xd8, + 0xbe, 0x82, 0xd4, 0x02, 0x53, 0xa5, 0xb3, 0xfe, 0x47, 0xf7, 0x98, 0x1e, 0xc3, 0x7e, 0xc3, 0xf3, + 0x5a, 0xba, 0xe1, 0x0f, 0x63, 0x0f, 0x2e, 0x3e, 0xdf, 0x6d, 0x43, 0xb2, 0xd9, 0x86, 0xe4, 0xf7, + 0x36, 0x24, 0xdf, 0x77, 0xe1, 0x68, 0xb3, 0x0b, 0x47, 0x3f, 0x77, 0xe1, 0xe8, 0xcb, 0x79, 0xa6, + 0xec, 0x4d, 0x9d, 0x44, 0x02, 0x0b, 0x26, 0xd0, 0x14, 0x68, 0x98, 0x4a, 0xc4, 0x69, 0x86, 0xac, + 0x39, 0x63, 0x05, 0xa6, 0x75, 0x2e, 0x8d, 0x5f, 0xa5, 0xb7, 0xef, 0x4f, 0x07, 0xdb, 0x64, 0x6f, + 0x4b, 0x69, 0x92, 0x03, 0xb7, 0x21, 0xef, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x25, 0x2c, + 0xa2, 0x71, 0x02, 0x00, 0x00, +} + +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 len(m.Data) > 0 { + for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.TimeoutTimestamp != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.DestinationId) > 0 { + i -= len(m.DestinationId) + copy(dAtA[i:], m.DestinationId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationId))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourceId) > 0 { + i -= len(m.SourceId) + copy(dAtA[i:], m.SourceId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceId))) + i-- + dAtA[i] = 0x12 + } + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x12 + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Payload) 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 *Payload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Encoding) > 0 { + i -= len(m.Encoding) + copy(dAtA[i:], m.Encoding) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { + offset -= sovChannel(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Packet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + l = len(m.SourceId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) + } + if len(m.Data) > 0 { + for _, e := range m.Data { + l = e.Size() + n += 1 + l + sovChannel(uint64(l)) + } + } + return n +} + +func (m *PacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationPort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = m.Payload.Size() + n += 1 + l + sovChannel(uint64(l)) + return n +} + +func (m *Payload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.Encoding) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + +func sovChannel(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozChannel(x uint64) (n int) { + return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowChannel + } + 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 ErrIntOverflowChannel + } + 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 SourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data, PacketData{}) + if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketData) 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 ErrIntOverflowChannel + } + 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: PacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketData: 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 ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + 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 DestinationPort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationPort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Payload) 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 ErrIntOverflowChannel + } + 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: Payload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Encoding = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipChannel(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, ErrIntOverflowChannel + } + 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, ErrIntOverflowChannel + } + 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, ErrIntOverflowChannel + } + 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, ErrInvalidLengthChannel + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupChannel + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthChannel + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go new file mode 100644 index 00000000000..145b8cf600c --- /dev/null +++ b/modules/core/04-channel/v2/types/packet.go @@ -0,0 +1,43 @@ +package types + +import ( + "crypto/sha256" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// CommitPacket returns the V2 packet commitment bytes. The commitment consists of: +// sha256_hash(timeout) + sha256_hash(destinationID) + sha256_hash(packetData) from a given packet. +// This results in a fixed length preimage. +// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. +func CommitPacket(packet Packet) []byte { + buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) + + destIDHash := sha256.Sum256([]byte(packet.DestinationId)) + buf = append(buf, destIDHash[:]...) + + for _, data := range packet.Data { + buf = append(buf, hashPacketData(data)...) + } + + hash := sha256.Sum256(buf) + return hash[:] +} + +// hashPacketData returns the hash of the packet data. +func hashPacketData(data PacketData) []byte { + var buf []byte + sourceHash := sha256.Sum256([]byte(data.SourcePort)) + buf = append(buf, sourceHash[:]...) + destHash := sha256.Sum256([]byte(data.DestinationPort)) + buf = append(buf, destHash[:]...) + payloadValueHash := sha256.Sum256(data.Payload.Value) + buf = append(buf, payloadValueHash[:]...) + payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) + buf = append(buf, payloadEncodingHash[:]...) + payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) + buf = append(buf, payloadVersionHash[:]...) + hash := sha256.Sum256(buf) + return hash[:] +} diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index 5c10d0a2e6b..77b523c181f 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -176,42 +176,6 @@ message PacketId { uint64 sequence = 3; } -// PacketV2 defines a type that carries data across different chains through IBC -message PacketV2 { - // 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 sending chain. - string source_id = 2; - // identifies the receiving chain. - string destination_id = 3; - // timeout timestamp after which the packet times out. - uint64 timeout_timestamp = 4; - // a list of packet data, each one for a specific application. - repeated PacketData data = 5 [(gogoproto.nullable) = false]; -} - -// PacketData contains the source and destination ports and payload for the application -message PacketData { - // specifies the source port of the packet. - string source_port = 1; - // specifies the destination port of the packet. - string destination_port = 2; - // the payload to be sent to the application. - Payload payload = 3 [(gogoproto.nullable) = false]; -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -message Payload { - // version of the specified application. - string version = 1; - // the encoding used for the provided value. - string encoding = 2; - // the raw bytes for the payload. - bytes value = 3; -} - // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto new file mode 100644 index 00000000000..d4946a21618 --- /dev/null +++ b/proto/ibc/core/channel/v2/channel.proto @@ -0,0 +1,44 @@ + +syntax = "proto3"; + +package ibc.core.channel.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; + +import "gogoproto/gogo.proto"; + +// Packet defines a type that carries data across different chains through IBC +message Packet { + // 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 sending chain. + string source_id = 2; + // identifies the receiving chain. + string destination_id = 3; + // timeout timestamp after which the packet times out. + uint64 timeout_timestamp = 4; + // a list of packet data, each one for a specific application. + repeated PacketData data = 5 [(gogoproto.nullable) = false]; +} + +// PacketData contains the source and destination ports and payload for the application +message PacketData { + // specifies the source port of the packet. + string source_port = 1; + // specifies the destination port of the packet. + string destination_port = 2; + // the payload to be sent to the application. + Payload payload = 3 [(gogoproto.nullable) = false]; +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +message Payload { + // version of the specified application. + string version = 1; + // the encoding used for the provided value. + string encoding = 2; + // the raw bytes for the payload. + bytes value = 3; +} From 78bb3bedc58a7052a987048f2e24a19bfb6913ef Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 1 Oct 2024 20:02:23 +0300 Subject: [PATCH 037/172] Add fallback function to grab counterparty for non-eureka channels (#7358) --- modules/core/04-channel/keeper/keeper.go | 28 +++++++ modules/core/04-channel/keeper/keeper_test.go | 82 ++++++++++++++++++- modules/core/packet-server/keeper/relay.go | 22 ++++- .../packet-server/types/expected_keepers.go | 3 + 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 1dddc74e126..04ef2f584ed 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -21,8 +21,10 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) var _ porttypes.ICS4Wrapper = (*Keeper)(nil) @@ -824,3 +826,29 @@ func (k *Keeper) PruneAcknowledgements(ctx context.Context, portID, channelID st return totalPruned, totalRemaining, nil } + +// GetV2Counterparty returns a version 2 counterparty for the given port and channel ID +// by converting the channel into a version 2 counterparty +func (k *Keeper) GetV2Counterparty(ctx context.Context, portID, channelID string) (packetserver.Counterparty, bool) { + channel, ok := k.GetChannel(ctx, portID, channelID) + if !ok { + return packetserver.Counterparty{}, false + } + // Do not allow channel to be converted into a version 2 counterparty + // if the channel is not OPEN or if it is ORDERED + if channel.State != types.OPEN || channel.Ordering == types.ORDERED { + return packetserver.Counterparty{}, false + } + connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) + if !ok { + return packetserver.Counterparty{}, false + } + merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) + + counterparty := packetserver.Counterparty{ + CounterpartyChannelId: channel.Counterparty.ChannelId, + ClientId: connection.ClientId, + MerklePathPrefix: merklePathPrefix, + } + return counterparty, true +} diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index c6014805af6..d5401e94c66 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -11,8 +11,10 @@ import ( transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" ) @@ -26,6 +28,7 @@ type KeeperTestSuite struct { // testing chains used for convenience and readability chainA *ibctesting.TestChain chainB *ibctesting.TestChain + chainC *ibctesting.TestChain } // TestKeeperTestSuite runs all the tests within this package. @@ -35,12 +38,14 @@ func TestKeeperTestSuite(t *testing.T) { // SetupTest creates a coordinator with 2 test chains. func (suite *KeeperTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) suite.coordinator.CommitNBlocks(suite.chainA, 2) suite.coordinator.CommitNBlocks(suite.chainB, 2) + suite.coordinator.CommitNBlocks(suite.chainC, 2) } // TestSetChannel create clients and connections on both chains. It tests for the non-existence @@ -544,6 +549,81 @@ func (suite *KeeperTestSuite) TestUnsetParams() { }) } +func (suite *KeeperTestSuite) TestGetV2Counterparty() { + var path *ibctesting.Path + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "failure: channel not found", + func() { + path.EndpointA.ChannelID = "" + }, + false, + }, + { + "failure: channel not OPEN", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.TRYOPEN }) + }, + false, + }, + { + "failure: channel is ORDERED", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) + }, + false, + }, + { + "failure: connection not found", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{ibctesting.InvalidID} }) + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + // create a previously existing path on chainA to change the identifiers + // between the path between chainA and chainB + path1 := ibctesting.NewPath(suite.chainA, suite.chainC) + path1.Setup() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + tc.malleate() + + counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Counterparty(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + + if tc.expPass { + suite.Require().True(found) + + merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) + expCounterparty := packetservertypes.NewCounterparty(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + suite.Require().Equal(counterparty, expCounterparty) + } else { + suite.Require().False(found) + suite.Require().Equal(counterparty, packetservertypes.Counterparty{}) + } + }) + } +} + func (suite *KeeperTestSuite) TestPruneAcknowledgements() { var ( path *ibctesting.Path diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index eaa16b9f80f..c4d559cae48 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -34,7 +34,16 @@ func (k Keeper) SendPacket( // Lookup counterparty associated with our source channel to retrieve the destination channel counterparty, ok := k.GetCounterparty(ctx, sourceChannel) if !ok { - return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) + // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // for future use. + if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, sourcePort, sourceChannel); ok { + // we can key on just the source channel here since channel ids are globally unique + k.SetCounterparty(ctx, sourceChannel, counterparty) + } else { + // if neither a counterparty nor channel is found then simply return an error + return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) + } } destChannel := counterparty.CounterpartyChannelId clientID := counterparty.ClientId @@ -112,7 +121,16 @@ func (k Keeper) RecvPacket( // that the packet was indeed sent by our counterparty. counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) if !ok { - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // for future use. + if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, packet.DestinationPort, packet.DestinationChannel); ok { + // we can key on just the destination channel here since channel ids are globally unique + k.SetCounterparty(ctx, packet.DestinationChannel, counterparty) + } else { + // if neither a counterparty nor channel is found then simply return an error + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + } } if counterparty.CounterpartyChannelId != packet.SourceChannel { diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 969005c4b7f..98140a084fc 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -38,6 +38,9 @@ type ChannelKeeper interface { // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) + + // GetV2Counterparty returns a version 2 counterparty for a given portID and channel ID + GetV2Counterparty(ctx context.Context, portID, channelID string) (Counterparty, bool) } type ClientKeeper interface { From 688302f7af723af2ee23f667f999ecbcdd500cd0 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Wed, 2 Oct 2024 11:39:53 +0100 Subject: [PATCH 038/172] Add channel keeper v2 (#7377) * chore: add scaffolding for channel keeper v2 * Update modules/core/04-channel/v2/keeper/keeper.go Co-authored-by: DimitrisJim --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/keeper/keeper.go | 63 +++ .../04-channel/v2/types/counterparty.pb.go | 438 ++++++++++++++++++ modules/core/04-channel/v2/types/keys.go | 11 + proto/ibc/core/channel/v2/counterparty.proto | 20 + 4 files changed, 532 insertions(+) create mode 100644 modules/core/04-channel/v2/keeper/keeper.go create mode 100644 modules/core/04-channel/v2/types/counterparty.pb.go create mode 100644 modules/core/04-channel/v2/types/keys.go create mode 100644 proto/ibc/core/channel/v2/counterparty.proto diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go new file mode 100644 index 00000000000..16b6e230e88 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "context" + "fmt" + + corestore "cosmossdk.io/core/store" + "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +// Keeper defines the channel keeper v2. +type Keeper struct { + cdc codec.BinaryCodec + storeService corestore.KVStoreService +} + +// NewKeeper creates a new channel v2 keeper +func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService) *Keeper { + return &Keeper{ + cdc: cdc, + storeService: storeService, + } +} + +// Logger returns a module-specific logger. +func (Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) +} + +func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.KVStore { + channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelStorePrefix, channelID)) + return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) +} + +// SetCounterparty sets the Counterparty for a given client identifier. +func (k *Keeper) SetCounterparty(ctx context.Context, clientID string, counterparty types.Counterparty) { + bz := k.cdc.MustMarshal(&counterparty) + k.ChannelStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) +} + +// GetCounterparty gets the Counterparty for a given client identifier. +func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Counterparty, bool) { + store := k.ChannelStore(ctx, clientID) + bz := store.Get([]byte(types.CounterpartyKey)) + if len(bz) == 0 { + return types.Counterparty{}, false + } + + var counterparty types.Counterparty + k.cdc.MustUnmarshal(bz, &counterparty) + return counterparty, true +} diff --git a/modules/core/04-channel/v2/types/counterparty.pb.go b/modules/core/04-channel/v2/types/counterparty.pb.go new file mode 100644 index 00000000000..75c5938d11f --- /dev/null +++ b/modules/core/04-channel/v2/types/counterparty.pb.go @@ -0,0 +1,438 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/channel/v2/counterparty.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + 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 + +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +type Counterparty struct { + // the client identifier of the light client representing the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the counterparty identifier that must be used by the packet + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_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_ce9c5094f22c756d, []int{0} +} +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 + +func (m *Counterparty) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *Counterparty) GetCounterpartyChannelId() string { + if m != nil { + return m.CounterpartyChannelId + } + return "" +} + +func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { + if m != nil { + return m.MerklePathPrefix + } + return v2.MerklePath{} +} + +func init() { + proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v2.Counterparty") +} + +func init() { + proto.RegisterFile("ibc/core/channel/v2/counterparty.proto", fileDescriptor_ce9c5094f22c756d) +} + +var fileDescriptor_ce9c5094f22c756d = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0x48, 0xcc, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0xd2, + 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x49, 0x2d, 0x2a, 0x48, 0x2c, 0x2a, 0xa9, 0xd4, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x12, 0xce, 0x4c, 0x4a, 0xd6, 0x03, 0xa9, 0xd3, 0x83, 0xaa, 0xd3, 0x2b, 0x33, + 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0xea, 0x08, + 0x23, 0xf3, 0x73, 0x73, 0x33, 0x4b, 0x72, 0x53, 0xf3, 0x4a, 0x20, 0xa6, 0xc2, 0x78, 0x10, 0x85, + 0x4a, 0xbb, 0x19, 0xb9, 0x78, 0x9c, 0x91, 0xac, 0x12, 0x92, 0xe6, 0xe2, 0x4c, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0x89, 0xcf, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x80, 0x08, 0x78, + 0xa6, 0x08, 0x99, 0x71, 0x89, 0x23, 0xbb, 0x2b, 0x1e, 0xea, 0x0e, 0x90, 0x52, 0x26, 0xb0, 0x52, + 0x51, 0x64, 0x69, 0x67, 0x88, 0xac, 0x67, 0x8a, 0x50, 0x18, 0x97, 0x50, 0x6e, 0x6a, 0x51, 0x76, + 0x4e, 0x6a, 0x7c, 0x41, 0x62, 0x49, 0x46, 0x7c, 0x41, 0x51, 0x6a, 0x5a, 0x66, 0x85, 0x04, 0xb3, + 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x92, 0x1e, 0xc2, 0x5b, 0x08, 0xd7, 0x95, 0x19, 0xe9, 0xf9, 0x82, + 0x75, 0x04, 0x24, 0x96, 0x64, 0x38, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x24, 0x90, 0x0b, 0x17, + 0x09, 0x00, 0x9b, 0xe0, 0x14, 0x76, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, + 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, + 0x36, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x20, 0x23, 0xf5, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, + 0xf5, 0x33, 0x93, 0x92, 0x75, 0xd3, 0xf3, 0xf5, 0xcb, 0x2c, 0xf5, 0x73, 0xf3, 0x53, 0x4a, 0x73, + 0x52, 0x8b, 0x21, 0x01, 0x64, 0x60, 0xa2, 0x8b, 0x14, 0xec, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, + 0x6c, 0xe0, 0xc0, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x88, 0xf9, 0x24, 0x25, 0x9a, 0x01, + 0x00, 0x00, +} + +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.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCounterparty(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { + offset -= sovCounterparty(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +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 + sovCounterparty(uint64(l)) + } + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovCounterparty(uint64(l)) + return n +} + +func sovCounterparty(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCounterparty(x uint64) (n int) { + return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowCounterparty + } + 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 ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + 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 CounterpartyChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCounterparty(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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrInvalidLengthCounterparty + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCounterparty + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCounterparty + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go new file mode 100644 index 00000000000..37a60421cf5 --- /dev/null +++ b/modules/core/04-channel/v2/types/keys.go @@ -0,0 +1,11 @@ +package types + +const ( + // SubModuleName defines the channelv2 module name. + SubModuleName = "channelv2" + + // CounterpartyKey is the key used to store counterparty in the client store. + // the counterparty key is imported from types instead of host because + // the counterparty key is not a part of the ics-24 host specification + CounterpartyKey = "counterparty" +) diff --git a/proto/ibc/core/channel/v2/counterparty.proto b/proto/ibc/core/channel/v2/counterparty.proto new file mode 100644 index 00000000000..fd0b88c612f --- /dev/null +++ b/proto/ibc/core/channel/v2/counterparty.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package ibc.core.channel.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/commitment/v2/commitment.proto"; + +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +message Counterparty { + // the client identifier of the light client representing the counterparty chain + string client_id = 1; + // the counterparty identifier that must be used by the packet + string counterparty_channel_id = 2; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; +} From d82e1cd6ca7750aa607e55bcae1d754aab6eff9c Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 2 Oct 2024 13:53:32 +0100 Subject: [PATCH 039/172] chore: Added SendPacket RPC skeleton and relative proto message (#7364) * chore: Added SendPacket RPC skeleton * chore: register new message * linter * add v2 codec.go * rename alias * linter --- modules/core/04-channel/v2/types/codec.go | 15 + modules/core/04-channel/v2/types/tx.pb.go | 687 ++++++++++++++++++++++ modules/core/types/codec.go | 3 + proto/ibc/core/channel/v2/tx.proto | 35 ++ 4 files changed, 740 insertions(+) create mode 100644 modules/core/04-channel/v2/types/codec.go create mode 100644 modules/core/04-channel/v2/types/tx.pb.go create mode 100644 proto/ibc/core/channel/v2/tx.proto diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go new file mode 100644 index 00000000000..a040c437472 --- /dev/null +++ b/modules/core/04-channel/v2/types/codec.go @@ -0,0 +1,15 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterInterfaces register the ibc channel submodule interfaces to protobuf +// Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgSendPacket{}, + ) +} diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go new file mode 100644 index 00000000000..331825c0dff --- /dev/null +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -0,0 +1,687 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/channel/v2/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// MsgSendPacket sends an outgoing IBC packet. +type MsgSendPacket struct { + SourceId string `protobuf:"bytes,1,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + TimeoutTimestamp uint64 `protobuf:"varint,2,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` + PacketData []PacketData `protobuf:"bytes,3,rep,name=packet_data,json=packetData,proto3" json:"packet_data"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgSendPacket) Reset() { *m = MsgSendPacket{} } +func (m *MsgSendPacket) String() string { return proto.CompactTextString(m) } +func (*MsgSendPacket) ProtoMessage() {} +func (*MsgSendPacket) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{0} +} +func (m *MsgSendPacket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendPacket.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 *MsgSendPacket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendPacket.Merge(m, src) +} +func (m *MsgSendPacket) XXX_Size() int { + return m.Size() +} +func (m *MsgSendPacket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendPacket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendPacket proto.InternalMessageInfo + +// MsgSendPacketResponse defines the Msg/SendPacket response type. +type MsgSendPacketResponse struct { + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *MsgSendPacketResponse) Reset() { *m = MsgSendPacketResponse{} } +func (m *MsgSendPacketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendPacketResponse) ProtoMessage() {} +func (*MsgSendPacketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{1} +} +func (m *MsgSendPacketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendPacketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendPacketResponse.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 *MsgSendPacketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendPacketResponse.Merge(m, src) +} +func (m *MsgSendPacketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendPacketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendPacketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendPacketResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") + proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } + +var fileDescriptor_d421c7119e969b99 = []byte{ + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0x48, 0xcc, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0xd2, + 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xce, 0x4c, 0x4a, 0xd6, 0x03, 0xc9, + 0xea, 0x41, 0x65, 0xf5, 0xca, 0x8c, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, 0xfa, 0x20, + 0x16, 0x44, 0xa9, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x6e, 0x71, 0xba, 0x7e, + 0x99, 0x21, 0x88, 0x82, 0x4a, 0x28, 0x62, 0xb3, 0x01, 0x66, 0x1c, 0x58, 0x89, 0xd2, 0x29, 0x46, + 0x2e, 0x5e, 0xdf, 0xe2, 0xf4, 0xe0, 0xd4, 0xbc, 0x94, 0x80, 0xc4, 0xe4, 0xec, 0xd4, 0x12, 0x21, + 0x69, 0x2e, 0xce, 0xe2, 0xfc, 0xd2, 0xa2, 0xe4, 0xd4, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x0e, 0x88, 0x80, 0x67, 0x8a, 0x90, 0x36, 0x97, 0x60, 0x49, 0x66, 0x6e, 0x6a, + 0x7e, 0x69, 0x49, 0x3c, 0x88, 0x2e, 0x2e, 0x49, 0xcc, 0x2d, 0x90, 0x60, 0x52, 0x60, 0xd4, 0x60, + 0x09, 0x12, 0x80, 0x4a, 0x84, 0xc0, 0xc4, 0x85, 0xdc, 0xb8, 0xb8, 0x0b, 0xc0, 0x66, 0xc6, 0xa7, + 0x24, 0x96, 0x24, 0x4a, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xeb, 0x61, 0xf1, 0x98, 0x1e, + 0xc4, 0x6e, 0x97, 0xc4, 0x92, 0x44, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xb8, 0x0a, 0xe0, + 0x22, 0x42, 0x62, 0x5c, 0x6c, 0xc5, 0x99, 0xe9, 0x79, 0xa9, 0x45, 0x12, 0x2c, 0x60, 0xe7, 0x40, + 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, 0xd0, 0x82, 0x0a, 0x28, 0x59, 0x72, + 0x89, 0xa2, 0xf8, 0x25, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x48, 0x8a, 0x8b, 0xa3, + 0x38, 0xb5, 0xb0, 0x34, 0x35, 0x2f, 0x39, 0x15, 0xec, 0x25, 0x96, 0x20, 0x38, 0xdf, 0x8a, 0x05, + 0x64, 0x8a, 0x51, 0x01, 0x17, 0x27, 0x44, 0x8f, 0x6f, 0x71, 0xba, 0x50, 0x0c, 0x17, 0x17, 0x52, + 0x80, 0x28, 0x61, 0x75, 0x31, 0x8a, 0x45, 0x52, 0x5a, 0x84, 0xd5, 0xc0, 0x1c, 0x23, 0xc5, 0xda, + 0xf0, 0x7c, 0x83, 0x16, 0xa3, 0x53, 0xd8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, + 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, + 0x44, 0xd9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xa3, 0x36, + 0x33, 0x29, 0x59, 0x37, 0x3d, 0x5f, 0xbf, 0xcc, 0x52, 0x3f, 0x37, 0x3f, 0xa5, 0x34, 0x27, 0xb5, + 0x18, 0x12, 0xad, 0x06, 0x26, 0xba, 0xc8, 0x69, 0xa7, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, + 0xb1, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42, 0x5d, 0x9d, 0x69, 0x5f, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// PacketMsgClient is the client API for PacketMsg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type PacketMsgClient interface { + // SendPacket defines a rpc handler method for MsgSendPacket. + SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) +} + +type packetMsgClient struct { + cc grpc1.ClientConn +} + +func NewPacketMsgClient(cc grpc1.ClientConn) PacketMsgClient { + return &packetMsgClient{cc} +} + +func (c *packetMsgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) { + out := new(MsgSendPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/SendPacket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PacketMsgServer is the server API for PacketMsg service. +type PacketMsgServer interface { + // SendPacket defines a rpc handler method for MsgSendPacket. + SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) +} + +// UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. +type UnimplementedPacketMsgServer struct { +} + +func (*UnimplementedPacketMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") +} + +func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { + s.RegisterService(&_PacketMsg_serviceDesc, srv) +} + +func _PacketMsg_SendPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSendPacket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).SendPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.PacketMsg/SendPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).SendPacket(ctx, req.(*MsgSendPacket)) + } + return interceptor(ctx, in, info, handler) +} + +var _PacketMsg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.channel.v2.PacketMsg", + HandlerType: (*PacketMsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendPacket", + Handler: _PacketMsg_SendPacket_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/channel/v2/tx.proto", +} + +func (m *MsgSendPacket) 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 *MsgSendPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendPacket) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.PacketData) > 0 { + for iNdEx := len(m.PacketData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.TimeoutTimestamp != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x10 + } + if len(m.SourceId) > 0 { + i -= len(m.SourceId) + copy(dAtA[i:], m.SourceId) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendPacketResponse) 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 *MsgSendPacketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSendPacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SourceId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovTx(uint64(m.TimeoutTimestamp)) + } + if len(m.PacketData) > 0 { + for _, e := range m.PacketData { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSendPacketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSendPacket) 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 ErrIntOverflowTx + } + 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: MsgSendPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendPacket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PacketData = append(m.PacketData, PacketData{}) + if err := m.PacketData[len(m.PacketData)-1].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 stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSendPacketResponse) 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 ErrIntOverflowTx + } + 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: MsgSendPacketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendPacketResponse: 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index 28b008ce3f6..d805413f912 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -6,6 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -18,4 +19,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { channeltypes.RegisterInterfaces(registry) packetservertypes.RegisterInterfaces(registry) commitmenttypes.RegisterInterfaces(registry) + + channeltypesv2.RegisterInterfaces(registry) } diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto new file mode 100644 index 00000000000..f6537b16aaf --- /dev/null +++ b/proto/ibc/core/channel/v2/tx.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package ibc.core.channel.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; +import "ibc/core/channel/v2/channel.proto"; + +// PacketMsg defines the ibc/channel PacketMsg service. +service PacketMsg { + option (cosmos.msg.v1.service) = true; + + // SendPacket defines a rpc handler method for MsgSendPacket. + rpc SendPacket(MsgSendPacket) returns (MsgSendPacketResponse); +} + +// MsgSendPacket sends an outgoing IBC packet. +message MsgSendPacket { + option (cosmos.msg.v1.signer) = "signer"; + option (gogoproto.goproto_getters) = false; + + string source_id = 1; + uint64 timeout_timestamp = 2; + repeated PacketData packet_data = 3 [(gogoproto.nullable) = false]; + string signer = 4; +} + +// MsgSendPacketResponse defines the Msg/SendPacket response type. +message MsgSendPacketResponse { + option (gogoproto.goproto_getters) = false; + + uint64 sequence = 1; +} From 17d348780220599a4ea28652fd60116a7b3cceac Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Wed, 2 Oct 2024 14:17:45 +0100 Subject: [PATCH 040/172] Add new keys and getter / setter functions (#7378) * chore: adding keys and keeper getter and setter functions * chore: use BigEndian for sequence in keys --- modules/core/04-channel/v2/keeper/keeper.go | 101 ++++++++++++++++++++ modules/core/24-host/v2/packet_keys.go | 24 +++++ 2 files changed, 125 insertions(+) create mode 100644 modules/core/24-host/v2/packet_keys.go diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 16b6e230e88..ac50715c836 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -61,3 +62,103 @@ func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Co k.cdc.MustUnmarshal(bz, &counterparty) return counterparty, true } + +// GetPacketReceipt returns the packet receipt from the packet receipt path based on the sourceID and sequence. +func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) (string, bool) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + bz, err := store.Get(hostv2.PacketReceiptKey(sourceID, bigEndianBz)) + if err != nil { + panic(err) + } + if len(bz) == 0 { + return "", false + } + return string(bz), true +} + +// SetPacketReceipt writes the packet receipt under the receipt path +// This is a public path that is standardized by the IBC V2 specification. +func (k *Keeper) SetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + if err := store.Set(hostv2.PacketReceiptKey(sourceID, bigEndianBz), []byte{byte(1)}); err != nil { + panic(err) + } +} + +// SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path +// This is a public path that is standardized by the IBC V2 specification. +func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64, ackHash []byte) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + if err := store.Set(hostv2.PacketAcknowledgementKey(sourceID, bigEndianBz), ackHash); err != nil { + panic(err) + } +} + +// HasPacketAcknowledgement check if the packet ack hash is already on the store. +func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64) bool { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + found, err := store.Has(hostv2.PacketAcknowledgementKey(sourceID, bigEndianBz)) + if err != nil { + panic(err) + } + + return found +} + +// GetPacketCommitment returns the packet commitment hash under the commitment path. +func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, sequence uint64) (string, bool) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + bz, err := store.Get(hostv2.PacketCommitmentKey(sourceID, bigEndianBz)) + if err != nil { + panic(err) + } + if len(bz) == 0 { + return "", false + } + return string(bz), true +} + +// SetPacketCommitment writes the commitment hash under the commitment path. +func (k *Keeper) SetPacketCommitment(ctx context.Context, sourceID string, sequence uint64, commitment []byte) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + if err := store.Set(hostv2.PacketCommitmentKey(sourceID, bigEndianBz), commitment); err != nil { + panic(err) + } +} + +// DeletePacketCommitment deletes the packet commitment hash under the commitment path. +func (k *Keeper) DeletePacketCommitment(ctx context.Context, sourceID string, sequence uint64) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + if err := store.Delete(hostv2.PacketCommitmentKey(sourceID, bigEndianBz)); err != nil { + panic(err) + } +} + +// GetNextSequenceSend returns the next send sequence from the sequence path +func (k *Keeper) GetNextSequenceSend(ctx context.Context, sourceID string) (uint64, bool) { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(hostv2.NextSequenceSendKey(sourceID)) + if err != nil { + panic(err) + } + if len(bz) == 0 { + return 0, false + } + return sdk.BigEndianToUint64(bz), true +} + +// SetNextSequenceSend writes the next send sequence under the sequence path +func (k *Keeper) SetNextSequenceSend(ctx context.Context, sourceID string, sequence uint64) { + store := k.storeService.OpenKVStore(ctx) + bigEndianBz := sdk.Uint64ToBigEndian(sequence) + if err := store.Set(hostv2.NextSequenceSendKey(sourceID), bigEndianBz); err != nil { + panic(err) + } +} diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go new file mode 100644 index 00000000000..62a855595aa --- /dev/null +++ b/modules/core/24-host/v2/packet_keys.go @@ -0,0 +1,24 @@ +package v2 + +import "fmt" + +// PacketReceiptKey returns the store key of under which a packet +// receipt is stored +func PacketReceiptKey(sourceID string, bigEndianSequence []byte) []byte { + return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +} + +// PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. +func PacketAcknowledgementKey(sourceID string, bigEndianSequence []byte) []byte { + return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +} + +// PacketCommitmentKey returns the store key of under which a packet commitment is stored. +func PacketCommitmentKey(sourceID string, bigEndianSequence []byte) []byte { + return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +} + +// NextSequenceSendKey returns the store key for the next sequence send of a given sourceID. +func NextSequenceSendKey(sourceID string) []byte { + return []byte(fmt.Sprintf("nextSequenceSend/%s", sourceID)) +} From d2ac6566c934fdc444defa8ae0dc1a40caedf45d Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 2 Oct 2024 15:25:12 +0100 Subject: [PATCH 041/172] chore: add MsgRecvPacket skeleton (#7379) * chore: add MsgRecvPacket skeleton * Add RPC proto definition for RecvPacket --- modules/core/04-channel/v2/types/codec.go | 1 + modules/core/04-channel/v2/types/tx.pb.go | 552 +++++++++++++++++++++- proto/ibc/core/channel/v2/tx.proto | 24 + 3 files changed, 551 insertions(+), 26 deletions(-) diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index a040c437472..ce3272b57ec 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -11,5 +11,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgSendPacket{}, + &MsgRecvPacket{}, ) } diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 331825c0dff..96c22a39b28 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -10,6 +10,8 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + types1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -108,40 +110,131 @@ func (m *MsgSendPacketResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSendPacketResponse proto.InternalMessageInfo +// MsgRecvPacket receives an incoming IBC packet. +type MsgRecvPacket struct { + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + ProofCommitment []byte `protobuf:"bytes,2,opt,name=proof_commitment,json=proofCommitment,proto3" json:"proof_commitment,omitempty"` + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgRecvPacket) Reset() { *m = MsgRecvPacket{} } +func (m *MsgRecvPacket) String() string { return proto.CompactTextString(m) } +func (*MsgRecvPacket) ProtoMessage() {} +func (*MsgRecvPacket) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{2} +} +func (m *MsgRecvPacket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRecvPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRecvPacket.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 *MsgRecvPacket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRecvPacket.Merge(m, src) +} +func (m *MsgRecvPacket) XXX_Size() int { + return m.Size() +} +func (m *MsgRecvPacket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRecvPacket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRecvPacket proto.InternalMessageInfo + +// MsgRecvPacketResponse defines the Msg/RecvPacket response type. +type MsgRecvPacketResponse struct { + Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +} + +func (m *MsgRecvPacketResponse) Reset() { *m = MsgRecvPacketResponse{} } +func (m *MsgRecvPacketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRecvPacketResponse) ProtoMessage() {} +func (*MsgRecvPacketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{3} +} +func (m *MsgRecvPacketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRecvPacketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRecvPacketResponse.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 *MsgRecvPacketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRecvPacketResponse.Merge(m, src) +} +func (m *MsgRecvPacketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRecvPacketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRecvPacketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRecvPacketResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") + proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v2.MsgRecvPacket") + proto.RegisterType((*MsgRecvPacketResponse)(nil), "ibc.core.channel.v2.MsgRecvPacketResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x4c, 0x4a, 0xd6, - 0x4f, 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13, 0xf7, 0xe4, 0x19, 0x82, 0xb8, 0x0a, 0xe0, - 0x22, 0x42, 0x62, 0x5c, 0x6c, 0xc5, 0x99, 0xe9, 0x79, 0xa9, 0x45, 0x12, 0x2c, 0x60, 0xe7, 0x40, - 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, 0xd0, 0x82, 0x0a, 0x28, 0x59, 0x72, - 0x89, 0xa2, 0xf8, 0x25, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x48, 0x8a, 0x8b, 0xa3, - 0x38, 0xb5, 0xb0, 0x34, 0x35, 0x2f, 0x39, 0x15, 0xec, 0x25, 0x96, 0x20, 0x38, 0xdf, 0x8a, 0x05, - 0x64, 0x8a, 0x51, 0x01, 0x17, 0x27, 0x44, 0x8f, 0x6f, 0x71, 0xba, 0x50, 0x0c, 0x17, 0x17, 0x52, - 0x80, 0x28, 0x61, 0x75, 0x31, 0x8a, 0x45, 0x52, 0x5a, 0x84, 0xd5, 0xc0, 0x1c, 0x23, 0xc5, 0xda, - 0xf0, 0x7c, 0x83, 0x16, 0xa3, 0x53, 0xd8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, - 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, - 0x44, 0xd9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xa3, 0x36, - 0x33, 0x29, 0x59, 0x37, 0x3d, 0x5f, 0xbf, 0xcc, 0x52, 0x3f, 0x37, 0x3f, 0xa5, 0x34, 0x27, 0xb5, - 0x18, 0x12, 0xad, 0x06, 0x26, 0xba, 0xc8, 0x69, 0xa7, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, - 0xb1, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42, 0x5d, 0x9d, 0x69, 0x5f, 0x02, 0x00, 0x00, + // 554 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0x6f, 0x58, 0xa9, 0x56, 0x77, 0xb0, 0x11, 0xfe, 0x55, 0x19, 0x4a, 0x4b, 0x2f, 0x94, 0xa2, + 0xc5, 0x34, 0x70, 0xe9, 0x84, 0x84, 0xb4, 0x21, 0x04, 0x87, 0x49, 0x28, 0x4c, 0x1c, 0xd0, 0x44, + 0x95, 0xba, 0x8f, 0xd4, 0xa2, 0x89, 0x43, 0xec, 0x44, 0xec, 0x86, 0x38, 0x71, 0xe4, 0x23, 0xf0, + 0x11, 0xf6, 0x31, 0x26, 0x0e, 0x68, 0x47, 0x4e, 0x08, 0xb5, 0x87, 0x7d, 0x0d, 0x14, 0xdb, 0x4d, + 0x3b, 0xd1, 0x01, 0x27, 0xdb, 0xef, 0xf7, 0x7b, 0xef, 0xfd, 0xde, 0xcf, 0x71, 0xd0, 0x2d, 0x3a, + 0x20, 0x98, 0xb0, 0x04, 0x30, 0x19, 0xf9, 0x51, 0x04, 0x63, 0x9c, 0xb9, 0x58, 0x7c, 0x70, 0xe2, + 0x84, 0x09, 0x66, 0x5e, 0xa5, 0x03, 0xe2, 0xe4, 0xa8, 0xa3, 0x51, 0x27, 0x73, 0xad, 0x6b, 0x01, + 0x0b, 0x98, 0xc4, 0x71, 0xbe, 0x53, 0x54, 0xeb, 0x26, 0x61, 0x3c, 0x64, 0x1c, 0x87, 0x3c, 0xc0, + 0x59, 0x37, 0x5f, 0x34, 0x70, 0x7b, 0x59, 0x87, 0x59, 0x39, 0x45, 0x59, 0x22, 0xa2, 0x5b, 0x88, + 0xb0, 0x1a, 0x73, 0x74, 0x4c, 0x21, 0x12, 0x39, 0xa8, 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 0x87, 0x31, 0xf0, 0x41, 0x45, 0xbe, 0xbe, 0x07, 0xbf, 0x03, 0x00, 0x00, + 0xff, 0xff, 0xce, 0x15, 0xfb, 0x02, 0x43, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,6 +251,8 @@ const _ = grpc.SupportPackageIsVersion4 type PacketMsgClient interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) } type packetMsgClient struct { @@ -177,10 +272,21 @@ func (c *packetMsgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opt return out, nil } +func (c *packetMsgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { + out := new(MsgRecvPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/RecvPacket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // PacketMsgServer is the server API for PacketMsg service. type PacketMsgServer interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) } // UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. @@ -190,6 +296,9 @@ type UnimplementedPacketMsgServer struct { func (*UnimplementedPacketMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") } +func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") +} func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { s.RegisterService(&_PacketMsg_serviceDesc, srv) @@ -213,6 +322,24 @@ func _PacketMsg_SendPacket_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _PacketMsg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRecvPacket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).RecvPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.PacketMsg/RecvPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + } + return interceptor(ctx, in, info, handler) +} + var _PacketMsg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.PacketMsg", HandlerType: (*PacketMsgServer)(nil), @@ -221,6 +348,10 @@ var _PacketMsg_serviceDesc = grpc.ServiceDesc{ MethodName: "SendPacket", Handler: _PacketMsg_SendPacket_Handler, }, + { + MethodName: "RecvPacket", + Handler: _PacketMsg_RecvPacket_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/tx.proto", @@ -310,6 +441,91 @@ func (m *MsgSendPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgRecvPacket) 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 *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRecvPacket) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ProofCommitment) > 0 { + i -= len(m.ProofCommitment) + copy(dAtA[i:], m.ProofCommitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgRecvPacketResponse) 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 *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -359,6 +575,39 @@ func (m *MsgSendPacketResponse) Size() (n int) { return n } +func (m *MsgRecvPacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofCommitment) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRecvPacketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -601,6 +850,257 @@ func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRecvPacket) 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 ErrIntOverflowTx + } + 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: MsgRecvPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRecvPacket: 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 ProofCommitment", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) + if m.ProofCommitment == nil { + m.ProofCommitment = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.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 stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRecvPacketResponse) 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 ErrIntOverflowTx + } + 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: MsgRecvPacketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRecvPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= types1.ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index f6537b16aaf..7c47eddef64 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -7,6 +7,8 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/type import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/core/channel/v2/channel.proto"; +import "ibc/core/channel/v1/tx.proto"; +import "ibc/core/client/v1/client.proto"; // PacketMsg defines the ibc/channel PacketMsg service. service PacketMsg { @@ -14,6 +16,9 @@ service PacketMsg { // SendPacket defines a rpc handler method for MsgSendPacket. rpc SendPacket(MsgSendPacket) returns (MsgSendPacketResponse); + + // RecvPacket defines a rpc handler method for MsgRecvPacket. + rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); } // MsgSendPacket sends an outgoing IBC packet. @@ -33,3 +38,22 @@ message MsgSendPacketResponse { uint64 sequence = 1; } + +// MsgRecvPacket receives an incoming IBC packet. +message MsgRecvPacket { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_commitment = 2; + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; + string signer = 4; +} + +// MsgRecvPacketResponse defines the Msg/RecvPacket response type. +message MsgRecvPacketResponse { + option (gogoproto.goproto_getters) = false; + + ibc.core.channel.v1.ResponseResultType result = 1; +} From 304cb0a884f68989a1bc080551d7bc50d7f73fcb Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 2 Oct 2024 15:44:45 +0100 Subject: [PATCH 042/172] chore: add MsgTimeout skeleton (#7380) * add MsgTimeout skeleton * missing saved file * restore docstring --- modules/core/04-channel/v2/types/codec.go | 1 + modules/core/04-channel/v2/types/tx.pb.go | 595 ++++++++++++++++++++-- proto/ibc/core/channel/v2/tx.proto | 23 + 3 files changed, 582 insertions(+), 37 deletions(-) diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index ce3272b57ec..6b505433102 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -12,5 +12,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgSendPacket{}, &MsgRecvPacket{}, + &MsgTimeout{}, ) } diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 96c22a39b28..4c60ac0135d 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -110,7 +110,7 @@ func (m *MsgSendPacketResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSendPacketResponse proto.InternalMessageInfo -// MsgRecvPacket receives an incoming IBC packet. +// MsgRecvPacket receives incoming IBC packet type MsgRecvPacket struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` ProofCommitment []byte `protobuf:"bytes,2,opt,name=proof_commitment,json=proofCommitment,proto3" json:"proof_commitment,omitempty"` @@ -189,52 +189,139 @@ func (m *MsgRecvPacketResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRecvPacketResponse proto.InternalMessageInfo +// MsgTimeout receives timed-out packet +type MsgTimeout struct { + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty"` + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + NextSequenceRecv uint64 `protobuf:"varint,4,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty"` + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" 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_d421c7119e969b99, []int{4} +} +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 + +// MsgTimeoutResponse defines the Msg/Timeout response type. +type MsgTimeoutResponse struct { + Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +} + +func (m *MsgTimeoutResponse) Reset() { *m = MsgTimeoutResponse{} } +func (m *MsgTimeoutResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTimeoutResponse) ProtoMessage() {} +func (*MsgTimeoutResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{5} +} +func (m *MsgTimeoutResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTimeoutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTimeoutResponse.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 *MsgTimeoutResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTimeoutResponse.Merge(m, src) +} +func (m *MsgTimeoutResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTimeoutResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTimeoutResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTimeoutResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v2.MsgRecvPacket") proto.RegisterType((*MsgRecvPacketResponse)(nil), "ibc.core.channel.v2.MsgRecvPacketResponse") + proto.RegisterType((*MsgTimeout)(nil), "ibc.core.channel.v2.MsgTimeout") + proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v2.MsgTimeoutResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x6f, 0x58, 0xa9, 0x56, 0x77, 0xb0, 0x11, 0xfe, 0x55, 0x19, 0x4a, 0x4b, 0x2f, 0x94, 0xa2, - 0xc5, 0x34, 0x70, 0xe9, 0x84, 0x84, 0xb4, 0x21, 0x04, 0x87, 0x49, 0x28, 0x4c, 0x1c, 0xd0, 0x44, - 0x95, 0xba, 0x8f, 0xd4, 0xa2, 0x89, 0x43, 0xec, 0x44, 0xec, 0x86, 0x38, 0x71, 0xe4, 0x23, 0xf0, - 0x11, 0xf6, 0x31, 0x26, 0x0e, 0x68, 0x47, 0x4e, 0x08, 0xb5, 0x87, 0x7d, 0x0d, 0x14, 0xdb, 0x4d, - 0x3b, 0xd1, 0x01, 0x27, 0xdb, 0xef, 0xf7, 0x7b, 0xef, 0xfd, 0xde, 0xcf, 0x71, 0xd0, 0x2d, 0x3a, - 0x20, 0x98, 0xb0, 0x04, 0x30, 0x19, 0xf9, 0x51, 0x04, 0x63, 0x9c, 0xb9, 0x58, 0x7c, 0x70, 0xe2, - 0x84, 0x09, 0x66, 0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, 0x9c, 0x4c, 0x6c, 0xe3, 0xd7, 0xc4, 0x36, 0xbe, 0x4c, 0xed, 0xd2, 0xc9, 0xd4, 0x2e, 0xfd, - 0x98, 0xda, 0xa5, 0xd7, 0x8f, 0x02, 0x2a, 0x46, 0xe9, 0xc0, 0x21, 0x2c, 0xc4, 0xfa, 0xf9, 0xd2, - 0x01, 0xd9, 0x0a, 0x18, 0xce, 0x7a, 0x38, 0x64, 0xc3, 0x74, 0x0c, 0x5c, 0xbd, 0xbc, 0xfb, 0x0f, - 0xb7, 0x16, 0xff, 0x0f, 0x87, 0x31, 0xf0, 0x41, 0x45, 0xbe, 0xbe, 0x07, 0xbf, 0x03, 0x00, 0x00, - 0xff, 0xff, 0xce, 0x15, 0xfb, 0x02, 0x43, 0x04, 0x00, 0x00, + // 637 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xc7, 0xb7, 0xb0, 0xec, 0x0f, 0x66, 0xf9, 0x09, 0xd6, 0x7f, 0x9b, 0x62, 0xba, 0xb8, 0x17, + 0x10, 0xa5, 0x75, 0xab, 0x17, 0x88, 0x89, 0x09, 0x18, 0xa3, 0x07, 0x12, 0x53, 0xd0, 0x83, 0x12, + 0x9b, 0xee, 0xf4, 0xb1, 0xdb, 0xb8, 0xed, 0xd4, 0xce, 0xb4, 0x81, 0x9b, 0xf1, 0xe4, 0xc9, 0xf8, + 0x12, 0x4c, 0x7c, 0x03, 0xbc, 0x0c, 0xe2, 0x89, 0xa3, 0x27, 0x63, 0xd8, 0x03, 0x6f, 0xc3, 0x74, + 0x66, 0xda, 0x5d, 0x92, 0x02, 0x1e, 0x38, 0xb5, 0x7d, 0xbe, 0xdf, 0x79, 0xfe, 0x7c, 0x3a, 0x33, + 0xe8, 0x76, 0xd0, 0xc3, 0x26, 0x26, 0x09, 0x98, 0xb8, 0xef, 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xe3, 0x38, 0xeb, 0xf6, 0x7c, 0xae, 0x6c, 0x4b, + 0x21, 0x87, 0x37, 0x06, 0x7c, 0xea, 0x7c, 0xe0, 0x6f, 0x91, 0x3a, 0xe2, 0x71, 0xc9, 0xb4, 0xad, + 0x1f, 0x13, 0x68, 0x46, 0xc0, 0xdb, 0xa2, 0xbe, 0xba, 0x8b, 0xd0, 0xd8, 0x29, 0xee, 0x54, 0xa2, + 0x3e, 0x75, 0x3a, 0xb4, 0x95, 0x8b, 0x3d, 0x65, 0xcb, 0xbb, 0x08, 0x8d, 0x9d, 0x8d, 0x33, 0xb3, + 0x8f, 0x3c, 0x67, 0x67, 0xaf, 0xd8, 0x7e, 0xdb, 0xe8, 0xbf, 0x62, 0xcf, 0xb4, 0xcf, 0x5a, 0x26, + 0x0d, 0xda, 0xd2, 0x05, 0x86, 0x22, 0xa9, 0x36, 0xf5, 0xe9, 0xe4, 0x60, 0x45, 0xd9, 0x78, 0x7d, + 0x78, 0xac, 0x2b, 0x47, 0xc7, 0xba, 0xf2, 0xe7, 0x58, 0x57, 0xbe, 0x0d, 0xf5, 0xda, 0xd1, 0x50, + 0xaf, 0xfd, 0x1a, 0xea, 0xb5, 0x37, 0x8f, 0xfd, 0x80, 0xf5, 0xd3, 0x9e, 0x81, 0x49, 0x68, 0xca, + 0x1b, 0x38, 0xe8, 0xe1, 0x55, 0x9f, 0x98, 0xd9, 0x9a, 0x19, 0x12, 0x2f, 0x1d, 0x00, 0x15, 0x97, + 0xe7, 0x83, 0x47, 0xab, 0xe3, 0x57, 0xfc, 0x7e, 0x0c, 0xb4, 0xd7, 0xe0, 0x17, 0xe8, 0xc3, 0xbf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x7c, 0x4f, 0xf0, 0x06, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -253,6 +340,8 @@ type PacketMsgClient interface { SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) } type packetMsgClient struct { @@ -281,12 +370,23 @@ func (c *packetMsgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opt return out, nil } +func (c *packetMsgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { + out := new(MsgTimeoutResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/Timeout", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // PacketMsgServer is the server API for PacketMsg service. type PacketMsgServer interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) } // UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. @@ -299,6 +399,9 @@ func (*UnimplementedPacketMsgServer) SendPacket(ctx context.Context, req *MsgSen func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") } +func (*UnimplementedPacketMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") +} func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { s.RegisterService(&_PacketMsg_serviceDesc, srv) @@ -340,6 +443,24 @@ func _PacketMsg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _PacketMsg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeout) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).Timeout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.PacketMsg/Timeout", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).Timeout(ctx, req.(*MsgTimeout)) + } + return interceptor(ctx, in, info, handler) +} + var _PacketMsg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.PacketMsg", HandlerType: (*PacketMsgServer)(nil), @@ -352,6 +473,10 @@ var _PacketMsg_serviceDesc = grpc.ServiceDesc{ MethodName: "RecvPacket", Handler: _PacketMsg_RecvPacket_Handler, }, + { + MethodName: "Timeout", + Handler: _PacketMsg_Timeout_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/tx.proto", @@ -526,6 +651,96 @@ func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.NextSequenceRecv != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) + i-- + dAtA[i] = 0x20 + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgTimeoutResponse) 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 *MsgTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -608,6 +823,42 @@ func (m *MsgRecvPacketResponse) Size() (n int) { return n } +func (m *MsgTimeout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofUnreceived) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + if m.NextSequenceRecv != 0 { + n += 1 + sovTx(uint64(m.NextSequenceRecv)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgTimeoutResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1101,6 +1352,276 @@ func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowTx + } + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 ProofUnreceived", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 ErrIntOverflowTx + } + 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 stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgTimeoutResponse) 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 ErrIntOverflowTx + } + 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: MsgTimeoutResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= types1.ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 7c47eddef64..b94e6e42de9 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -19,6 +19,9 @@ service PacketMsg { // RecvPacket defines a rpc handler method for MsgRecvPacket. rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); + + // Timeout defines a rpc handler method for MsgTimeout. + rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); } // MsgSendPacket sends an outgoing IBC packet. @@ -57,3 +60,23 @@ message MsgRecvPacketResponse { ibc.core.channel.v1.ResponseResultType result = 1; } + +// MsgTimeout receives timed-out packet +message MsgTimeout { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_unreceived = 2; + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; + uint64 next_sequence_recv = 4; + string signer = 5; +} + +// MsgTimeoutResponse defines the Msg/Timeout response type. +message MsgTimeoutResponse { + option (gogoproto.goproto_getters) = false; + + ibc.core.channel.v1.ResponseResultType result = 1; +} From bb0bfa5e57f6289c9cce06485488a835ab639b3d Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 3 Oct 2024 11:40:08 +0100 Subject: [PATCH 043/172] chore: add Acknowledgement message proto. (#7381) * chore: add Acknowledgment message! * chore: fix proto mess * random fixes --- .../core/04-channel/v2/types/channel.pb.go | 723 +++++++++++++++++- modules/core/04-channel/v2/types/codec.go | 1 + modules/core/04-channel/v2/types/tx.pb.go | 628 +++++++++++++-- proto/ibc/core/channel/v2/channel.proto | 31 + proto/ibc/core/channel/v2/tx.proto | 23 + 5 files changed, 1335 insertions(+), 71 deletions(-) diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go index 52cbc2a2dee..6ba9798bb01 100644 --- a/modules/core/04-channel/v2/types/channel.pb.go +++ b/modules/core/04-channel/v2/types/channel.pb.go @@ -23,6 +23,42 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// PacketStatus specifies the status of a RecvPacketResult. +type PacketStatus int32 + +const ( + // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. + PacketStatus_NONE PacketStatus = 0 + // PACKET_STATUS_SUCCESS indicates a successful packet receipt. + PacketStatus_Success PacketStatus = 1 + // PACKET_STATUS_FAILURE indicates a failed packet receipt. + PacketStatus_Failure PacketStatus = 2 + // PACKET_STATUS_ASYNC indicates an async packet receipt. + PacketStatus_Async PacketStatus = 3 +) + +var PacketStatus_name = map[int32]string{ + 0: "PACKET_STATUS_UNSPECIFIED", + 1: "PACKET_STATUS_SUCCESS", + 2: "PACKET_STATUS_FAILURE", + 3: "PACKET_STATUS_ASYNC", +} + +var PacketStatus_value = map[string]int32{ + "PACKET_STATUS_UNSPECIFIED": 0, + "PACKET_STATUS_SUCCESS": 1, + "PACKET_STATUS_FAILURE": 2, + "PACKET_STATUS_ASYNC": 3, +} + +func (x PacketStatus) String() string { + return proto.EnumName(PacketStatus_name, int32(x)) +} + +func (PacketStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{0} +} + // 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 @@ -235,42 +271,215 @@ func (m *Payload) GetValue() []byte { return nil } +// Acknowledgement contains a list of all ack results associated with a single packet. +type Acknowledgement struct { + AcknowledgementResults []AcknowledgementResult `protobuf:"bytes,1,rep,name=acknowledgement_results,json=acknowledgementResults,proto3" json:"acknowledgement_results"` +} + +func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } +func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } +func (*Acknowledgement) ProtoMessage() {} +func (*Acknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{3} +} +func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Acknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Acknowledgement.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 *Acknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_Acknowledgement.Merge(m, src) +} +func (m *Acknowledgement) XXX_Size() int { + return m.Size() +} +func (m *Acknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_Acknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo + +func (m *Acknowledgement) GetAcknowledgementResults() []AcknowledgementResult { + if m != nil { + return m.AcknowledgementResults + } + return nil +} + +// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. +type AcknowledgementResult struct { + AppName string `protobuf:"bytes,1,opt,name=app_name,json=appName,proto3" json:"app_name,omitempty"` + RecvPacketResult RecvPacketResult `protobuf:"bytes,2,opt,name=recv_packet_result,json=recvPacketResult,proto3" json:"recv_packet_result"` +} + +func (m *AcknowledgementResult) Reset() { *m = AcknowledgementResult{} } +func (m *AcknowledgementResult) String() string { return proto.CompactTextString(m) } +func (*AcknowledgementResult) ProtoMessage() {} +func (*AcknowledgementResult) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{4} +} +func (m *AcknowledgementResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AcknowledgementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AcknowledgementResult.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 *AcknowledgementResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_AcknowledgementResult.Merge(m, src) +} +func (m *AcknowledgementResult) XXX_Size() int { + return m.Size() +} +func (m *AcknowledgementResult) XXX_DiscardUnknown() { + xxx_messageInfo_AcknowledgementResult.DiscardUnknown(m) +} + +var xxx_messageInfo_AcknowledgementResult proto.InternalMessageInfo + +func (m *AcknowledgementResult) GetAppName() string { + if m != nil { + return m.AppName + } + return "" +} + +func (m *AcknowledgementResult) GetRecvPacketResult() RecvPacketResult { + if m != nil { + return m.RecvPacketResult + } + return RecvPacketResult{} +} + +// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. +type RecvPacketResult struct { + // status of the packet + Status PacketStatus `protobuf:"varint,1,opt,name=status,proto3,enum=ibc.core.channel.v2.PacketStatus" json:"status,omitempty"` + // acknowledgement of the packet + Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` +} + +func (m *RecvPacketResult) Reset() { *m = RecvPacketResult{} } +func (m *RecvPacketResult) String() string { return proto.CompactTextString(m) } +func (*RecvPacketResult) ProtoMessage() {} +func (*RecvPacketResult) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{5} +} +func (m *RecvPacketResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecvPacketResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecvPacketResult.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 *RecvPacketResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecvPacketResult.Merge(m, src) +} +func (m *RecvPacketResult) XXX_Size() int { + return m.Size() +} +func (m *RecvPacketResult) XXX_DiscardUnknown() { + xxx_messageInfo_RecvPacketResult.DiscardUnknown(m) +} + +var xxx_messageInfo_RecvPacketResult proto.InternalMessageInfo + +func (m *RecvPacketResult) GetStatus() PacketStatus { + if m != nil { + return m.Status + } + return PacketStatus_NONE +} + +func (m *RecvPacketResult) GetAcknowledgement() []byte { + if m != nil { + return m.Acknowledgement + } + return nil +} + func init() { + proto.RegisterEnum("ibc.core.channel.v2.PacketStatus", PacketStatus_name, PacketStatus_value) proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v2.PacketData") proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") + proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v2.Acknowledgement") + proto.RegisterType((*AcknowledgementResult)(nil), "ibc.core.channel.v2.AcknowledgementResult") + proto.RegisterType((*RecvPacketResult)(nil), "ibc.core.channel.v2.RecvPacketResult") } func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } var fileDescriptor_7e9b57d8f218397d = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x3d, 0x6f, 0xd4, 0x30, - 0x18, 0x3e, 0xd3, 0x6b, 0xaf, 0xf7, 0x1e, 0x1f, 0xc5, 0x74, 0x88, 0x0a, 0xca, 0x1d, 0x27, 0x21, - 0x1d, 0x42, 0x8d, 0xd1, 0xc1, 0x52, 0xa9, 0x53, 0xc5, 0xd2, 0xad, 0x8a, 0x80, 0x81, 0xa5, 0x72, - 0x1c, 0x2b, 0xb5, 0x48, 0xfc, 0x86, 0xd8, 0x89, 0xd4, 0x7f, 0xc1, 0xc4, 0x6f, 0xea, 0x78, 0x23, - 0x13, 0x42, 0x77, 0x7f, 0x04, 0xc5, 0x4e, 0x20, 0x03, 0x9d, 0xe2, 0xe7, 0xc3, 0x7a, 0x9f, 0x27, - 0x7e, 0xe1, 0xa5, 0x4a, 0x04, 0x13, 0x58, 0x49, 0x26, 0x6e, 0xb8, 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xe4, 0xb7, 0x39, 0x72, 0x5f, 0x71, 0xb6, 0x7e, 0x71, 0x4f, 0x30, 0xe7, 0xe9, 0x52, 0xf5, 0x57, - 0x96, 0x9f, 0x60, 0xd2, 0x29, 0x34, 0x80, 0x49, 0x23, 0x2b, 0xa3, 0x50, 0x77, 0x81, 0x7a, 0xd8, - 0xbe, 0x82, 0xd4, 0x02, 0x53, 0xa5, 0xb3, 0xfe, 0x47, 0xf7, 0x98, 0x1e, 0xc3, 0x7e, 0xc3, 0xf3, - 0x5a, 0xba, 0xe1, 0x0f, 0x63, 0x0f, 0x2e, 0x3e, 0xdf, 0x6d, 0x43, 0xb2, 0xd9, 0x86, 0xe4, 0xf7, - 0x36, 0x24, 0xdf, 0x77, 0xe1, 0x68, 0xb3, 0x0b, 0x47, 0x3f, 0x77, 0xe1, 0xe8, 0xcb, 0x79, 0xa6, - 0xec, 0x4d, 0x9d, 0x44, 0x02, 0x0b, 0x26, 0xd0, 0x14, 0x68, 0x98, 0x4a, 0xc4, 0x69, 0x86, 0xac, - 0x39, 0x63, 0x05, 0xa6, 0x75, 0x2e, 0x8d, 0x5f, 0xa5, 0xb7, 0xef, 0x4f, 0x07, 0xdb, 0x64, 0x6f, - 0x4b, 0x69, 0x92, 0x03, 0xb7, 0x21, 0xef, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x25, 0x2c, - 0xa2, 0x71, 0x02, 0x00, 0x00, + // 660 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x41, 0x4f, 0x1a, 0x4f, + 0x18, 0xc6, 0x59, 0x45, 0x81, 0x17, 0xff, 0xba, 0xff, 0x51, 0x5b, 0xa4, 0x0d, 0x22, 0x89, 0x2d, + 0xb5, 0x91, 0x6d, 0x68, 0x2f, 0x26, 0x5e, 0x10, 0x31, 0x21, 0x6d, 0x28, 0xd9, 0x85, 0x26, 0xf6, +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 0xa9, 0x6f, 0xf7, 0xa5, 0xd4, 0xfb, 0xc3, 0x91, 0x25, 0xce, 0x82, 0x61, + 0x8d, 0x30, 0x47, 0x23, 0x8c, 0x3b, 0x8c, 0x6b, 0xd6, 0x90, 0xec, 0x8f, 0x98, 0x16, 0x1e, 0x68, + 0x0e, 0x33, 0x03, 0x9b, 0xf2, 0xe8, 0xfd, 0x79, 0xf1, 0x6a, 0x7f, 0xe2, 0x09, 0x12, 0x97, 0x1e, + 0xe5, 0xc3, 0x65, 0xf9, 0xac, 0xbc, 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0x55, 0xf8, 0x84, 0x77, + 0xa6, 0x04, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -425,6 +634,118 @@ func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Acknowledgement) 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 *Acknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AcknowledgementResults) > 0 { + for iNdEx := len(m.AcknowledgementResults) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AcknowledgementResults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AcknowledgementResult) 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 *AcknowledgementResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AcknowledgementResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RecvPacketResult.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AppName) > 0 { + i -= len(m.AppName) + copy(dAtA[i:], m.AppName) + i = encodeVarintChannel(dAtA, i, uint64(len(m.AppName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecvPacketResult) 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 *RecvPacketResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecvPacketResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Acknowledgement))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { offset -= sovChannel(v) base := offset @@ -505,6 +826,52 @@ func (m *Payload) Size() (n int) { return n } +func (m *Acknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AcknowledgementResults) > 0 { + for _, e := range m.AcknowledgementResults { + l = e.Size() + n += 1 + l + sovChannel(uint64(l)) + } + } + return n +} + +func (m *AcknowledgementResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AppName) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = m.RecvPacketResult.Size() + n += 1 + l + sovChannel(uint64(l)) + return n +} + +func (m *RecvPacketResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovChannel(uint64(m.Status)) + } + l = len(m.Acknowledgement) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -992,6 +1359,308 @@ func (m *Payload) Unmarshal(dAtA []byte) error { } return nil } +func (m *Acknowledgement) 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 ErrIntOverflowChannel + } + 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: Acknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Acknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcknowledgementResults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcknowledgementResults = append(m.AcknowledgementResults, AcknowledgementResult{}) + if err := m.AcknowledgementResults[len(m.AcknowledgementResults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AcknowledgementResult) 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 ErrIntOverflowChannel + } + 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: AcknowledgementResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AcknowledgementResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecvPacketResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RecvPacketResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RecvPacketResult) 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 ErrIntOverflowChannel + } + 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: RecvPacketResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecvPacketResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= PacketStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) + if m.Acknowledgement == nil { + m.Acknowledgement = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index 6b505433102..1053c8b64d6 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -13,5 +13,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgSendPacket{}, &MsgRecvPacket{}, &MsgTimeout{}, + &MsgAcknowledgement{}, ) } diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 4c60ac0135d..7dc604e3999 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -110,7 +110,7 @@ func (m *MsgSendPacketResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSendPacketResponse proto.InternalMessageInfo -// MsgRecvPacket receives incoming IBC packet +// MsgRecvPacket receives an incoming IBC packet. type MsgRecvPacket struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` ProofCommitment []byte `protobuf:"bytes,2,opt,name=proof_commitment,json=proofCommitment,proto3" json:"proof_commitment,omitempty"` @@ -269,6 +269,86 @@ func (m *MsgTimeoutResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgTimeoutResponse proto.InternalMessageInfo +// MsgAcknowledgement receives incoming IBC acknowledgement. +type MsgAcknowledgement struct { + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + Acknowledgement Acknowledgement `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement"` + ProofAcked []byte `protobuf:"bytes,3,opt,name=proof_acked,json=proofAcked,proto3" json:"proof_acked,omitempty"` + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" 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_d421c7119e969b99, []int{6} +} +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 + +// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. +type MsgAcknowledgementResponse struct { + Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +} + +func (m *MsgAcknowledgementResponse) Reset() { *m = MsgAcknowledgementResponse{} } +func (m *MsgAcknowledgementResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAcknowledgementResponse) ProtoMessage() {} +func (*MsgAcknowledgementResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{7} +} +func (m *MsgAcknowledgementResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAcknowledgementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAcknowledgementResponse.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 *MsgAcknowledgementResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAcknowledgementResponse.Merge(m, src) +} +func (m *MsgAcknowledgementResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAcknowledgementResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") @@ -276,52 +356,60 @@ func init() { proto.RegisterType((*MsgRecvPacketResponse)(nil), "ibc.core.channel.v2.MsgRecvPacketResponse") proto.RegisterType((*MsgTimeout)(nil), "ibc.core.channel.v2.MsgTimeout") proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v2.MsgTimeoutResponse") + proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.core.channel.v2.MsgAcknowledgement") + proto.RegisterType((*MsgAcknowledgementResponse)(nil), "ibc.core.channel.v2.MsgAcknowledgementResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 637 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x4f, 0xd4, 0x4e, - 0x18, 0xc7, 0xb7, 0xb0, 0xec, 0x0f, 0x66, 0xf9, 0x09, 0xd6, 0x7f, 0x9b, 0x62, 0xba, 0xb8, 0x17, - 0x10, 0xa5, 0x75, 0xab, 0x17, 0x88, 0x89, 0x09, 0x18, 0xa3, 0x07, 0x12, 0x53, 0xd0, 0x83, 0x12, - 0x9b, 0xee, 0xf4, 0xb1, 0xdb, 0xb8, 0xed, 0xd4, 0xce, 0xb4, 0x81, 0x9b, 0xf1, 0xe4, 0xc9, 0xf8, - 0x12, 0x4c, 0x7c, 0x03, 0xbc, 0x0c, 0xe2, 0x89, 0xa3, 0x27, 0x63, 0xd8, 0x03, 0x6f, 0xc3, 0x74, - 0x66, 0xda, 0x5d, 0x92, 0x02, 0x1e, 0x38, 0xb5, 0x7d, 0xbe, 0xdf, 0x79, 0xfe, 0x7c, 0x3a, 0x33, - 0xe8, 0x76, 0xd0, 0xc3, 0x26, 0x26, 0x09, 0x98, 0xb8, 0xef, 0x46, 0x11, 0x0c, 0xcc, 0xcc, 0x32, - 0xd9, 0x9e, 0x11, 0x27, 0x84, 0x11, 0xf5, 0x5a, 0xd0, 0xc3, 0x46, 0xae, 0x1a, 0x52, 0x35, 0x32, - 0x4b, 0xbb, 0xee, 0x13, 0x9f, 0x70, 0xdd, 0xcc, 0xdf, 0x84, 0x55, 0xbb, 0x85, 0x09, 0x0d, 0x09, - 0x35, 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, 0xa2, - 0x3e, 0x75, 0x3a, 0xb4, 0x95, 0x8b, 0x3d, 0x65, 0xcb, 0xbb, 0x08, 0x8d, 0x9d, 0x8d, 0x33, 0xb3, - 0x8f, 0x3c, 0x67, 0x67, 0xaf, 0xd8, 0x7e, 0xdb, 0xe8, 0xbf, 0x62, 0xcf, 0xb4, 0xcf, 0x5a, 0x26, - 0x0d, 0xda, 0xd2, 0x05, 0x86, 0x22, 0xa9, 0x36, 0xf5, 0xe9, 0xe4, 0x60, 0x45, 0xd9, 0x78, 0x7d, - 0x78, 0xac, 0x2b, 0x47, 0xc7, 0xba, 0xf2, 0xe7, 0x58, 0x57, 0xbe, 0x0d, 0xf5, 0xda, 0xd1, 0x50, - 0xaf, 0xfd, 0x1a, 0xea, 0xb5, 0x37, 0x8f, 0xfd, 0x80, 0xf5, 0xd3, 0x9e, 0x81, 0x49, 0x68, 0xca, - 0x1b, 0x38, 0xe8, 0xe1, 0x55, 0x9f, 0x98, 0xd9, 0x9a, 0x19, 0x12, 0x2f, 0x1d, 0x00, 0x15, 0x97, - 0xe7, 0x83, 0x47, 0xab, 0xe3, 0x57, 0xfc, 0x7e, 0x0c, 0xb4, 0xd7, 0xe0, 0x17, 0xe8, 0xc3, 0xbf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x7c, 0x4f, 0xf0, 0x06, 0x06, 0x00, 0x00, + // 724 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0x26, 0x0d, 0xed, 0xa4, 0x90, 0x62, 0xbe, 0x22, 0x17, 0x25, 0x25, 0x42, 0x6a, + 0x29, 0xd4, 0x26, 0x81, 0x4b, 0x2b, 0x24, 0xd4, 0x16, 0x21, 0x38, 0x54, 0x42, 0x6e, 0xe0, 0x00, + 0x15, 0x91, 0xb3, 0x5e, 0x1c, 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, 0x7b, 0x9a, 0xd1, 0xee, 0x09, 0x47, 0xc3, 0x16, + 0x5c, 0xe9, 0xfe, 0xcf, 0xa5, 0x51, 0xc3, 0x84, 0x40, 0x59, 0x38, 0x47, 0x10, 0x9b, 0xee, 0x40, + 0x7e, 0x78, 0xdb, 0x8e, 0x1c, 0x3b, 0x24, 0x54, 0xb4, 0x0b, 0x0a, 0xbb, 0xc5, 0x94, 0xc9, 0xaf, + 0x27, 0x07, 0x4b, 0xd2, 0xfa, 0xbb, 0xc3, 0xe3, 0xa2, 0x74, 0x74, 0x5c, 0x94, 0xfe, 0x1d, 0x17, + 0xa5, 0xfd, 0x4e, 0x31, 0x75, 0xd4, 0x29, 0xa6, 0xfe, 0x74, 0x8a, 0xa9, 0xf7, 0xcf, 0x2c, 0x3b, + 0x68, 0xb6, 0x1b, 0x2a, 0x22, 0x8e, 0x26, 0xae, 0x62, 0xbb, 0x81, 0x96, 0x2d, 0xa2, 0x85, 0x2b, + 0x9a, 0x43, 0xcc, 0x76, 0x0b, 0x53, 0x7e, 0x8b, 0x3e, 0x7e, 0xba, 0xdc, 0x7f, 0xd7, 0xef, 0x79, + 0x98, 0x36, 0xb2, 0xec, 0x26, 0x7d, 0xf2, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xad, 0x6c, 0xf0, 0x25, + 0x0f, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -340,8 +428,10 @@ type PacketMsgClient interface { SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. + // Timeout defines a rpc handler method for MsgTimeout. Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) } type packetMsgClient struct { @@ -379,14 +469,25 @@ func (c *packetMsgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...g return out, nil } +func (c *packetMsgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { + out := new(MsgAcknowledgementResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/Acknowledgement", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // PacketMsgServer is the server API for PacketMsg service. type PacketMsgServer interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. + // Timeout defines a rpc handler method for MsgTimeout. Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) } // UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. @@ -402,6 +503,9 @@ func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRec func (*UnimplementedPacketMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") } +func (*UnimplementedPacketMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") +} func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { s.RegisterService(&_PacketMsg_serviceDesc, srv) @@ -461,6 +565,24 @@ func _PacketMsg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _PacketMsg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAcknowledgement) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PacketMsgServer).Acknowledgement(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.PacketMsg/Acknowledgement", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PacketMsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) + } + return interceptor(ctx, in, info, handler) +} + var _PacketMsg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.PacketMsg", HandlerType: (*PacketMsgServer)(nil), @@ -477,6 +599,10 @@ var _PacketMsg_serviceDesc = grpc.ServiceDesc{ MethodName: "Timeout", Handler: _PacketMsg_Timeout_Handler, }, + { + MethodName: "Acknowledgement", + Handler: _PacketMsg_Acknowledgement_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/tx.proto", @@ -741,6 +867,101 @@ func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ProofAcked) > 0 { + i -= len(m.ProofAcked) + copy(dAtA[i:], m.ProofAcked) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Acknowledgement.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgAcknowledgementResponse) 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 *MsgAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -859,6 +1080,41 @@ func (m *MsgTimeoutResponse) Size() (n int) { return n } +func (m *MsgAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Acknowledgement.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofAcked) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAcknowledgementResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1622,6 +1878,290 @@ func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowTx + } + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Acknowledgement.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAcked == nil { + m.ProofAcked = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAcknowledgementResponse) 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 ErrIntOverflowTx + } + 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: MsgAcknowledgementResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= types1.ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto index d4946a21618..4bbe3df2342 100644 --- a/proto/ibc/core/channel/v2/channel.proto +++ b/proto/ibc/core/channel/v2/channel.proto @@ -42,3 +42,34 @@ message Payload { // the raw bytes for the payload. bytes value = 3; } + +// Acknowledgement contains a list of all ack results associated with a single packet. +message Acknowledgement { + repeated AcknowledgementResult acknowledgement_results = 1 [(gogoproto.nullable) = false]; +} + +// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. +message AcknowledgementResult { + string app_name = 1; + RecvPacketResult recv_packet_result = 2 [(gogoproto.nullable) = false]; +} + +// PacketStatus specifies the status of a RecvPacketResult. +enum PacketStatus { + // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. + PACKET_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; + // PACKET_STATUS_SUCCESS indicates a successful packet receipt. + PACKET_STATUS_SUCCESS = 1 [(gogoproto.enumvalue_customname) = "Success"]; + // PACKET_STATUS_FAILURE indicates a failed packet receipt. + PACKET_STATUS_FAILURE = 2 [(gogoproto.enumvalue_customname) = "Failure"]; + // PACKET_STATUS_ASYNC indicates an async packet receipt. + PACKET_STATUS_ASYNC = 3 [(gogoproto.enumvalue_customname) = "Async"]; +} + +// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. +message RecvPacketResult { + // status of the packet + PacketStatus status = 1; + // acknowledgement of the packet + bytes acknowledgement = 2; +} diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index b94e6e42de9..b25ebd50341 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -22,6 +22,9 @@ service PacketMsg { // Timeout defines a rpc handler method for MsgTimeout. rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); + + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); } // MsgSendPacket sends an outgoing IBC packet. @@ -80,3 +83,23 @@ message MsgTimeoutResponse { ibc.core.channel.v1.ResponseResultType result = 1; } + +// MsgAcknowledgement receives incoming IBC acknowledgement. +message MsgAcknowledgement { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + Acknowledgement acknowledgement = 2 [(gogoproto.nullable) = false]; + bytes proof_acked = 3; + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; + string signer = 5; +} + +// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. +message MsgAcknowledgementResponse { + option (gogoproto.goproto_getters) = false; + + ibc.core.channel.v1.ResponseResultType result = 1; +} From 1ee4ec0fa39ae34453fba855916b194cde118748 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 3 Oct 2024 14:03:17 +0100 Subject: [PATCH 044/172] chore: Add PacketV2 ValidateBasic() function (#7389) * chore: Add PacketV2 ValidateBasic() function * remove unused function * PR feedback * Added tests * linter * solve import cycle * create ValidateBasic for PacketData --- modules/core/04-channel/v2/types/errors.go | 11 ++ modules/core/04-channel/v2/types/packet.go | 82 ++++++++++ .../core/04-channel/v2/types/packet_test.go | 140 ++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 modules/core/04-channel/v2/types/errors.go create mode 100644 modules/core/04-channel/v2/types/packet_test.go diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go new file mode 100644 index 00000000000..bf32cfe0289 --- /dev/null +++ b/modules/core/04-channel/v2/types/errors.go @@ -0,0 +1,11 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +// IBC channel sentinel errors +var ( + ErrInvalidPacket = errorsmod.Register(SubModuleName, 1, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 2, "invalid payload") +) diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 145b8cf600c..85924dca020 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -2,10 +2,92 @@ package types import ( "crypto/sha256" + "strings" + + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) +// NewPacket constructs a new packet. +func NewPacket(sequence uint64, sourceID, destinationID string, timeoutTimestamp uint64, data ...PacketData) Packet { + return Packet{ + Sequence: sequence, + SourceId: sourceID, + DestinationId: destinationID, + TimeoutTimestamp: timeoutTimestamp, + Data: data, + } +} + +// NewPayload constructs a new Payload +func NewPayload(version, encoding string, value []byte) Payload { + return Payload{ + Version: version, + Encoding: encoding, + Value: value, + } +} + +// ValidateBasic validates that a Packet satisfies the basic requirements. +func (p Packet) ValidateBasic() error { + if len(p.Data) == 0 { + return errorsmod.Wrap(ErrInvalidPacket, "packet data must not be empty") + } + + for _, pd := range p.Data { + if err := pd.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "invalid Packet Data") + } + } + + if err := host.ChannelIdentifierValidator(p.SourceId); err != nil { + return errorsmod.Wrap(err, "invalid source channel ID") + } + if err := host.ChannelIdentifierValidator(p.DestinationId); err != nil { + return errorsmod.Wrap(err, "invalid destination channel ID") + } + + if p.Sequence == 0 { + return errorsmod.Wrap(ErrInvalidPacket, "packet sequence cannot be 0") + } + if p.TimeoutTimestamp == 0 { + return errorsmod.Wrap(ErrInvalidPacket, "packet timeout timestamp cannot be 0") + } + + return nil +} + +// ValidateBasic validates a PacketData +func (p PacketData) ValidateBasic() error { + if err := host.PortIdentifierValidator(p.SourcePort); err != nil { + return errorsmod.Wrap(err, "invalid source port ID") + } + if err := host.PortIdentifierValidator(p.DestinationPort); err != nil { + return errorsmod.Wrap(err, "invalid destination port ID") + } + if err := p.Payload.Validate(); err != nil { + return err + } + return nil +} + +// Validate validates a Payload. +func (p Payload) Validate() error { + if strings.TrimSpace(p.Version) == "" { + return errorsmod.Wrap(ErrInvalidPayload, "payload version cannot be empty") + } + if strings.TrimSpace(p.Encoding) == "" { + return errorsmod.Wrap(ErrInvalidPayload, "payload encoding cannot be empty") + } + if len(p.Value) == 0 { + return errorsmod.Wrap(ErrInvalidPayload, "payload value cannot be empty") + } + return nil +} + // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: // sha256_hash(timeout) + sha256_hash(destinationID) + sha256_hash(packetData) from a given packet. // This results in a fixed length preimage. diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go new file mode 100644 index 00000000000..691e3f8e408 --- /dev/null +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -0,0 +1,140 @@ +package types_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/ibc-go/v9/testing/mock" +) + +// TestValidate tests the Validate function of Packet +func TestValidate(t *testing.T) { + testCases := []struct { + name string + payload types.Payload + expErr error + }{ + { + "success", + types.NewPayload("ics20-v1", "json", mock.MockPacketData), + nil, + }, + { + "failure: empty version", + types.NewPayload("", "json", mock.MockPacketData), + types.ErrInvalidPayload, + }, + { + "failure: empty encoding", + types.NewPayload("ics20-v2", "", mock.MockPacketData), + types.ErrInvalidPayload, + }, + { + "failure: empty value", + types.NewPayload("ics20-v1", "json", []byte{}), + types.ErrInvalidPayload, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + err := tc.payload.Validate() + if tc.expErr == nil { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, tc.expErr) + } + }) + } +} + +// TestValidateBasic tests the ValidateBasic functio of Packet +func TestValidateBasic(t *testing.T) { + var packet types.Packet + testCases := []struct { + name string + malleate func() + expErr error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: empty data", + func() { + packet.Data = []types.PacketData{} + }, + types.ErrInvalidPacket, + }, + { + "failure: invalid data source port ID", + func() { + packet.Data[0].SourcePort = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid data dest port ID", + func() { + packet.Data[0].DestinationPort = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid source channel ID", + func() { + packet.SourceId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid dest channel ID", + func() { + packet.DestinationId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid sequence", + func() { + packet.Sequence = 0 + }, + types.ErrInvalidPacket, + }, + { + "failure: invalid timestamp", + func() { + packet.TimeoutTimestamp = 0 + }, + types.ErrInvalidPacket, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + packet = types.NewPacket(1, ibctesting.FirstClientID, ibctesting.FirstClientID, uint64(time.Now().Unix()), types.PacketData{ + SourcePort: ibctesting.MockPort, + DestinationPort: ibctesting.MockPort, + Payload: types.Payload{ + Version: "ics20-v2", + Encoding: "json", + Value: mock.MockPacketData, + }, + }) + + tc.malleate() + + err := packet.ValidateBasic() + if tc.expErr == nil { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, tc.expErr) + } + }) + } +} From a8fa564d1f0ad20c385abc4428c9ba7b30e10ca6 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 3 Oct 2024 16:36:43 +0300 Subject: [PATCH 045/172] refactor: Add CreateChannel rpc (#7382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: add protos + implementation + validation + tests for CreateChannel rpc. * Update proto/ibc/core/packetserver/v1/tx.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * chore: move signer as final arg --------- Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/core/keeper/msg_server.go | 15 + modules/core/keeper/msg_server_test.go | 2 +- modules/core/packet-server/types/codec.go | 1 + modules/core/packet-server/types/msgs.go | 28 +- modules/core/packet-server/types/msgs_test.go | 60 +- modules/core/packet-server/types/tx.pb.go | 516 +++++++++++++++++- proto/ibc/core/packetserver/v1/tx.proto | 26 + testing/endpoint.go | 2 +- 8 files changed, 623 insertions(+), 27 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 390c719b271..ef7720d3311 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -144,6 +144,21 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI return &clienttypes.MsgIBCSoftwareUpgradeResponse{}, nil } +// CreateChannel defines a rpc handler method for MsgCreateChannel +func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.MsgCreateChannel) (*packetservertypes.MsgCreateChannelResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + channelID := k.ChannelKeeper.GenerateChannelIdentifier(ctx) + + // Initialize counterparty with empty counterparty channel identifier. + counterparty := packetservertypes.NewCounterparty(msg.ClientId, "", msg.MerklePathPrefix) + k.PacketServerKeeper.SetCounterparty(ctx, channelID, counterparty) + + k.ClientKeeper.SetCreator(ctx, channelID, msg.Signer) + + return &packetservertypes.MsgCreateChannelResponse{ChannelId: channelID}, nil +} + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 1e54f08eecd..6a9b788990b 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1250,7 +1250,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = packetservertypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) + msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix, signer) tc.malleate() diff --git a/modules/core/packet-server/types/codec.go b/modules/core/packet-server/types/codec.go index e2eb9996bc7..1c0bd85c7c2 100644 --- a/modules/core/packet-server/types/codec.go +++ b/modules/core/packet-server/types/codec.go @@ -10,5 +10,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgProvideCounterparty{}, + &MsgCreateChannel{}, ) } diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go index 3ecdaa5326e..86849d43be7 100644 --- a/modules/core/packet-server/types/msgs.go +++ b/modules/core/packet-server/types/msgs.go @@ -16,7 +16,7 @@ var ( ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { +func NewMsgProvideCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgProvideCounterparty { counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) return &MsgProvideCounterparty{ @@ -42,3 +42,29 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { return nil } + +// NewMsgCreateChannel creates a new MsgCreateChannel instance +func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgCreateChannel { + return &MsgCreateChannel{ + Signer: signer, + ClientId: clientID, + MerklePathPrefix: merklePathPrefix, + } +} + +// ValidateBasic performs basic checks on a MsgCreateChannel. +func (msg *MsgCreateChannel) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + return err + } + + if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { + return err + } + + return nil +} diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index e3ad1c6b99b..f61f8a1a052 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -1,6 +1,8 @@ package types_test import ( + "errors" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" @@ -54,10 +56,10 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { for _, tc := range testCases { msg = types.NewMsgProvideCounterparty( - ibctesting.TestAccAddress, ibctesting.FirstClientID, ibctesting.SecondClientID, commitmenttypes.NewMerklePath([]byte("key")), + ibctesting.TestAccAddress, ) tc.malleate() @@ -71,3 +73,59 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { } } } + +// TestMsgCreateChannelValidateBasic tests ValidateBasic for MsgCreateChannel +func (s *TypesTestSuite) TestMsgCreateChannelValidateBasic() { + var msg *types.MsgCreateChannel + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: invalid signer address", + func() { + msg.Signer = "invalid" + }, + ibcerrors.ErrInvalidAddress, + }, + { + "failure: invalid client ID", + func() { + msg.ClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: empty key path of counterparty of merkle path prefix", + func() { + msg.MerklePathPrefix.KeyPath = nil + }, + errors.New("path cannot have length 0"), + }, + } + + for _, tc := range testCases { + msg = types.NewMsgCreateChannel( + ibctesting.FirstClientID, + commitmenttypes.NewMerklePath([]byte("key")), + ibctesting.TestAccAddress, + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err, "valid case %s failed", tc.name) + } else { + s.Require().ErrorContains(err, tc.expError.Error(), "invalid case %s passed", tc.name) + } + } +} diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index 46212f381ec..d25b93cb293 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -10,6 +10,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -111,37 +112,130 @@ func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo +// MsgCreateChannel defines the message used to create a v2 Channel. +type MsgCreateChannel struct { + // the client identifier of the light client representing the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } +func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannel) ProtoMessage() {} +func (*MsgCreateChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{2} +} +func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannel.Merge(m, src) +} +func (m *MsgCreateChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +type MsgCreateChannelResponse struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } +func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannelResponse) ProtoMessage() {} +func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{3} +} +func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannelResponse.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 *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) +} +func (m *MsgCreateChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.packetserver.v1.MsgProvideCounterparty") proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.packetserver.v1.MsgProvideCounterpartyResponse") + proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.packetserver.v1.MsgCreateChannel") + proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.packetserver.v1.MsgCreateChannelResponse") } func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } var fileDescriptor_3c556aec8b7966db = []byte{ - // 351 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0x29, 0x4e, 0x2d, 0x2a, 0x4b, - 0x2d, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xc8, - 0x4c, 0x4a, 0xd6, 0x03, 0x29, 0xd1, 0x43, 0x56, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, - 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x4b, 0x69, 0xe3, 0x34, 0x32, 0x39, 0xbf, 0x34, - 0xaf, 0x24, 0xb5, 0xa8, 0x20, 0xb1, 0xa8, 0xa4, 0x12, 0xaa, 0x58, 0x3c, 0x39, 0xbf, 0x38, 0x37, - 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x22, 0xb7, 0x38, 0x1d, 0x22, 0xa1, 0xb4, 0x89, 0x91, - 0x4b, 0xcc, 0xb7, 0x38, 0x3d, 0xa0, 0x28, 0xbf, 0x2c, 0x33, 0x25, 0xd5, 0x19, 0x49, 0xa7, 0x90, - 0x2c, 0x17, 0x57, 0x72, 0x46, 0x62, 0x5e, 0x5e, 0x6a, 0x4e, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, - 0xa3, 0x06, 0x67, 0x10, 0x27, 0x54, 0xc4, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x22, 0x09, - 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0xde, 0xd0, 0x43, 0x36, 0xdc, 0x89, 0xe5, - 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, - 0x8b, 0x24, 0x98, 0xc1, 0x96, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, - 0xd0, 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x73, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, - 0x71, 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, - 0x7e, 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, - 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, - 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, - 0x21, 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4f, - 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, - 0xc5, 0xc8, 0x31, 0xad, 0x0b, 0x8d, 0xea, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x44, - 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, 0x6d, 0x15, 0x38, 0x63, 0x02, 0x00, 0x00, + // 478 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0xb5, 0xa5, 0x22, 0x07, 0x88, 0xca, 0xa0, 0x62, 0x19, 0xe1, 0x86, 0x0c, 0x50, 0x05, + 0xd5, 0x47, 0xcd, 0x02, 0x15, 0x12, 0x52, 0x33, 0x75, 0x88, 0x14, 0x65, 0xe8, 0xc0, 0x12, 0xd9, + 0xe7, 0xc7, 0xe5, 0xd4, 0x9c, 0xcf, 0xba, 0xbb, 0x58, 0xed, 0x46, 0x99, 0x18, 0xf9, 0x09, 0xfc, + 0x84, 0x88, 0x5f, 0xd1, 0xb1, 0x23, 0x13, 0x42, 0xc9, 0xd0, 0xbf, 0x81, 0xec, 0x5c, 0x53, 0xb7, + 0x4a, 0xa0, 0x6c, 0x7e, 0xcf, 0xdf, 0xfb, 0xde, 0xf7, 0xe9, 0xdd, 0x87, 0x9f, 0xf3, 0x98, 0x12, + 0x2a, 0x15, 0x90, 0x2c, 0xa2, 0x47, 0x60, 0x34, 0xa8, 0x1c, 0x14, 0xc9, 0x77, 0x89, 0x39, 0x0e, + 0x32, 0x25, 0x8d, 0x74, 0x5c, 0x1e, 0xd3, 0xa0, 0x80, 0x04, 0x55, 0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 0x3a, 0x1a, 0x42, 0x3f, 0x8b, 0xcc, 0xa0, 0x9f, 0x29, 0xf8, 0xc4, 0x8f, 0xad, 0xa9, 0xe6, + 0x95, 0xa9, 0xca, 0x19, 0xf2, 0x30, 0xe8, 0x94, 0x13, 0xdd, 0xc8, 0x0c, 0xac, 0xa1, 0x0d, 0x31, + 0xef, 0x74, 0x4b, 0x86, 0xdb, 0x9b, 0xfa, 0x80, 0xdd, 0x9b, 0x8a, 0x2f, 0xed, 0xfc, 0xe3, 0x14, + 0x7b, 0x6b, 0x05, 0x57, 0x78, 0xba, 0x82, 0x57, 0x3b, 0x9a, 0x39, 0x12, 0x3f, 0xb8, 0xee, 0xbb, + 0xb5, 0xfc, 0x26, 0x37, 0x37, 0x7a, 0xe1, 0xed, 0xb1, 0x73, 0x75, 0xa7, 0x08, 0x3f, 0x5a, 0xf4, + 0x80, 0x5e, 0xff, 0x95, 0x6b, 0xc1, 0x84, 0xf7, 0xf6, 0x7f, 0x27, 0x2e, 0x35, 0x78, 0x77, 0x3e, + 0x5f, 0x8c, 0x5b, 0x68, 0xff, 0xf0, 0x6c, 0xe2, 0xa3, 0xf3, 0x89, 0x8f, 0x7e, 0x4f, 0x7c, 0xf4, + 0x6d, 0xea, 0xd7, 0xce, 0xa7, 0x7e, 0xed, 0xe7, 0xd4, 0xaf, 0x7d, 0x7c, 0xcf, 0xb8, 0x19, 0x8c, + 0xe2, 0xe2, 0x80, 0xc4, 0x86, 0x81, 0xc7, 0x74, 0x87, 0x49, 0x92, 0xbf, 0x23, 0x42, 0x26, 0xa3, + 0x21, 0xe8, 0x6a, 0x9c, 0x76, 0x6c, 0x9e, 0xcc, 0x49, 0x06, 0x3a, 0x5e, 0x2f, 0xd3, 0xf2, 0xe6, + 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x9c, 0x69, 0x26, 0xf1, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -156,6 +250,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // CreateChannel defines a rpc handler method for MsgCreateChannel + CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) } @@ -168,6 +264,15 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) { + out := new(MsgCreateChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/CreateChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { out := new(MsgProvideCounterpartyResponse) err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", in, out, opts...) @@ -179,6 +284,8 @@ func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCount // MsgServer is the server API for Msg service. type MsgServer interface { + // CreateChannel defines a rpc handler method for MsgCreateChannel + CreateChannel(context.Context, *MsgCreateChannel) (*MsgCreateChannelResponse, error) // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) } @@ -187,6 +294,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) CreateChannel(ctx context.Context, req *MsgCreateChannel) (*MsgCreateChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") +} func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") } @@ -195,6 +305,24 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.packetserver.v1.Msg/CreateChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateChannel(ctx, req.(*MsgCreateChannel)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgProvideCounterparty) if err := dec(in); err != nil { @@ -217,6 +345,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.packetserver.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "CreateChannel", + Handler: _Msg_CreateChannel_Handler, + }, { MethodName: "ProvideCounterparty", Handler: _Msg_ProvideCounterparty_Handler, @@ -296,6 +428,83 @@ func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgCreateChannel) 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 *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateChannel) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateChannelResponse) 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 *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateChannelResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -335,6 +544,38 @@ func (m *MsgProvideCounterpartyResponse) Size() (n int) { return n } +func (m *MsgCreateChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -538,6 +779,235 @@ func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateChannel) 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 ErrIntOverflowTx + } + 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: MsgCreateChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateChannel: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateChannelResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto index 2a0b835a179..9e831d45944 100644 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -6,6 +6,7 @@ package ibc.core.packetserver.v1; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; import "gogoproto/gogo.proto"; +import "ibc/core/commitment/v2/commitment.proto"; import "ibc/core/packetserver/v1/counterparty.proto"; import "cosmos/msg/v1/msg.proto"; @@ -13,6 +14,9 @@ import "cosmos/msg/v1/msg.proto"; service Msg { option (cosmos.msg.v1.service) = true; + // CreateChannel defines a rpc handler method for MsgCreateChannel + rpc CreateChannel(MsgCreateChannel) returns (MsgCreateChannelResponse); + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); } @@ -35,3 +39,25 @@ message MsgProvideCounterparty { // MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. message MsgProvideCounterpartyResponse {} + +// MsgCreateChannel defines the message used to create a v2 Channel. +message MsgCreateChannel { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // the client identifier of the light client representing the counterparty chain + string client_id = 1; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +message MsgCreateChannelResponse { + option (gogoproto.goproto_getters) = false; + + string channel_id = 1; +} diff --git a/testing/endpoint.go b/testing/endpoint.go index 736ddecacdc..f3ef692bea6 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -180,7 +180,7 @@ func (endpoint *Endpoint) FreezeClient() { func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - msg := packetservertypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) From ef8b0abc7c9904f48ab028f15960ffce48f8de7d Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 3 Oct 2024 15:23:36 +0100 Subject: [PATCH 046/172] chore: adding implementation for SendPacket message server (#7383) * chore: adding implementation for SendPacket message server * chore: adding issue links * chore: add additional issue link * chore: using sourceID * chore: adding commented aliasing code * chore: adding tests for aliasing and required functions * chore: moved IBCModule interface into api directort --- modules/core/04-channel/types/timeout.go | 13 +++ modules/core/04-channel/v2/keeper/events.go | 12 ++ modules/core/04-channel/v2/keeper/keeper.go | 43 ++++++- .../core/04-channel/v2/keeper/keeper_test.go | 109 ++++++++++++++++++ .../core/04-channel/v2/keeper/msg_server.go | 56 +++++++++ modules/core/04-channel/v2/keeper/relay.go | 89 ++++++++++++++ .../core/04-channel/v2/types/counterparty.go | 34 ++++++ modules/core/04-channel/v2/types/errors.go | 7 +- .../04-channel/v2/types/expected_keepers.go | 25 ++++ modules/core/api/module.go | 29 +++++ modules/core/keeper/keeper.go | 4 + 11 files changed, 415 insertions(+), 6 deletions(-) create mode 100644 modules/core/04-channel/v2/keeper/events.go create mode 100644 modules/core/04-channel/v2/keeper/keeper_test.go create mode 100644 modules/core/04-channel/v2/keeper/msg_server.go create mode 100644 modules/core/04-channel/v2/keeper/relay.go create mode 100644 modules/core/04-channel/v2/types/counterparty.go create mode 100644 modules/core/04-channel/v2/types/expected_keepers.go create mode 100644 modules/core/api/module.go diff --git a/modules/core/04-channel/types/timeout.go b/modules/core/04-channel/types/timeout.go index 47265d5b3a9..ca1e70ca8e6 100644 --- a/modules/core/04-channel/types/timeout.go +++ b/modules/core/04-channel/types/timeout.go @@ -14,6 +14,14 @@ func NewTimeout(height clienttypes.Height, timestamp uint64) Timeout { } } +// NewTimeoutWithTimestamp creates a new Timeout with only the timestamp set. +func NewTimeoutWithTimestamp(timestamp uint64) Timeout { + return Timeout{ + Height: clienttypes.ZeroHeight(), + Timestamp: timestamp, + } +} + // IsValid returns true if either the height or timestamp is non-zero. func (t Timeout) IsValid() bool { return !t.Height.IsZero() || t.Timestamp != 0 @@ -25,6 +33,11 @@ func (t Timeout) Elapsed(height clienttypes.Height, timestamp uint64) bool { return t.heightElapsed(height) || t.timestampElapsed(timestamp) } +// TimestampElapsed returns true if the provided timestamp is past the timeout timestamp. +func (t Timeout) TimestampElapsed(timestamp uint64) bool { + return t.timestampElapsed(timestamp) +} + // ErrTimeoutElapsed returns a timeout elapsed error indicating which timeout value // has elapsed. func (t Timeout) ErrTimeoutElapsed(height clienttypes.Height, timestamp uint64) error { diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go new file mode 100644 index 00000000000..ddaf8876080 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/events.go @@ -0,0 +1,12 @@ +package keeper + +import ( + "context" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +// EmitSendPacketEvents emits events for the SendPacket handler. +func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { + // TODO: https://github.com/cosmos/ibc-go/issues/7386 +} diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index ac50715c836..d367855475a 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -13,7 +13,11 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" + connectionkeeper "github.com/cosmos/ibc-go/v9/modules/core/03-connection/keeper" + channelkeeperv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -23,13 +27,20 @@ import ( type Keeper struct { cdc codec.BinaryCodec storeService corestore.KVStoreService + ClientKeeper types.ClientKeeper + // channelKeeperV1 is used for channel aliasing only. + channelKeeperV1 *channelkeeperv1.Keeper + connectionKeeper *connectionkeeper.Keeper } // NewKeeper creates a new channel v2 keeper -func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService, clientKeeper types.ClientKeeper, channelKeeperV1 *channelkeeperv1.Keeper, connectionKeeper *connectionkeeper.Keeper) *Keeper { return &Keeper{ - cdc: cdc, - storeService: storeService, + cdc: cdc, + storeService: storeService, + channelKeeperV1: channelKeeperV1, + connectionKeeper: connectionKeeper, + ClientKeeper: clientKeeper, } } @@ -162,3 +173,29 @@ func (k *Keeper) SetNextSequenceSend(ctx context.Context, sourceID string, seque panic(err) } } + +// AliasV1Channel returns a version 2 channel for the given port and channel ID +// by converting the channel into a version 2 channel. +func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Counterparty, bool) { + channel, ok := k.channelKeeperV1.GetChannel(ctx, portID, channelID) + if !ok { + return types.Counterparty{}, false + } + // Do not allow channel to be converted into a version 2 counterparty + // if the channel is not OPEN or if it is ORDERED + if channel.State != channeltypesv1.OPEN || channel.Ordering == channeltypesv1.ORDERED { + return types.Counterparty{}, false + } + connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) + if !ok { + return types.Counterparty{}, false + } + merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) + + counterparty := types.Counterparty{ + CounterpartyChannelId: channel.Counterparty.ChannelId, + ClientId: connection.ClientId, + MerklePathPrefix: merklePathPrefix, + } + return counterparty, true +} diff --git a/modules/core/04-channel/v2/keeper/keeper_test.go b/modules/core/04-channel/v2/keeper/keeper_test.go new file mode 100644 index 00000000000..07269aeb645 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/keeper_test.go @@ -0,0 +1,109 @@ +package keeper_test + +import ( + "testing" + + testifysuite "github.com/stretchr/testify/suite" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypes2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func TestKeeperTestSuite(t *testing.T) { + testifysuite.Run(t, new(KeeperTestSuite)) +} + +type KeeperTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + chainC *ibctesting.TestChain +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) +} + +func (suite *KeeperTestSuite) TestAliasV1Channel() { + var path *ibctesting.Path + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "failure: channel not found", + func() { + path.EndpointA.ChannelID = "" + }, + false, + }, + { + "failure: channel not OPEN", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.TRYOPEN }) + }, + false, + }, + { + "failure: channel is ORDERED", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) + }, + false, + }, + { + "failure: connection not found", + func() { + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{ibctesting.InvalidID} }) + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + // create a previously existing path on chainA to change the identifiers + // between the path between chainA and chainB + path1 := ibctesting.NewPath(suite.chainA, suite.chainC) + path1.Setup() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + tc.malleate() + + counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2.AliasV1Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + + if tc.expPass { + suite.Require().True(found) + + merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) + expCounterparty := channeltypes2.NewCounterparty(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + suite.Require().Equal(counterparty, expCounterparty) + } else { + suite.Require().False(found) + suite.Require().Equal(counterparty, channeltypes2.Counterparty{}) + } + }) + } +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go new file mode 100644 index 00000000000..90dca4d6b14 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +var _ channeltypesv2.PacketMsgServer = &Keeper{} + +// SendPacket implements the PacketMsgServer SendPacket method. +func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + sequence, err := k.sendPacket(ctx, msg.SourceId, msg.TimeoutTimestamp, msg.PacketData) + if err != nil { + sdkCtx.Logger().Error("send packet failed", "source-id", msg.SourceId, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceId) + } + + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + sdkCtx.Logger().Error("send packet failed", "error", errorsmod.Wrap(err, "invalid address for msg Signer")) + return nil, errorsmod.Wrap(err, "invalid address for msg Signer") + } + + _ = signer + + // TODO: implement once app router is wired up. + // https://github.com/cosmos/ibc-go/issues/7384 + // for _, pd := range msg.PacketData { + // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) + // err := cbs.OnSendPacket(ctx, msg.SourceId, sequence, msg.TimeoutTimestamp, pd, signer) + // if err != nil { + // return nil, err + // } + // } + + return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil +} + +func (k Keeper) Acknowledgement(ctx context.Context, acknowledgement *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { + panic("implement me") +} + +// RecvPacket implements the PacketMsgServer RecvPacket method. +func (k *Keeper) RecvPacket(ctx context.Context, packet *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { + panic("implement me") +} + +// Timeout implements the PacketMsgServer Timeout method. +func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { + panic("implement me") +} diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go new file mode 100644 index 00000000000..ce7af228895 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -0,0 +1,89 @@ +package keeper + +import ( + "context" + "strconv" + + errorsmod "cosmossdk.io/errors" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// sendPacket constructs a packet from the input arguments, writes a packet commitment to state +// in order for the packet to be sent to the counterparty. +func (k *Keeper) sendPacket( + ctx context.Context, + sourceID string, + timeoutTimestamp uint64, + data []channeltypesv2.PacketData, +) (uint64, error) { + // Lookup counterparty associated with our source channel to retrieve the destination channel + counterparty, ok := k.GetCounterparty(ctx, sourceID) + if !ok { + // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // for future use. + // TODO: figure out how aliasing will work when more than one packet data is sent. + if counterparty, ok = k.AliasV1Channel(ctx, data[0].SourcePort, sourceID); ok { + // we can key on just the source channel here since channel ids are globally unique + k.SetCounterparty(ctx, sourceID, counterparty) + } else { + // if neither a counterparty nor channel is found then simply return an error + return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceID) + } + } + + destID := counterparty.CounterpartyChannelId + clientId := counterparty.ClientId + + // retrieve the sequence send for this channel + // if no packets have been sent yet, initialize the sequence to 1. + sequence, found := k.GetNextSequenceSend(ctx, sourceID) + if !found { + sequence = 1 + } + + // construct packet from given fields and channel state + packet := channeltypesv2.NewPacket(sequence, sourceID, destID, timeoutTimestamp, data...) + + if err := packet.ValidateBasic(); err != nil { + return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) + } + + // check that the client of counterparty chain is still active + if status := k.ClientKeeper.GetClientStatus(ctx, clientId); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientId, status) + } + + // retrieve latest height and timestamp of the client of counterparty chain + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientId) + if latestHeight.IsZero() { + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientId) + } + + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientId, latestHeight) + if err != nil { + return 0, err + } + // check if packet is timed out on the receiving chain + timeout := channeltypes.NewTimeoutWithTimestamp(timeoutTimestamp) + if timeout.TimestampElapsed(latestTimestamp) { + return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + } + + commitment := channeltypesv2.CommitPacket(packet) + + // bump the sequence and set the packet commitment, so it is provable by the counterparty + k.SetNextSequenceSend(ctx, sourceID, sequence+1) + k.SetPacketCommitment(ctx, sourceID, packet.GetSequence(), commitment) + + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_id", packet.DestinationId, "src_id", packet.SourceId) + + EmitSendPacketEvents(ctx, packet) + + return sequence, nil +} diff --git a/modules/core/04-channel/v2/types/counterparty.go b/modules/core/04-channel/v2/types/counterparty.go new file mode 100644 index 00000000000..d63a92da3e8 --- /dev/null +++ b/modules/core/04-channel/v2/types/counterparty.go @@ -0,0 +1,34 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" +) + +// NewCounterparty creates a new Counterparty instance +func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { + return Counterparty{ + ClientId: clientID, + CounterpartyChannelId: counterpartyChannelID, + MerklePathPrefix: merklePathPrefix, + } +} + +// Validate validates the Counterparty +func (c Counterparty) Validate() error { + if err := host.ClientIdentifierValidator(c.ClientId); err != nil { + return err + } + + if err := host.ChannelIdentifierValidator(c.CounterpartyChannelId); err != nil { + return err + } + + if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { + return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) + } + + return nil +} diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index bf32cfe0289..25acab9190d 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -4,8 +4,9 @@ import ( errorsmod "cosmossdk.io/errors" ) -// IBC channel sentinel errors var ( - ErrInvalidPacket = errorsmod.Register(SubModuleName, 1, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 2, "invalid payload") + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") + ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") ) diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go new file mode 100644 index 00000000000..31833373ed9 --- /dev/null +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -0,0 +1,25 @@ +package types + +import ( + "context" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +type ClientKeeper interface { + // VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height. + VerifyMembership(ctx context.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error + // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. + VerifyNonMembership(ctx context.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error + // GetClientStatus returns the status of a client given the client ID + GetClientStatus(ctx context.Context, clientID string) exported.Status + // GetClientLatestHeight returns the latest height of a client given the client ID + GetClientLatestHeight(ctx context.Context, clientID string) clienttypes.Height + // GetClientTimestampAtHeight returns the timestamp for a given height on the client + // given its client ID and height + GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) + + // GetCreator returns the creator of the client denoted by the clientID. + GetCreator(ctx context.Context, clientID string) (string, bool) +} diff --git a/modules/core/api/module.go b/modules/core/api/module.go new file mode 100644 index 00000000000..f54f12d86a1 --- /dev/null +++ b/modules/core/api/module.go @@ -0,0 +1,29 @@ +package api + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +// IBCModule defines an interface that implements all the callbacks +// that modules must define as specified in IBC Protocol V2. +type IBCModule interface { + // OnSendPacket is executed when a packet is being sent from sending chain. + // this callback is provided with the source and destination IDs, the signer, the packet sequence and the packet data + // for this specific application. + OnSendPacket( + ctx context.Context, + sourceID string, + destinationID string, + sequence uint64, + data channeltypesv2.PacketData, + signer sdk.AccAddress, + ) error + + // OnRecvPacket + + // OnAcknowledgementPacket + + // OnTimeoutPacket +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 665a43ee096..c58fcffbd70 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -13,6 +13,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectionkeeper "github.com/cosmos/ibc-go/v9/modules/core/03-connection/keeper" channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" + channelkeeperv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" portkeeper "github.com/cosmos/ibc-go/v9/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" @@ -24,6 +25,7 @@ type Keeper struct { ClientKeeper *clientkeeper.Keeper ConnectionKeeper *connectionkeeper.Keeper ChannelKeeper *channelkeeper.Keeper + ChannelKeeperV2 *channelkeeperv2.Keeper PacketServerKeeper *packetserver.Keeper PortKeeper *portkeeper.Keeper @@ -51,12 +53,14 @@ func NewKeeper( portKeeper := portkeeper.NewKeeper() channelKeeper := channelkeeper.NewKeeper(cdc, storeService, clientKeeper, connectionKeeper) packetKeeper := packetserver.NewKeeper(cdc, storeService, channelKeeper, clientKeeper) + channelKeeperV2 := channelkeeperv2.NewKeeper(cdc, storeService, clientKeeper, channelKeeper, connectionKeeper) return &Keeper{ cdc: cdc, ClientKeeper: clientKeeper, ConnectionKeeper: connectionKeeper, ChannelKeeper: channelKeeper, + ChannelKeeperV2: channelKeeperV2, PacketServerKeeper: packetKeeper, PortKeeper: portKeeper, authority: authority, From 6e61910d0f83f71e115115b8b001bd894f87e556 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 7 Oct 2024 12:12:28 +0100 Subject: [PATCH 047/172] Adding router v2 (#7392) * chore: adding router v2 * chore: addressing PR feedback * chore: address PR feedback and fix linter --- .../core/04-channel/v2/keeper/msg_server.go | 7 +- modules/core/04-channel/v2/keeper/relay.go | 12 +-- modules/core/api/api_test.go | 15 ++++ modules/core/api/module.go | 2 + modules/core/api/router.go | 69 ++++++++++++++++ modules/core/api/router_test.go | 81 +++++++++++++++++++ modules/core/keeper/msg_server.go | 20 +++-- testing/mock/v2/ibc_module.go | 18 +++++ 8 files changed, 204 insertions(+), 20 deletions(-) create mode 100644 modules/core/api/api_test.go create mode 100644 modules/core/api/router.go create mode 100644 modules/core/api/router_test.go create mode 100644 testing/mock/v2/ibc_module.go diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 90dca4d6b14..e418f9fa394 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -41,16 +42,16 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil } -func (k Keeper) Acknowledgement(ctx context.Context, acknowledgement *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { +func (*Keeper) Acknowledgement(ctx context.Context, acknowledgement *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { panic("implement me") } // RecvPacket implements the PacketMsgServer RecvPacket method. -func (k *Keeper) RecvPacket(ctx context.Context, packet *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { +func (*Keeper) RecvPacket(ctx context.Context, packet *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { panic("implement me") } // Timeout implements the PacketMsgServer Timeout method. -func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { +func (*Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { panic("implement me") } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index ce7af228895..f30d72cec73 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -38,7 +38,7 @@ func (k *Keeper) sendPacket( } destID := counterparty.CounterpartyChannelId - clientId := counterparty.ClientId + clientID := counterparty.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -55,17 +55,17 @@ func (k *Keeper) sendPacket( } // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, clientId); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientId, status) + if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientId) + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientId) + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) } - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientId, latestHeight) + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) if err != nil { return 0, err } diff --git a/modules/core/api/api_test.go b/modules/core/api/api_test.go new file mode 100644 index 00000000000..799bc785209 --- /dev/null +++ b/modules/core/api/api_test.go @@ -0,0 +1,15 @@ +package api_test + +import ( + "testing" + + testifysuite "github.com/stretchr/testify/suite" +) + +type APITestSuite struct { + testifysuite.Suite +} + +func TestApiTestSuite(t *testing.T) { + testifysuite.Run(t, new(APITestSuite)) +} diff --git a/modules/core/api/module.go b/modules/core/api/module.go index f54f12d86a1..d90878d678f 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -2,7 +2,9 @@ package api import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) diff --git a/modules/core/api/router.go b/modules/core/api/router.go new file mode 100644 index 00000000000..893dece45a9 --- /dev/null +++ b/modules/core/api/router.go @@ -0,0 +1,69 @@ +package api + +import ( + "errors" + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Router contains all the module-defined callbacks required by IBC Protocol V2. +type Router struct { + routes map[string]IBCModule +} + +// NewRouter creates a new Router instance. +func NewRouter() *Router { + return &Router{ + routes: make(map[string]IBCModule), + } +} + +// AddRoute registers a route for a given module name. +func (rtr *Router) AddRoute(module string, cbs IBCModule) *Router { + if !sdk.IsAlphaNumeric(module) { + panic(errors.New("route expressions can only contain alphanumeric characters")) + } + + if rtr.HasRoute(module) { + panic(fmt.Errorf("route %s has already been registered", module)) + } + + rtr.routes[module] = cbs + + return rtr +} + +// Route returns the IBCModule for a given module name. +func (rtr *Router) Route(module string) IBCModule { + route, ok := rtr.routeOrPrefixedRoute(module) + if !ok { + panic(fmt.Sprintf("no route for %s", module)) + } + return route +} + +// HasRoute returns true if the Router has a module registered or false otherwise. +func (rtr *Router) HasRoute(module string) bool { + _, ok := rtr.routeOrPrefixedRoute(module) + return ok +} + +// routeOrPrefixedRoute returns the IBCModule for a given module name. +// if an exact match is not found, a route with the provided prefix is searched for instead. +func (rtr *Router) routeOrPrefixedRoute(module string) (IBCModule, bool) { + route, ok := rtr.routes[module] + if ok { + return route, true + } + + // it's possible that some routes have been dynamically added e.g. with interchain accounts. + // in this case, we need to check if the module has the specified prefix. + for prefix, ibcModule := range rtr.routes { + if strings.HasPrefix(module, prefix) { + return ibcModule, true + } + } + return nil, false +} diff --git a/modules/core/api/router_test.go b/modules/core/api/router_test.go new file mode 100644 index 00000000000..bdcaa3e9c5a --- /dev/null +++ b/modules/core/api/router_test.go @@ -0,0 +1,81 @@ +package api_test + +import ( + "github.com/cosmos/ibc-go/v9/modules/core/api" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" +) + +func (suite *APITestSuite) TestRouter() { + var router *api.Router + + testCases := []struct { + name string + malleate func() + assertionFn func() + }{ + { + name: "success", + malleate: func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + }, + assertionFn: func() { + suite.Require().True(router.HasRoute("module01")) + }, + }, + { + name: "success: multiple modules", + malleate: func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + router.AddRoute("module02", &mockv2.IBCModule{}) + router.AddRoute("module03", &mockv2.IBCModule{}) + }, + assertionFn: func() { + suite.Require().True(router.HasRoute("module01")) + suite.Require().True(router.HasRoute("module02")) + suite.Require().True(router.HasRoute("module03")) + }, + }, + { + name: "success: find by prefix", + malleate: func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + }, + assertionFn: func() { + suite.Require().True(router.HasRoute("module01-foo")) + }, + }, + { + name: "failure: panics on duplicate module", + malleate: func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + }, + assertionFn: func() { + suite.Require().PanicsWithError("route module01 has already been registered", func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + }) + }, + }, + { + name: "failure: panics invalid-name", + malleate: func() { + router.AddRoute("module01", &mockv2.IBCModule{}) + }, + assertionFn: func() { + suite.Require().PanicsWithError("route expressions can only contain alphanumeric characters", func() { + router.AddRoute("module-02", &mockv2.IBCModule{}) + }) + }, + }, + } + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + router = api.NewRouter() + + tc.malleate() + + tc.assertionFn() + }) + } +} diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index ef7720d3311..216d8947438 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -9,7 +9,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" @@ -446,7 +445,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, _, _, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) + packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) if err != nil { ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.DestinationPort, "channel-id", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -518,7 +517,7 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, _, _, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.SourcePort, msg.Packet.SourceChannel) + packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) if err != nil { ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -627,7 +626,7 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, _, _, err = k.getPacketHandlerAndModule(ctx, msg.Packet.ProtocolVersion, msg.Packet.SourcePort, msg.Packet.SourceChannel) + packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) if err != nil { ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -1065,17 +1064,16 @@ func convertToErrorEvents(events sdk.Events) sdk.Events { return newEvents } -// getPacketHandlerAndModule returns the appropriate packet handler, module name, and capability -// given the provided port and channel identifiers. The packet handler is determined by the -// provided protocol version. An error is returned if the module cannot be found or if the protocol +// getPacketHandlerAndModule returns the appropriate packet handler +// given the protocol version. An error is returned if the protocol // version is not supported. -func (k *Keeper) getPacketHandlerAndModule(ctx sdk.Context, protocolVersion channeltypes.IBCVersion, port, channel string) (PacketHandler, string, *capabilitytypes.Capability, error) { +func (k *Keeper) getPacketHandlerAndModule(protocolVersion channeltypes.IBCVersion) (PacketHandler, error) { switch protocolVersion { case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: - return k.ChannelKeeper, "", nil, nil + return k.ChannelKeeper, nil case channeltypes.IBC_VERSION_2: - return k.PacketServerKeeper, port, nil, nil + return k.PacketServerKeeper, nil default: - return nil, "", nil, fmt.Errorf("unsupported protocol %s", protocolVersion) + return nil, fmt.Errorf("unsupported protocol %s", protocolVersion) } } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go new file mode 100644 index 00000000000..bdf921dd904 --- /dev/null +++ b/testing/mock/v2/ibc_module.go @@ -0,0 +1,18 @@ +package mock + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/api" +) + +var _ api.IBCModule = (*IBCModule)(nil) + +type IBCModule struct{} + +func (IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { + panic("implement me") +} From 8271fcebdb280b7f8ffae6744a121b9cfa7e53f5 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 7 Oct 2024 12:35:08 +0100 Subject: [PATCH 048/172] Add mock ibc module v2 (#7398) * chore: adding router v2 * chore: addressing PR feedback * chore: address PR feedback and fix linter * chore: adding mock v2 module --- testing/mock/v2/ibc_app.go | 13 +++++++++++ testing/mock/v2/ibc_module.go | 41 ++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 testing/mock/v2/ibc_app.go diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go new file mode 100644 index 00000000000..2e3598b5d96 --- /dev/null +++ b/testing/mock/v2/ibc_app.go @@ -0,0 +1,13 @@ +package mock + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +type IBCApp struct { + OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error +} diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index bdf921dd904..b2589e7cb65 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -11,8 +11,43 @@ import ( var _ api.IBCModule = (*IBCModule)(nil) -type IBCModule struct{} +// IBCModule is a mock implementation of the IBCModule interface. +// which delegates calls to the underlying IBCApp. +type IBCModule struct { + IBCApp *IBCApp +} + +// NewIBCModule creates a new IBCModule with an underlying mock IBC application. +func NewIBCModule() IBCModule { + return IBCModule{ + IBCApp: &IBCApp{}, + } +} -func (IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { - panic("implement me") +func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { + if im.IBCApp.OnSendPacket != nil { + return im.IBCApp.OnSendPacket(ctx, sourceID, destinationID, sequence, data, signer) + } + return nil } + +// func (im IBCModule) OnRecvPacket() error { +// if im.IBCApp.OnRecvPacket != nil { +// return im.IBCApp.OnRecvPacket(...) +// } +// return nil +// } +// +// func (im IBCModule) OnAcknowledgementPacket() error { +// if im.IBCApp.OnAcknowledgementPacket != nil { +// return im.IBCApp.OnAcknowledgementPacket(...) +// } +// return nil +// } +// +// func (im IBCModule) OnTimeoutPacket() error { +// if im.IBCApp.OnTimeoutPacket != nil { +// return im.IBCApp.OnTimeoutPacket(...) +// } +// return nil +// } From 049497d7fd93fcb5a93966a6097504237f1d1ef7 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 7 Oct 2024 14:41:15 +0100 Subject: [PATCH 049/172] chore: add RecvPacket to V2 (#7399) * chore: add RecvPacket to V2 * fix wrong log * Update modules/core/04-channel/v2/keeper/relay.go Co-authored-by: Cian Hatton * PR feeback --------- Co-authored-by: Cian Hatton --- modules/core/04-channel/v2/keeper/events.go | 5 ++ .../core/04-channel/v2/keeper/msg_server.go | 30 ++++++- modules/core/04-channel/v2/keeper/relay.go | 82 +++++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index ddaf8876080..9e09d43ec20 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -10,3 +10,8 @@ import ( func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } + +// EmitRecvPacketEvents emits events for the RecvPacket handler. +func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { + // TODO: https://github.com/cosmos/ibc-go/issues/7386 +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index e418f9fa394..02cea03179c 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) @@ -47,8 +48,33 @@ func (*Keeper) Acknowledgement(ctx context.Context, acknowledgement *channeltype } // RecvPacket implements the PacketMsgServer RecvPacket method. -func (*Keeper) RecvPacket(ctx context.Context, packet *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { - panic("implement me") +func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + err := k.recvPacket(ctx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) + if err != nil { + sdkCtx.Logger().Error("receive packet failed", "source-id", msg.Packet.SourceId, "dest-id", msg.Packet.DestinationId, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "receive packet failed for source id: %s and destination id: %s", msg.Packet.SourceId, msg.Packet.DestinationId) + } + + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + sdkCtx.Logger().Error("receive packet failed", "error", errorsmod.Wrap(err, "invalid address for msg Signer")) + return nil, errorsmod.Wrap(err, "invalid address for msg Signer") + } + + _ = signer + + // TODO: implement once app router is wired up. + // https://github.com/cosmos/ibc-go/issues/7384 + // for _, pd := range packet.PacketData { + // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) + // err := cbs.OnRecvPacket(ctx, packet, msg.ProofCommitment, msg.ProofHeight, signer) + // if err != nil { + // return nil, err + // } + // } + + return &channeltypesv2.MsgRecvPacketResponse{Result: types.SUCCESS}, nil } // Timeout implements the PacketMsgServer Timeout method. diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index f30d72cec73..6a9910b2c60 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -5,10 +5,12 @@ import ( "strconv" errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -87,3 +89,83 @@ func (k *Keeper) sendPacket( return sequence, nil } + +// recvPacket implements the packet receiving logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If the packet has already been received a no-op error is returned. +// The packet handler will verify that the packet has not timed out and that the +// counterparty stored a packet commitment. If successful, a packet receipt is stored +// to indicate to the counterparty successful delivery. +func (k Keeper) recvPacket( + ctx context.Context, + packet channeltypesv2.Packet, + proof []byte, + proofHeight exported.Height, +) error { + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.GetCounterparty(ctx, packet.DestinationId) + if !ok { + // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // for future use. + // TODO: figure out how aliasing will work when more than one packet data is sent. + if counterparty, ok = k.AliasV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceId); ok { + // we can key on just the source channel here since channel ids are globally unique + k.SetCounterparty(ctx, packet.SourceId, counterparty) + } else { + // if neither a counterparty nor channel is found then simply return an error + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceId) + } + } + if counterparty.ClientId != packet.SourceId { + return channeltypes.ErrInvalidChannelIdentifier + } + + // check if packet timed out by comparing it with the latest height of the chain + sdkCtx := sdk.UnwrapSDKContext(ctx) + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(sdkCtx.BlockTime().UnixNano()) + timeout := channeltypes.NewTimeoutWithTimestamp(packet.GetTimeoutTimestamp()) + if timeout.Elapsed(selfHeight, selfTimestamp) { + return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + } + + // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received + // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale + // by the increase of the recvStartSequence. + _, found := k.GetPacketReceipt(ctx, packet.DestinationId, packet.Sequence) + if found { + EmitRecvPacketEvents(ctx, packet) + // This error indicates that the packet has already been relayed. Core IBC will + // treat this error as a no-op in order to prevent an entire relay transaction + // from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + path := hostv2.PacketCommitmentKey(packet.SourceId, sdk.Uint64ToBigEndian(packet.Sequence)) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + commitment := channeltypesv2.CommitPacket(packet) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + packet.DestinationId, + proofHeight, + 0, 0, + proof, + merklePath, + commitment, + ); err != nil { + return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationId) + } + + // Set Packet Receipt to prevent timeout from occurring on counterparty + k.SetPacketReceipt(ctx, packet.DestinationId, packet.Sequence) + + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceId, "dst_id", packet.DestinationId) + + EmitRecvPacketEvents(ctx, packet) + + return nil +} From 759ff434082f881f76d485edcf9a94d386707bca Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 7 Oct 2024 16:14:31 +0100 Subject: [PATCH 050/172] chore: create helper function for counterparty falllback. (#7405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: create helper function for counterparty falllback. * Fix source/dest ID * Update modules/core/04-channel/v2/keeper/relay.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/core/04-channel/v2/keeper/relay.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --------- Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/core/04-channel/v2/keeper/relay.go | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 6a9910b2c60..57b3542c6b5 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -15,6 +15,18 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) +// getV1Counterparty attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it +// to a v2 counterparty and stores it in the v2 channel keeper for future use +func (k *Keeper) getV1Counterparty(ctx context.Context, port, id string) (channeltypesv2.Counterparty, bool) { + if counterparty, ok := k.AliasV1Channel(ctx, port, id); ok { + // we can key on just the channel here since channel ids are globally unique + k.SetCounterparty(ctx, id, counterparty) + return counterparty, true + } + + return channeltypesv2.Counterparty{}, false +} + // sendPacket constructs a packet from the input arguments, writes a packet commitment to state // in order for the packet to be sent to the counterparty. func (k *Keeper) sendPacket( @@ -26,15 +38,9 @@ func (k *Keeper) sendPacket( // Lookup counterparty associated with our source channel to retrieve the destination channel counterparty, ok := k.GetCounterparty(ctx, sourceID) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper - // for future use. // TODO: figure out how aliasing will work when more than one packet data is sent. - if counterparty, ok = k.AliasV1Channel(ctx, data[0].SourcePort, sourceID); ok { - // we can key on just the source channel here since channel ids are globally unique - k.SetCounterparty(ctx, sourceID, counterparty) - } else { - // if neither a counterparty nor channel is found then simply return an error + counterparty, ok = k.getV1Counterparty(ctx, data[0].SourcePort, sourceID) + if !ok { return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceID) } } @@ -107,16 +113,10 @@ func (k Keeper) recvPacket( // that the packet was indeed sent by our counterparty. counterparty, ok := k.GetCounterparty(ctx, packet.DestinationId) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper - // for future use. // TODO: figure out how aliasing will work when more than one packet data is sent. - if counterparty, ok = k.AliasV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceId); ok { - // we can key on just the source channel here since channel ids are globally unique - k.SetCounterparty(ctx, packet.SourceId, counterparty) - } else { - // if neither a counterparty nor channel is found then simply return an error - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceId) + counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationId) + if !ok { + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) } } if counterparty.ClientId != packet.SourceId { From 753673ae8b6eeed769e1a72a0b4b90b72308a63b Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 8 Oct 2024 08:54:29 +0100 Subject: [PATCH 051/172] chore: Add Timeout to Channel Keeper (#7400) * chore: Add Timeout to Channel Keeper * reintroduce method * linter * pr feedback * use helper fn --- modules/core/04-channel/v2/keeper/events.go | 5 ++ .../core/04-channel/v2/keeper/msg_server.go | 32 ++++++- modules/core/04-channel/v2/keeper/relay.go | 83 ++++++++++++++++++- 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 9e09d43ec20..e1ffea106ff 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -11,6 +11,11 @@ func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } +// EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. +func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { + // TODO: https://github.com/cosmos/ibc-go/issues/7386 +} + // EmitRecvPacketEvents emits events for the RecvPacket handler. func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 02cea03179c..62d0683fd3e 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) @@ -74,10 +74,34 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack // } // } - return &channeltypesv2.MsgRecvPacketResponse{Result: types.SUCCESS}, nil + return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil } // Timeout implements the PacketMsgServer Timeout method. -func (*Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { - panic("implement me") +func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + if err := k.timeoutPacket(ctx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { + sdkCtx.Logger().Error("Timeout packet failed", "source-id", timeout.Packet.SourceId, "destination-id", timeout.Packet.DestinationId, "error", errorsmod.Wrap(err, "timeout packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s and destination id: %s", timeout.Packet.SourceId, timeout.Packet.DestinationId) + } + + signer, err := sdk.AccAddressFromBech32(timeout.Signer) + if err != nil { + sdkCtx.Logger().Error("timeout packet failed", "error", errorsmod.Wrap(err, "invalid address for msg Signer")) + return nil, errorsmod.Wrap(err, "invalid address for msg Signer") + } + + _ = signer + + // TODO: implement once app router is wired up. + // https://github.com/cosmos/ibc-go/issues/7384 + // for _, pd := range timeout.Packet.Data { + // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) + // err := cbs.OnTimeoutPacket(timeout.Packet.SourceId, timeout.Packet.TimeoutTimestamp, signer) + // if err != nil { + // return err, err + // } + // } + + return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 57b3542c6b5..df034cc2f6a 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -1,10 +1,12 @@ package keeper import ( + "bytes" "context" "strconv" errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" @@ -96,7 +98,8 @@ func (k *Keeper) sendPacket( return sequence, nil } -// recvPacket implements the packet receiving logic required by a packet handler. +// recvPacket implements the packet receiving logic required by a packet handler. + // The packet is checked for correctness including asserting that the packet was // sent and received on clients which are counterparties for one another. // If the packet has already been received a no-op error is returned. @@ -169,3 +172,81 @@ func (k Keeper) recvPacket( return nil } + +// timeoutPacket implements the timeout logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// an absence proof of the packet receipt is performed to ensure that the packet +// was never delivered to the counterparty. If successful, the packet commitment +// is deleted and the packet has completed its lifecycle. +func (k Keeper) timeoutPacket( + ctx context.Context, + packet channeltypesv2.Packet, + proof []byte, + proofHeight exported.Height, +) error { + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.GetCounterparty(ctx, packet.SourceId) + if !ok { + // TODO: figure out how aliasing will work when more than one packet data is sent. + counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceId) + if !ok { + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) + } + } + + // check that timeout height or timeout timestamp has passed on the other end + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceId, proofHeight) + if err != nil { + return err + } + + timeout := channeltypes.NewTimeoutWithTimestamp(packet.GetTimeoutTimestamp()) + if !timeout.Elapsed(clienttypes.ZeroHeight(), proofTimestamp) { + return errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + } + + // check that the commitment has not been cleared and that it matches the packet sent by relayer + commitment, ok := k.GetPacketCommitment(ctx, packet.SourceId, packet.Sequence) + + if !ok { + EmitTimeoutPacketEvents(ctx, packet) + // This error indicates that the timeout has already been relayed + // or there is a misconfigured relayer attempting to prove a timeout + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypesv2.CommitPacket(packet) + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal([]byte(commitment), packetCommitment) { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + } + + // verify packet receipt absence + path := hostv2.PacketReceiptKey(packet.SourceId, sdk.Uint64ToBigEndian(packet.Sequence)) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyNonMembership( + ctx, + packet.SourceId, + proofHeight, + 0, 0, + proof, + merklePath, + ); err != nil { + return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceId) + } + + // delete packet commitment to prevent replay + k.DeletePacketCommitment(ctx, packet.SourceId, packet.Sequence) + + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceId, "dst_id", packet.DestinationId) + + EmitTimeoutPacketEvents(ctx, packet) + + return nil +} From 7dac4befc98f0ea87eaba4b70f79bacf630a7ed8 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 8 Oct 2024 10:12:10 +0200 Subject: [PATCH 052/172] chore: register v2 msg service and rename (#7407) --- go.mod | 3 +- go.sum | 6 +- .../core/04-channel/v2/keeper/msg_server.go | 2 +- modules/core/04-channel/v2/types/tx.pb.go | 184 +++++++++--------- modules/core/module.go | 2 + modules/core/packet-server/types/tx.pb.go | 3 +- proto/ibc/core/channel/v2/tx.proto | 4 +- 7 files changed, 104 insertions(+), 100 deletions(-) diff --git a/go.mod b/go.mod index 7737ee796b0..08b5227b6e5 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.50.10-0.20240808075341-156231be8aef github.com/cosmos/gogoproto v1.7.0 - github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ics23/go v0.11.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -114,6 +113,7 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect + github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect @@ -143,6 +143,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240607163614-bb94eb51e7a7 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/go.sum b/go.sum index 5edbbed702e..fc5995828a5 100644 --- a/go.sum +++ b/go.sum @@ -354,8 +354,6 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= -github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= -github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -462,6 +460,7 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -791,6 +790,7 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= @@ -1236,6 +1236,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1356,6 +1357,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 62d0683fd3e..0455fd7adbe 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -11,7 +11,7 @@ import ( channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) -var _ channeltypesv2.PacketMsgServer = &Keeper{} +var _ channeltypesv2.MsgServer = &Keeper{} // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 7dc604e3999..b06a92f0e96 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -363,53 +363,53 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 724 bytes of a gzipped FileDescriptorProto + // 723 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcd, 0x6e, 0xd3, 0x40, 0x10, 0xc7, 0xe3, 0x26, 0x0d, 0xed, 0xa4, 0x90, 0x62, 0xbe, 0x22, 0x17, 0x25, 0x25, 0x42, 0x6a, 0x29, 0xd4, 0x26, 0x81, 0x4b, 0x2b, 0x24, 0xd4, 0x16, 0x21, 0x38, 0x54, 0x42, 0x6e, 0xe0, 0x00, - 0x15, 0x91, 0xb3, 0x5e, 0x1c, 0xab, 0xb1, 0xd7, 0x78, 0x1d, 0xd3, 0xde, 0x10, 0x27, 0x4e, 0xa8, - 0x8f, 0xc0, 0x23, 0xf4, 0xc0, 0x43, 0x54, 0x9c, 0x7a, 0xe4, 0x84, 0x50, 0x73, 0xe8, 0x6b, 0x20, - 0xef, 0x6e, 0x9c, 0x8f, 0x3a, 0x6d, 0xa5, 0xe6, 0x64, 0x7b, 0xe6, 0xbf, 0xff, 0x99, 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 0x29, 0xbf, 0x3f, 0x1f, 0x3e, 0x5e, 0xee, 0xbf, 0xe5, 0xf7, 0x3c, 0x4c, + 0x1b, 0x59, 0x76, 0x87, 0x3e, 0xfa, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x75, 0x3c, 0x36, 0x09, + 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -420,188 +420,188 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// PacketMsgClient is the client API for PacketMsg service. +// MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type PacketMsgClient interface { +type MsgClient interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. + // Timeout defines a rpc handler method for MsgTimeout. Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) // Acknowledgement defines a rpc handler method for MsgAcknowledgement. Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) } -type packetMsgClient struct { +type msgClient struct { cc grpc1.ClientConn } -func NewPacketMsgClient(cc grpc1.ClientConn) PacketMsgClient { - return &packetMsgClient{cc} +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} } -func (c *packetMsgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) { +func (c *msgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) { out := new(MsgSendPacketResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/SendPacket", in, out, opts...) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/SendPacket", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *packetMsgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { +func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { out := new(MsgRecvPacketResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/RecvPacket", in, out, opts...) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/RecvPacket", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *packetMsgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { +func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { out := new(MsgTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/Timeout", in, out, opts...) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/Timeout", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *packetMsgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { +func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { out := new(MsgAcknowledgementResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.PacketMsg/Acknowledgement", in, out, opts...) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/Acknowledgement", in, out, opts...) if err != nil { return nil, err } return out, nil } -// PacketMsgServer is the server API for PacketMsg service. -type PacketMsgServer interface { +// MsgServer is the server API for Msg service. +type MsgServer interface { // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. + // Timeout defines a rpc handler method for MsgTimeout. Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) // Acknowledgement defines a rpc handler method for MsgAcknowledgement. Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) } -// UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. -type UnimplementedPacketMsgServer struct { +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func (*UnimplementedPacketMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { +func (*UnimplementedMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") } -func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { +func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") } -func (*UnimplementedPacketMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { +func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") } -func (*UnimplementedPacketMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { +func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") } -func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { - s.RegisterService(&_PacketMsg_serviceDesc, srv) +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) } -func _PacketMsg_SendPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_SendPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSendPacket) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PacketMsgServer).SendPacket(ctx, in) + return srv.(MsgServer).SendPacket(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v2.PacketMsg/SendPacket", + FullMethod: "/ibc.core.channel.v2.Msg/SendPacket", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).SendPacket(ctx, req.(*MsgSendPacket)) + return srv.(MsgServer).SendPacket(ctx, req.(*MsgSendPacket)) } return interceptor(ctx, in, info, handler) } -func _PacketMsg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgRecvPacket) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PacketMsgServer).RecvPacket(ctx, in) + return srv.(MsgServer).RecvPacket(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v2.PacketMsg/RecvPacket", + FullMethod: "/ibc.core.channel.v2.Msg/RecvPacket", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + return srv.(MsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) } return interceptor(ctx, in, info, handler) } -func _PacketMsg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgTimeout) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PacketMsgServer).Timeout(ctx, in) + return srv.(MsgServer).Timeout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v2.PacketMsg/Timeout", + FullMethod: "/ibc.core.channel.v2.Msg/Timeout", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).Timeout(ctx, req.(*MsgTimeout)) + return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) } return interceptor(ctx, in, info, handler) } -func _PacketMsg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgAcknowledgement) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PacketMsgServer).Acknowledgement(ctx, in) + return srv.(MsgServer).Acknowledgement(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v2.PacketMsg/Acknowledgement", + FullMethod: "/ibc.core.channel.v2.Msg/Acknowledgement", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) + return srv.(MsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) } return interceptor(ctx, in, info, handler) } -var _PacketMsg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.channel.v2.PacketMsg", - HandlerType: (*PacketMsgServer)(nil), +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.channel.v2.Msg", + HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SendPacket", - Handler: _PacketMsg_SendPacket_Handler, + Handler: _Msg_SendPacket_Handler, }, { MethodName: "RecvPacket", - Handler: _PacketMsg_RecvPacket_Handler, + Handler: _Msg_RecvPacket_Handler, }, { MethodName: "Timeout", - Handler: _PacketMsg_Timeout_Handler, + Handler: _Msg_Timeout_Handler, }, { MethodName: "Acknowledgement", - Handler: _PacketMsg_Acknowledgement_Handler, + Handler: _Msg_Acknowledgement_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/modules/core/module.go b/modules/core/module.go index e0b7baf4a67..29c1d2d8d04 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -24,6 +24,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" @@ -138,6 +139,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) + channeltypesv2.RegisterMsgServer(cfg.MsgServer(), am.keeper.ChannelKeeperV2) packetservertypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index d25b93cb293..626e262a3d9 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -117,8 +117,7 @@ type MsgCreateChannel struct { // the client identifier of the light client representing the counterparty chain ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. + // will use to send to us. MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` // signer address Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index b25ebd50341..1fef3095a23 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -10,8 +10,8 @@ import "ibc/core/channel/v2/channel.proto"; import "ibc/core/channel/v1/tx.proto"; import "ibc/core/client/v1/client.proto"; -// PacketMsg defines the ibc/channel PacketMsg service. -service PacketMsg { +// Msg defines the ibc/channel/v2 Msg service. +service Msg { option (cosmos.msg.v1.service) = true; // SendPacket defines a rpc handler method for MsgSendPacket. From 6a193370c86b8630dcd3f9f9a05d8dc3b78eccfe Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Tue, 8 Oct 2024 09:23:23 +0100 Subject: [PATCH 053/172] Wire up simapp to use mock v2 modules (#7401) * chore: adding router v2 * chore: addressing PR feedback * chore: address PR feedback and fix linter * chore: adding mock v2 module * chore: adding mock application wiring in simapp * chore: fix linter --- modules/core/05-port/keeper/keeper.go | 5 +++-- modules/core/keeper/keeper.go | 6 ++++++ simapp/app.go | 18 +++++++++++++++++- testing/mock/v2/ibc_module.go | 7 +++++++ testing/mock/v2/mock.go | 5 +++++ 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 testing/mock/v2/mock.go diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index a35288a48c1..eceaed94184 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -3,18 +3,19 @@ package keeper import ( "context" "strings" - "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + "github.com/cosmos/ibc-go/v9/modules/core/api" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) // Keeper defines the IBC connection keeper type Keeper struct { - Router *types.Router + Router *types.Router + RouterV2 *api.Router } // NewKeeper creates a new IBC connection Keeper instance diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index c58fcffbd70..2c3b9c980df 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -16,6 +16,7 @@ import ( channelkeeperv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" portkeeper "github.com/cosmos/ibc-go/v9/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + "github.com/cosmos/ibc-go/v9/modules/core/api" packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -83,6 +84,11 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { k.PortKeeper.Router.Seal() } +// SetRouterV2 sets the v2 router for the IBC Keeper. +func (k *Keeper) SetRouterV2(rtr *api.Router) { + k.PortKeeper.RouterV2 = rtr +} + // GetAuthority returns the ibc module's authority. func (k *Keeper) GetAuthority() string { return k.authority diff --git a/simapp/app.go b/simapp/app.go index c5a9039c6ae..f190d17b5a3 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -119,11 +119,13 @@ import ( ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + ibcapi "github.com/cosmos/ibc-go/v9/modules/core/api" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v9/testing/mock" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) const appName = "SimApp" @@ -200,6 +202,9 @@ type SimApp struct { ICAAuthModule mock.IBCModule FeeMockModule mock.IBCModule + MockModuleV2A mockv2.IBCModule + MockModuleV2B mockv2.IBCModule + // the module manager ModuleManager *module.Manager BasicModuleManager module.BasicManager @@ -417,6 +422,7 @@ func NewSimApp( // Create IBC Router ibcRouter := porttypes.NewRouter() + ibcRouterV2 := ibcapi.NewRouter() // Middleware Stacks @@ -511,8 +517,18 @@ func NewSimApp( feeWithMockModule := ibcfee.NewIBCMiddleware(feeMockModule, app.IBCFeeKeeper) ibcRouter.AddRoute(MockFeePort, feeWithMockModule) - // Seal the IBC Router + // create two separate mock v2 applications so that it is possible to test multi packet data. + mockV2A := mockv2.NewIBCModule() + ibcRouterV2.AddRoute(mockv2.ModuleNameA, mockV2A) + app.MockModuleV2A = mockV2A + + mockV2B := mockv2.NewIBCModule() + ibcRouterV2.AddRoute(mockv2.ModuleNameB, mockV2B) + app.MockModuleV2B = mockV2B + + // Set the IBC Routers app.IBCKeeper.SetRouter(ibcRouter) + app.IBCKeeper.SetRouterV2(ibcRouterV2) clientKeeper := app.IBCKeeper.ClientKeeper storeProvider := clientKeeper.GetStoreProvider() diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index b2589e7cb65..637d0381439 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -11,6 +11,13 @@ import ( var _ api.IBCModule = (*IBCModule)(nil) +const ( + // ModuleNameA is a name that can be used for the first mock application. + ModuleNameA = ModuleName + "A" + // ModuleNameB is a name that can be used for the second mock application. + ModuleNameB = ModuleName + "B" +) + // IBCModule is a mock implementation of the IBCModule interface. // which delegates calls to the underlying IBCApp. type IBCModule struct { diff --git a/testing/mock/v2/mock.go b/testing/mock/v2/mock.go new file mode 100644 index 00000000000..6f0f56535fc --- /dev/null +++ b/testing/mock/v2/mock.go @@ -0,0 +1,5 @@ +package mock + +const ( + ModuleName = "mockv2" +) From 9264b1c240b8c71a52596693274c3b1994f59517 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 8 Oct 2024 13:59:40 +0300 Subject: [PATCH 054/172] chore: add pluming necessary for testing CreateChannel (#7406) * chore: add pluming necessary for testings. * chore: docustring for event func. * chore: wire up call to emit in msg_server * chore: fix linter mess. * chore: review touch ups. --- modules/core/keeper/msg_server.go | 3 +++ modules/core/packet-server/keeper/events.go | 25 +++++++++++++++++++++ modules/core/packet-server/types/events.go | 19 ++++++++++++++++ testing/endpoint.go | 16 +++++++++++++ testing/events.go | 5 +++-- testing/path.go | 16 +++++++++++++ testing/values.go | 1 + 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 modules/core/packet-server/keeper/events.go create mode 100644 modules/core/packet-server/types/events.go diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 216d8947438..2daf744cc75 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -16,6 +16,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/telemetry" + packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -155,6 +156,8 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg k.ClientKeeper.SetCreator(ctx, channelID, msg.Signer) + packetserverkeeper.EmitCreateChannelEvent(goCtx, channelID) + return &packetservertypes.MsgCreateChannelResponse{ChannelId: channelID}, nil } diff --git a/modules/core/packet-server/keeper/events.go b/modules/core/packet-server/keeper/events.go new file mode 100644 index 00000000000..64f5c023205 --- /dev/null +++ b/modules/core/packet-server/keeper/events.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// EmitCreateChannelEvent emits a channel create event. +func EmitCreateChannelEvent(ctx context.Context, channelID string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCreateChannel, + sdk.NewAttribute(types.AttributeKeyChannelID, channelID), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) +} diff --git a/modules/core/packet-server/types/events.go b/modules/core/packet-server/types/events.go new file mode 100644 index 00000000000..6166f0422d1 --- /dev/null +++ b/modules/core/packet-server/types/events.go @@ -0,0 +1,19 @@ +package types + +import ( + "fmt" + + ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +// IBC channel events +const ( + AttributeKeyChannelID = "channel_id" +) + +// IBC channel events vars +var ( + EventTypeCreateChannel = "create_channel" + + AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) +) diff --git a/testing/endpoint.go b/testing/endpoint.go index f3ef692bea6..689f71089fb 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -188,6 +188,22 @@ func (endpoint *Endpoint) ProvideCounterparty() (err error) { return err } +// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. +func (endpoint *Endpoint) CreateChannel() (err error) { + msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + + // create channel + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events) + require.NoError(endpoint.Chain.TB, err) + + return nil +} + // UpgradeChain will upgrade a chain's chainID to the next revision number. // It will also update the counterparty client. // TODO: implement actual upgrade chain functionality via scheduling an upgrade diff --git a/testing/events.go b/testing/events.go index 7c467c5e48c..0fa3cfafb73 100644 --- a/testing/events.go +++ b/testing/events.go @@ -14,6 +14,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the @@ -44,10 +45,10 @@ func ParseConnectionIDFromEvents(events []abci.Event) (string, error) { } // ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or -// MsgChannelOpenTry and returns the channel identifier. +// MsgChannelOpenTry or a MsgCreateChannel and returns the channel identifier. func ParseChannelIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { - if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { + if ev.Type == packetservertypes.EventTypeCreateChannel || ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { if attribute, found := attributeByKey(ev.Attributes, channeltypes.AttributeKeyChannelID); found { return attribute.Value, nil } diff --git a/testing/path.go b/testing/path.go index fc9c0aac564..6cca511eded 100644 --- a/testing/path.go +++ b/testing/path.go @@ -152,6 +152,9 @@ func (path *Path) Setup() { // This is all that is necessary for path setup with the Eureka (V2) protocol func (path *Path) SetupV2() { path.SetupClients() + + // path.CreateChannelsV2() + path.SetupCounterparties() } @@ -252,6 +255,19 @@ func (path *Path) CreateChannels() { } } +// CreateChannelsV2 initializes two channel endpoints by executing CreateChannel on both chainA and chainB. +func (path *Path) CreateChannelsV2() { + err := path.EndpointA.CreateChannel() + if err != nil { + panic(err) + } + + err = path.EndpointB.CreateChannel() + if err != nil { + panic(err) + } +} + // EnableFeeOnPath enables fee on a channel given a path. func EnableFeeOnPath(path *Path) *Path { path.EndpointA.ChannelConfig.Version = ibcmock.MockFeeVersion diff --git a/testing/values.go b/testing/values.go index c5920910681..61fe31badbb 100644 --- a/testing/values.go +++ b/testing/values.go @@ -77,4 +77,5 @@ var ( prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) // unusedHash is a placeholder hash used for testing. unusedHash = tmhash.Sum([]byte{0x00}) + merklePath = commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) ) From 1683b4f2f69477d1ed47797ec8c93fabea15f280 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 8 Oct 2024 13:35:10 +0100 Subject: [PATCH 055/172] chore: add OnRecvPacket to IBCModule V2 interface (#7415) --- modules/core/05-port/keeper/keeper.go | 1 + modules/core/api/module.go | 8 +++++++- testing/mock/v2/ibc_app.go | 1 + testing/mock/v2/ibc_module.go | 17 +++++++++++------ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index eceaed94184..41bce412efc 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "context" "strings" + "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/modules/core/api/module.go b/modules/core/api/module.go index d90878d678f..33bca8c69fa 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -23,7 +23,13 @@ type IBCModule interface { signer sdk.AccAddress, ) error - // OnRecvPacket + OnRecvPacket( + ctx context.Context, + sourceID string, + destinationID string, + data channeltypesv2.PacketData, + relayer sdk.AccAddress, + ) channeltypesv2.RecvPacketResult // OnAcknowledgementPacket diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index 2e3598b5d96..b1892f551af 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -10,4 +10,5 @@ import ( type IBCApp struct { OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 637d0381439..686d5e4498a 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -7,6 +7,7 @@ import ( channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/api" + mockv1 "github.com/cosmos/ibc-go/v9/testing/mock" ) var _ api.IBCModule = (*IBCModule)(nil) @@ -38,12 +39,16 @@ func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinati return nil } -// func (im IBCModule) OnRecvPacket() error { -// if im.IBCApp.OnRecvPacket != nil { -// return im.IBCApp.OnRecvPacket(...) -// } -// return nil -// } +func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + if im.IBCApp.OnRecvPacket != nil { + return im.IBCApp.OnRecvPacket(ctx, sourceID, destinationID, data, relayer) + } + return channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Success, + Acknowledgement: mockv1.MockPacketData, + } +} + // // func (im IBCModule) OnAcknowledgementPacket() error { // if im.IBCApp.OnAcknowledgementPacket != nil { From 115749fba3422e3026231f7b6ee18b63d229d7f5 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 8 Oct 2024 14:55:18 +0100 Subject: [PATCH 056/172] chore: add OnTimeoutPacket to IBCModule V2 interface (#7418) --- modules/core/api/module.go | 9 ++++++++- testing/mock/v2/ibc_app.go | 5 +++-- testing/mock/v2/ibc_module.go | 13 +++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 33bca8c69fa..f15dfad6611 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -33,5 +33,12 @@ type IBCModule interface { // OnAcknowledgementPacket - // OnTimeoutPacket + // OnTimeoutPacket is executed when a packet has timed out on the receiving chain. + OnTimeoutPacket( + ctx context.Context, + sourceID string, + destinationID string, + data channeltypesv2.PacketData, + relayer sdk.AccAddress, + ) error } diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index b1892f551af..ddf4c67f115 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,6 +9,7 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 686d5e4498a..0e948daa471 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -57,9 +57,10 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati // return nil // } // -// func (im IBCModule) OnTimeoutPacket() error { -// if im.IBCApp.OnTimeoutPacket != nil { -// return im.IBCApp.OnTimeoutPacket(...) -// } -// return nil -// } + +func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { + if im.IBCApp.OnTimeoutPacket != nil { + return im.IBCApp.OnTimeoutPacket(ctx, sourceID, destinationID, data, relayer) + } + return nil +} From a42ed56ef637dd463128a6de97010938e4d6105f Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 9 Oct 2024 14:13:49 +0200 Subject: [PATCH 057/172] refactor: host keys apis to use uint64 sequence and fmt big endian bytes internally (#7419) --- modules/core/04-channel/v2/keeper/keeper.go | 21 +++++++-------------- modules/core/04-channel/v2/keeper/relay.go | 4 ++-- modules/core/24-host/v2/packet_keys.go | 18 +++++++++++------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index d367855475a..b6223402a6d 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -77,8 +77,7 @@ func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Co // GetPacketReceipt returns the packet receipt from the packet receipt path based on the sourceID and sequence. func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) (string, bool) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - bz, err := store.Get(hostv2.PacketReceiptKey(sourceID, bigEndianBz)) + bz, err := store.Get(hostv2.PacketReceiptKey(sourceID, sequence)) if err != nil { panic(err) } @@ -92,8 +91,7 @@ func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence // This is a public path that is standardized by the IBC V2 specification. func (k *Keeper) SetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(hostv2.PacketReceiptKey(sourceID, bigEndianBz), []byte{byte(1)}); err != nil { + if err := store.Set(hostv2.PacketReceiptKey(sourceID, sequence), []byte{byte(1)}); err != nil { panic(err) } } @@ -102,8 +100,7 @@ func (k *Keeper) SetPacketReceipt(ctx context.Context, sourceID string, sequence // This is a public path that is standardized by the IBC V2 specification. func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64, ackHash []byte) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(hostv2.PacketAcknowledgementKey(sourceID, bigEndianBz), ackHash); err != nil { + if err := store.Set(hostv2.PacketAcknowledgementKey(sourceID, sequence), ackHash); err != nil { panic(err) } } @@ -111,8 +108,7 @@ func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, sourceID string, // HasPacketAcknowledgement check if the packet ack hash is already on the store. func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64) bool { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - found, err := store.Has(hostv2.PacketAcknowledgementKey(sourceID, bigEndianBz)) + found, err := store.Has(hostv2.PacketAcknowledgementKey(sourceID, sequence)) if err != nil { panic(err) } @@ -123,8 +119,7 @@ func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, // GetPacketCommitment returns the packet commitment hash under the commitment path. func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, sequence uint64) (string, bool) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - bz, err := store.Get(hostv2.PacketCommitmentKey(sourceID, bigEndianBz)) + bz, err := store.Get(hostv2.PacketCommitmentKey(sourceID, sequence)) if err != nil { panic(err) } @@ -137,8 +132,7 @@ func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, seque // SetPacketCommitment writes the commitment hash under the commitment path. func (k *Keeper) SetPacketCommitment(ctx context.Context, sourceID string, sequence uint64, commitment []byte) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(hostv2.PacketCommitmentKey(sourceID, bigEndianBz), commitment); err != nil { + if err := store.Set(hostv2.PacketCommitmentKey(sourceID, sequence), commitment); err != nil { panic(err) } } @@ -146,8 +140,7 @@ func (k *Keeper) SetPacketCommitment(ctx context.Context, sourceID string, seque // DeletePacketCommitment deletes the packet commitment hash under the commitment path. func (k *Keeper) DeletePacketCommitment(ctx context.Context, sourceID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) - bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Delete(hostv2.PacketCommitmentKey(sourceID, bigEndianBz)); err != nil { + if err := store.Delete(hostv2.PacketCommitmentKey(sourceID, sequence)); err != nil { panic(err) } } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index df034cc2f6a..201df3cc5d4 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -146,7 +146,7 @@ func (k Keeper) recvPacket( return channeltypes.ErrNoOpMsg } - path := hostv2.PacketCommitmentKey(packet.SourceId, sdk.Uint64ToBigEndian(packet.Sequence)) + path := hostv2.PacketCommitmentKey(packet.SourceId, packet.Sequence) merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) commitment := channeltypesv2.CommitPacket(packet) @@ -227,7 +227,7 @@ func (k Keeper) timeoutPacket( } // verify packet receipt absence - path := hostv2.PacketReceiptKey(packet.SourceId, sdk.Uint64ToBigEndian(packet.Sequence)) + path := hostv2.PacketReceiptKey(packet.SourceId, packet.Sequence) merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index 62a855595aa..aebd1255f88 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -1,21 +1,25 @@ package v2 -import "fmt" +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) // PacketReceiptKey returns the store key of under which a packet // receipt is stored -func PacketReceiptKey(sourceID string, bigEndianSequence []byte) []byte { - return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +func PacketReceiptKey(sourceID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) } // PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. -func PacketAcknowledgementKey(sourceID string, bigEndianSequence []byte) []byte { - return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +func PacketAcknowledgementKey(sourceID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) } // PacketCommitmentKey returns the store key of under which a packet commitment is stored. -func PacketCommitmentKey(sourceID string, bigEndianSequence []byte) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", sourceID, string(bigEndianSequence))) +func PacketCommitmentKey(sourceID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) } // NextSequenceSendKey returns the store key for the next sequence send of a given sourceID. From 8e9b8ccaebfd43399755c89ff07af4ac3427ff30 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 9 Oct 2024 16:17:57 +0300 Subject: [PATCH 058/172] feat: create channel before invoking provide counterparty. (#7420) --- modules/core/02-client/keeper/keeper.go | 23 ----------- modules/core/02-client/keeper/keeper_test.go | 26 ------------ modules/core/02-client/types/keys.go | 5 --- .../04-channel/v2/types/expected_keepers.go | 3 -- modules/core/keeper/msg_server.go | 22 +++++----- modules/core/keeper/msg_server_test.go | 41 +++++++++---------- .../core/packet-server/keeper/grpc_query.go | 2 +- .../packet-server/keeper/grpc_query_test.go | 4 +- modules/core/packet-server/keeper/keeper.go | 23 +++++++++++ .../core/packet-server/keeper/keeper_test.go | 26 ++++++++++++ modules/core/packet-server/keeper/relay.go | 8 ++-- .../core/packet-server/keeper/relay_test.go | 29 ++++++------- .../packet-server/types/expected_keepers.go | 3 -- modules/core/packet-server/types/keys.go | 5 +++ testing/endpoint.go | 4 +- testing/path.go | 2 +- 16 files changed, 109 insertions(+), 117 deletions(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index a19ec874743..27bd89e12a1 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -313,29 +313,6 @@ func (k *Keeper) GetLatestClientConsensusState(ctx context.Context, clientID str return k.GetClientConsensusState(ctx, clientID, clientModule.LatestHeight(ctx, clientID)) } -// GetCreator returns the creator of the client. -func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - bz := k.ClientStore(sdkCtx, clientID).Get([]byte(types.CreatorKey)) - if len(bz) == 0 { - return "", false - } - - return string(bz), true -} - -// SetCreator sets the creator of the client. -func (k *Keeper) SetCreator(ctx context.Context, clientID, creator string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ClientStore(sdkCtx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) -} - -// DeleteCreator deletes the creator associated with the client. -func (k *Keeper) DeleteCreator(ctx context.Context, clientID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ClientStore(sdkCtx, clientID).Delete([]byte(types.CreatorKey)) -} - // VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height. func (k *Keeper) VerifyMembership(ctx context.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error { clientModule, err := k.Route(ctx, clientID) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index adf412a9459..1db1949bbee 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -129,32 +129,6 @@ func (suite *KeeperTestSuite) TestSetClientState() { suite.Require().Equal(clientState, retrievedState, "Client states are not equal") } -func (suite *KeeperTestSuite) TestSetCreator() { - clientID := ibctesting.FirstClientID - expectedCreator := "test-creator" - - // Set the creator for the client - suite.keeper.SetCreator(suite.ctx, clientID, expectedCreator) - - // Retrieve the creator from the store - retrievedCreator, found := suite.keeper.GetCreator(suite.ctx, clientID) - - // Verify that the retrieved creator matches the expected creator - suite.Require().True(found, "GetCreator did not return stored creator") - suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") - - // Verify non stored creator is not found - retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, ibctesting.SecondClientID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") - - // Verify that the creator is deleted from the store - suite.keeper.DeleteCreator(suite.ctx, clientID) - retrievedCreator, found = suite.keeper.GetCreator(suite.ctx, clientID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") -} - func (suite *KeeperTestSuite) TestSetClientConsensusState() { suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index 29604c2816e..8619b7c3371 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -33,11 +33,6 @@ const ( // would allow any wired up light client modules to be allowed AllowAllClients = "*" - // CreatorKey is the key used to store the client creator in the client store - // the creator key is imported from types instead of host because - // the creator key is not a part of the ics-24 host specification - CreatorKey = "creator" - // CounterpartyKey is the key used to store counterparty in the client store. // the counterparty key is imported from types instead of host because // the counterparty key is not a part of the ics-24 host specification diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 31833373ed9..5a1a0a5d058 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -19,7 +19,4 @@ type ClientKeeper interface { // GetClientTimestampAtHeight returns the timestamp for a given height on the client // given its client ID and height GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) - - // GetCreator returns the creator of the client denoted by the clientID. - GetCreator(ctx context.Context, clientID string) (string, bool) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 2daf744cc75..4bd4eec1884 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -50,9 +50,7 @@ func (k *Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateC return nil, err } - k.ClientKeeper.SetCreator(ctx, clientID, msg.Signer) - - return &clienttypes.MsgCreateClientResponse{}, nil + return &clienttypes.MsgCreateClientResponse{ClientId: clientID}, nil } // UpdateClient defines a rpc handler method for MsgUpdateClient. @@ -154,7 +152,7 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg counterparty := packetservertypes.NewCounterparty(msg.ClientId, "", msg.MerklePathPrefix) k.PacketServerKeeper.SetCounterparty(ctx, channelID, counterparty) - k.ClientKeeper.SetCreator(ctx, channelID, msg.Signer) + k.PacketServerKeeper.SetCreator(ctx, channelID, msg.Signer) packetserverkeeper.EmitCreateChannelEvent(goCtx, channelID) @@ -165,22 +163,24 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - creator, found := k.ClientKeeper.GetCreator(ctx, msg.Counterparty.ClientId) + creator, found := k.PacketServerKeeper.GetCreator(ctx, msg.ChannelId) if !found { - return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "client creator must be set") + return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") } if creator != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) } - if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId); ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ChannelId) + counterparty, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId) + if !ok { + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty must exist for channel %s", msg.ChannelId) } - k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, msg.Counterparty) + counterparty.CounterpartyChannelId = msg.Counterparty.CounterpartyChannelId + k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, counterparty) // Delete client creator from state as it is not needed after this point. - k.ClientKeeper.DeleteCreator(ctx, msg.Counterparty.ClientId) + k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) return &packetservertypes.MsgProvideCounterpartyResponse{}, nil } diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 6a9b788990b..c45feaa1823 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -241,7 +241,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) }, nil, false, @@ -256,7 +256,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockFailPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) }, nil, true, @@ -271,7 +271,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibcmock.MockAsyncPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) }, nil, false, @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) }, @@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { "packet not sent", func() { path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) }, fmt.Errorf("receive packet verification failed"), false, @@ -696,7 +696,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) @@ -936,7 +936,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, timeoutTimestamp, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp, ibcmock.Version) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, nil, @@ -957,7 +957,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) } err := path.EndpointA.UpdateClient() @@ -971,7 +971,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { { "success no-op: packet not sent", func() { path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, nil, @@ -1216,15 +1216,11 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { }{ { "success", - func() {}, - nil, - }, - { - "failure: unknown client identifier", func() { - msg.Counterparty.ClientId = ibctesting.InvalidID + // set it before handler + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) }, - ibcerrors.ErrUnauthorized, + nil, }, { "failure: signer does not match creator", @@ -1234,10 +1230,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { ibcerrors.ErrUnauthorized, }, { - "failure: counterparty already exists", + "failure: counterparty does not already exists", func() { - // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.CounterpartyKey)) }, packetservertypes.ErrInvalidCounterparty, }, @@ -1248,9 +1243,11 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() + suite.Require().NoError(path.EndpointA.CreateChannel()) + signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix, signer) + msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, merklePrefix, signer) tc.malleate() @@ -1263,11 +1260,11 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty set and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) suite.Require().Equal(counterparty, msg.Counterparty) - _, found = suite.chainA.App.GetIBCKeeper().ClientKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) + _, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().False(found) } else { suite.Require().Nil(resp) diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/packet-server/keeper/grpc_query.go index 2632ea1dc4b..7e6b37878bf 100644 --- a/modules/core/packet-server/keeper/grpc_query.go +++ b/modules/core/packet-server/keeper/grpc_query.go @@ -42,7 +42,7 @@ func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) sdkCtx := sdk.UnwrapSDKContext(ctx) - creator, foundCreator := q.ClientKeeper.GetCreator(sdkCtx, req.ClientId) + creator, foundCreator := q.GetCreator(sdkCtx, req.ClientId) counterparty, foundCounterparty := q.GetCounterparty(sdkCtx, req.ClientId) if !foundCreator && !foundCounterparty { diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/packet-server/keeper/grpc_query_test.go index 014efa8cf59..46fa6e5250b 100644 --- a/modules/core/packet-server/keeper/grpc_query_test.go +++ b/modules/core/packet-server/keeper/grpc_query_test.go @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { "success", func() { ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) req = &types.QueryClientRequest{ @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { func() { expCounterparty = types.Counterparty{} - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) req = &types.QueryClientRequest{ ClientId: ibctesting.FirstClientID, diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 8c98d623a12..73b2d0358c0 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -66,3 +66,26 @@ func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Co k.cdc.MustUnmarshal(bz, &counterparty) return counterparty, true } + +// GetCreator returns the creator of the client. +func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + bz := k.ChannelStore(sdkCtx, clientID).Get([]byte(types.CreatorKey)) + if len(bz) == 0 { + return "", false + } + + return string(bz), true +} + +// SetCreator sets the creator of the client. +func (k *Keeper) SetCreator(ctx context.Context, clientID, creator string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + k.ChannelStore(sdkCtx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) +} + +// DeleteCreator deletes the creator associated with the client. +func (k *Keeper) DeleteCreator(ctx context.Context, clientID string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + k.ChannelStore(sdkCtx, clientID).Delete([]byte(types.CreatorKey)) +} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 47e3f2e3f3b..67f9227c9d1 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -25,3 +25,29 @@ func (suite *KeeperTestSuite) TestSetCounterparty() { suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") } + +func (suite *KeeperTestSuite) TestSetCreator() { + clientID := ibctesting.FirstClientID + expectedCreator := "test-creator" + + // Set the creator for the client + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), clientID, expectedCreator) + + // Retrieve the creator from the store + retrievedCreator, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), clientID) + + // Verify that the retrieved creator matches the expected creator + suite.Require().True(found, "GetCreator did not return stored creator") + suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") + + // Verify non stored creator is not found + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Empty(retrievedCreator, "Creator is not empty") + + // Verify that the creator is deleted from the store + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.DeleteCreator(suite.chainA.GetContext(), clientID) + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), clientID) + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Empty(retrievedCreator, "Creator is not empty") +} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index c4d559cae48..b1e8fd1ea48 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -209,7 +209,7 @@ func (k Keeper) WriteAcknowledgement( if !ok { return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } - if counterparty.ClientId != packet.SourceChannel { + if counterparty.CounterpartyChannelId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } @@ -266,7 +266,7 @@ func (k Keeper) AcknowledgePacket( return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) } - if counterparty.ClientId != packet.DestinationChannel { + if counterparty.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } clientID := counterparty.ClientId @@ -337,13 +337,13 @@ func (k Keeper) TimeoutPacket( return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) } - if counterparty.ClientId != packet.DestinationChannel { + if counterparty.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } clientID := counterparty.ClientId // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) if err != nil { return "", err } diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go index 2fdd95fe7d8..d1b61be35d1 100644 --- a/modules/core/packet-server/keeper/relay_test.go +++ b/modules/core/packet-server/keeper/relay_test.go @@ -20,6 +20,7 @@ import ( var ( defaultTimeoutHeight = clienttypes.NewHeight(1, 100) disabledTimeoutTimestamp = uint64(0) + unusedChannel = "channel-5" ) // KeeperTestSuite is a testing suite to test keeper functions. @@ -68,7 +69,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { { "counterparty not found", func() { - packet.SourceChannel = ibctesting.FirstChannelID + packet.SourceChannel = ibctesting.InvalidID }, types.ErrCounterpartyNotFound, }, @@ -121,7 +122,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { // create standard packet that can be malleated packet = channeltypes.NewPacketWithVersion(mock.MockPacketData, 1, mock.PortID, - path.EndpointA.ClientID, mock.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(1, 100), 0, mock.Version) + path.EndpointA.ChannelID, mock.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0, mock.Version) // malleate the test case tc.malleate() @@ -173,7 +174,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { { "failure: counterparty not found", func() { - packet.DestinationChannel = ibctesting.FirstChannelID + packet.DestinationChannel = ibctesting.InvalidID }, types.ErrCounterpartyNotFound, }, @@ -187,7 +188,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { { "failure: counterparty client identifier different than source channel", func() { - packet.SourceChannel = ibctesting.FirstChannelID + packet.SourceChannel = unusedChannel }, channeltypes.ErrInvalidChannelIdentifier, }, @@ -230,7 +231,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) tc.malleate() @@ -280,14 +281,14 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { { "failure: counterparty not found", func() { - packet.DestinationChannel = ibctesting.FirstChannelID + packet.DestinationChannel = ibctesting.InvalidID }, types.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", func() { - packet.SourceChannel = ibctesting.FirstChannelID + packet.SourceChannel = unusedChannel }, channeltypes.ErrInvalidChannelIdentifier, }, @@ -330,7 +331,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) ack = mock.MockAcknowledgement suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) @@ -381,14 +382,14 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { { "failure: counterparty not found", func() { - packet.SourceChannel = ibctesting.FirstChannelID + packet.SourceChannel = ibctesting.InvalidID }, types.ErrCounterpartyNotFound, }, { "failure: counterparty client identifier different than source channel", func() { - packet.DestinationChannel = ibctesting.FirstChannelID + packet.DestinationChannel = unusedChannel }, channeltypes.ErrInvalidChannelIdentifier, }, @@ -436,7 +437,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) suite.Require().NoError(err) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) err = path.EndpointB.RecvPacket(packet) suite.Require().NoError(err) @@ -523,7 +524,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) suite.Require().NoError(err, "send packet failed") - packet.SourceChannel = ibctesting.FirstChannelID + packet.SourceChannel = ibctesting.InvalidID }, types.ErrCounterpartyNotFound, }, @@ -535,7 +536,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) suite.Require().NoError(err, "send packet failed") - packet.DestinationChannel = ibctesting.FirstChannelID + packet.DestinationChannel = unusedChannel }, channeltypes.ErrInvalidChannelIdentifier, }, @@ -607,7 +608,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // create default packet with a timed out height // test cases may mutate timeout values timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) tc.malleate() diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 98140a084fc..176de889391 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -55,7 +55,4 @@ type ClientKeeper interface { // GetClientTimestampAtHeight returns the timestamp for a given height on the client // given its client ID and height GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) - - // GetCreator returns the creator of the client denoted by the clientID. - GetCreator(ctx context.Context, clientID string) (string, bool) } diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index 34c291f67af..b6edf17dc7b 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -8,4 +8,9 @@ const ( // the counterparty key is imported from types instead of host because // the counterparty key is not a part of the ics-24 host specification CounterpartyKey = "counterparty" + + // CreatorKey is the key used to store the client creator in the client store + // the creator key is imported from types instead of host because + // the creator key is not a part of the ics-24 host specification + CreatorKey = "creator" ) diff --git a/testing/endpoint.go b/testing/endpoint.go index 689f71089fb..18f5973a481 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -180,7 +180,7 @@ func (endpoint *Endpoint) FreezeClient() { func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) @@ -481,7 +481,7 @@ func (endpoint *Endpoint) SendPacketV2( data []byte, ) (uint64, error) { // no need to send message, acting as a module - sequence, err := endpoint.Chain.App.GetPacketServer().SendPacket(endpoint.Chain.GetContext(), endpoint.ClientID, endpoint.ChannelConfig.PortID, endpoint.Counterparty.ChannelConfig.PortID, timeoutHeight, timeoutTimestamp, version, data) + sequence, err := endpoint.Chain.App.GetPacketServer().SendPacket(endpoint.Chain.GetContext(), endpoint.ChannelID, endpoint.ChannelConfig.PortID, endpoint.Counterparty.ChannelConfig.PortID, timeoutHeight, timeoutTimestamp, version, data) if err != nil { return 0, err } diff --git a/testing/path.go b/testing/path.go index 6cca511eded..85c5eaa9d1b 100644 --- a/testing/path.go +++ b/testing/path.go @@ -153,7 +153,7 @@ func (path *Path) Setup() { func (path *Path) SetupV2() { path.SetupClients() - // path.CreateChannelsV2() + path.CreateChannelsV2() path.SetupCounterparties() } From b509c50b129ee0f5093469e7a19035d4117ae188 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 9 Oct 2024 18:46:36 +0300 Subject: [PATCH 059/172] chore: clean up ProvideCounterparty tx. (#7422) * chore: clean up msgprovidecounterparty. * Update modules/core/keeper/msg_server_test.go Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --------- Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- modules/core/keeper/msg_server.go | 2 +- modules/core/keeper/msg_server_test.go | 10 +- modules/core/packet-server/client/cli/tx.go | 43 ++------ modules/core/packet-server/types/msgs.go | 12 +-- modules/core/packet-server/types/msgs_test.go | 14 +-- modules/core/packet-server/types/tx.pb.go | 102 +++++++++--------- proto/ibc/core/packetserver/v1/tx.proto | 5 +- testing/endpoint.go | 6 +- testing/values.go | 2 +- 9 files changed, 78 insertions(+), 118 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 4bd4eec1884..e909ebfe765 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -177,7 +177,7 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty must exist for channel %s", msg.ChannelId) } - counterparty.CounterpartyChannelId = msg.Counterparty.CounterpartyChannelId + counterparty.CounterpartyChannelId = msg.CounterpartyChannelId k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, counterparty) // Delete client creator from state as it is not needed after this point. k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index c45feaa1823..9a787a14cc6 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -17,7 +17,6 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -1218,7 +1217,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, @@ -1246,8 +1245,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().NoError(path.EndpointA.CreateChannel()) signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, merklePrefix, signer) + msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) tc.malleate() @@ -1259,10 +1257,10 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().NotNil(resp) suite.Require().Nil(err) - // Assert counterparty set and creator deleted + // Assert counterparty channel id filled in and creator deleted counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) - suite.Require().Equal(counterparty, msg.Counterparty) + suite.Require().Equal(counterparty.CounterpartyChannelId, path.EndpointB.ChannelID) _, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().False(found) diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 0482ba21e30..619e96e1875 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -1,9 +1,7 @@ package cli import ( - "encoding/hex" "fmt" - "strings" "github.com/spf13/cobra" @@ -12,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/version" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -20,30 +17,25 @@ import ( // newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. func newProvideCounterpartyCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "provide-counterparty [client-identifier] [counterparty-client-identifier] [counterparty-merkle-path-prefix]", - Args: cobra.ExactArgs(3), - Short: "provide the counterparty to an IBC client", - Long: `Provide the counterparty to an IBC client specified by its client ID. + Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", + Args: cobra.ExactArgs(2), + Short: "provide the counterparty channel to an IBC channel end", + Long: `Provide the counterparty to an IBC channel end specified by its channel ID. The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, - Example: fmt.Sprintf("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), + Example: fmt.Sprintf("%s tx %s %s provide-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - clientIdentifier := args[0] - counterpartyClientIdentifier := args[1] - counterpartyMerklePathPrefix, err := parseMerklePathPrefix(args[2]) - if err != nil { - return err - } + channelID := args[0] + counterpartyChannelID := args[1] - counterparty := types.NewCounterparty(clientIdentifier, counterpartyClientIdentifier, counterpartyMerklePathPrefix) msg := types.MsgProvideCounterparty{ - ChannelId: clientIdentifier, - Counterparty: counterparty, - Signer: clientCtx.GetFromAddress().String(), + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, + Signer: clientCtx.GetFromAddress().String(), } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, @@ -52,18 +44,3 @@ The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded s flags.AddTxFlagsToCmd(cmd) return cmd } - -// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. -func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { - var keyPath [][]byte - hexPrefixes := strings.Split(merklePathPrefixString, ",") - for _, hexPrefix := range hexPrefixes { - prefix, err := hex.DecodeString(hexPrefix) - if err != nil { - return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) - } - keyPath = append(keyPath, prefix) - } - - return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil -} diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go index 86849d43be7..a291f62ab2d 100644 --- a/modules/core/packet-server/types/msgs.go +++ b/modules/core/packet-server/types/msgs.go @@ -16,13 +16,11 @@ var ( ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgProvideCounterparty { - counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) - +func NewMsgProvideCounterparty(channelID, counterpartyChannelID string, signer string) *MsgProvideCounterparty { return &MsgProvideCounterparty{ - Signer: signer, - ChannelId: clientID, - Counterparty: counterparty, + Signer: signer, + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, } } @@ -36,7 +34,7 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { return err } - if err := msg.Counterparty.Validate(); err != nil { + if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { return err } diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index f61f8a1a052..bac3552e9f1 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -32,33 +32,25 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { ibcerrors.ErrInvalidAddress, }, { - "failure: invalid client ID", + "failure: invalid channel ID", func() { msg.ChannelId = "" }, host.ErrInvalidID, }, { - "failure: invalid counterparty client ID", + "failure: invalid counterparty channel ID", func() { - msg.Counterparty.ClientId = "" + msg.CounterpartyChannelId = "" }, host.ErrInvalidID, }, - { - "failure: empty key path of counterparty of merkle path prefix", - func() { - msg.Counterparty.MerklePathPrefix.KeyPath = nil - }, - types.ErrInvalidCounterparty, - }, } for _, tc := range testCases { msg = types.NewMsgProvideCounterparty( ibctesting.FirstClientID, ibctesting.SecondClientID, - commitmenttypes.NewMerklePath([]byte("key")), ibctesting.TestAccAddress, ) diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index 626e262a3d9..22b052db787 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -36,8 +36,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgProvideCounterparty struct { // unique identifier we will use to write all packet messages sent to counterparty ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // counterparty client - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` + // counterparty channel identifier + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` // signer address Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } @@ -204,37 +204,37 @@ func init() { func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } var fileDescriptor_3c556aec8b7966db = []byte{ - // 478 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0xb5, 0xa5, 0x22, 0x07, 0x88, 0xca, 0xa0, 0x62, 0x19, 0x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0xf6, 0x7f, 0x27, 0x2e, 0x35, 0x78, 0x77, 0x3e, - 0x5f, 0x8c, 0x5b, 0x68, 0xff, 0xf0, 0x6c, 0xe2, 0xa3, 0xf3, 0x89, 0x8f, 0x7e, 0x4f, 0x7c, 0xf4, - 0x6d, 0xea, 0xd7, 0xce, 0xa7, 0x7e, 0xed, 0xe7, 0xd4, 0xaf, 0x7d, 0x7c, 0xcf, 0xb8, 0x19, 0x8c, - 0xe2, 0xe2, 0x80, 0xc4, 0x86, 0x81, 0xc7, 0x74, 0x87, 0x49, 0x92, 0xbf, 0x23, 0x42, 0x26, 0xa3, - 0x21, 0xe8, 0x6a, 0x9c, 0x76, 0x6c, 0x9e, 0xcc, 0x49, 0x06, 0x3a, 0x5e, 0x2f, 0xd3, 0xf2, 0xe6, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x9c, 0x69, 0x26, 0xf1, 0x03, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x7d, 0x6d, 0xa9, 0xc8, 0x21, 0x44, 0x65, 0xa0, 0x8d, 0x8c, 0x70, 0x4b, 0x16, 0x50, + 0xa4, 0xde, 0x51, 0x23, 0x21, 0xa8, 0x90, 0x90, 0x9a, 0xa9, 0x43, 0xa4, 0x28, 0x43, 0x07, 0x96, + 0xc8, 0x3e, 0x3f, 0x2e, 0xa7, 0xfa, 0x7c, 0xd6, 0xdd, 0xc5, 0x6a, 0x37, 0xca, 0xc4, 0xc8, 0xc8, + 0xc8, 0x47, 0xc8, 0xc7, 0xe8, 0xd8, 0x91, 0x09, 0xa1, 0x64, 0xe8, 0xd7, 0x40, 0x76, 0x5c, 0x63, + 0xaa, 0x00, 0x65, 0xf3, 0xbd, 0xf7, 0x7b, 0xef, 0xfd, 0xdf, 0xf3, 0x7b,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0xff, 0xff, 0x4e, 0x8b, 0x7a, 0x32, + 0xaa, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -384,16 +384,13 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x1a } - { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.ChannelId) > 0 { i -= len(m.ChannelId) copy(dAtA[i:], m.ChannelId) @@ -525,8 +522,10 @@ func (m *MsgProvideCounterparty) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Counterparty.Size() - n += 1 + l + sovTx(uint64(l)) + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -644,9 +643,9 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -656,24 +655,23 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto index 9e831d45944..c179e9ae25c 100644 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -7,7 +7,6 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/type import "gogoproto/gogo.proto"; import "ibc/core/commitment/v2/commitment.proto"; -import "ibc/core/packetserver/v1/counterparty.proto"; import "cosmos/msg/v1/msg.proto"; // Msg defines the ibc/packetserver Msg service. @@ -31,8 +30,8 @@ message MsgProvideCounterparty { // unique identifier we will use to write all packet messages sent to counterparty string channel_id = 1; - // counterparty client - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + // counterparty channel identifier + string counterparty_channel_id = 2; // signer address string signer = 3; } diff --git a/testing/endpoint.go b/testing/endpoint.go index 18f5973a481..05ad6c1e654 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -178,9 +178,7 @@ func (endpoint *Endpoint) FreezeClient() { // ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. func (endpoint *Endpoint) ProvideCounterparty() (err error) { - merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - - msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) @@ -190,7 +188,7 @@ func (endpoint *Endpoint) ProvideCounterparty() (err error) { // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { - msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // create channel res, err := endpoint.Chain.SendMsgs(msg) diff --git a/testing/values.go b/testing/values.go index 61fe31badbb..9571004c2db 100644 --- a/testing/values.go +++ b/testing/values.go @@ -77,5 +77,5 @@ var ( prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) // unusedHash is a placeholder hash used for testing. unusedHash = tmhash.Sum([]byte{0x00}) - merklePath = commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + MerklePath = commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) ) From 7e02a968bac801f43053b0ccdc82e94f85e8941b Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:06:31 +0200 Subject: [PATCH 060/172] Rename Id Fields to Channel for Packet V2 (#7428) * change id fields to channel * Apply suggestions from code review Co-authored-by: Damian Nolan --------- Co-authored-by: Damian Nolan --- .../core/04-channel/v2/keeper/msg_server.go | 18 +-- modules/core/04-channel/v2/keeper/relay.go | 42 +++--- .../core/04-channel/v2/types/channel.pb.go | 124 +++++++++--------- modules/core/04-channel/v2/types/packet.go | 20 +-- .../core/04-channel/v2/types/packet_test.go | 4 +- modules/core/04-channel/v2/types/tx.pb.go | 110 ++++++++-------- proto/ibc/core/channel/v2/channel.proto | 4 +- proto/ibc/core/channel/v2/tx.proto | 2 +- 8 files changed, 162 insertions(+), 162 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 0455fd7adbe..819e3a6549e 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -16,10 +16,10 @@ var _ channeltypesv2.MsgServer = &Keeper{} // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - sequence, err := k.sendPacket(ctx, msg.SourceId, msg.TimeoutTimestamp, msg.PacketData) + sequence, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.PacketData) if err != nil { - sdkCtx.Logger().Error("send packet failed", "source-id", msg.SourceId, "error", errorsmod.Wrap(err, "send packet failed")) - return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceId) + sdkCtx.Logger().Error("send packet failed", "source-id", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) } signer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -34,7 +34,7 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack // https://github.com/cosmos/ibc-go/issues/7384 // for _, pd := range msg.PacketData { // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnSendPacket(ctx, msg.SourceId, sequence, msg.TimeoutTimestamp, pd, signer) + // err := cbs.OnSendPacket(ctx, msg.SourceChannel, sequence, msg.TimeoutTimestamp, pd, signer) // if err != nil { // return nil, err // } @@ -52,8 +52,8 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack sdkCtx := sdk.UnwrapSDKContext(ctx) err := k.recvPacket(ctx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) if err != nil { - sdkCtx.Logger().Error("receive packet failed", "source-id", msg.Packet.SourceId, "dest-id", msg.Packet.DestinationId, "error", errorsmod.Wrap(err, "send packet failed")) - return nil, errorsmod.Wrapf(err, "receive packet failed for source id: %s and destination id: %s", msg.Packet.SourceId, msg.Packet.DestinationId) + sdkCtx.Logger().Error("receive packet failed", "source-id", msg.Packet.SourceChannel, "dest-id", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "receive packet failed for source id: %s and destination id: %s", msg.Packet.SourceChannel, msg.Packet.DestinationChannel) } signer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -81,8 +81,8 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) if err := k.timeoutPacket(ctx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { - sdkCtx.Logger().Error("Timeout packet failed", "source-id", timeout.Packet.SourceId, "destination-id", timeout.Packet.DestinationId, "error", errorsmod.Wrap(err, "timeout packet failed")) - return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s and destination id: %s", timeout.Packet.SourceId, timeout.Packet.DestinationId) + sdkCtx.Logger().Error("Timeout packet failed", "source-id", timeout.Packet.SourceChannel, "destination-id", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s and destination id: %s", timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) } signer, err := sdk.AccAddressFromBech32(timeout.Signer) @@ -97,7 +97,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout // https://github.com/cosmos/ibc-go/issues/7384 // for _, pd := range timeout.Packet.Data { // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnTimeoutPacket(timeout.Packet.SourceId, timeout.Packet.TimeoutTimestamp, signer) + // err := cbs.OnTimeoutPacket(timeout.Packet.SourceChannel, timeout.Packet.TimeoutTimestamp, signer) // if err != nil { // return err, err // } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 201df3cc5d4..93856fe77c6 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -91,7 +91,7 @@ func (k *Keeper) sendPacket( k.SetNextSequenceSend(ctx, sourceID, sequence+1) k.SetPacketCommitment(ctx, sourceID, packet.GetSequence(), commitment) - k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_id", packet.DestinationId, "src_id", packet.SourceId) + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_channel_id", packet.DestinationChannel, "src_channel_id", packet.SourceChannel) EmitSendPacketEvents(ctx, packet) @@ -114,15 +114,15 @@ func (k Keeper) recvPacket( ) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationId) + counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationId) + counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } } - if counterparty.ClientId != packet.SourceId { + if counterparty.ClientId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } @@ -137,7 +137,7 @@ func (k Keeper) recvPacket( // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. - _, found := k.GetPacketReceipt(ctx, packet.DestinationId, packet.Sequence) + _, found := k.GetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) if found { EmitRecvPacketEvents(ctx, packet) // This error indicates that the packet has already been relayed. Core IBC will @@ -146,27 +146,27 @@ func (k Keeper) recvPacket( return channeltypes.ErrNoOpMsg } - path := hostv2.PacketCommitmentKey(packet.SourceId, packet.Sequence) + path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) commitment := channeltypesv2.CommitPacket(packet) if err := k.ClientKeeper.VerifyMembership( ctx, - packet.DestinationId, + packet.DestinationChannel, proofHeight, 0, 0, proof, merklePath, commitment, ); err != nil { - return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationId) + return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) } // Set Packet Receipt to prevent timeout from occurring on counterparty - k.SetPacketReceipt(ctx, packet.DestinationId, packet.Sequence) + k.SetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) - k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceId, "dst_id", packet.DestinationId) + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceChannel, "dst_id", packet.DestinationChannel) EmitRecvPacketEvents(ctx, packet) @@ -188,17 +188,17 @@ func (k Keeper) timeoutPacket( ) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceId) + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceId) + counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } } // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceId, proofHeight) + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) if err != nil { return err } @@ -209,7 +209,7 @@ func (k Keeper) timeoutPacket( } // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment, ok := k.GetPacketCommitment(ctx, packet.SourceId, packet.Sequence) + commitment, ok := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if !ok { EmitTimeoutPacketEvents(ctx, packet) @@ -227,24 +227,24 @@ func (k Keeper) timeoutPacket( } // verify packet receipt absence - path := hostv2.PacketReceiptKey(packet.SourceId, packet.Sequence) + path := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, - packet.SourceId, + packet.SourceChannel, proofHeight, 0, 0, proof, merklePath, ); err != nil { - return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceId) + return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) } // delete packet commitment to prevent replay - k.DeletePacketCommitment(ctx, packet.SourceId, packet.Sequence) + k.DeletePacketCommitment(ctx, packet.SourceChannel, packet.Sequence) - k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceId, "dst_id", packet.DestinationId) + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_channel_id", packet.SourceChannel, "dst_channel_id", packet.DestinationChannel) EmitTimeoutPacketEvents(ctx, packet) diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go index 6ba9798bb01..2a9829af5d5 100644 --- a/modules/core/04-channel/v2/types/channel.pb.go +++ b/modules/core/04-channel/v2/types/channel.pb.go @@ -66,9 +66,9 @@ type Packet struct { // with a later sequence number. Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` // identifies the sending chain. - SourceId string `protobuf:"bytes,2,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` // identifies the receiving chain. - DestinationId string `protobuf:"bytes,3,opt,name=destination_id,json=destinationId,proto3" json:"destination_id,omitempty"` + DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` // timeout timestamp after which the packet times out. TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` // a list of packet data, each one for a specific application. @@ -115,16 +115,16 @@ func (m *Packet) GetSequence() uint64 { return 0 } -func (m *Packet) GetSourceId() string { +func (m *Packet) GetSourceChannel() string { if m != nil { - return m.SourceId + return m.SourceChannel } return "" } -func (m *Packet) GetDestinationId() string { +func (m *Packet) GetDestinationChannel() string { if m != nil { - return m.DestinationId + return m.DestinationChannel } return "" } @@ -438,48 +438,48 @@ func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescri var fileDescriptor_7e9b57d8f218397d = []byte{ // 660 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x41, 0x4f, 0x1a, 0x4f, - 0x18, 0xc6, 0x59, 0x45, 0x81, 0x17, 0xff, 0xba, 0xff, 0x51, 0x5b, 0xa4, 0x0d, 0x22, 0x89, 0x2d, - 0xb5, 0x91, 0x6d, 0x68, 0x2f, 0x26, 0x5e, 0x10, 0x31, 0x21, 0x6d, 0x28, 0xd9, 0x85, 0x26, 0xf6, - 0x42, 0x86, 0xd9, 0x09, 0x6e, 0xdc, 0xdd, 0xd9, 0xee, 0xcc, 0xae, 0x31, 0xe9, 0x27, 0x30, 0x69, - 0xd2, 0x53, 0x6f, 0x7e, 0x82, 0x7e, 0x11, 0x8f, 0x1e, 0x7b, 0x6a, 0x1a, 0xfd, 0x22, 0x0d, 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, 0xc7, 0xd6, 0x3d, 0xe6, 0x0b, 0x99, 0x2c, 0xa7, 0x43, 0x24, 0x75, - 0x99, 0x2f, 0xd0, 0x33, 0x50, 0x27, 0xed, 0x4b, 0x2a, 0x8a, 0xb8, 0x36, 0xa1, 0x4b, 0xf4, 0x10, - 0x32, 0x1e, 0xbe, 0xb4, 0x19, 0x8e, 0x22, 0xe6, 0xeb, 0x8f, 0xff, 0x62, 0x4c, 0x32, 0xb1, 0xab, - 0x64, 0xa4, 0xd2, 0x87, 0x4c, 0xdc, 0x41, 0x05, 0xc8, 0x84, 0xd4, 0xe7, 0x16, 0x73, 0x63, 0x43, - 0x49, 0x39, 0xbe, 0x05, 0xea, 0x12, 0x66, 0x5a, 0xee, 0x28, 0x39, 0xe8, 0xa4, 0x46, 0x1b, 0xb0, - 0x14, 0x62, 0x3b, 0xa0, 0x72, 0xf3, 0x15, 0x3d, 0x2a, 0x2a, 0x1f, 0x61, 0xad, 0x41, 0xce, 0x5d, - 0x76, 0x61, 0x53, 0x73, 0x44, 0x1d, 0xea, 0x0a, 0x64, 0xc1, 0x43, 0x3c, 0x2d, 0x0d, 0x7c, 0xca, - 0x03, 0x5b, 0xf0, 0x82, 0x22, 0x0f, 0x74, 0x6f, 0xae, 0xef, 0x99, 0x65, 0x74, 0x39, 0x12, 0xa7, - 0x78, 0x80, 0xe7, 0x35, 0x79, 0xe5, 0x93, 0x02, 0x9b, 0x73, 0xe7, 0xd0, 0x16, 0x64, 0xb1, 0xe7, - 0x0d, 0x5c, 0xec, 0xd0, 0x24, 0x24, 0xf6, 0xbc, 0x0e, 0x76, 0x28, 0x3a, 0x05, 0xe4, 0x53, 0x12, - 0x0e, 0x3c, 0x79, 0x4d, 0xb1, 0x37, 0x19, 0x37, 0x5f, 0xdf, 0x9d, 0x6b, 0x4d, 0xa7, 0x24, 0x8c, - 0x2e, 0x75, 0xca, 0x95, 0xea, 0xcf, 0xe8, 0x95, 0x0b, 0x50, 0x67, 0x59, 0x74, 0x00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d, 0xf4, 0x14, 0xd6, 0xc7, 0x41, 0xb3, 0xdb, 0x68, 0x34, 0x4d, 0x53, 0x55, + 0x8a, 0xf9, 0xcb, 0xab, 0x72, 0xce, 0x0c, 0x09, 0xa1, 0x9c, 0xff, 0xcd, 0x1d, 0xd5, 0x8f, 0xdf, + 0x76, 0x8d, 0xa6, 0x3a, 0x13, 0x73, 0x47, 0xd8, 0x76, 0xc2, 0x80, 0x22, 0x0d, 0x56, 0xc7, 0xb9, + 0xba, 0x79, 0xd2, 0x6a, 0xa8, 0xb3, 0xc5, 0xc5, 0xcb, 0xab, 0xf2, 0x5c, 0x9d, 0x5f, 0x78, 0xe4, + 0xe0, 0xfd, 0xf5, 0x6d, 0x49, 0xb9, 0xb9, 0x2d, 0x29, 0x3f, 0x6f, 0x4b, 0xca, 0x97, 0xbb, 0x52, + 0xe6, 0xe6, 0xae, 0x94, 0xf9, 0x7e, 0x57, 0xca, 0x7c, 0xd8, 0x1f, 0xd8, 0xe2, 0x34, 0xec, 0x55, + 0x09, 0x73, 0x75, 0xc2, 0xb8, 0xcb, 0xb8, 0x6e, 0xf7, 0xc8, 0xee, 0x80, 0xe9, 0xd1, 0x9e, 0xee, + 0xb2, 0x7e, 0xe8, 0x50, 0x1e, 0xbf, 0x49, 0x2f, 0x5f, 0xef, 0x8e, 0x3c, 0x4b, 0xe2, 0xc2, 0xa7, + 0xbc, 0x37, 0x2f, 0x9f, 0x9a, 0x57, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xcc, 0x0a, 0xf3, + 0xba, 0x04, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -521,17 +521,17 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.DestinationId) > 0 { - i -= len(m.DestinationId) - copy(dAtA[i:], m.DestinationId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationId))) + if len(m.DestinationChannel) > 0 { + i -= len(m.DestinationChannel) + copy(dAtA[i:], m.DestinationChannel) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationChannel))) i-- dAtA[i] = 0x1a } - if len(m.SourceId) > 0 { - i -= len(m.SourceId) - copy(dAtA[i:], m.SourceId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceId))) + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceChannel))) i-- dAtA[i] = 0x12 } @@ -766,11 +766,11 @@ func (m *Packet) Size() (n int) { if m.Sequence != 0 { n += 1 + sovChannel(uint64(m.Sequence)) } - l = len(m.SourceId) + l = len(m.SourceChannel) if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - l = len(m.DestinationId) + l = len(m.DestinationChannel) if l > 0 { n += 1 + l + sovChannel(uint64(l)) } @@ -928,7 +928,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -956,11 +956,11 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SourceId = string(dAtA[iNdEx:postIndex]) + m.SourceChannel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DestinationChannel", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -988,7 +988,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DestinationId = string(dAtA[iNdEx:postIndex]) + m.DestinationChannel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 0 { diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 85924dca020..6cf39b0372f 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -12,13 +12,13 @@ import ( ) // NewPacket constructs a new packet. -func NewPacket(sequence uint64, sourceID, destinationID string, timeoutTimestamp uint64, data ...PacketData) Packet { +func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, data ...PacketData) Packet { return Packet{ - Sequence: sequence, - SourceId: sourceID, - DestinationId: destinationID, - TimeoutTimestamp: timeoutTimestamp, - Data: data, + Sequence: sequence, + SourceChannel: sourceChannel, + DestinationChannel: destinationChannel, + TimeoutTimestamp: timeoutTimestamp, + Data: data, } } @@ -43,10 +43,10 @@ func (p Packet) ValidateBasic() error { } } - if err := host.ChannelIdentifierValidator(p.SourceId); err != nil { + if err := host.ChannelIdentifierValidator(p.SourceChannel); err != nil { return errorsmod.Wrap(err, "invalid source channel ID") } - if err := host.ChannelIdentifierValidator(p.DestinationId); err != nil { + if err := host.ChannelIdentifierValidator(p.DestinationChannel); err != nil { return errorsmod.Wrap(err, "invalid destination channel ID") } @@ -89,14 +89,14 @@ func (p Payload) Validate() error { } // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout) + sha256_hash(destinationID) + sha256_hash(packetData) from a given packet. +// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(packetData) from a given packet. // This results in a fixed length preimage. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. func CommitPacket(packet Packet) []byte { buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) - destIDHash := sha256.Sum256([]byte(packet.DestinationId)) + destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) buf = append(buf, destIDHash[:]...) for _, data := range packet.Data { diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index 691e3f8e408..aad8539edc1 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -89,14 +89,14 @@ func TestValidateBasic(t *testing.T) { { "failure: invalid source channel ID", func() { - packet.SourceId = "" + packet.SourceChannel = "" }, host.ErrInvalidID, }, { "failure: invalid dest channel ID", func() { - packet.DestinationId = "" + packet.DestinationChannel = "" }, host.ErrInvalidID, }, diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index b06a92f0e96..e85b1319cf9 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgSendPacket sends an outgoing IBC packet. type MsgSendPacket struct { - SourceId string `protobuf:"bytes,1,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + SourceChannel string `protobuf:"bytes,1,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` TimeoutTimestamp uint64 `protobuf:"varint,2,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` PacketData []PacketData `protobuf:"bytes,3,rep,name=packet_data,json=packetData,proto3" json:"packet_data"` Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` @@ -363,53 +363,53 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 723 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0xe3, 0x26, 0x0d, 0xed, 0xa4, 0x90, 0x62, 0xbe, 0x22, 0x17, 0x25, 0x25, 0x42, 0x6a, - 0x29, 0xd4, 0x26, 0x81, 0x4b, 0x2b, 0x24, 0xd4,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 0xb3, 0x94, 0xa5, 0xb3, 0x35, 0x71, 0xb3, - 0xdb, 0x00, 0x7d, 0x27, 0xd6, 0x48, 0xf7, 0x9e, 0x66, 0xb4, 0x7b, 0xc2, 0xa1, 0xb0, 0x05, 0x97, - 0xba, 0x7f, 0x72, 0x69, 0xd4, 0x30, 0x21, 0x50, 0x16, 0xce, 0x10, 0xc4, 0xa6, 0x3b, 0x90, 0x1f, - 0xde, 0xb0, 0x23, 0xc7, 0x0e, 0x09, 0x15, 0xed, 0x9c, 0xc2, 0x6e, 0x31, 0x65, 0xf2, 0xf3, 0xf1, - 0xfe, 0x92, 0xb4, 0xfe, 0xe6, 0xe0, 0xa8, 0x28, 0x1d, 0x1e, 0x15, 0xa5, 0x7f, 0x47, 0x45, 0xe9, - 0x47, 0xa7, 0x98, 0x3a, 0xec, 0x14, 0x53, 0x7f, 0x3a, 0xc5, 0xd4, 0xdb, 0x27, 0x96, 0x1d, 0x34, - 0xdb, 0x0d, 0x15, 0x11, 0x47, 0x13, 0x97, 0xb0, 0xdd, 0x40, 0xcb, 0x16, 0xd1, 0xc2, 0x15, 0xcd, - 0x21, 0x66, 0xbb, 0x85, 0x29, 0xbf, 0x3f, 0x1f, 0x3e, 0x5e, 0xee, 0xbf, 0xe5, 0xf7, 0x3c, 0x4c, - 0x1b, 0x59, 0x76, 0x87, 0x3e, 0xfa, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x75, 0x3c, 0x36, 0x09, - 0x08, 0x00, 0x00, + // 727 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xe3, 0x26, 0xcd, 0xbd, 0xf7, 0xa4, 0x6d, 0x7a, 0x7d, 0x2f, 0x10, 0x19, 0x94, 0x94, + 0x08, 0xd4, 0x52, 0xa8, 0x4d, 0x02, 0x9b, 0x56, 0x48, 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 0xb6, 0x7c, + 0xbe, 0x26, 0x6e, 0x76, 0x07, 0x60, 0xe0, 0xc4, 0x1a, 0xeb, 0xde, 0xd7, 0x8c, 0x77, 0x4f, 0x38, + 0x14, 0xb6, 0xe1, 0xaf, 0xde, 0x9f, 0x5c, 0x1a, 0x37, 0x4c, 0x0a, 0xb4, 0xc5, 0x73, 0x04, 0xb1, + 0xe9, 0x2e, 0xe4, 0x47, 0x37, 0xec, 0xd8, 0xb1, 0x23, 0x42, 0xcd, 0xb8, 0xa0, 0xb0, 0x57, 0x4c, + 0x9b, 0xfe, 0x70, 0x72, 0xb0, 0xac, 0x6c, 0xbc, 0x3c, 0x3c, 0x2e, 0x2a, 0x47, 0xc7, 0x45, 0xe5, + 0xf7, 0x71, 0x51, 0xf9, 0xda, 0x2d, 0xa6, 0x8e, 0xba, 0xc5, 0xd4, 0xcf, 0x6e, 0x31, 0xf5, 0xea, + 0x91, 0xed, 0xb0, 0x56, 0xa7, 0xa1, 0x23, 0xe2, 0x1a, 0xf2, 0x3a, 0x76, 0x1a, 0x68, 0xc5, 0x26, + 0x46, 0xb8, 0x6a, 0xb8, 0xa4, 0xd9, 0x69, 0x63, 0x2a, 0x6e, 0xd2, 0xfb, 0x0f, 0x57, 0x06, 0xef, + 0xfb, 0x7d, 0x1f, 0xd3, 0x46, 0x96, 0xdf, 0xa6, 0x0f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb1, + 0x1c, 0xb4, 0xdc, 0x13, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -654,10 +654,10 @@ func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.SourceId) > 0 { - i -= len(m.SourceId) - copy(dAtA[i:], m.SourceId) - i = encodeVarintTx(dAtA, i, uint64(len(m.SourceId))) + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) i-- dAtA[i] = 0xa } @@ -979,7 +979,7 @@ func (m *MsgSendPacket) Size() (n int) { } var l int _ = l - l = len(m.SourceId) + l = len(m.SourceChannel) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1152,7 +1152,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1180,7 +1180,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SourceId = string(dAtA[iNdEx:postIndex]) + m.SourceChannel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto index 4bbe3df2342..20d002d2e6e 100644 --- a/proto/ibc/core/channel/v2/channel.proto +++ b/proto/ibc/core/channel/v2/channel.proto @@ -14,9 +14,9 @@ message Packet { // with a later sequence number. uint64 sequence = 1; // identifies the sending chain. - string source_id = 2; + string source_channel = 2; // identifies the receiving chain. - string destination_id = 3; + string destination_channel = 3; // timeout timestamp after which the packet times out. uint64 timeout_timestamp = 4; // a list of packet data, each one for a specific application. diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 1fef3095a23..95b19c91cf5 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -32,7 +32,7 @@ message MsgSendPacket { option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.goproto_getters) = false; - string source_id = 1; + string source_channel = 1; uint64 timeout_timestamp = 2; repeated PacketData packet_data = 3 [(gogoproto.nullable) = false]; string signer = 4; From f1102b2f76e3bcdcc732a133dc73b324243bd36d Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:00:09 +0200 Subject: [PATCH 061/172] packetserver: Rename Counterparty to Channel (#7429) * chore: clean up msgprovidecounterparty. * Update modules/core/keeper/msg_server_test.go Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> * rename counterparty to channel in packetserver * change var names * chore: fix merge mess. --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/keeper/keeper.go | 16 +- modules/core/04-channel/keeper/keeper_test.go | 10 +- modules/core/04-channel/v2/keeper/relay.go | 6 +- modules/core/keeper/msg_server.go | 16 +- modules/core/keeper/msg_server_test.go | 16 +- modules/core/packet-server/client/cli/cli.go | 2 +- .../core/packet-server/client/cli/query.go | 12 +- modules/core/packet-server/client/cli/tx.go | 11 +- .../core/packet-server/keeper/grpc_query.go | 18 +- .../packet-server/keeper/grpc_query_test.go | 50 ++--- modules/core/packet-server/keeper/keeper.go | 22 +- .../core/packet-server/keeper/keeper_test.go | 20 +- modules/core/packet-server/keeper/relay.go | 76 +++---- .../core/packet-server/keeper/relay_test.go | 28 +-- .../types/{counterparty.go => channel.go} | 12 +- .../{counterparty.pb.go => channel.pb.go} | 174 ++++++++------- .../{counterparty_test.go => channel_test.go} | 10 +- modules/core/packet-server/types/errors.go | 4 +- .../packet-server/types/expected_keepers.go | 4 +- modules/core/packet-server/types/keys.go | 8 +- modules/core/packet-server/types/msgs_test.go | 2 +- modules/core/packet-server/types/query.pb.go | 211 +++++++++--------- .../core/packet-server/types/query.pb.gw.go | 44 ++-- .../v1/{counterparty.proto => channel.proto} | 10 +- proto/ibc/core/packetserver/v1/query.proto | 22 +- testing/values.go | 10 +- 26 files changed, 412 insertions(+), 402 deletions(-) rename modules/core/packet-server/types/{counterparty.go => channel.go} (63%) rename modules/core/packet-server/types/{counterparty.pb.go => channel.pb.go} (56%) rename modules/core/packet-server/types/{counterparty_test.go => channel_test.go} (89%) rename proto/ibc/core/packetserver/v1/{counterparty.proto => channel.proto} (59%) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 04ef2f584ed..8e8bff09e3b 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -827,28 +827,28 @@ func (k *Keeper) PruneAcknowledgements(ctx context.Context, portID, channelID st return totalPruned, totalRemaining, nil } -// GetV2Counterparty returns a version 2 counterparty for the given port and channel ID -// by converting the channel into a version 2 counterparty -func (k *Keeper) GetV2Counterparty(ctx context.Context, portID, channelID string) (packetserver.Counterparty, bool) { +// GetV2Channel returns a version 2 channel for the given port and channel ID +// by converting the v1 channel into a version 2 channel +func (k *Keeper) GetV2Channel(ctx context.Context, portID, channelID string) (packetserver.Channel, bool) { channel, ok := k.GetChannel(ctx, portID, channelID) if !ok { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } // Do not allow channel to be converted into a version 2 counterparty // if the channel is not OPEN or if it is ORDERED if channel.State != types.OPEN || channel.Ordering == types.ORDERED { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) if !ok { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - counterparty := packetserver.Counterparty{ + channelv2 := packetserver.Channel{ CounterpartyChannelId: channel.Counterparty.ChannelId, ClientId: connection.ClientId, MerklePathPrefix: merklePathPrefix, } - return counterparty, true + return channelv2, true } diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index d5401e94c66..ca57cf1c70a 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -549,7 +549,7 @@ func (suite *KeeperTestSuite) TestUnsetParams() { }) } -func (suite *KeeperTestSuite) TestGetV2Counterparty() { +func (suite *KeeperTestSuite) TestGetV2Channel() { var path *ibctesting.Path testCases := []struct { @@ -608,17 +608,17 @@ func (suite *KeeperTestSuite) TestGetV2Counterparty() { tc.malleate() - counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Counterparty(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) if tc.expPass { suite.Require().True(found) merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expCounterparty := packetservertypes.NewCounterparty(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) - suite.Require().Equal(counterparty, expCounterparty) + expChannel := packetservertypes.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + suite.Require().Equal(channel, expChannel) } else { suite.Require().False(found) - suite.Require().Equal(counterparty, packetservertypes.Counterparty{}) + suite.Require().Equal(channel, packetservertypes.Channel{}) } }) } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 93856fe77c6..1bedc747b25 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -43,7 +43,7 @@ func (k *Keeper) sendPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, data[0].SourcePort, sourceID) if !ok { - return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceID) + return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceID) } } @@ -119,7 +119,7 @@ func (k Keeper) recvPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } if counterparty.ClientId != packet.SourceChannel { @@ -193,7 +193,7 @@ func (k Keeper) timeoutPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e909ebfe765..9f4351369bc 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -30,8 +30,6 @@ var ( ) // CreateClient defines a rpc handler method for MsgCreateClient. -// It stores the signer of MsgCreateClient as the creator of the client, which is afterwards -// compared against the signer of MsgProvideCounterparty. // NOTE: The raw bytes of the concrete types encoded into protobuf.Any is passed to the client keeper. // The 02-client handler will route to the appropriate light client module based on client type and it is the responsibility // of the light client module to unmarshal and interpret the proto encoded bytes. @@ -148,9 +146,9 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg channelID := k.ChannelKeeper.GenerateChannelIdentifier(ctx) - // Initialize counterparty with empty counterparty channel identifier. - counterparty := packetservertypes.NewCounterparty(msg.ClientId, "", msg.MerklePathPrefix) - k.PacketServerKeeper.SetCounterparty(ctx, channelID, counterparty) + // Initialize channel with empty counterparty channel identifier. + channel := packetservertypes.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + k.PacketServerKeeper.SetChannel(ctx, channelID, channel) k.PacketServerKeeper.SetCreator(ctx, channelID, msg.Signer) @@ -172,13 +170,13 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) } - counterparty, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId) + channel, ok := k.PacketServerKeeper.GetChannel(ctx, msg.ChannelId) if !ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty must exist for channel %s", msg.ChannelId) + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) } - counterparty.CounterpartyChannelId = msg.CounterpartyChannelId - k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, counterparty) + channel.CounterpartyChannelId = msg.CounterpartyChannelId + k.PacketServerKeeper.SetChannel(ctx, msg.ChannelId, channel) // Delete client creator from state as it is not needed after this point. k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 9a787a14cc6..404240f72d7 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // any non-nil value of packet is valid suite.Require().NotNil(packet) }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, false, false, @@ -658,7 +658,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { func() { packet.SourceChannel = "invalid-client" }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, }, { @@ -984,7 +984,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, }, } @@ -1217,7 +1217,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, @@ -1231,9 +1231,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { { "failure: counterparty does not already exists", func() { - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.CounterpartyKey)) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.ChannelKey)) }, - packetservertypes.ErrInvalidCounterparty, + packetservertypes.ErrInvalidChannel, }, } @@ -1258,9 +1258,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty channel id filled in and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ChannelID) + channel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) - suite.Require().Equal(counterparty.CounterpartyChannelId, path.EndpointB.ChannelID) + suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) _, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().False(found) diff --git a/modules/core/packet-server/client/cli/cli.go b/modules/core/packet-server/client/cli/cli.go index eff92825a94..5c5a897b0f9 100644 --- a/modules/core/packet-server/client/cli/cli.go +++ b/modules/core/packet-server/client/cli/cli.go @@ -19,7 +19,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( - getCmdQueryClient(), + getCmdQueryChannel(), ) return queryCmd diff --git a/modules/core/packet-server/client/cli/query.go b/modules/core/packet-server/client/cli/query.go index 7cebadf9a4d..ad23f2ef5d6 100644 --- a/modules/core/packet-server/client/cli/query.go +++ b/modules/core/packet-server/client/cli/query.go @@ -13,12 +13,12 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// getCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID. -func getCmdQueryClient() *cobra.Command { +// getCmdQueryChannel defines the command to query the client information (creator and channel) for the given client ID. +func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ Use: "client [client-id]", Short: "Query the information of a client.", - Long: "Query the client information (creator and counterparty) for the provided client ID.", + Long: "Query the client information (creator and channel) for the provided client ID.", Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -28,11 +28,11 @@ func getCmdQueryClient() *cobra.Command { } clientID := args[0] - queryClient := types.NewQueryClient(clientCtx) + queryChannel := types.NewQueryClient(clientCtx) - req := &types.QueryClientRequest{ClientId: clientID} + req := &types.QueryChannelRequest{ChannelId: clientID} - res, err := queryClient.Client(cmd.Context(), req) + res, err := queryChannel.Channel(cmd.Context(), req) if err != nil { return err } diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 619e96e1875..a1180c24b87 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -14,14 +14,13 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. +// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC channel. func newProvideCounterpartyCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", - Args: cobra.ExactArgs(2), - Short: "provide the counterparty channel to an IBC channel end", - Long: `Provide the counterparty to an IBC channel end specified by its channel ID. -The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, + Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", + Args: cobra.ExactArgs(2), + Short: "provide the counterparty channel id to an IBC channel end", + Long: `Provide the counterparty channel id to an IBC channel end specified by its channel ID.`, Example: fmt.Sprintf("%s tx %s %s provide-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/packet-server/keeper/grpc_query.go index 7e6b37878bf..bc0182180bf 100644 --- a/modules/core/packet-server/keeper/grpc_query.go +++ b/modules/core/packet-server/keeper/grpc_query.go @@ -28,31 +28,31 @@ func NewQueryServer(k *Keeper) types.QueryServer { } } -// Client implements the Query/Client gRPC method -func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) (*types.QueryClientResponse, error) { +// Channel implements the Query/Channel gRPC method +func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ClientIdentifierValidator(req.ClientId); err != nil { + if err := host.ClientIdentifierValidator(req.ChannelId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - res := types.QueryClientResponse{} + res := types.QueryChannelResponse{} sdkCtx := sdk.UnwrapSDKContext(ctx) - creator, foundCreator := q.GetCreator(sdkCtx, req.ClientId) - counterparty, foundCounterparty := q.GetCounterparty(sdkCtx, req.ClientId) + creator, foundCreator := q.GetCreator(sdkCtx, req.ChannelId) + channel, foundChannel := q.GetChannel(sdkCtx, req.ChannelId) - if !foundCreator && !foundCounterparty { + if !foundCreator && !foundChannel { return nil, status.Error( codes.NotFound, - errorsmod.Wrapf(types.ErrCounterpartyNotFound, "client-id: %s", req.ClientId).Error(), + errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error(), ) } - res.Counterparty = counterparty + res.Channel = channel res.Creator = creator return &res, nil diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/packet-server/keeper/grpc_query_test.go index 46fa6e5250b..79a2987c789 100644 --- a/modules/core/packet-server/keeper/grpc_query_test.go +++ b/modules/core/packet-server/keeper/grpc_query_test.go @@ -12,11 +12,11 @@ import ( ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -func (suite *KeeperTestSuite) TestQueryClient() { +func (suite *KeeperTestSuite) TestQueryChannel() { var ( - req *types.QueryClientRequest - expCreator string - expCounterparty types.Counterparty + req *types.QueryChannelRequest + expCreator string + expChannel types.Channel ) testCases := []struct { @@ -28,11 +28,11 @@ func (suite *KeeperTestSuite) TestQueryClient() { "success", func() { ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstChannelID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, @@ -42,23 +42,23 @@ func (suite *KeeperTestSuite) TestQueryClient() { func() { expCreator = "" - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, expChannel) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, }, { - "success: no counterparty", + "success: no channel", func() { - expCounterparty = types.Counterparty{} + expChannel = types.Channel{} - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expCreator) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, @@ -71,18 +71,18 @@ func (suite *KeeperTestSuite) TestQueryClient() { status.Error(codes.InvalidArgument, "empty request"), }, { - "no creator and no counterparty", + "no creator and no channel", func() { - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, - status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: counterparty not found", ibctesting.FirstClientID)), + status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", ibctesting.FirstChannelID)), }, { - "invalid clientID", + "invalid channelID", func() { - req = &types.QueryClientRequest{} + req = &types.QueryChannelRequest{} }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, @@ -96,19 +96,19 @@ func (suite *KeeperTestSuite) TestQueryClient() { expCreator = ibctesting.TestAccAddress merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) - expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} + expChannel = types.Channel{ClientId: ibctesting.SecondClientID, CounterpartyChannelId: ibctesting.SecondChannelID, MerklePathPrefix: merklePathPrefix} tc.malleate() queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.PacketServerKeeper) - res, err := queryServer.Client(suite.chainA.GetContext(), req) + res, err := queryServer.Channel(suite.chainA.GetContext(), req) expPass := tc.expError == nil if expPass { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expCreator, res.Creator) - suite.Require().Equal(expCounterparty, res.Counterparty) + suite.Require().Equal(expChannel, res.Channel) } else { suite.Require().ErrorIs(err, tc.expError) suite.Require().Nil(res) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 73b2d0358c0..b862b3e0ed5 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -48,23 +48,23 @@ func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.K return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } -// SetCounterparty sets the Counterparty for a given client identifier. -func (k *Keeper) SetCounterparty(ctx context.Context, clientID string, counterparty types.Counterparty) { - bz := k.cdc.MustMarshal(&counterparty) - k.ChannelStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) +// SetChannel sets the Channel for a given client identifier. +func (k *Keeper) SetChannel(ctx context.Context, clientID string, channel types.Channel) { + bz := k.cdc.MustMarshal(&channel) + k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) } -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Counterparty, bool) { +// GetChannel gets the Channel for a given client identifier. +func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel, bool) { store := k.ChannelStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) + bz := store.Get([]byte(types.ChannelKey)) if len(bz) == 0 { - return types.Counterparty{}, false + return types.Channel{}, false } - var counterparty types.Counterparty - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true + var channel types.Channel + k.cdc.MustUnmarshal(bz, &channel) + return channel, true } // GetCreator returns the creator of the client. diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 67f9227c9d1..3c95dc45e0e 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -8,22 +8,22 @@ import ( const testClientID = "tendermint-0" -func (suite *KeeperTestSuite) TestSetCounterparty() { +func (suite *KeeperTestSuite) TestSetChannel() { merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - counterparty := types.Counterparty{ + channel := types.Channel{ ClientId: testClientID, MerklePathPrefix: merklePathPrefix, } - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), testClientID, counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), testClientID, channel) - retrievedCounterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), testClientID) - suite.Require().True(found, "GetCounterparty does not return counterparty") - suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") + retrievedChannel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), testClientID) + suite.Require().True(found, "GetChannel does not return channel") + suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") - // Counterparty not yet stored for another client. - retrievedCounterparty, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), ibctesting.SecondClientID) - suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") - suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") + // Channel not yet stored for another client. + retrievedChannel, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetChannel unexpectedly returned a channel") + suite.Require().Equal(types.Channel{}, retrievedChannel, "Channel retrieved not empty") } func (suite *KeeperTestSuite) TestSetCreator() { diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index b1e8fd1ea48..9ad03fb70c8 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -19,7 +19,7 @@ import ( // SendPacket implements the packet sending logic required by a packet handler. // It will generate a packet and store the commitment hash if all arguments provided are valid. -// The destination channel will be filled in using the counterparty information. +// The destination channel will be filled in using the channel information. // The next sequence send will be initialized if this is the first packet sent for the given client. func (k Keeper) SendPacket( ctx context.Context, @@ -31,22 +31,22 @@ func (k Keeper) SendPacket( version string, data []byte, ) (uint64, error) { - // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.GetCounterparty(ctx, sourceChannel) + // Lookup channel associated with our source channel to retrieve the destination channel + channel, ok := k.GetChannel(ctx, sourceChannel) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, sourcePort, sourceChannel); ok { + if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, sourcePort, sourceChannel); ok { // we can key on just the source channel here since channel ids are globally unique - k.SetCounterparty(ctx, sourceChannel, counterparty) + k.SetChannel(ctx, sourceChannel, channel) } else { - // if neither a counterparty nor channel is found then simply return an error - return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) + // if neither a channel v2 nor channel v1 is found then simply return an error + return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } } - destChannel := counterparty.CounterpartyChannelId - clientID := counterparty.ClientId + destChannel := channel.CounterpartyChannelId + clientID := channel.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -117,26 +117,26 @@ func (k Keeper) RecvPacket( // packetv2 := convert(packet) - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + // Lookup channel associated with our channel and ensure + // that the packet was indeed sent by our channel. + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, packet.DestinationPort, packet.DestinationChannel); ok { + if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, packet.DestinationPort, packet.DestinationChannel); ok { // we can key on just the destination channel here since channel ids are globally unique - k.SetCounterparty(ctx, packet.DestinationChannel, counterparty) + k.SetChannel(ctx, packet.DestinationChannel, channel) } else { - // if neither a counterparty nor channel is found then simply return an error - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + // if neither a channel v1 nor channel v1 is found then simply return an error + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } - if counterparty.CounterpartyChannelId != packet.SourceChannel { + if channel.CounterpartyChannelId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 @@ -159,7 +159,7 @@ func (k Keeper) RecvPacket( } path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) commitment := channeltypes.CommitPacket(packet) @@ -203,13 +203,13 @@ func (k Keeper) WriteAcknowledgement( return channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure + // Lookup channel associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } - if counterparty.CounterpartyChannelId != packet.SourceChannel { + if channel.CounterpartyChannelId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } @@ -261,15 +261,15 @@ func (k Keeper) AcknowledgePacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } - if counterparty.CounterpartyChannelId != packet.DestinationChannel { + if channel.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { @@ -290,7 +290,7 @@ func (k Keeper) AcknowledgePacket( } path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -330,17 +330,17 @@ func (k Keeper) TimeoutPacket( if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { return "", channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure + // Lookup channel associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } - if counterparty.CounterpartyChannelId != packet.DestinationChannel { + if channel.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId // check that timeout height or timeout timestamp has passed on the other end proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) @@ -373,7 +373,7 @@ func (k Keeper) TimeoutPacket( // verify packet receipt absence path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go index d1b61be35d1..e2fb7e8458b 100644 --- a/modules/core/packet-server/keeper/relay_test.go +++ b/modules/core/packet-server/keeper/relay_test.go @@ -67,11 +67,11 @@ func (suite *KeeperTestSuite) TestSendPacket() { nil, }, { - "counterparty not found", + "channel not found", func() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "packet failed basic validation", @@ -172,11 +172,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.DestinationChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "failure: client is not active", @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { clienttypes.ErrClientNotActive, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.SourceChannel = unusedChannel }, @@ -279,14 +279,14 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.DestinationChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.SourceChannel = unusedChannel }, @@ -380,14 +380,14 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.DestinationChannel = unusedChannel }, @@ -517,7 +517,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { // send packet _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, @@ -526,10 +526,10 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { // send packet _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/channel.go similarity index 63% rename from modules/core/packet-server/types/counterparty.go rename to modules/core/packet-server/types/channel.go index d63a92da3e8..3a45be384fb 100644 --- a/modules/core/packet-server/types/counterparty.go +++ b/modules/core/packet-server/types/channel.go @@ -7,17 +7,17 @@ import ( host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) -// NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { - return Counterparty{ +// NewChannel creates a new Channel instance +func NewChannel(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Channel { + return Channel{ ClientId: clientID, CounterpartyChannelId: counterpartyChannelID, MerklePathPrefix: merklePathPrefix, } } -// Validate validates the Counterparty -func (c Counterparty) Validate() error { +// Validate validates the Channel +func (c Channel) Validate() error { if err := host.ClientIdentifierValidator(c.ClientId); err != nil { return err } @@ -27,7 +27,7 @@ func (c Counterparty) Validate() error { } if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) + return errorsmod.Wrap(ErrInvalidChannel, err.Error()) } return nil diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/channel.pb.go similarity index 56% rename from modules/core/packet-server/types/counterparty.pb.go rename to modules/core/packet-server/types/channel.pb.go index 2358d3b8213..91dfcd17df5 100644 --- a/modules/core/packet-server/types/counterparty.pb.go +++ b/modules/core/packet-server/types/channel.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/packetserver/v1/counterparty.proto +// source: ibc/core/packetserver/v1/channel.proto package types @@ -24,8 +24,14 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -type Counterparty struct { +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +type Channel struct { // the client identifier of the light client representing the counterparty chain ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // the counterparty identifier that must be used by the packet @@ -36,18 +42,18 @@ type Counterparty struct { MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_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_e0c60a0709a0040c, []int{0} +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_740f6a3702ba2291, []int{0} } -func (m *Counterparty) XXX_Unmarshal(b []byte) error { +func (m *Channel) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Channel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + return xxx_messageInfo_Channel.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -57,33 +63,33 @@ func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *Counterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counterparty.Merge(m, src) +func (m *Channel) XXX_Merge(src proto.Message) { + xxx_messageInfo_Channel.Merge(m, src) } -func (m *Counterparty) XXX_Size() int { +func (m *Channel) XXX_Size() int { return m.Size() } -func (m *Counterparty) XXX_DiscardUnknown() { - xxx_messageInfo_Counterparty.DiscardUnknown(m) +func (m *Channel) XXX_DiscardUnknown() { + xxx_messageInfo_Channel.DiscardUnknown(m) } -var xxx_messageInfo_Counterparty proto.InternalMessageInfo +var xxx_messageInfo_Channel proto.InternalMessageInfo -func (m *Counterparty) GetClientId() string { +func (m *Channel) GetClientId() string { if m != nil { return m.ClientId } return "" } -func (m *Counterparty) GetCounterpartyChannelId() string { +func (m *Channel) GetCounterpartyChannelId() string { if m != nil { return m.CounterpartyChannelId } return "" } -func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { +func (m *Channel) GetMerklePathPrefix() v2.MerklePath { if m != nil { return m.MerklePathPrefix } @@ -91,38 +97,38 @@ func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { } func init() { - proto.RegisterType((*Counterparty)(nil), "ibc.core.packetserver.v1.Counterparty") + proto.RegisterType((*Channel)(nil), "ibc.core.packetserver.v1.Channel") } func init() { - proto.RegisterFile("ibc/core/packetserver/v1/counterparty.proto", fileDescriptor_e0c60a0709a0040c) + proto.RegisterFile("ibc/core/packetserver/v1/channel.proto", fileDescriptor_740f6a3702ba2291) } -var fileDescriptor_e0c60a0709a0040c = []byte{ - // 310 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc3, 0x30, - 0x1c, 0xc6, 0x1b, 0x15, 0x71, 0xd5, 0x83, 0x14, 0xc5, 0x31, 0x21, 0x8e, 0x5d, 0x1c, 0xc8, 0x12, - 0x36, 0x41, 0x10, 0x3c, 0x6d, 0xa7, 0x1d, 0x84, 0xb1, 0xc3, 0x0e, 0x5e, 0x4a, 0x9b, 0xfe, 0x6d, - 0xc3, 0x9a, 0x26, 0xa4, 0x59, 0x70, 0x6f, 0xe1, 0xfb, 0xf8, 0x02, 0x3b, 0xee, 0xe8, 0x49, 0x64, - 0x7b, 0x11, 0x69, 0x2b, 0x23, 0xb7, 0xe4, 0xff, 0xfd, 0xf2, 0xe5, 0xfb, 0x7f, 0xfe, 0x03, 0x8f, - 0x19, 0x65, 0x52, 0x03, 0x55, 0x11, 0x5b, 0x82, 0x29, 0x41, 0x5b, 0xd0, 0xd4, 0x0e, 0x29, 0x93, - 0xab, 0xc2, 0x80, 0x56, 0x91, 0x36, 0x6b, 0xa2, 0xb4, 0x34, 0x32, 0x68, 0xf3, 0x98, 0x91, 0x0a, - 0x26, 0x2e, 0x4c, 0xec, 0xb0, 0x73, 0x95, 0xca, 0x54, 0xd6, 0x10, 0xad, 0x4e, 0x0d, 0xdf, 0xb9, - 0x3f, 0x98, 0x33, 0x29, 0x04, 0x37, 0x02, 0x0a, 0x43, 0xed, 0xc8, 0xb9, 0x35, 0x60, 0xef, 0x0b, - 0xf9, 0x17, 0x13, 0xe7, 0xbf, 0xe0, 0xd6, 0x6f, 0xb1, 0x9c, 0x43, 0x61, 0x42, 0x9e, 0xb4, 0x51, - 0x17, 0xf5, 0x5b, 0xf3, 0xb3, 0x66, 0x30, 0x4d, 0x82, 0x27, 0xff, 0xc6, 0x0d, 0x17, 0xb2, 0x2c, - 0x2a, 0x0a, 0xc8, 0x2b, 0xf4, 0xa8, 0x46, 0xaf, 0x5d, 0x79, 0xd2, 0xa8, 0xd3, 0x24, 0x58, 0xf8, - 0x81, 0x00, 0xbd, 0xcc, 0x21, 0x54, 0x91, 0xc9, 0x42, 0xa5, 0xe1, 0x9d, 0x7f, 0xb4, 0x8f, 0xbb, - 0xa8, 0x7f, 0x3e, 0xea, 0x91, 0xc3, 0x6e, 0x4e, 0x3a, 0x3b, 0x22, 0xaf, 0xf5, 0x8b, 0x59, 0x64, - 0xb2, 0xf1, 0xc9, 0xe6, 0xe7, 0xce, 0x9b, 0x5f, 0x8a, 0xc3, 0x64, 0x56, 0x3b, 0x8c, 0x17, 0x9b, - 0x1d, 0x46, 0xdb, 0x1d, 0x46, 0xbf, 0x3b, 0x8c, 0x3e, 0xf7, 0xd8, 0xdb, 0xee, 0xb1, 0xf7, 0xbd, - 0xc7, 0xde, 0xdb, 0x4b, 0xca, 0x4d, 0xb6, 0x8a, 0x2b, 0x4b, 0xca, 0x64, 0x29, 0x64, 0x49, 0x79, - 0xcc, 0x06, 0xa9, 0xa4, 0xf6, 0x99, 0x0a, 0x99, 0xac, 0x72, 0x28, 0xdd, 0xf6, 0x07, 0xff, 0xf5, - 0x9b, 0xb5, 0x82, 0x32, 0x3e, 0xad, 0xcb, 0x79, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x34, 0xa3, - 0x29, 0x7a, 0xa4, 0x01, 0x00, 0x00, +var fileDescriptor_740f6a3702ba2291 = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcf, 0x4a, 0xc3, 0x30, + 0x1c, 0xc7, 0x1b, 0x15, 0x75, 0xf5, 0x22, 0x45, 0x71, 0x4c, 0x88, 0x63, 0x07, 0xdd, 0x65, 0x09, + 0x9b, 0x20, 0x08, 0x9e, 0xe6, 0x69, 0x07, 0x61, 0xec, 0xb0, 0x83, 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0xdb, 0xdf, 0x3b, 0x67, 0x71, 0x29, 0x9a, 0xc9, 0xbc, 0x34, 0x4c, 0x97, 0xdb, 0x3d, + 0x46, 0xbb, 0x3d, 0x46, 0x7f, 0x7b, 0x8c, 0xbe, 0x0e, 0xd8, 0xd9, 0x1d, 0xb0, 0xf3, 0x73, 0xc0, + 0xce, 0xfb, 0x4b, 0xcc, 0x4d, 0xb2, 0x0e, 0x0b, 0x25, 0x65, 0x32, 0x17, 0x32, 0xa7, 0x3c, 0x64, + 0xa3, 0x58, 0x52, 0xfb, 0x4c, 0x85, 0x8c, 0xd6, 0x29, 0xe4, 0xed, 0xce, 0x47, 0x75, 0xe9, 0x66, + 0xa3, 0x20, 0x0f, 0x4f, 0xcb, 0x5e, 0x1e, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x94, 0x68, 0x6c, + 0x3f, 0x9a, 0x01, 0x00, 0x00, } -func (m *Counterparty) Marshal() (dAtA []byte, err error) { +func (m *Channel) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -132,12 +138,12 @@ func (m *Counterparty) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { +func (m *Channel) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -148,29 +154,29 @@ func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintCounterparty(dAtA, i, uint64(size)) + i = encodeVarintChannel(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a if len(m.CounterpartyChannelId) > 0 { i -= len(m.CounterpartyChannelId) copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i = encodeVarintChannel(dAtA, i, uint64(len(m.CounterpartyChannelId))) i-- dAtA[i] = 0x12 } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) - i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { - offset -= sovCounterparty(v) +func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { + offset -= sovChannel(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -180,7 +186,7 @@ func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Counterparty) Size() (n int) { +func (m *Channel) Size() (n int) { if m == nil { return 0 } @@ -188,24 +194,24 @@ func (m *Counterparty) Size() (n int) { _ = l l = len(m.ClientId) if l > 0 { - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) } l = len(m.CounterpartyChannelId) if l > 0 { - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) } l = m.MerklePathPrefix.Size() - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) return n } -func sovCounterparty(x uint64) (n int) { +func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozCounterparty(x uint64) (n int) { - return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozChannel(x uint64) (n int) { + return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Counterparty) Unmarshal(dAtA []byte) error { +func (m *Channel) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -213,7 +219,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -228,10 +234,10 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + return fmt.Errorf("proto: Channel: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Channel: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -241,7 +247,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -255,11 +261,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -273,7 +279,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -287,11 +293,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -305,7 +311,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -318,11 +324,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -333,12 +339,12 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCounterparty(dAtA[iNdEx:]) + skippy, err := skipChannel(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -352,7 +358,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } return nil } -func skipCounterparty(dAtA []byte) (n int, err error) { +func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -360,7 +366,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -377,7 +383,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -393,7 +399,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -406,14 +412,14 @@ func skipCounterparty(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthCounterparty + return 0, ErrInvalidLengthChannel } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCounterparty + return 0, ErrUnexpectedEndOfGroupChannel } depth-- case 5: @@ -422,7 +428,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthCounterparty + return 0, ErrInvalidLengthChannel } if depth == 0 { return iNdEx, nil @@ -432,7 +438,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") ) diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/channel_test.go similarity index 89% rename from modules/core/packet-server/types/counterparty_test.go rename to modules/core/packet-server/types/channel_test.go index 462861a211d..f5d6948a23b 100644 --- a/modules/core/packet-server/types/counterparty_test.go +++ b/modules/core/packet-server/types/channel_test.go @@ -11,7 +11,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -func TestValidateCounterparty(t *testing.T) { +func TestValidateChannel(t *testing.T) { testCases := []struct { name string clientID string @@ -66,22 +66,22 @@ func TestValidateCounterparty(t *testing.T) { ibctesting.FirstClientID, ibctesting.FirstChannelID, commitmenttypes.NewMerklePath(), - types.ErrInvalidCounterparty, + types.ErrInvalidChannel, }, { "failure: empty key in merkle path prefix first element", ibctesting.FirstClientID, ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), - types.ErrInvalidCounterparty, + types.ErrInvalidChannel, }, } for _, tc := range testCases { tc := tc - counterparty := types.NewCounterparty(tc.clientID, tc.channelID, tc.merklePathPrefix) - err := counterparty.Validate() + channel := types.NewChannel(tc.clientID, tc.channelID, tc.merklePathPrefix) + err := channel.Validate() expPass := tc.expError == nil if expPass { diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go index a38e7eaa18f..1c2d5cb3481 100644 --- a/modules/core/packet-server/types/errors.go +++ b/modules/core/packet-server/types/errors.go @@ -5,6 +5,6 @@ import ( ) var ( - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") - ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") ) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 176de889391..1fa932c4efd 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -39,8 +39,8 @@ type ChannelKeeper interface { // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) - // GetV2Counterparty returns a version 2 counterparty for a given portID and channel ID - GetV2Counterparty(ctx context.Context, portID, channelID string) (Counterparty, bool) + // GetV2Channel returns a version 2 channel for a given portID and channel ID + GetV2Channel(ctx context.Context, portID, channelID string) (Channel, bool) } type ClientKeeper interface { diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index b6edf17dc7b..fcbeb56d5e4 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -4,10 +4,10 @@ const ( // SubModuleName defines the IBC packet server name. SubModuleName = "packetserver" - // CounterpartyKey is the key used to store counterparty in the client store. - // the counterparty key is imported from types instead of host because - // the counterparty key is not a part of the ics-24 host specification - CounterpartyKey = "counterparty" + // ChannelKey is the key used to store channel in the client store. + // the channel key is imported from types instead of host because + // the channel key is not a part of the ics-24 host specification + ChannelKey = "channel" // CreatorKey is the key used to store the client creator in the client store // the creator key is imported from types instead of host because diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index bac3552e9f1..c6af4cf8684 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -95,7 +95,7 @@ func (s *TypesTestSuite) TestMsgCreateChannelValidateBasic() { host.ErrInvalidID, }, { - "failure: empty key path of counterparty of merkle path prefix", + "failure: empty key path", func() { msg.MerklePathPrefix.KeyPath = nil }, diff --git a/modules/core/packet-server/types/query.pb.go b/modules/core/packet-server/types/query.pb.go index 02d3e24447a..694ab5b79ba 100644 --- a/modules/core/packet-server/types/query.pb.go +++ b/modules/core/packet-server/types/query.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryClientRequest is the request type for the Query/Client RPC method -type QueryClientRequest struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +// QueryChannelRequest is the request type for the Query/Channel RPC method +type QueryChannelRequest struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` } -func (m *QueryClientRequest) Reset() { *m = QueryClientRequest{} } -func (m *QueryClientRequest) String() string { return proto.CompactTextString(m) } -func (*QueryClientRequest) ProtoMessage() {} -func (*QueryClientRequest) Descriptor() ([]byte, []int) { +func (m *QueryChannelRequest) Reset() { *m = QueryChannelRequest{} } +func (m *QueryChannelRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelRequest) ProtoMessage() {} +func (*QueryChannelRequest) Descriptor() ([]byte, []int) { return fileDescriptor_7ac0ae50eee8e6db, []int{0} } -func (m *QueryClientRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryChannelRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryClientRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryChannelRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,43 +55,43 @@ func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryClientRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientRequest.Merge(m, src) +func (m *QueryChannelRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelRequest.Merge(m, src) } -func (m *QueryClientRequest) XXX_Size() int { +func (m *QueryChannelRequest) XXX_Size() int { return m.Size() } -func (m *QueryClientRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientRequest.DiscardUnknown(m) +func (m *QueryChannelRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryChannelRequest proto.InternalMessageInfo -func (m *QueryClientRequest) GetClientId() string { +func (m *QueryChannelRequest) GetChannelId() string { if m != nil { - return m.ClientId + return m.ChannelId } return "" } -// QueryClientRequest is the response type for the Query/Client RPC method -type QueryClientResponse struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` +// QueryChannelRequest is the response type for the Query/Channel RPC method +type QueryChannelResponse struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Channel Channel `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel"` } -func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } -func (m *QueryClientResponse) String() string { return proto.CompactTextString(m) } -func (*QueryClientResponse) ProtoMessage() {} -func (*QueryClientResponse) Descriptor() ([]byte, []int) { +func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } +func (m *QueryChannelResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelResponse) ProtoMessage() {} +func (*QueryChannelResponse) Descriptor() ([]byte, []int) { return fileDescriptor_7ac0ae50eee8e6db, []int{1} } -func (m *QueryClientResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryChannelResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryClientResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryChannelResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -101,35 +101,35 @@ func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientResponse.Merge(m, src) +func (m *QueryChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelResponse.Merge(m, src) } -func (m *QueryClientResponse) XXX_Size() int { +func (m *QueryChannelResponse) XXX_Size() int { return m.Size() } -func (m *QueryClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientResponse.DiscardUnknown(m) +func (m *QueryChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryClientResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryChannelResponse proto.InternalMessageInfo -func (m *QueryClientResponse) GetCreator() string { +func (m *QueryChannelResponse) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *QueryClientResponse) GetCounterparty() Counterparty { +func (m *QueryChannelResponse) GetChannel() Channel { if m != nil { - return m.Counterparty + return m.Channel } - return Counterparty{} + return Channel{} } func init() { - proto.RegisterType((*QueryClientRequest)(nil), "ibc.core.packetserver.v1.QueryClientRequest") - proto.RegisterType((*QueryClientResponse)(nil), "ibc.core.packetserver.v1.QueryClientResponse") + proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.packetserver.v1.QueryChannelRequest") + proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.packetserver.v1.QueryChannelResponse") } func init() { @@ -137,30 +137,29 @@ func init() { } var fileDescriptor_7ac0ae50eee8e6db = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3d, 0x4b, 0x2b, 0x41, - 0x14, 0xdd, 0x09, 0xef, 0xe5, 0xbd, 0xcc, 0x7b, 0xd5, 0x68, 0xb1, 0x44, 0x59, 0x43, 0x10, 0x8d, - 0x68, 0x76, 0x48, 0xac, 0x04, 0xab, 0xa4, 0xb2, 0xd3, 0x14, 0x16, 0x36, 0xb2, 0x3b, 0xb9, 0xac, - 0x8b, 0xc9, 0xde, 0xcd, 0xcc, 0xec, 0x42, 0x10, 0x0b, 0xfd, 0x05, 0x82, 0x60, 0xed, 0xcf, 0x49, - 0x19, 0xb0, 0xb1, 0x12, 0x49, 0xfc, 0x21, 0xb2, 0x1f, 0x86, 0x0d, 0x12, 0xb0, 0xbb, 0x73, 0xe7, - 0x9c, 0xc3, 0x39, 0xf7, 0xd0, 0x6d, 0xdf, 0x15, 0x5c, 0xa0, 0x04, 0x1e, 0x3a, 0xe2, 0x1a, 0xb4, - 0x02, 0x19, 0x83, 0xe4, 0x71, 0x8b, 0x8f, 0x22, 0x90, 0x63, 0x3b, 0x94, 0xa8, 0x91, 0x99, 0xbe, - 0x2b, 0xec, 0x04, 0x65, 0x17, 0x51, 0x76, 0xdc, 0xaa, 0xee,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- 0x5b, 0xc6, 0xeb, 0xdc, 0x32, 0x2e, 0x8e, 0x3d, 0x5f, 0x5f, 0x45, 0xae, 0x2d, 0x70, 0xc8, 0x05, - 0xaa, 0x21, 0xaa, 0x44, 0xb3, 0xe9, 0x21, 0x8f, 0x8f, 0xf8, 0x10, 0xfb, 0xd1, 0x00, 0x54, 0xb1, - 0xf4, 0x66, 0xde, 0xba, 0x1e, 0x87, 0xa0, 0xdc, 0x72, 0x5a, 0xdc, 0xe1, 0x67, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x90, 0xb9, 0x8b, 0xca, 0x5b, 0x02, 0x00, 0x00, + // 351 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x4b, 0x03, 0x31, + 0x14, 0xc7, 0x2f, 0x45, 0x2d, 0x8d, 0x5b, 0xec, 0x70, 0x14, 0x3d, 0x6b, 0x11, 0xa9, 0x48, 0x13, + 0x5a, 0x5d, 0x04, 0x17, 0xeb, 0xe4, 0x68, 0x07, 0x07, 0x17, 0xb9, 0x4b, 0xc3, 0xf5, 0xb0, 0xbd, + 0x77, 0x4d, 0x72, 0x07, 0x45, 0x5c, 0xfc, 0x04, 0x82, 0xa3, 0xb3, 0xdf, 0xa5, 0x63, 0xc1, 0xc5, + 0x49, 0xa4, 0xf5, 0x83, 0xc8, 0xf5, 0xd2, 0x5a, 0xc1, 0x03, 0xb7, 0x97, 0x97, 0xff, 0xff, 0x97, + 0xf7, 0xf2, 0xc7, 0xfb, 0x81, 0xc7, 0x19, 0x07, 0x29, 0x58, 0xe4, 0xf2, 0x3b, 0xa1, 0x95, 0x90, + 0x89, 0x90, 0x2c, 0x69, 0xb2, 0x61, 0x2c, 0xe4, 0x88, 0x46, 0x12, 0x34, 0x10, 0x3b, 0xf0, 0x38, + 0x4d, 0x55, 0x74, 0x55, 0x45, 0x93, 0x66, 0xe5, 0x20, 0xd7, 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+ 0x8f, 0x72, 0x18, 0x30, 0x0e, 0x6a, 0x00, 0x2a, 0xa5, 0x36, 0x7c, 0x60, 0xc9, 0x29, 0x1b, 0x40, + 0x37, 0xee, 0x0b, 0xb5, 0x1a, 0x74, 0xc3, 0x24, 0xad, 0x47, 0x91, 0x50, 0xde, 0xc6, 0x3c, 0xb1, + 0xe3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xe3, 0xea, 0xfa, 0x4f, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -175,8 +174,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Client queries the counterparty of an IBC client. - Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) + // Channel queries the counterparty of an IBC client. + Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) } type queryClient struct { @@ -187,9 +186,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) { - out := new(QueryClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Client", in, out, opts...) +func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) { + out := new(QueryChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Channel", in, out, opts...) if err != nil { return nil, err } @@ -198,36 +197,36 @@ func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { - // Client queries the counterparty of an IBC client. - Client(context.Context, *QueryClientRequest) (*QueryClientResponse, error) + // Channel queries the counterparty of an IBC client. + Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Client(ctx context.Context, req *QueryClientRequest) (*QueryClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Client not implemented") +func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryClientRequest) +func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Client(ctx, in) + return srv.(QueryServer).Channel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.packetserver.v1.Query/Client", + FullMethod: "/ibc.core.packetserver.v1.Query/Channel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Client(ctx, req.(*QueryClientRequest)) + return srv.(QueryServer).Channel(ctx, req.(*QueryChannelRequest)) } return interceptor(ctx, in, info, handler) } @@ -237,15 +236,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Client", - Handler: _Query_Client_Handler, + MethodName: "Channel", + Handler: _Query_Channel_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/packetserver/v1/query.proto", } -func (m *QueryClientRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryChannelRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -255,27 +254,27 @@ func (m *QueryClientRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryClientRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryChannelRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryClientRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryClientResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryChannelResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -285,18 +284,18 @@ func (m *QueryClientResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryClientResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryChannelResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -326,20 +325,20 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryClientRequest) Size() (n int) { +func (m *QueryChannelRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ClientId) + l = len(m.ChannelId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryClientResponse) Size() (n int) { +func (m *QueryChannelResponse) Size() (n int) { if m == nil { return 0 } @@ -349,7 +348,7 @@ func (m *QueryClientResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = m.Counterparty.Size() + l = m.Channel.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -360,7 +359,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { +func (m *QueryChannelRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -383,15 +382,15 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryClientRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryChannelRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryChannelRequest: 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) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -419,7 +418,7 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -442,7 +441,7 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { +func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -465,10 +464,10 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryClientResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryChannelResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -505,7 +504,7 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -532,7 +531,7 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/modules/core/packet-server/types/query.pb.gw.go b/modules/core/packet-server/types/query.pb.gw.go index dbe2224a7b8..caea72e9575 100644 --- a/modules/core/packet-server/types/query.pb.gw.go +++ b/modules/core/packet-server/types/query.pb.gw.go @@ -33,8 +33,8 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest +func request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelRequest var metadata runtime.ServerMetadata var ( @@ -44,24 +44,24 @@ func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, cl _ = err ) - val, ok = pathParams["client_id"] + val, ok = pathParams["channel_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ClientId, err = runtime.String(val) + protoReq.ChannelId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := client.Client(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Channel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest +func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelRequest var metadata runtime.ServerMetadata var ( @@ -71,18 +71,18 @@ func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshal _ = err ) - val, ok = pathParams["client_id"] + val, ok = pathParams["channel_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ClientId, err = runtime.String(val) + protoReq.ChannelId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := server.Client(ctx, &protoReq) + msg, err := server.Channel(ctx, &protoReq) return msg, metadata, err } @@ -93,7 +93,7 @@ func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshal // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -104,7 +104,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Client_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Channel_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -112,7 +112,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -157,7 +157,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -166,14 +166,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Client_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Channel_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -181,9 +181,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Client_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "clients", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 2, 1, 0, 4, 1, 5, 4}, []string{"ibc", "core", "channel", "v2", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Client_0 = runtime.ForwardResponseMessage + forward_Query_Channel_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/channel.proto similarity index 59% rename from proto/ibc/core/packetserver/v1/counterparty.proto rename to proto/ibc/core/packetserver/v1/channel.proto index f708694b21e..8ff15c78023 100644 --- a/proto/ibc/core/packetserver/v1/counterparty.proto +++ b/proto/ibc/core/packetserver/v1/channel.proto @@ -7,8 +7,14 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/type import "gogoproto/gogo.proto"; import "ibc/core/commitment/v2/commitment.proto"; -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -message Counterparty { +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +message Channel { // the client identifier of the light client representing the counterparty chain string client_id = 1; // the counterparty identifier that must be used by the packet diff --git a/proto/ibc/core/packetserver/v1/query.proto b/proto/ibc/core/packetserver/v1/query.proto index f056da89c32..f429a185e87 100644 --- a/proto/ibc/core/packetserver/v1/query.proto +++ b/proto/ibc/core/packetserver/v1/query.proto @@ -4,25 +4,25 @@ package ibc.core.packetserver.v1; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; -import "ibc/core/packetserver/v1/counterparty.proto"; +import "ibc/core/packetserver/v1/channel.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; // Query provides defines the gRPC querier service service Query { - // Client queries the counterparty of an IBC client. - rpc Client(QueryClientRequest) returns (QueryClientResponse) { - option (google.api.http).get = "/ibc/core/client/v1/clients/{client_id}"; + // Channel queries the counterparty of an IBC client. + rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channel/{channel_id}"; } } -// QueryClientRequest is the request type for the Query/Client RPC method -message QueryClientRequest { - string client_id = 1; +// QueryChannelRequest is the request type for the Query/Channel RPC method +message QueryChannelRequest { + string channel_id = 1; } -// QueryClientRequest is the response type for the Query/Client RPC method -message QueryClientResponse { - string creator = 1; - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; +// QueryChannelRequest is the response type for the Query/Channel RPC method +message QueryChannelResponse { + string creator = 1; + Channel channel = 2 [(gogoproto.nullable) = false]; } diff --git a/testing/values.go b/testing/values.go index 9571004c2db..79c995b4974 100644 --- a/testing/values.go +++ b/testing/values.go @@ -22,10 +22,12 @@ import ( ) const ( - FirstClientID = "07-tendermint-0" - SecondClientID = "07-tendermint-1" - FirstChannelID = "channel-0" - FirstConnectionID = "connection-0" + FirstClientID = "07-tendermint-0" + SecondClientID = "07-tendermint-1" + FirstChannelID = "channel-0" + SecondChannelID = "channel-1" + FirstConnectionID = "connection-0" + SecondConnectionID = "connection-1" // Default params constants used to create a TM client TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 From b59528424c5fcd952c6100018249f2e797d08a2d Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 10 Oct 2024 10:46:15 +0200 Subject: [PATCH 062/172] feat: add acknowledgePacket handler to channel/v2 (#7412) * chore: add commitment.go with temporary commit acknowledgement func * feat: impl acknowledgePacket handler in channel/v2 * nit: vanity nits * chore: add placeholder event func and logs * chore: fix conflict and address todo * nit: update to pointer recvr args * chore: update ids in log --- modules/core/04-channel/v2/keeper/events.go | 13 ++- modules/core/04-channel/v2/keeper/keeper.go | 35 ++++++-- .../core/04-channel/v2/keeper/msg_server.go | 38 ++++++++- .../v2/keeper/{relay.go => packet.go} | 82 ++++++++++++++----- .../core/04-channel/v2/types/commitment.go | 55 +++++++++++++ modules/core/04-channel/v2/types/packet.go | 39 --------- 6 files changed, 191 insertions(+), 71 deletions(-) rename modules/core/04-channel/v2/keeper/{relay.go => packet.go} (79%) create mode 100644 modules/core/04-channel/v2/types/commitment.go diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index e1ffea106ff..9d90ff5b36e 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -11,12 +11,17 @@ func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } -// EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. -func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +// EmitRecvPacketEvents emits events for the RecvPacket handler. +func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } -// EmitRecvPacketEvents emits events for the RecvPacket handler. -func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +// EmitAcknowledgePacketEvents emits events for the AcknowledgePacket handler. +func EmitAcknowledgePacketEvents(ctx context.Context, packet channeltypesv2.Packet) { + // TODO: https://github.com/cosmos/ibc-go/issues/7386 +} + +// EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. +func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index b6223402a6d..4a5058d537e 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -75,16 +75,27 @@ func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Co } // GetPacketReceipt returns the packet receipt from the packet receipt path based on the sourceID and sequence. -func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) (string, bool) { +func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) ([]byte, bool) { store := k.storeService.OpenKVStore(ctx) bz, err := store.Get(hostv2.PacketReceiptKey(sourceID, sequence)) if err != nil { panic(err) } if len(bz) == 0 { - return "", false + return nil, false } - return string(bz), true + return bz, true +} + +// HasPacketRceipt returns true if the packet receipt exists, otherwise false. +func (k *Keeper) HasPacketReceipt(ctx context.Context, sourceID string, sequence uint64) bool { + store := k.storeService.OpenKVStore(ctx) + has, err := store.Has(hostv2.PacketReceiptKey(sourceID, sequence)) + if err != nil { + panic(err) + } + + return has } // SetPacketReceipt writes the packet receipt under the receipt path @@ -117,16 +128,16 @@ func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, } // GetPacketCommitment returns the packet commitment hash under the commitment path. -func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, sequence uint64) (string, bool) { +func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, sequence uint64) []byte { store := k.storeService.OpenKVStore(ctx) bz, err := store.Get(hostv2.PacketCommitmentKey(sourceID, sequence)) if err != nil { panic(err) } if len(bz) == 0 { - return "", false + return nil } - return string(bz), true + return bz } // SetPacketCommitment writes the commitment hash under the commitment path. @@ -192,3 +203,15 @@ func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) ( } return counterparty, true } + +// getV1Counterparty attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it +// to a v2 counterparty and stores it in the v2 channel keeper for future use +func (k *Keeper) getV1Counterparty(ctx context.Context, port, id string) (types.Counterparty, bool) { + if counterparty, ok := k.AliasV1Channel(ctx, port, id); ok { + // we can key on just the channel here since channel ids are globally unique + k.SetCounterparty(ctx, id, counterparty) + return counterparty, true + } + + return types.Counterparty{}, false +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 819e3a6549e..53e6327d1c8 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -43,8 +43,42 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil } -func (*Keeper) Acknowledgement(ctx context.Context, acknowledgement *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { - panic("implement me") +func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + relayer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + sdkCtx.Logger().Error("acknowledgement failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") + } + + cacheCtx, writeFn := sdkCtx.CacheContext() + err = k.acknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + + switch err { + case nil: + writeFn() + case channeltypesv1.ErrNoOpMsg: + // no-ops do not need event emission as they will be ignored + sdkCtx.Logger().Debug("no-op on redundant relay", "source-id", msg.Packet.SourceChannel) + return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil + default: + sdkCtx.Logger().Error("acknowledgement failed", "source-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) + return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") + } + + _ = relayer + + // TODO: implement once app router is wired up. + // https://github.com/cosmos/ibc-go/issues/7384 + // for _, pd := range msg.PacketData { + // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) + // err := cbs.OnSendPacket(ctx, msg.SourceId, sequence, msg.TimeoutTimestamp, pd, signer) + // if err != nil { + // return nil, err + // } + // } + + return nil, nil } // RecvPacket implements the PacketMsgServer RecvPacket method. diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/packet.go similarity index 79% rename from modules/core/04-channel/v2/keeper/relay.go rename to modules/core/04-channel/v2/keeper/packet.go index 1bedc747b25..72f2b3ee82c 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -17,18 +17,6 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// getV1Counterparty attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it -// to a v2 counterparty and stores it in the v2 channel keeper for future use -func (k *Keeper) getV1Counterparty(ctx context.Context, port, id string) (channeltypesv2.Counterparty, bool) { - if counterparty, ok := k.AliasV1Channel(ctx, port, id); ok { - // we can key on just the channel here since channel ids are globally unique - k.SetCounterparty(ctx, id, counterparty) - return counterparty, true - } - - return channeltypesv2.Counterparty{}, false -} - // sendPacket constructs a packet from the input arguments, writes a packet commitment to state // in order for the packet to be sent to the counterparty. func (k *Keeper) sendPacket( @@ -106,7 +94,7 @@ func (k *Keeper) sendPacket( // The packet handler will verify that the packet has not timed out and that the // counterparty stored a packet commitment. If successful, a packet receipt is stored // to indicate to the counterparty successful delivery. -func (k Keeper) recvPacket( +func (k *Keeper) recvPacket( ctx context.Context, packet channeltypesv2.Packet, proof []byte, @@ -137,8 +125,7 @@ func (k Keeper) recvPacket( // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. - _, found := k.GetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) - if found { + if k.HasPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) { EmitRecvPacketEvents(ctx, packet) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction @@ -173,6 +160,62 @@ func (k Keeper) recvPacket( return nil } +func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Packet, acknowledgement channeltypesv2.Acknowledgement, proof []byte, proofHeight exported.Height) error { + // Lookup counterparty associated with our channel and ensure + // that the packet was indeed sent by our counterparty. + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) + } + + if counterparty.ClientId != packet.DestinationChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + clientID := counterparty.ClientId + + commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + if len(commitment) == 0 { + // TODO: signal noop in events? + EmitAcknowledgePacketEvents(ctx, packet) + + // This error indicates that the acknowledgement has already been relayed + // or there is a misconfigured relayer attempting to prove an acknowledgement + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypesv2.CommitPacket(packet) + + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + } + + path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + clientID, + proofHeight, + 0, 0, + proof, + merklePath, + channeltypesv2.CommitAcknowledgement(acknowledgement), + ); err != nil { + return errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) + } + + k.DeletePacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + + k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "source_channel_id", packet.GetSourceChannel(), "destination_channel_id", packet.GetDestinationChannel()) + + EmitAcknowledgePacketEvents(ctx, packet) + + return nil +} + // timeoutPacket implements the timeout logic required by a packet handler. // The packet is checked for correctness including asserting that the packet was // sent and received on clients which are counterparties for one another. @@ -180,7 +223,7 @@ func (k Keeper) recvPacket( // an absence proof of the packet receipt is performed to ensure that the packet // was never delivered to the counterparty. If successful, the packet commitment // is deleted and the packet has completed its lifecycle. -func (k Keeper) timeoutPacket( +func (k *Keeper) timeoutPacket( ctx context.Context, packet channeltypesv2.Packet, proof []byte, @@ -209,9 +252,8 @@ func (k Keeper) timeoutPacket( } // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment, ok := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) - - if !ok { + commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + if len(commitment) == 0 { EmitTimeoutPacketEvents(ctx, packet) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout @@ -222,7 +264,7 @@ func (k Keeper) timeoutPacket( packetCommitment := channeltypesv2.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal([]byte(commitment), packetCommitment) { + if !bytes.Equal(commitment, packetCommitment) { return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) } diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go new file mode 100644 index 00000000000..1bde0803ad8 --- /dev/null +++ b/modules/core/04-channel/v2/types/commitment.go @@ -0,0 +1,55 @@ +package types + +import ( + "crypto/sha256" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// CommitPacket returns the V2 packet commitment bytes. The commitment consists of: +// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(packetData) from a given packet. +// This results in a fixed length preimage. +// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able +// to malleate the packet fields and create a commitment hash that matches the original packet. +func CommitPacket(packet Packet) []byte { + buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) + + destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) + buf = append(buf, destIDHash[:]...) + + for _, data := range packet.Data { + buf = append(buf, hashPacketData(data)...) + } + + hash := sha256.Sum256(buf) + return hash[:] +} + +// hashPacketData returns the hash of the packet data. +func hashPacketData(data PacketData) []byte { + var buf []byte + sourceHash := sha256.Sum256([]byte(data.SourcePort)) + buf = append(buf, sourceHash[:]...) + destHash := sha256.Sum256([]byte(data.DestinationPort)) + buf = append(buf, destHash[:]...) + payloadValueHash := sha256.Sum256(data.Payload.Value) + buf = append(buf, payloadValueHash[:]...) + payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) + buf = append(buf, payloadEncodingHash[:]...) + payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) + buf = append(buf, payloadVersionHash[:]...) + hash := sha256.Sum256(buf) + return hash[:] +} + +// CommitAcknowledgement returns the hash of the acknowledgement data. +func CommitAcknowledgement(acknowledgement Acknowledgement) []byte { + var buf []byte + for _, ack := range acknowledgement.GetAcknowledgementResults() { + hash := sha256.Sum256(ack.RecvPacketResult.GetAcknowledgement()) + buf = append(buf, hash[:]...) + } + + hash := sha256.Sum256(buf) + return hash[:] +} diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 6cf39b0372f..81dd8905e14 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -1,13 +1,10 @@ package types import ( - "crypto/sha256" "strings" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) @@ -87,39 +84,3 @@ func (p Payload) Validate() error { } return nil } - -// CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(packetData) from a given packet. -// This results in a fixed length preimage. -// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able -// to malleate the packet fields and create a commitment hash that matches the original packet. -func CommitPacket(packet Packet) []byte { - buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) - - destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) - buf = append(buf, destIDHash[:]...) - - for _, data := range packet.Data { - buf = append(buf, hashPacketData(data)...) - } - - hash := sha256.Sum256(buf) - return hash[:] -} - -// hashPacketData returns the hash of the packet data. -func hashPacketData(data PacketData) []byte { - var buf []byte - sourceHash := sha256.Sum256([]byte(data.SourcePort)) - buf = append(buf, sourceHash[:]...) - destHash := sha256.Sum256([]byte(data.DestinationPort)) - buf = append(buf, destHash[:]...) - payloadValueHash := sha256.Sum256(data.Payload.Value) - buf = append(buf, payloadValueHash[:]...) - payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) - buf = append(buf, payloadEncodingHash[:]...) - payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) - buf = append(buf, payloadVersionHash[:]...) - hash := sha256.Sum256(buf) - return hash[:] -} From 56be85b716dbe8b67a339044dad0d060d570f691 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:56:42 +0200 Subject: [PATCH 063/172] channel/v2: Rename Counterparty to Channel (#7432) * rename counterparty to channel in v2 folder * rename getV1Channel to getV2Channel * fix var naming err from last pr --- modules/core/04-channel/v2/keeper/keeper.go | 44 +- .../core/04-channel/v2/keeper/keeper_test.go | 8 +- modules/core/04-channel/v2/keeper/packet.go | 31 +- .../v2/types/{counterparty.go => channel.go} | 12 +- .../core/04-channel/v2/types/channel.pb.go | 1697 ++-------------- .../04-channel/v2/types/counterparty.pb.go | 438 ----- modules/core/04-channel/v2/types/errors.go | 8 +- modules/core/04-channel/v2/types/keys.go | 8 +- modules/core/04-channel/v2/types/packet.pb.go | 1747 +++++++++++++++++ modules/core/04-channel/v2/types/tx.pb.go | 94 +- .../core/packet-server/client/cli/query.go | 4 +- proto/ibc/core/channel/v2/channel.proto | 86 +- proto/ibc/core/channel/v2/counterparty.proto | 20 - proto/ibc/core/channel/v2/packet.proto | 75 + proto/ibc/core/channel/v2/tx.proto | 2 +- 15 files changed, 2143 insertions(+), 2131 deletions(-) rename modules/core/04-channel/v2/types/{counterparty.go => channel.go} (63%) delete mode 100644 modules/core/04-channel/v2/types/counterparty.pb.go create mode 100644 modules/core/04-channel/v2/types/packet.pb.go delete mode 100644 proto/ibc/core/channel/v2/counterparty.proto create mode 100644 proto/ibc/core/channel/v2/packet.proto diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 4a5058d537e..4be8251a74a 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -55,23 +55,23 @@ func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.K return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } -// SetCounterparty sets the Counterparty for a given client identifier. -func (k *Keeper) SetCounterparty(ctx context.Context, clientID string, counterparty types.Counterparty) { - bz := k.cdc.MustMarshal(&counterparty) - k.ChannelStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) +// SetChannel sets the Channel for a given client identifier. +func (k *Keeper) SetChannel(ctx context.Context, clientID string, channel types.Channel) { + bz := k.cdc.MustMarshal(&channel) + k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) } -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Counterparty, bool) { +// GetChannel gets the Channel for a given client identifier. +func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel, bool) { store := k.ChannelStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) + bz := store.Get([]byte(types.ChannelKey)) if len(bz) == 0 { - return types.Counterparty{}, false + return types.Channel{}, false } - var counterparty types.Counterparty - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true + var channel types.Channel + k.cdc.MustUnmarshal(bz, &channel) + return channel, true } // GetPacketReceipt returns the packet receipt from the packet receipt path based on the sourceID and sequence. @@ -180,38 +180,38 @@ func (k *Keeper) SetNextSequenceSend(ctx context.Context, sourceID string, seque // AliasV1Channel returns a version 2 channel for the given port and channel ID // by converting the channel into a version 2 channel. -func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Counterparty, bool) { +func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { channel, ok := k.channelKeeperV1.GetChannel(ctx, portID, channelID) if !ok { - return types.Counterparty{}, false + return types.Channel{}, false } - // Do not allow channel to be converted into a version 2 counterparty + // Do not allow channel to be converted into a version 2 channel // if the channel is not OPEN or if it is ORDERED if channel.State != channeltypesv1.OPEN || channel.Ordering == channeltypesv1.ORDERED { - return types.Counterparty{}, false + return types.Channel{}, false } connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) if !ok { - return types.Counterparty{}, false + return types.Channel{}, false } merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - counterparty := types.Counterparty{ + channelv2 := types.Channel{ CounterpartyChannelId: channel.Counterparty.ChannelId, ClientId: connection.ClientId, MerklePathPrefix: merklePathPrefix, } - return counterparty, true + return channelv2, true } -// getV1Counterparty attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it +// convertV1Channel attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it // to a v2 counterparty and stores it in the v2 channel keeper for future use -func (k *Keeper) getV1Counterparty(ctx context.Context, port, id string) (types.Counterparty, bool) { +func (k *Keeper) convertV1Channel(ctx context.Context, port, id string) (types.Channel, bool) { if counterparty, ok := k.AliasV1Channel(ctx, port, id); ok { // we can key on just the channel here since channel ids are globally unique - k.SetCounterparty(ctx, id, counterparty) + k.SetChannel(ctx, id, counterparty) return counterparty, true } - return types.Counterparty{}, false + return types.Channel{}, false } diff --git a/modules/core/04-channel/v2/keeper/keeper_test.go b/modules/core/04-channel/v2/keeper/keeper_test.go index 07269aeb645..80363d813d7 100644 --- a/modules/core/04-channel/v2/keeper/keeper_test.go +++ b/modules/core/04-channel/v2/keeper/keeper_test.go @@ -92,17 +92,17 @@ func (suite *KeeperTestSuite) TestAliasV1Channel() { tc.malleate() - counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2.AliasV1Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2.AliasV1Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) if tc.expPass { suite.Require().True(found) merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expCounterparty := channeltypes2.NewCounterparty(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) - suite.Require().Equal(counterparty, expCounterparty) + expChannel := channeltypes2.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + suite.Require().Equal(channel, expChannel) } else { suite.Require().False(found) - suite.Require().Equal(counterparty, channeltypes2.Counterparty{}) + suite.Require().Equal(channel, channeltypes2.Channel{}) } }) } diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 72f2b3ee82c..8fb946186fa 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -25,18 +25,18 @@ func (k *Keeper) sendPacket( timeoutTimestamp uint64, data []channeltypesv2.PacketData, ) (uint64, error) { - // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.GetCounterparty(ctx, sourceID) + // Lookup channel associated with our source channel to retrieve the destination channel + channel, ok := k.GetChannel(ctx, sourceID) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - counterparty, ok = k.getV1Counterparty(ctx, data[0].SourcePort, sourceID) + channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceID) if !ok { return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceID) } } - destID := counterparty.CounterpartyChannelId - clientID := counterparty.ClientId + destID := channel.CounterpartyChannelId + clientID := channel.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -100,17 +100,18 @@ func (k *Keeper) recvPacket( proof []byte, proofHeight exported.Height, ) error { - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + // Lookup channel associated with destination channel ID and ensure + // that the packet was indeed sent by our counterparty by verifying + // packet sender is our channel's counterparty channel id. + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) + channel, ok = k.convertV1Channel(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } - if counterparty.ClientId != packet.SourceChannel { + if channel.ClientId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } @@ -134,7 +135,7 @@ func (k *Keeper) recvPacket( } path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) commitment := channeltypesv2.CommitPacket(packet) @@ -163,7 +164,7 @@ func (k *Keeper) recvPacket( func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Packet, acknowledgement channeltypesv2.Acknowledgement, proof []byte, proofHeight exported.Height) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } @@ -231,10 +232,10 @@ func (k *Keeper) timeoutPacket( ) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceChannel) + channel, ok = k.convertV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } @@ -270,7 +271,7 @@ func (k *Keeper) timeoutPacket( // verify packet receipt absence path := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/04-channel/v2/types/counterparty.go b/modules/core/04-channel/v2/types/channel.go similarity index 63% rename from modules/core/04-channel/v2/types/counterparty.go rename to modules/core/04-channel/v2/types/channel.go index d63a92da3e8..3a45be384fb 100644 --- a/modules/core/04-channel/v2/types/counterparty.go +++ b/modules/core/04-channel/v2/types/channel.go @@ -7,17 +7,17 @@ import ( host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) -// NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { - return Counterparty{ +// NewChannel creates a new Channel instance +func NewChannel(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Channel { + return Channel{ ClientId: clientID, CounterpartyChannelId: counterpartyChannelID, MerklePathPrefix: merklePathPrefix, } } -// Validate validates the Counterparty -func (c Counterparty) Validate() error { +// Validate validates the Channel +func (c Channel) Validate() error { if err := host.ClientIdentifierValidator(c.ClientId); err != nil { return err } @@ -27,7 +27,7 @@ func (c Counterparty) Validate() error { } if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) + return errorsmod.Wrap(ErrInvalidChannel, err.Error()) } return nil diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go index 2a9829af5d5..8666e2f8517 100644 --- a/modules/core/04-channel/v2/types/channel.pb.go +++ b/modules/core/04-channel/v2/types/channel.pb.go @@ -7,6 +7,7 @@ import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" io "io" math "math" math_bits "math/bits" @@ -23,1427 +24,192 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// PacketStatus specifies the status of a RecvPacketResult. -type PacketStatus int32 - -const ( - // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. - PacketStatus_NONE PacketStatus = 0 - // PACKET_STATUS_SUCCESS indicates a successful packet receipt. - PacketStatus_Success PacketStatus = 1 - // PACKET_STATUS_FAILURE indicates a failed packet receipt. - PacketStatus_Failure PacketStatus = 2 - // PACKET_STATUS_ASYNC indicates an async packet receipt. - PacketStatus_Async PacketStatus = 3 -) - -var PacketStatus_name = map[int32]string{ - 0: "PACKET_STATUS_UNSPECIFIED", - 1: "PACKET_STATUS_SUCCESS", - 2: "PACKET_STATUS_FAILURE", - 3: "PACKET_STATUS_ASYNC", -} - -var PacketStatus_value = map[string]int32{ - "PACKET_STATUS_UNSPECIFIED": 0, - "PACKET_STATUS_SUCCESS": 1, - "PACKET_STATUS_FAILURE": 2, - "PACKET_STATUS_ASYNC": 3, -} - -func (x PacketStatus) String() string { - return proto.EnumName(PacketStatus_name, int32(x)) -} - -func (PacketStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{0} -} - -// 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 sending chain. - SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` - // identifies the receiving chain. - DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` - // timeout timestamp after which the packet times out. - TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` - // a list of packet data, each one for a specific application. - Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` -} - -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_7e9b57d8f218397d, []int{0} -} -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 (m *Packet) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - -func (m *Packet) GetSourceChannel() string { - if m != nil { - return m.SourceChannel - } - return "" -} - -func (m *Packet) GetDestinationChannel() string { - if m != nil { - return m.DestinationChannel - } - return "" -} - -func (m *Packet) GetTimeoutTimestamp() uint64 { - if m != nil { - return m.TimeoutTimestamp - } - return 0 -} - -func (m *Packet) GetData() []PacketData { - if m != nil { - return m.Data - } - return nil -} - -// PacketData contains the source and destination ports and payload for the application -type PacketData struct { - // specifies the source port of the packet. - SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` - // specifies the destination port of the packet. - DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` - // the payload to be sent to the application. - Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` -} - -func (m *PacketData) Reset() { *m = PacketData{} } -func (m *PacketData) String() string { return proto.CompactTextString(m) } -func (*PacketData) ProtoMessage() {} -func (*PacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{1} -} -func (m *PacketData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PacketData.Merge(m, src) -} -func (m *PacketData) XXX_Size() int { - return m.Size() -} -func (m *PacketData) XXX_DiscardUnknown() { - xxx_messageInfo_PacketData.DiscardUnknown(m) -} - -var xxx_messageInfo_PacketData proto.InternalMessageInfo - -func (m *PacketData) GetSourcePort() string { - if m != nil { - return m.SourcePort - } - return "" -} - -func (m *PacketData) GetDestinationPort() string { - if m != nil { - return m.DestinationPort - } - return "" -} - -func (m *PacketData) GetPayload() Payload { - if m != nil { - return m.Payload - } - return Payload{} -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -type Payload struct { - // version of the specified application. - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - // the encoding used for the provided value. - Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` - // the raw bytes for the payload. - Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *Payload) Reset() { *m = Payload{} } -func (m *Payload) String() string { return proto.CompactTextString(m) } -func (*Payload) ProtoMessage() {} -func (*Payload) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{2} -} -func (m *Payload) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Payload.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 *Payload) XXX_Merge(src proto.Message) { - xxx_messageInfo_Payload.Merge(m, src) -} -func (m *Payload) XXX_Size() int { - return m.Size() -} -func (m *Payload) XXX_DiscardUnknown() { - xxx_messageInfo_Payload.DiscardUnknown(m) -} - -var xxx_messageInfo_Payload proto.InternalMessageInfo - -func (m *Payload) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *Payload) GetEncoding() string { - if m != nil { - return m.Encoding - } - return "" -} - -func (m *Payload) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -// Acknowledgement contains a list of all ack results associated with a single packet. -type Acknowledgement struct { - AcknowledgementResults []AcknowledgementResult `protobuf:"bytes,1,rep,name=acknowledgement_results,json=acknowledgementResults,proto3" json:"acknowledgement_results"` -} - -func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } -func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } -func (*Acknowledgement) ProtoMessage() {} -func (*Acknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{3} -} -func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Acknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Acknowledgement.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 *Acknowledgement) XXX_Merge(src proto.Message) { - xxx_messageInfo_Acknowledgement.Merge(m, src) -} -func (m *Acknowledgement) XXX_Size() int { - return m.Size() -} -func (m *Acknowledgement) XXX_DiscardUnknown() { - xxx_messageInfo_Acknowledgement.DiscardUnknown(m) -} - -var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo - -func (m *Acknowledgement) GetAcknowledgementResults() []AcknowledgementResult { - if m != nil { - return m.AcknowledgementResults - } - return nil -} - -// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. -type AcknowledgementResult struct { - AppName string `protobuf:"bytes,1,opt,name=app_name,json=appName,proto3" json:"app_name,omitempty"` - RecvPacketResult RecvPacketResult `protobuf:"bytes,2,opt,name=recv_packet_result,json=recvPacketResult,proto3" json:"recv_packet_result"` -} - -func (m *AcknowledgementResult) Reset() { *m = AcknowledgementResult{} } -func (m *AcknowledgementResult) String() string { return proto.CompactTextString(m) } -func (*AcknowledgementResult) ProtoMessage() {} -func (*AcknowledgementResult) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{4} -} -func (m *AcknowledgementResult) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AcknowledgementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AcknowledgementResult.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 *AcknowledgementResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_AcknowledgementResult.Merge(m, src) -} -func (m *AcknowledgementResult) XXX_Size() int { - return m.Size() -} -func (m *AcknowledgementResult) XXX_DiscardUnknown() { - xxx_messageInfo_AcknowledgementResult.DiscardUnknown(m) -} - -var xxx_messageInfo_AcknowledgementResult proto.InternalMessageInfo - -func (m *AcknowledgementResult) GetAppName() string { - if m != nil { - return m.AppName - } - return "" -} - -func (m *AcknowledgementResult) GetRecvPacketResult() RecvPacketResult { - if m != nil { - return m.RecvPacketResult - } - return RecvPacketResult{} -} - -// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. -type RecvPacketResult struct { - // status of the packet - Status PacketStatus `protobuf:"varint,1,opt,name=status,proto3,enum=ibc.core.channel.v2.PacketStatus" json:"status,omitempty"` - // acknowledgement of the packet - Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` -} - -func (m *RecvPacketResult) Reset() { *m = RecvPacketResult{} } -func (m *RecvPacketResult) String() string { return proto.CompactTextString(m) } -func (*RecvPacketResult) ProtoMessage() {} -func (*RecvPacketResult) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{5} -} -func (m *RecvPacketResult) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RecvPacketResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RecvPacketResult.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 *RecvPacketResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_RecvPacketResult.Merge(m, src) -} -func (m *RecvPacketResult) XXX_Size() int { - return m.Size() -} -func (m *RecvPacketResult) XXX_DiscardUnknown() { - xxx_messageInfo_RecvPacketResult.DiscardUnknown(m) -} - -var xxx_messageInfo_RecvPacketResult proto.InternalMessageInfo - -func (m *RecvPacketResult) GetStatus() PacketStatus { - if m != nil { - return m.Status - } - return PacketStatus_NONE -} - -func (m *RecvPacketResult) GetAcknowledgement() []byte { - if m != nil { - return m.Acknowledgement - } - return nil -} - -func init() { - proto.RegisterEnum("ibc.core.channel.v2.PacketStatus", PacketStatus_name, PacketStatus_value) - proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") - proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v2.PacketData") - proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") - proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v2.Acknowledgement") - proto.RegisterType((*AcknowledgementResult)(nil), "ibc.core.channel.v2.AcknowledgementResult") - proto.RegisterType((*RecvPacketResult)(nil), "ibc.core.channel.v2.RecvPacketResult") -} - -func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } - -var fileDescriptor_7e9b57d8f218397d = []byte{ - // 660 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xc1, 0x4e, 0x13, 0x41, - 0x18, 0xc7, 0xbb, 0x50, 0x28, 0x7c, 0x45, 0x58, 0x07, 0xd0, 0xd2, 0x98, 0x52, 0x36, 0x41, 0x2b, - 0x86, 0xae, 0xa9, 0x5e, 0x48, 0xb8, 0x94, 0x52, 0x12, 0xa2, 0xa9, 0xcd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x97, 0xbb, 0x52, - 0xe6, 0xe6, 0xae, 0x94, 0xf9, 0x7e, 0x57, 0xca, 0x7c, 0xd8, 0x1f, 0xd8, 0xe2, 0x34, 0xec, 0x55, - 0x09, 0x73, 0x75, 0xc2, 0xb8, 0xcb, 0xb8, 0x6e, 0xf7, 0xc8, 0xee, 0x80, 0xe9, 0xd1, 0x9e, 0xee, - 0xb2, 0x7e, 0xe8, 0x50, 0x1e, 0xbf, 0x49, 0x2f, 0x5f, 0xef, 0x8e, 0x3c, 0x4b, 0xe2, 0xc2, 0xa7, - 0xbc, 0x37, 0x2f, 0x9f, 0x9a, 0x57, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xcc, 0x0a, 0xf3, - 0xba, 0x04, 0x00, 0x00, -} - -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 len(m.Data) > 0 { - for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.TimeoutTimestamp != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) - i-- - dAtA[i] = 0x20 - } - if len(m.DestinationChannel) > 0 { - i -= len(m.DestinationChannel) - copy(dAtA[i:], m.DestinationChannel) - i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationChannel))) - i-- - dAtA[i] = 0x1a - } - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceChannel))) - i-- - dAtA[i] = 0x12 - } - if m.Sequence != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.DestinationPort) > 0 { - i -= len(m.DestinationPort) - copy(dAtA[i:], m.DestinationPort) - i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationPort))) - i-- - dAtA[i] = 0x12 - } - if len(m.SourcePort) > 0 { - i -= len(m.SourcePort) - copy(dAtA[i:], m.SourcePort) - i = encodeVarintChannel(dAtA, i, uint64(len(m.SourcePort))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Payload) 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 *Payload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x1a - } - if len(m.Encoding) > 0 { - i -= len(m.Encoding) - copy(dAtA[i:], m.Encoding) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) - i-- - dAtA[i] = 0x12 - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Acknowledgement) 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 *Acknowledgement) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AcknowledgementResults) > 0 { - for iNdEx := len(m.AcknowledgementResults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AcknowledgementResults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *AcknowledgementResult) 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 *AcknowledgementResult) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AcknowledgementResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.RecvPacketResult.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.AppName) > 0 { - i -= len(m.AppName) - copy(dAtA[i:], m.AppName) - i = encodeVarintChannel(dAtA, i, uint64(len(m.AppName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RecvPacketResult) 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 *RecvPacketResult) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RecvPacketResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Acknowledgement) > 0 { - i -= len(m.Acknowledgement) - copy(dAtA[i:], m.Acknowledgement) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Acknowledgement))) - i-- - dAtA[i] = 0x12 - } - if m.Status != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { - offset -= sovChannel(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Packet) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sequence != 0 { - n += 1 + sovChannel(uint64(m.Sequence)) - } - l = len(m.SourceChannel) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.DestinationChannel) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - if m.TimeoutTimestamp != 0 { - n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) - } - if len(m.Data) > 0 { - for _, e := range m.Data { - l = e.Size() - n += 1 + l + sovChannel(uint64(l)) - } - } - return n -} - -func (m *PacketData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SourcePort) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.DestinationPort) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = m.Payload.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - -func (m *Payload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Version) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.Encoding) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - return n -} - -func (m *Acknowledgement) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AcknowledgementResults) > 0 { - for _, e := range m.AcknowledgementResults { - l = e.Size() - n += 1 + l + sovChannel(uint64(l)) - } - } - return n -} - -func (m *AcknowledgementResult) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AppName) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = m.RecvPacketResult.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - -func (m *RecvPacketResult) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != 0 { - n += 1 + sovChannel(uint64(m.Status)) - } - l = len(m.Acknowledgement) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - return n -} - -func sovChannel(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozChannel(x uint64) (n int) { - return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -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 ErrIntOverflowChannel - } - 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 ErrIntOverflowChannel - } - 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 SourceChannel", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationChannel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - 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 ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeoutTimestamp |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data, PacketData{}) - if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PacketData) 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 ErrIntOverflowChannel - } - 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: PacketData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PacketData: 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - 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 DestinationPort", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationPort = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Payload) 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 ErrIntOverflowChannel - } - 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: Payload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Encoding = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +type Channel struct { + // the client identifier of the light client representing the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the counterparty identifier that must be used by packets sent by counterparty + // to our channel end. + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` +} + +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_7e9b57d8f218397d, []int{0} +} +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) +} - if iNdEx > l { - return io.ErrUnexpectedEOF +var xxx_messageInfo_Channel proto.InternalMessageInfo + +func (m *Channel) GetClientId() string { + if m != nil { + return m.ClientId } - return nil + return "" } -func (m *Acknowledgement) 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 ErrIntOverflowChannel - } - 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: Acknowledgement: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Acknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcknowledgementResults", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcknowledgementResults = append(m.AcknowledgementResults, AcknowledgementResult{}) - if err := m.AcknowledgementResults[len(m.AcknowledgementResults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + +func (m *Channel) GetCounterpartyChannelId() string { + if m != nil { + return m.CounterpartyChannelId + } + return "" +} + +func (m *Channel) GetMerklePathPrefix() v2.MerklePath { + if m != nil { + return m.MerklePathPrefix + } + return v2.MerklePath{} +} + +func init() { + proto.RegisterType((*Channel)(nil), "ibc.core.channel.v2.Channel") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } + +var fileDescriptor_7e9b57d8f218397d = []byte{ + // 302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0x83, 0x40, + 0x18, 0xc7, 0x39, 0x35, 0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0xb0, 0xdb, 0x17, 0xb5, 0x87, + 0x15, 0x8e, 0xfd, 0xaa, 0xff, 0x98, 0x7a, 0x2a, 0x1a, 0x1f, 0x2c, 0x7f, 0xaf, 0x8d, 0xd9, 0xa9, + 0xd8, 0x26, 0x53, 0x6d, 0x18, 0xcf, 0x97, 0x25, 0x46, 0xab, 0x12, 0xa3, 0xbf, 0x12, 0xa3, 0xaf, + 0x0a, 0x1b, 0xab, 0x0a, 0x1b, 0x3f, 0x15, 0x36, 0xde, 0x9e, 0x43, 0xae, 0xa2, 0xdc, 0xaf, 0x95, + 0x84, 0x42, 0x26, 0x20, 0x23, 0xdc, 0xa7, 0xa3, 0x10, 0x48, 0xf1, 0x44, 0x04, 0x04, 0x79, 0xcc, + 0xb2, 0xa6, 0x9b, 0xbb, 0x87, 0xd1, 0x4e, 0xd9, 0x6a, 0x91, 0xb2, 0xcc, 0x3f, 0xd4, 0xbd, 0xdc, + 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdc, 0xac, 0x74, 0x90, 0x01, 0x00, 0x00, +} + +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 + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa } + return len(dAtA) - i, nil +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { + offset -= sovChannel(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return nil + dAtA[offset] = uint8(v) + return base +} +func (m *Channel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovChannel(uint64(l)) + return n +} + +func sovChannel(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozChannel(x uint64) (n int) { + return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *AcknowledgementResult) Unmarshal(dAtA []byte) error { +func (m *Channel) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1466,15 +232,15 @@ func (m *AcknowledgementResult) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AcknowledgementResult: wiretype end group for non-group") + return fmt.Errorf("proto: Channel: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AcknowledgementResult: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Channel: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1502,13 +268,13 @@ func (m *AcknowledgementResult) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AppName = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecvPacketResult", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -1518,99 +284,29 @@ func (m *AcknowledgementResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthChannel } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.RecvPacketResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RecvPacketResult) 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 ErrIntOverflowChannel - } - 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: RecvPacketResult: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RecvPacketResult: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= PacketStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgement", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -1620,24 +316,23 @@ func (m *RecvPacketResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthChannel } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF } - m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) - if m.Acknowledgement == nil { - m.Acknowledgement = []byte{} + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: diff --git a/modules/core/04-channel/v2/types/counterparty.pb.go b/modules/core/04-channel/v2/types/counterparty.pb.go deleted file mode 100644 index 75c5938d11f..00000000000 --- a/modules/core/04-channel/v2/types/counterparty.pb.go +++ /dev/null @@ -1,438 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/channel/v2/counterparty.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - 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 - -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -type Counterparty struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the counterparty identifier that must be used by the packet - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_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_ce9c5094f22c756d, []int{0} -} -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 - -func (m *Counterparty) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Counterparty) GetCounterpartyChannelId() string { - if m != nil { - return m.CounterpartyChannelId - } - return "" -} - -func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { - if m != nil { - return m.MerklePathPrefix - } - return v2.MerklePath{} -} - -func init() { - proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v2.Counterparty") -} - -func init() { - proto.RegisterFile("ibc/core/channel/v2/counterparty.proto", fileDescriptor_ce9c5094f22c756d) -} - -var fileDescriptor_ce9c5094f22c756d = []byte{ - // 306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0x48, 0xcc, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0xd2, - 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x49, 0x2d, 0x2a, 0x48, 0x2c, 0x2a, 0xa9, 0xd4, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0x12, 0xce, 0x4c, 0x4a, 0xd6, 0x03, 0xa9, 0xd3, 0x83, 0xaa, 0xd3, 0x2b, 0x33, - 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0xea, 0x08, - 0x23, 0xf3, 0x73, 0x73, 0x33, 0x4b, 0x72, 0x53, 0xf3, 0x4a, 0x20, 0xa6, 0xc2, 0x78, 0x10, 0x85, - 0x4a, 0xbb, 0x19, 0xb9, 0x78, 0x9c, 0x91, 0xac, 0x12, 0x92, 0xe6, 0xe2, 0x4c, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0x89, 0xcf, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x80, 0x08, 0x78, - 0xa6, 0x08, 0x99, 0x71, 0x89, 0x23, 0xbb, 0x2b, 0x1e, 0xea, 0x0e, 0x90, 0x52, 0x26, 0xb0, 0x52, - 0x51, 0x64, 0x69, 0x67, 0x88, 0xac, 0x67, 0x8a, 0x50, 0x18, 0x97, 0x50, 0x6e, 0x6a, 0x51, 0x76, - 0x4e, 0x6a, 0x7c, 0x41, 0x62, 0x49, 0x46, 0x7c, 0x41, 0x51, 0x6a, 0x5a, 0x66, 0x85, 0x04, 0xb3, - 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x92, 0x1e, 0xc2, 0x5b, 0x08, 0xd7, 0x95, 0x19, 0xe9, 0xf9, 0x82, - 0x75, 0x04, 0x24, 0x96, 0x64, 0x38, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x24, 0x90, 0x0b, 0x17, - 0x09, 0x00, 0x9b, 0xe0, 0x14, 0x76, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, - 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, - 0x36, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x20, 0x23, 0xf5, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, - 0xf5, 0x33, 0x93, 0x92, 0x75, 0xd3, 0xf3, 0xf5, 0xcb, 0x2c, 0xf5, 0x73, 0xf3, 0x53, 0x4a, 0x73, - 0x52, 0x8b, 0x21, 0x01, 0x64, 0x60, 0xa2, 0x8b, 0x14, 0xec, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, - 0x6c, 0xe0, 0xc0, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x88, 0xf9, 0x24, 0x25, 0x9a, 0x01, - 0x00, 0x00, -} - -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.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCounterparty(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { - offset -= sovCounterparty(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -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 + sovCounterparty(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovCounterparty(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovCounterparty(uint64(l)) - return n -} - -func sovCounterparty(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozCounterparty(x uint64) (n int) { - return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -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 ErrIntOverflowCounterparty - } - 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 ErrIntOverflowCounterparty - } - 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 ErrInvalidLengthCounterparty - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCounterparty - } - 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 CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCounterparty - } - 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 ErrInvalidLengthCounterparty - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCounterparty - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCounterparty - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCounterparty - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCounterparty - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCounterparty(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCounterparty - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipCounterparty(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, ErrIntOverflowCounterparty - } - 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, ErrIntOverflowCounterparty - } - 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, ErrIntOverflowCounterparty - } - 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, ErrInvalidLengthCounterparty - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCounterparty - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthCounterparty - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") -) diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 25acab9190d..7f56d8f8e34 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,8 +5,8 @@ import ( ) var ( - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") - ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") ) diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index 37a60421cf5..965f010716e 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -4,8 +4,8 @@ const ( // SubModuleName defines the channelv2 module name. SubModuleName = "channelv2" - // CounterpartyKey is the key used to store counterparty in the client store. - // the counterparty key is imported from types instead of host because - // the counterparty key is not a part of the ics-24 host specification - CounterpartyKey = "counterparty" + // ChannelKey is the key used to store channel in the client store. + // the channel key is imported from types instead of host because + // the channel key is not a part of the ics-24 host specification + ChannelKey = "channel" ) diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go new file mode 100644 index 00000000000..7ec4ffaadb0 --- /dev/null +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -0,0 +1,1747 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/channel/v2/packet.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// PacketStatus specifies the status of a RecvPacketResult. +type PacketStatus int32 + +const ( + // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. + PacketStatus_NONE PacketStatus = 0 + // PACKET_STATUS_SUCCESS indicates a successful packet receipt. + PacketStatus_Success PacketStatus = 1 + // PACKET_STATUS_FAILURE indicates a failed packet receipt. + PacketStatus_Failure PacketStatus = 2 + // PACKET_STATUS_ASYNC indicates an async packet receipt. + PacketStatus_Async PacketStatus = 3 +) + +var PacketStatus_name = map[int32]string{ + 0: "PACKET_STATUS_UNSPECIFIED", + 1: "PACKET_STATUS_SUCCESS", + 2: "PACKET_STATUS_FAILURE", + 3: "PACKET_STATUS_ASYNC", +} + +var PacketStatus_value = map[string]int32{ + "PACKET_STATUS_UNSPECIFIED": 0, + "PACKET_STATUS_SUCCESS": 1, + "PACKET_STATUS_FAILURE": 2, + "PACKET_STATUS_ASYNC": 3, +} + +func (x PacketStatus) String() string { + return proto.EnumName(PacketStatus_name, int32(x)) +} + +func (PacketStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{0} +} + +// 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 sending chain. + SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + // identifies the receiving chain. + DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` + // timeout timestamp after which the packet times out. + TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` + // a list of packet data, each one for a specific application. + Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` +} + +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_2f814aba9ca97169, []int{0} +} +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 (m *Packet) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *Packet) GetSourceChannel() string { + if m != nil { + return m.SourceChannel + } + return "" +} + +func (m *Packet) GetDestinationChannel() string { + if m != nil { + return m.DestinationChannel + } + return "" +} + +func (m *Packet) GetTimeoutTimestamp() uint64 { + if m != nil { + return m.TimeoutTimestamp + } + return 0 +} + +func (m *Packet) GetData() []PacketData { + if m != nil { + return m.Data + } + return nil +} + +// PacketData contains the source and destination ports and payload for the application +type PacketData struct { + // specifies the source port of the packet. + SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // specifies the destination port of the packet. + DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` + // the payload to be sent to the application. + Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` +} + +func (m *PacketData) Reset() { *m = PacketData{} } +func (m *PacketData) String() string { return proto.CompactTextString(m) } +func (*PacketData) ProtoMessage() {} +func (*PacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{1} +} +func (m *PacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketData.Merge(m, src) +} +func (m *PacketData) XXX_Size() int { + return m.Size() +} +func (m *PacketData) XXX_DiscardUnknown() { + xxx_messageInfo_PacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketData proto.InternalMessageInfo + +func (m *PacketData) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *PacketData) GetDestinationPort() string { + if m != nil { + return m.DestinationPort + } + return "" +} + +func (m *PacketData) GetPayload() Payload { + if m != nil { + return m.Payload + } + return Payload{} +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +type Payload struct { + // version of the specified application. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // the encoding used for the provided value. + Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` + // the raw bytes for the payload. + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *Payload) Reset() { *m = Payload{} } +func (m *Payload) String() string { return proto.CompactTextString(m) } +func (*Payload) ProtoMessage() {} +func (*Payload) Descriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{2} +} +func (m *Payload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Payload.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 *Payload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Payload.Merge(m, src) +} +func (m *Payload) XXX_Size() int { + return m.Size() +} +func (m *Payload) XXX_DiscardUnknown() { + xxx_messageInfo_Payload.DiscardUnknown(m) +} + +var xxx_messageInfo_Payload proto.InternalMessageInfo + +func (m *Payload) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Payload) GetEncoding() string { + if m != nil { + return m.Encoding + } + return "" +} + +func (m *Payload) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +// Acknowledgement contains a list of all ack results associated with a single packet. +type Acknowledgement struct { + AcknowledgementResults []AcknowledgementResult `protobuf:"bytes,1,rep,name=acknowledgement_results,json=acknowledgementResults,proto3" json:"acknowledgement_results"` +} + +func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } +func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } +func (*Acknowledgement) ProtoMessage() {} +func (*Acknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{3} +} +func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Acknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Acknowledgement.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 *Acknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_Acknowledgement.Merge(m, src) +} +func (m *Acknowledgement) XXX_Size() int { + return m.Size() +} +func (m *Acknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_Acknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo + +func (m *Acknowledgement) GetAcknowledgementResults() []AcknowledgementResult { + if m != nil { + return m.AcknowledgementResults + } + return nil +} + +// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. +type AcknowledgementResult struct { + AppName string `protobuf:"bytes,1,opt,name=app_name,json=appName,proto3" json:"app_name,omitempty"` + RecvPacketResult RecvPacketResult `protobuf:"bytes,2,opt,name=recv_packet_result,json=recvPacketResult,proto3" json:"recv_packet_result"` +} + +func (m *AcknowledgementResult) Reset() { *m = AcknowledgementResult{} } +func (m *AcknowledgementResult) String() string { return proto.CompactTextString(m) } +func (*AcknowledgementResult) ProtoMessage() {} +func (*AcknowledgementResult) Descriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{4} +} +func (m *AcknowledgementResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AcknowledgementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AcknowledgementResult.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 *AcknowledgementResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_AcknowledgementResult.Merge(m, src) +} +func (m *AcknowledgementResult) XXX_Size() int { + return m.Size() +} +func (m *AcknowledgementResult) XXX_DiscardUnknown() { + xxx_messageInfo_AcknowledgementResult.DiscardUnknown(m) +} + +var xxx_messageInfo_AcknowledgementResult proto.InternalMessageInfo + +func (m *AcknowledgementResult) GetAppName() string { + if m != nil { + return m.AppName + } + return "" +} + +func (m *AcknowledgementResult) GetRecvPacketResult() RecvPacketResult { + if m != nil { + return m.RecvPacketResult + } + return RecvPacketResult{} +} + +// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. +type RecvPacketResult struct { + // status of the packet + Status PacketStatus `protobuf:"varint,1,opt,name=status,proto3,enum=ibc.core.channel.v2.PacketStatus" json:"status,omitempty"` + // acknowledgement of the packet + Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` +} + +func (m *RecvPacketResult) Reset() { *m = RecvPacketResult{} } +func (m *RecvPacketResult) String() string { return proto.CompactTextString(m) } +func (*RecvPacketResult) ProtoMessage() {} +func (*RecvPacketResult) Descriptor() ([]byte, []int) { + return fileDescriptor_2f814aba9ca97169, []int{5} +} +func (m *RecvPacketResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecvPacketResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecvPacketResult.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 *RecvPacketResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecvPacketResult.Merge(m, src) +} +func (m *RecvPacketResult) XXX_Size() int { + return m.Size() +} +func (m *RecvPacketResult) XXX_DiscardUnknown() { + xxx_messageInfo_RecvPacketResult.DiscardUnknown(m) +} + +var xxx_messageInfo_RecvPacketResult proto.InternalMessageInfo + +func (m *RecvPacketResult) GetStatus() PacketStatus { + if m != nil { + return m.Status + } + return PacketStatus_NONE +} + +func (m *RecvPacketResult) GetAcknowledgement() []byte { + if m != nil { + return m.Acknowledgement + } + return nil +} + +func init() { + proto.RegisterEnum("ibc.core.channel.v2.PacketStatus", PacketStatus_name, PacketStatus_value) + proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") + proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v2.PacketData") + proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") + proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v2.Acknowledgement") + proto.RegisterType((*AcknowledgementResult)(nil), "ibc.core.channel.v2.AcknowledgementResult") + proto.RegisterType((*RecvPacketResult)(nil), "ibc.core.channel.v2.RecvPacketResult") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/packet.proto", fileDescriptor_2f814aba9ca97169) } + +var fileDescriptor_2f814aba9ca97169 = []byte{ + // 664 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xc1, 0x4e, 0xdb, 0x4a, + 0x14, 0x86, 0x63, 0x08, 0x04, 0x4e, 0xb8, 0xe0, 0x3b, 0xc0, 0xbd, 0x21, 0xba, 0x0a, 0xbe, 0x96, + 0x68, 0x53, 0x2a, 0xec, 0x2a, 0xed, 0x06, 0x89, 0x4d, 0x08, 0x41, 0x42, 0xad, 0xd2, 0xc8, 0x4e, + 0x2a, 0xd1, 0x8d, 0x35, 0x99, 0x8c, 0x82, 0x85, 0xed, 0x71, 0x3d, 0x63, 0x23, 0xa4, 0x3e, 0x01, + 0x52, 0xa5, 0xae, 0xba, 0xe3, 0x09, 0xfa, 0x22, 0x2c, 0x59, 0x76, 0x55, 0x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0x60, + 0x66, 0xb2, 0x6f, 0xfa, 0xac, 0x1f, 0x7b, 0x94, 0xa7, 0x4f, 0xd2, 0xb3, 0x17, 0x7b, 0x63, 0xaf, + 0x92, 0xb8, 0x0c, 0x29, 0xef, 0x2d, 0xca, 0xa7, 0xe6, 0xf9, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x4b, 0xd0, 0x86, 0x84, 0xb9, 0x04, 0x00, 0x00, +} + +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 len(m.Data) > 0 { + for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.TimeoutTimestamp != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.DestinationChannel) > 0 { + i -= len(m.DestinationChannel) + copy(dAtA[i:], m.DestinationChannel) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationChannel))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintPacket(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x12 + } + if m.Sequence != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x12 + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintPacket(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Payload) 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 *Payload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Encoding) > 0 { + i -= len(m.Encoding) + copy(dAtA[i:], m.Encoding) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Encoding))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Acknowledgement) 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 *Acknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AcknowledgementResults) > 0 { + for iNdEx := len(m.AcknowledgementResults) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AcknowledgementResults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AcknowledgementResult) 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 *AcknowledgementResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AcknowledgementResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RecvPacketResult.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AppName) > 0 { + i -= len(m.AppName) + copy(dAtA[i:], m.AppName) + i = encodeVarintPacket(dAtA, i, uint64(len(m.AppName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecvPacketResult) 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 *RecvPacketResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecvPacketResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Acknowledgement))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPacket(dAtA []byte, offset int, v uint64) int { + offset -= sovPacket(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Packet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovPacket(uint64(m.Sequence)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.DestinationChannel) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovPacket(uint64(m.TimeoutTimestamp)) + } + if len(m.Data) > 0 { + for _, e := range m.Data { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + return n +} + +func (m *PacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.DestinationPort) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = m.Payload.Size() + n += 1 + l + sovPacket(uint64(l)) + return n +} + +func (m *Payload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.Encoding) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func (m *Acknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AcknowledgementResults) > 0 { + for _, e := range m.AcknowledgementResults { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + return n +} + +func (m *AcknowledgementResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AppName) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = m.RecvPacketResult.Size() + n += 1 + l + sovPacket(uint64(l)) + return n +} + +func (m *RecvPacketResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovPacket(uint64(m.Status)) + } + l = len(m.Acknowledgement) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func sovPacket(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPacket(x uint64) (n int) { + return sovPacket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowPacket + } + 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 ErrIntOverflowPacket + } + 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 SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data, PacketData{}) + if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketData) 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 ErrIntOverflowPacket + } + 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: PacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketData: 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 ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + 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 DestinationPort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationPort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Payload) 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 ErrIntOverflowPacket + } + 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: Payload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Encoding = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Acknowledgement) 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 ErrIntOverflowPacket + } + 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: Acknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Acknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcknowledgementResults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcknowledgementResults = append(m.AcknowledgementResults, AcknowledgementResult{}) + if err := m.AcknowledgementResults[len(m.AcknowledgementResults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AcknowledgementResult) 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 ErrIntOverflowPacket + } + 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: AcknowledgementResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AcknowledgementResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecvPacketResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RecvPacketResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RecvPacketResult) 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 ErrIntOverflowPacket + } + 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: RecvPacketResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecvPacketResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= PacketStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) + if m.Acknowledgement == nil { + m.Acknowledgement = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPacket(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, ErrIntOverflowPacket + } + 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, ErrIntOverflowPacket + } + 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, ErrIntOverflowPacket + } + 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, ErrInvalidLengthPacket + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPacket + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPacket + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPacket = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPacket = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPacket = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index e85b1319cf9..0532c9c4c4a 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -363,53 +363,53 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 727 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcf, 0x6e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09, 0xce, 0x59, 0x13, 0x04, 0xda, 0x69, 0x6a, 0x13, 0x5e, 0x9b, 0xea, 0xe7, 0x34, 0xa4, - 0xb7, 0xa8, 0xad, 0xee, 0x00, 0x0c, 0x9c, 0xb2, 0xe5, 0x44, 0x8c, 0x43, 0x67, 0x96, 0xb6, 0x7c, - 0xbe, 0x26, 0x6e, 0x76, 0x07, 0x60, 0xe0, 0xc4, 0x1a, 0xeb, 0xde, 0xd7, 0x8c, 0x77, 0x4f, 0x38, - 0x14, 0xb6, 0xe1, 0xaf, 0xde, 0x9f, 0x5c, 0x1a, 0x37, 0x4c, 0x0a, 0xb4, 0xc5, 0x73, 0x04, 0xb1, - 0xe9, 0x2e, 0xe4, 0x47, 0x37, 0xec, 0xd8, 0xb1, 0x23, 0x42, 0xcd, 0xb8, 0xa0, 0xb0, 0x57, 0x4c, - 0x9b, 0xfe, 0x70, 0x72, 0xb0, 0xac, 0x6c, 0xbc, 0x3c, 0x3c, 0x2e, 0x2a, 0x47, 0xc7, 0x45, 0xe5, - 0xf7, 0x71, 0x51, 0xf9, 0xda, 0x2d, 0xa6, 0x8e, 0xba, 0xc5, 0xd4, 0xcf, 0x6e, 0x31, 0xf5, 0xea, - 0x91, 0xed, 0xb0, 0x56, 0xa7, 0xa1, 0x23, 0xe2, 0x1a, 0xf2, 0x3a, 0x76, 0x1a, 0x68, 0xc5, 0x26, - 0x46, 0xb8, 0x6a, 0xb8, 0xa4, 0xd9, 0x69, 0x63, 0x2a, 0x6e, 0xd2, 0xfb, 0x0f, 0x57, 0x06, 0xef, - 0xfb, 0x7d, 0x1f, 0xd3, 0x46, 0x96, 0xdf, 0xa6, 0x0f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb1, - 0x1c, 0xb4, 0xdc, 0x13, 0x08, 0x00, 0x00, + // 724 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d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0x83, 0x39, 0x4a, 0xda, 0x01, 0xc2, 0x35, 0x69, 0x98, 0x53, 0x8a, 0xca, + 0xe2, 0x15, 0x73, 0x56, 0x44, 0x37, 0x44, 0x50, 0x7d, 0x00, 0x57, 0x99, 0xe3, 0x62, 0xd2, 0x66, + 0xb5, 0xe8, 0x49, 0x99, 0xe5, 0xfa, 0xb9, 0xa9, 0xa2, 0xb2, 0x98, 0x32, 0xe7, 0x65, 0xa2, 0xda, + 0x8d, 0xab, 0x2f, 0x20, 0x23, 0x9a, 0xae, 0x35, 0x2c, 0x66, 0xe5, 0x92, 0xc5, 0xe4, 0x62, 0xa6, + 0x52, 0xd0, 0x47, 0x00, 0xd2, 0x45, 0x17, 0xcf, 0x2d, 0x66, 0xad, 0xa7, 0x0e, 0xfe, 0x16, 0x12, + 0x26, 0xf8, 0x71, 0x44, 0xbd, 0x09, 0x69, 0xea, 0xd8, 0x1e, 0x0e, 0x72, 0x29, 0xde, 0x93, 0xfc, + 0x5a, 0xcd, 0x7e, 0xfd, 0x59, 0x48, 0x7c, 0x39, 0xde, 0x5f, 0x92, 0x81, 0xd2, 0x0a, 0xdc, 0x18, + 0x98, 0x95, 0x89, 0xa9, 0x4f, 0x3c, 0x8a, 0x55, 0x0d, 0x2e, 0x53, 0xfc, 0xb1, 0x8d, 0x3d, 0x84, + 0xf9, 0xbc, 0x52, 0x66, 0xfc, 0xbd, 0x9a, 0x8a, 0x5c, 0x4a, 0x1d, 0x41, 0xc4, 0xc4, 0x28, 0x94, + 0x44, 0x56, 0x20, 0x2d, 0x7a, 0xe0, 0x23, 0x32, 0x95, 0xdb, 0xa7, 0x34, 0x2e, 0x9b, 0x96, 0x03, + 0xd4, 0xfb, 0x30, 0xef, 0x07, 0x84, 0x7c, 0xa8, 0x21, 0xe2, 0xba, 0x0e, 0x73, 0xb1, 0xc7, 0x38, + 0xa4, 0x19, 0x33, 0xcb, 0xe3, 0x1b, 0x71, 0x58, 0xdd, 0x80, 0x19, 0x21, 0x6d,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 0x81, 0x76, 0x92, 0xda, 0x84, 0xd7, 0xa6, 0xf2, 0x2d, 0x09, 0xc9, 0x4d, 0x6a, 0xab, + 0xdb, 0x00, 0x7d, 0xa7, 0x6c, 0x69, 0x24, 0xc6, 0x81, 0x33, 0x4b, 0x5b, 0x3a, 0x5b, 0x13, 0x37, + 0xbb, 0x0d, 0xd0, 0x77, 0x62, 0x8d, 0x75, 0xef, 0x69, 0xc6, 0xbb, 0x8f, 0x38, 0x14, 0xb6, 0xe0, + 0x52, 0xf7, 0x4f, 0x2e, 0x8c, 0x1b, 0x26, 0x05, 0xda, 0xc2, 0x19, 0x82, 0xd8, 0x74, 0x07, 0xb2, + 0xc3, 0x1b, 0x76, 0xec, 0xd8, 0x21, 0xa1, 0x66, 0x9c, 0x53, 0xd8, 0x2d, 0xa6, 0x4d, 0x7f, 0x3e, + 0xde, 0x5f, 0x52, 0xd6, 0xdf, 0x1c, 0x1c, 0xe5, 0x95, 0xc3, 0xa3, 0xbc, 0xf2, 0xef, 0x28, 0xaf, + 0xfc, 0xe8, 0xe4, 0x13, 0x87, 0x9d, 0x7c, 0xe2, 0x4f, 0x27, 0x9f, 0x78, 0xfb, 0xd4, 0x76, 0x58, + 0xb3, 0x5d, 0xd7, 0x11, 0x71, 0x0d, 0x79, 0x1b, 0x3b, 0x75, 0xb4, 0x6c, 0x13, 0x23, 0x5c, 0x31, + 0x5c, 0xd2, 0x68, 0xb7, 0x30, 0x15, 0x37, 0xe9, 0xa3, 0x27, 0xcb, 0xfd, 0xd7, 0xfd, 0x9e, 0x8f, + 0x69, 0x3d, 0xcd, 0x6f, 0xd3, 0xc7, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x8c, 0xff, 0x15, + 0x12, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/modules/core/packet-server/client/cli/query.go b/modules/core/packet-server/client/cli/query.go index ad23f2ef5d6..82e87400007 100644 --- a/modules/core/packet-server/client/cli/query.go +++ b/modules/core/packet-server/client/cli/query.go @@ -28,11 +28,11 @@ func getCmdQueryChannel() *cobra.Command { } clientID := args[0] - queryChannel := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) req := &types.QueryChannelRequest{ChannelId: clientID} - res, err := queryChannel.Channel(cmd.Context(), req) + res, err := queryClient.Channel(cmd.Context(), req) if err != nil { return err } diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto index 20d002d2e6e..67a5a1871be 100644 --- a/proto/ibc/core/channel/v2/channel.proto +++ b/proto/ibc/core/channel/v2/channel.proto @@ -1,4 +1,3 @@ - syntax = "proto3"; package ibc.core.channel.v2; @@ -6,70 +5,23 @@ package ibc.core.channel.v2; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; import "gogoproto/gogo.proto"; - -// Packet defines a type that carries data across different chains through IBC -message Packet { - // 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 sending chain. - string source_channel = 2; - // identifies the receiving chain. - string destination_channel = 3; - // timeout timestamp after which the packet times out. - uint64 timeout_timestamp = 4; - // a list of packet data, each one for a specific application. - repeated PacketData data = 5 [(gogoproto.nullable) = false]; -} - -// PacketData contains the source and destination ports and payload for the application -message PacketData { - // specifies the source port of the packet. - string source_port = 1; - // specifies the destination port of the packet. - string destination_port = 2; - // the payload to be sent to the application. - Payload payload = 3 [(gogoproto.nullable) = false]; -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -message Payload { - // version of the specified application. - string version = 1; - // the encoding used for the provided value. - string encoding = 2; - // the raw bytes for the payload. - bytes value = 3; -} - -// Acknowledgement contains a list of all ack results associated with a single packet. -message Acknowledgement { - repeated AcknowledgementResult acknowledgement_results = 1 [(gogoproto.nullable) = false]; -} - -// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. -message AcknowledgementResult { - string app_name = 1; - RecvPacketResult recv_packet_result = 2 [(gogoproto.nullable) = false]; -} - -// PacketStatus specifies the status of a RecvPacketResult. -enum PacketStatus { - // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. - PACKET_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; - // PACKET_STATUS_SUCCESS indicates a successful packet receipt. - PACKET_STATUS_SUCCESS = 1 [(gogoproto.enumvalue_customname) = "Success"]; - // PACKET_STATUS_FAILURE indicates a failed packet receipt. - PACKET_STATUS_FAILURE = 2 [(gogoproto.enumvalue_customname) = "Failure"]; - // PACKET_STATUS_ASYNC indicates an async packet receipt. - PACKET_STATUS_ASYNC = 3 [(gogoproto.enumvalue_customname) = "Async"]; -} - -// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. -message RecvPacketResult { - // status of the packet - PacketStatus status = 1; - // acknowledgement of the packet - bytes acknowledgement = 2; +import "ibc/core/commitment/v2/commitment.proto"; + +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +message Channel { + // the client identifier of the light client representing the counterparty chain + string client_id = 1; + // the counterparty identifier that must be used by packets sent by counterparty + // to our channel end. + string counterparty_channel_id = 2; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/ibc/core/channel/v2/counterparty.proto b/proto/ibc/core/channel/v2/counterparty.proto deleted file mode 100644 index fd0b88c612f..00000000000 --- a/proto/ibc/core/channel/v2/counterparty.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v2; - -option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/commitment/v2/commitment.proto"; - -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -message Counterparty { - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the counterparty identifier that must be used by the packet - string counterparty_channel_id = 2; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; -} diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto new file mode 100644 index 00000000000..20d002d2e6e --- /dev/null +++ b/proto/ibc/core/channel/v2/packet.proto @@ -0,0 +1,75 @@ + +syntax = "proto3"; + +package ibc.core.channel.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; + +import "gogoproto/gogo.proto"; + +// Packet defines a type that carries data across different chains through IBC +message Packet { + // 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 sending chain. + string source_channel = 2; + // identifies the receiving chain. + string destination_channel = 3; + // timeout timestamp after which the packet times out. + uint64 timeout_timestamp = 4; + // a list of packet data, each one for a specific application. + repeated PacketData data = 5 [(gogoproto.nullable) = false]; +} + +// PacketData contains the source and destination ports and payload for the application +message PacketData { + // specifies the source port of the packet. + string source_port = 1; + // specifies the destination port of the packet. + string destination_port = 2; + // the payload to be sent to the application. + Payload payload = 3 [(gogoproto.nullable) = false]; +} + +// Payload holds the version, encoding and raw bytes to be passed to an application +message Payload { + // version of the specified application. + string version = 1; + // the encoding used for the provided value. + string encoding = 2; + // the raw bytes for the payload. + bytes value = 3; +} + +// Acknowledgement contains a list of all ack results associated with a single packet. +message Acknowledgement { + repeated AcknowledgementResult acknowledgement_results = 1 [(gogoproto.nullable) = false]; +} + +// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. +message AcknowledgementResult { + string app_name = 1; + RecvPacketResult recv_packet_result = 2 [(gogoproto.nullable) = false]; +} + +// PacketStatus specifies the status of a RecvPacketResult. +enum PacketStatus { + // PACKET_STATUS_UNSPECIFIED indicates an unknown packet status. + PACKET_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; + // PACKET_STATUS_SUCCESS indicates a successful packet receipt. + PACKET_STATUS_SUCCESS = 1 [(gogoproto.enumvalue_customname) = "Success"]; + // PACKET_STATUS_FAILURE indicates a failed packet receipt. + PACKET_STATUS_FAILURE = 2 [(gogoproto.enumvalue_customname) = "Failure"]; + // PACKET_STATUS_ASYNC indicates an async packet receipt. + PACKET_STATUS_ASYNC = 3 [(gogoproto.enumvalue_customname) = "Async"]; +} + +// RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. +message RecvPacketResult { + // status of the packet + PacketStatus status = 1; + // acknowledgement of the packet + bytes acknowledgement = 2; +} diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 95b19c91cf5..771706b3efc 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -6,7 +6,7 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/type import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; -import "ibc/core/channel/v2/channel.proto"; +import "ibc/core/channel/v2/packet.proto"; import "ibc/core/channel/v1/tx.proto"; import "ibc/core/client/v1/client.proto"; From 756b94ee5acf816dc890ff81f5e1ed9168ac4529 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 10 Oct 2024 11:20:04 +0100 Subject: [PATCH 064/172] Implement MsgSendPacket RPC handler and tests (#7413) * chore: added application callback to SendPacketV2 rpc * chore: adding additional msg server tests * chore: adding additional tests * chore: address PR feedback * chore: rename sourceID to sourceChannel --- modules/core/04-channel/v2/keeper/keeper.go | 5 + .../core/04-channel/v2/keeper/msg_server.go | 30 ++--- .../04-channel/v2/keeper/msg_server_test.go | 113 ++++++++++++++++++ modules/core/04-channel/v2/keeper/packet.go | 33 +++-- modules/core/04-channel/v2/types/msgs.go | 11 ++ modules/core/keeper/keeper.go | 2 +- simapp/app.go | 16 --- testing/mock/v2/mock.go | 17 +++ testing/simapp/app.go | 16 +++ 9 files changed, 192 insertions(+), 51 deletions(-) create mode 100644 modules/core/04-channel/v2/keeper/msg_server_test.go create mode 100644 modules/core/04-channel/v2/types/msgs.go diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 4be8251a74a..88964e60201 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -20,6 +20,7 @@ import ( commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + "github.com/cosmos/ibc-go/v9/modules/core/api" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -31,6 +32,10 @@ type Keeper struct { // channelKeeperV1 is used for channel aliasing only. channelKeeperV1 *channelkeeperv1.Keeper connectionKeeper *connectionkeeper.Keeper + + // Router is used to route messages to the appropriate module callbacks + // NOTE: it must be explicitly set before usage. + Router *api.Router } // NewKeeper creates a new channel v2 keeper diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 53e6327d1c8..740ebb02daa 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -16,9 +16,9 @@ var _ channeltypesv2.MsgServer = &Keeper{} // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - sequence, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.PacketData) + sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.PacketData) if err != nil { - sdkCtx.Logger().Error("send packet failed", "source-id", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) + sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) } @@ -28,17 +28,13 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } - _ = signer - - // TODO: implement once app router is wired up. - // https://github.com/cosmos/ibc-go/issues/7384 - // for _, pd := range msg.PacketData { - // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnSendPacket(ctx, msg.SourceChannel, sequence, msg.TimeoutTimestamp, pd, signer) - // if err != nil { - // return nil, err - // } - // } + for _, pd := range msg.PacketData { + cbs := k.Router.Route(pd.SourcePort) + err := cbs.OnSendPacket(ctx, msg.SourceChannel, destChannel, sequence, pd, signer) + if err != nil { + return nil, err + } + } return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil } @@ -59,10 +55,10 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck writeFn() case channeltypesv1.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored - sdkCtx.Logger().Debug("no-op on redundant relay", "source-id", msg.Packet.SourceChannel) + sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil default: - sdkCtx.Logger().Error("acknowledgement failed", "source-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) + sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } @@ -86,7 +82,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack sdkCtx := sdk.UnwrapSDKContext(ctx) err := k.recvPacket(ctx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) if err != nil { - sdkCtx.Logger().Error("receive packet failed", "source-id", msg.Packet.SourceChannel, "dest-id", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "send packet failed")) + sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "send packet failed")) return nil, errorsmod.Wrapf(err, "receive packet failed for source id: %s and destination id: %s", msg.Packet.SourceChannel, msg.Packet.DestinationChannel) } @@ -115,7 +111,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) if err := k.timeoutPacket(ctx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { - sdkCtx.Logger().Error("Timeout packet failed", "source-id", timeout.Packet.SourceChannel, "destination-id", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) + sdkCtx.Logger().Error("Timeout packet failed", "source-channel", timeout.Packet.SourceChannel, "destination-channel", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s and destination id: %s", timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go new file mode 100644 index 00000000000..1f4aabd1c86 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -0,0 +1,113 @@ +package keeper_test + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/ibc-go/v9/testing/mock" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" +) + +func (suite *KeeperTestSuite) TestMsgSendPacket() { + var ( + path *ibctesting.Path + msg *channeltypesv2.MsgSendPacket + expectedPacket channeltypesv2.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + expError: nil, + }, + { + name: "failure: timeout elapsed", + malleate: func() { + // ensure a message timeout. + msg.TimeoutTimestamp = uint64(1) + }, + expError: channeltypesv1.ErrTimeoutElapsed, + }, + { + name: "failure: inactive client", + malleate: func() { + path.EndpointA.FreezeClient() + }, + expError: clienttypes.ErrClientNotActive, + }, + { + name: "failure: application callback error", + malleate: func() { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { + return mock.MockApplicationCallbackError + } + }, + expError: mock.MockApplicationCallbackError, + }, + { + name: "failure: counterparty not found", + malleate: func() { + msg.SourceChannel = "foo" + }, + expError: channeltypesv1.ErrChannelNotFound, + }, + { + name: "failure: route to non existing app", + malleate: func() { + msg.PacketData[0].SourcePort = "foo" + }, + expError: fmt.Errorf("no route for foo"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + msg = channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + + expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + + tc.malleate() + + res, err := path.EndpointA.Chain.SendMsgs(msg) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + ck := path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 + + packetCommitment := ck.GetPacketCommitment(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID, 1) + suite.Require().NotNil(packetCommitment) + suite.Require().Equal(channeltypesv2.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") + + nextSequenceSend, ok := ck.GetNextSequenceSend(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(ok) + suite.Require().Equal(uint64(2), nextSequenceSend, "next sequence send was not incremented correctly") + + } else { + suite.Require().Error(err) + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError) + } + }) + } +} diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 8fb946186fa..02692b93ba9 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -21,73 +21,72 @@ import ( // in order for the packet to be sent to the counterparty. func (k *Keeper) sendPacket( ctx context.Context, - sourceID string, + sourceChannel string, timeoutTimestamp uint64, data []channeltypesv2.PacketData, -) (uint64, error) { +) (uint64, string, error) { // Lookup channel associated with our source channel to retrieve the destination channel - channel, ok := k.GetChannel(ctx, sourceID) + channel, ok := k.GetChannel(ctx, sourceChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceID) + channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceChannel) if !ok { - return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceID) + return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } } - destID := channel.CounterpartyChannelId + destChannel := channel.CounterpartyChannelId clientID := channel.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. - sequence, found := k.GetNextSequenceSend(ctx, sourceID) + sequence, found := k.GetNextSequenceSend(ctx, sourceChannel) if !found { sequence = 1 } // construct packet from given fields and channel state - packet := channeltypesv2.NewPacket(sequence, sourceID, destID, timeoutTimestamp, data...) + packet := channeltypesv2.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, data...) if err := packet.ValidateBasic(); err != nil { - return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) + return 0, "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) } // check that the client of counterparty chain is still active if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) + return 0, "", errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } // retrieve latest height and timestamp of the client of counterparty chain latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) + return 0, "", errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) } latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) if err != nil { - return 0, err + return 0, "", err } // check if packet is timed out on the receiving chain timeout := channeltypes.NewTimeoutWithTimestamp(timeoutTimestamp) if timeout.TimestampElapsed(latestTimestamp) { - return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + return 0, "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") } commitment := channeltypesv2.CommitPacket(packet) // bump the sequence and set the packet commitment, so it is provable by the counterparty - k.SetNextSequenceSend(ctx, sourceID, sequence+1) - k.SetPacketCommitment(ctx, sourceID, packet.GetSequence(), commitment) + k.SetNextSequenceSend(ctx, sourceChannel, sequence+1) + k.SetPacketCommitment(ctx, sourceChannel, packet.GetSequence(), commitment) k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_channel_id", packet.DestinationChannel, "src_channel_id", packet.SourceChannel) EmitSendPacketEvents(ctx, packet) - return sequence, nil + return sequence, destChannel, nil } // recvPacket implements the packet receiving logic required by a packet handler. - // The packet is checked for correctness including asserting that the packet was // sent and received on clients which are counterparties for one another. // If the packet has already been received a no-op error is returned. diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go new file mode 100644 index 00000000000..f2b52aaf802 --- /dev/null +++ b/modules/core/04-channel/v2/types/msgs.go @@ -0,0 +1,11 @@ +package types + +// NewMsgSendPacket creates a new MsgSendPacket instance. +func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer string, packetData ...PacketData) *MsgSendPacket { + return &MsgSendPacket{ + SourceChannel: sourceChannel, + TimeoutTimestamp: timeoutTimestamp, + PacketData: packetData, + Signer: signer, + } +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 2c3b9c980df..a26fbcef482 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -86,7 +86,7 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { // SetRouterV2 sets the v2 router for the IBC Keeper. func (k *Keeper) SetRouterV2(rtr *api.Router) { - k.PortKeeper.RouterV2 = rtr + k.ChannelKeeperV2.Router = rtr } // GetAuthority returns the ibc module's authority. diff --git a/simapp/app.go b/simapp/app.go index f190d17b5a3..2994befb5a4 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -119,13 +119,11 @@ import ( ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" - ibcapi "github.com/cosmos/ibc-go/v9/modules/core/api" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v9/testing/mock" - mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) const appName = "SimApp" @@ -202,9 +200,6 @@ type SimApp struct { ICAAuthModule mock.IBCModule FeeMockModule mock.IBCModule - MockModuleV2A mockv2.IBCModule - MockModuleV2B mockv2.IBCModule - // the module manager ModuleManager *module.Manager BasicModuleManager module.BasicManager @@ -422,7 +417,6 @@ func NewSimApp( // Create IBC Router ibcRouter := porttypes.NewRouter() - ibcRouterV2 := ibcapi.NewRouter() // Middleware Stacks @@ -517,18 +511,8 @@ func NewSimApp( feeWithMockModule := ibcfee.NewIBCMiddleware(feeMockModule, app.IBCFeeKeeper) ibcRouter.AddRoute(MockFeePort, feeWithMockModule) - // create two separate mock v2 applications so that it is possible to test multi packet data. - mockV2A := mockv2.NewIBCModule() - ibcRouterV2.AddRoute(mockv2.ModuleNameA, mockV2A) - app.MockModuleV2A = mockV2A - - mockV2B := mockv2.NewIBCModule() - ibcRouterV2.AddRoute(mockv2.ModuleNameB, mockV2B) - app.MockModuleV2B = mockV2B - // Set the IBC Routers app.IBCKeeper.SetRouter(ibcRouter) - app.IBCKeeper.SetRouterV2(ibcRouterV2) clientKeeper := app.IBCKeeper.ClientKeeper storeProvider := clientKeeper.GetStoreProvider() diff --git a/testing/mock/v2/mock.go b/testing/mock/v2/mock.go index 6f0f56535fc..6ac92899672 100644 --- a/testing/mock/v2/mock.go +++ b/testing/mock/v2/mock.go @@ -1,5 +1,22 @@ package mock +import ( + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/testing/mock" +) + const ( ModuleName = "mockv2" ) + +func NewMockPacketData(sourcePort, destPort string) types.PacketData { + return types.PacketData{ + SourcePort: sourcePort, + DestinationPort: destPort, + Payload: types.Payload{ + Encoding: "json", + Value: mock.MockPacketData, + Version: mock.Version, + }, + } +} diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 77d9de44f57..d9b5cc38ea0 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -105,12 +105,14 @@ import ( ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + ibcapi "github.com/cosmos/ibc-go/v9/modules/core/api" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ibctestingtypes "github.com/cosmos/ibc-go/v9/testing/types" ) @@ -181,6 +183,9 @@ type SimApp struct { ICAAuthModule ibcmock.IBCModule FeeMockModule ibcmock.IBCModule + MockModuleV2A mockv2.IBCModule + MockModuleV2B mockv2.IBCModule + // the module manager ModuleManager *module.Manager BasicModuleManager module.BasicManager @@ -385,6 +390,7 @@ func NewSimApp( // Create IBC Router ibcRouter := porttypes.NewRouter() + ibcRouterV2 := ibcapi.NewRouter() // Middleware Stacks @@ -479,8 +485,18 @@ func NewSimApp( feeWithMockModule := ibcfee.NewIBCMiddleware(feeMockModule, app.IBCFeeKeeper) ibcRouter.AddRoute(MockFeePort, feeWithMockModule) + // create two separate mock v2 applications so that it is possible to test multi packet data. + mockV2A := mockv2.NewIBCModule() + ibcRouterV2.AddRoute(mockv2.ModuleNameA, mockV2A) + app.MockModuleV2A = mockV2A + + mockV2B := mockv2.NewIBCModule() + ibcRouterV2.AddRoute(mockv2.ModuleNameB, mockV2B) + app.MockModuleV2B = mockV2B + // Seal the IBC Router app.IBCKeeper.SetRouter(ibcRouter) + app.IBCKeeper.SetRouterV2(ibcRouterV2) clientKeeper := app.IBCKeeper.ClientKeeper storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider() From cfd1fbaf30a38692da6a80f6224266b65357b5db Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 10 Oct 2024 13:59:22 +0300 Subject: [PATCH 065/172] chore: ensure correct usage of ids. (#7433) --- modules/core/04-channel/v2/keeper/packet.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 02692b93ba9..a3ac7e3401e 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -110,9 +110,10 @@ func (k *Keeper) recvPacket( return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } - if channel.ClientId != packet.SourceChannel { + if channel.CounterpartyChannelId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } + clientID := channel.ClientId // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -140,7 +141,7 @@ func (k *Keeper) recvPacket( if err := k.ClientKeeper.VerifyMembership( ctx, - packet.DestinationChannel, + clientID, proofHeight, 0, 0, proof, @@ -163,15 +164,15 @@ func (k *Keeper) recvPacket( func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Packet, acknowledgement channeltypesv2.Acknowledgement, proof []byte, proofHeight exported.Height) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } - if counterparty.ClientId != packet.DestinationChannel { + if channel.CounterpartyChannelId != packet.DestinationChannel { return channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { @@ -193,7 +194,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa } path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -239,9 +240,13 @@ func (k *Keeper) timeoutPacket( return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } + if channel.CounterpartyChannelId != packet.DestinationChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + clientID := channel.ClientId // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) if err != nil { return err } @@ -274,7 +279,7 @@ func (k *Keeper) timeoutPacket( if err := k.ClientKeeper.VerifyNonMembership( ctx, - packet.SourceChannel, + clientID, proofHeight, 0, 0, proof, From 26b2cd59d4eeea928ce32b3e360f828da31cf826 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 10 Oct 2024 13:15:00 +0200 Subject: [PATCH 066/172] chore: cleanup ids in eureka branch (#7434) * chore: sourceID -> channelID * chore: clientID -> channelID --- modules/core/04-channel/v2/keeper/keeper.go | 60 ++++++++++----------- modules/core/24-host/v2/packet_keys.go | 18 +++---- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 88964e60201..0d2d00a6da9 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -60,15 +60,15 @@ func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.K return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } -// SetChannel sets the Channel for a given client identifier. -func (k *Keeper) SetChannel(ctx context.Context, clientID string, channel types.Channel) { +// SetChannel sets the Channel for a given channel identifier. +func (k *Keeper) SetChannel(ctx context.Context, channelID string, channel types.Channel) { bz := k.cdc.MustMarshal(&channel) - k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) + k.ChannelStore(ctx, channelID).Set([]byte(types.ChannelKey), bz) } -// GetChannel gets the Channel for a given client identifier. -func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel, bool) { - store := k.ChannelStore(ctx, clientID) +// GetChannel gets the Channel for a given channel identifier. +func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channel, bool) { + store := k.ChannelStore(ctx, channelID) bz := store.Get([]byte(types.ChannelKey)) if len(bz) == 0 { return types.Channel{}, false @@ -79,10 +79,10 @@ func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel return channel, true } -// GetPacketReceipt returns the packet receipt from the packet receipt path based on the sourceID and sequence. -func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) ([]byte, bool) { +// GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. +func (k *Keeper) GetPacketReceipt(ctx context.Context, channelID string, sequence uint64) ([]byte, bool) { store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.PacketReceiptKey(sourceID, sequence)) + bz, err := store.Get(hostv2.PacketReceiptKey(channelID, sequence)) if err != nil { panic(err) } @@ -93,9 +93,9 @@ func (k *Keeper) GetPacketReceipt(ctx context.Context, sourceID string, sequence } // HasPacketRceipt returns true if the packet receipt exists, otherwise false. -func (k *Keeper) HasPacketReceipt(ctx context.Context, sourceID string, sequence uint64) bool { +func (k *Keeper) HasPacketReceipt(ctx context.Context, channelID string, sequence uint64) bool { store := k.storeService.OpenKVStore(ctx) - has, err := store.Has(hostv2.PacketReceiptKey(sourceID, sequence)) + has, err := store.Has(hostv2.PacketReceiptKey(channelID, sequence)) if err != nil { panic(err) } @@ -105,26 +105,26 @@ func (k *Keeper) HasPacketReceipt(ctx context.Context, sourceID string, sequence // SetPacketReceipt writes the packet receipt under the receipt path // This is a public path that is standardized by the IBC V2 specification. -func (k *Keeper) SetPacketReceipt(ctx context.Context, sourceID string, sequence uint64) { +func (k *Keeper) SetPacketReceipt(ctx context.Context, channelID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketReceiptKey(sourceID, sequence), []byte{byte(1)}); err != nil { + if err := store.Set(hostv2.PacketReceiptKey(channelID, sequence), []byte{byte(1)}); err != nil { panic(err) } } // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC V2 specification. -func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64, ackHash []byte) { +func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64, ackHash []byte) { store := k.storeService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketAcknowledgementKey(sourceID, sequence), ackHash); err != nil { + if err := store.Set(hostv2.PacketAcknowledgementKey(channelID, sequence), ackHash); err != nil { panic(err) } } // HasPacketAcknowledgement check if the packet ack hash is already on the store. -func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, sequence uint64) bool { +func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) bool { store := k.storeService.OpenKVStore(ctx) - found, err := store.Has(hostv2.PacketAcknowledgementKey(sourceID, sequence)) + found, err := store.Has(hostv2.PacketAcknowledgementKey(channelID, sequence)) if err != nil { panic(err) } @@ -133,9 +133,9 @@ func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, sourceID string, } // GetPacketCommitment returns the packet commitment hash under the commitment path. -func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, sequence uint64) []byte { +func (k *Keeper) GetPacketCommitment(ctx context.Context, channelID string, sequence uint64) []byte { store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.PacketCommitmentKey(sourceID, sequence)) + bz, err := store.Get(hostv2.PacketCommitmentKey(channelID, sequence)) if err != nil { panic(err) } @@ -146,25 +146,25 @@ func (k *Keeper) GetPacketCommitment(ctx context.Context, sourceID string, seque } // SetPacketCommitment writes the commitment hash under the commitment path. -func (k *Keeper) SetPacketCommitment(ctx context.Context, sourceID string, sequence uint64, commitment []byte) { +func (k *Keeper) SetPacketCommitment(ctx context.Context, channelID string, sequence uint64, commitment []byte) { store := k.storeService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketCommitmentKey(sourceID, sequence), commitment); err != nil { + if err := store.Set(hostv2.PacketCommitmentKey(channelID, sequence), commitment); err != nil { panic(err) } } // DeletePacketCommitment deletes the packet commitment hash under the commitment path. -func (k *Keeper) DeletePacketCommitment(ctx context.Context, sourceID string, sequence uint64) { +func (k *Keeper) DeletePacketCommitment(ctx context.Context, channelID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) - if err := store.Delete(hostv2.PacketCommitmentKey(sourceID, sequence)); err != nil { + if err := store.Delete(hostv2.PacketCommitmentKey(channelID, sequence)); err != nil { panic(err) } } // GetNextSequenceSend returns the next send sequence from the sequence path -func (k *Keeper) GetNextSequenceSend(ctx context.Context, sourceID string) (uint64, bool) { +func (k *Keeper) GetNextSequenceSend(ctx context.Context, channelID string) (uint64, bool) { store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.NextSequenceSendKey(sourceID)) + bz, err := store.Get(hostv2.NextSequenceSendKey(channelID)) if err != nil { panic(err) } @@ -175,10 +175,10 @@ func (k *Keeper) GetNextSequenceSend(ctx context.Context, sourceID string) (uint } // SetNextSequenceSend writes the next send sequence under the sequence path -func (k *Keeper) SetNextSequenceSend(ctx context.Context, sourceID string, sequence uint64) { +func (k *Keeper) SetNextSequenceSend(ctx context.Context, channelID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(hostv2.NextSequenceSendKey(sourceID), bigEndianBz); err != nil { + if err := store.Set(hostv2.NextSequenceSendKey(channelID), bigEndianBz); err != nil { panic(err) } } @@ -212,10 +212,10 @@ func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) ( // convertV1Channel attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it // to a v2 counterparty and stores it in the v2 channel keeper for future use func (k *Keeper) convertV1Channel(ctx context.Context, port, id string) (types.Channel, bool) { - if counterparty, ok := k.AliasV1Channel(ctx, port, id); ok { + if channel, ok := k.AliasV1Channel(ctx, port, id); ok { // we can key on just the channel here since channel ids are globally unique - k.SetChannel(ctx, id, counterparty) - return counterparty, true + k.SetChannel(ctx, id, channel) + return channel, true } return types.Channel{}, false diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index aebd1255f88..a556df4de38 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -8,21 +8,21 @@ import ( // PacketReceiptKey returns the store key of under which a packet // receipt is stored -func PacketReceiptKey(sourceID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) +func PacketReceiptKey(channelID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) } // PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. -func PacketAcknowledgementKey(sourceID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) +func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) } // PacketCommitmentKey returns the store key of under which a packet commitment is stored. -func PacketCommitmentKey(sourceID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", sourceID, sdk.Uint64ToBigEndian(sequence))) +func PacketCommitmentKey(channelID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) } -// NextSequenceSendKey returns the store key for the next sequence send of a given sourceID. -func NextSequenceSendKey(sourceID string) []byte { - return []byte(fmt.Sprintf("nextSequenceSend/%s", sourceID)) +// NextSequenceSendKey returns the store key for the next sequence send of a given channelID. +func NextSequenceSendKey(channelID string) []byte { + return []byte(fmt.Sprintf("nextSequenceSend/%s", channelID)) } From 5fdd3445780699ef7c060f8073d5b501bd6eaa11 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 14 Oct 2024 12:37:39 +0300 Subject: [PATCH 067/172] chore: move tx's to channel/v2 (#7435) * chore: move tx's to channel/v2 * Use channel identifier when setting creator. --- e2e/testsuite/codec.go | 4 +- .../v2}/client/cli/cli.go | 0 .../v2}/client/cli/query.go | 2 +- .../v2}/client/cli/tx.go | 2 +- modules/core/04-channel/v2/keeper/events.go | 18 + .../v2}/keeper/grpc_query.go | 2 +- .../v2}/keeper/grpc_query_test.go | 14 +- modules/core/04-channel/v2/keeper/keeper.go | 23 + .../core/04-channel/v2/keeper/keeper_test.go | 45 + .../core/04-channel/v2/keeper/msg_server.go | 44 + .../04-channel/v2/keeper/msg_server_test.go | 71 ++ modules/core/04-channel/v2/keeper/packet.go | 15 +- .../v2}/module.go | 4 +- modules/core/04-channel/v2/types/codec.go | 2 + .../v2}/types/events.go | 0 modules/core/04-channel/v2/types/keys.go | 5 + .../v2}/types/merkle.go | 0 .../v2}/types/merkle_test.go | 24 +- modules/core/04-channel/v2/types/msgs.go | 70 ++ .../v2}/types/msgs_test.go | 23 +- .../v2}/types/query.pb.go | 76 +- .../v2}/types/query.pb.gw.go | 2 +- modules/core/04-channel/v2/types/tx.pb.go | 1013 ++++++++++++++- modules/core/client/cli/cli.go | 6 +- modules/core/keeper/msg_server.go | 46 - modules/core/keeper/msg_server_test.go | 69 -- modules/core/module.go | 5 - modules/core/packet-server/keeper/events.go | 25 - modules/core/packet-server/keeper/keeper.go | 23 - .../core/packet-server/keeper/keeper_test.go | 53 - modules/core/packet-server/keeper/relay.go | 7 +- modules/core/packet-server/types/codec.go | 15 - modules/core/packet-server/types/keys.go | 5 - modules/core/packet-server/types/msgs.go | 68 - modules/core/packet-server/types/tx.pb.go | 1091 ----------------- modules/core/types/codec.go | 2 - .../v1 => channel/v2}/query.proto | 6 +- proto/ibc/core/channel/v2/tx.proto | 48 + proto/ibc/core/packetserver/v1/tx.proto | 62 - testing/endpoint.go | 6 +- testing/events.go | 4 +- 41 files changed, 1373 insertions(+), 1627 deletions(-) rename modules/core/{packet-server => 04-channel/v2}/client/cli/cli.go (100%) rename modules/core/{packet-server => 04-channel/v2}/client/cli/query.go (95%) rename modules/core/{packet-server => 04-channel/v2}/client/cli/tx.go (95%) rename modules/core/{packet-server => 04-channel/v2}/keeper/grpc_query.go (95%) rename modules/core/{packet-server => 04-channel/v2}/keeper/grpc_query_test.go (78%) rename modules/core/{packet-server => 04-channel/v2}/module.go (75%) rename modules/core/{packet-server => 04-channel/v2}/types/events.go (100%) rename modules/core/{packet-server => 04-channel/v2}/types/merkle.go (100%) rename modules/core/{packet-server => 04-channel/v2}/types/merkle_test.go (78%) rename modules/core/{packet-server => 04-channel/v2}/types/msgs_test.go (81%) rename modules/core/{packet-server => 04-channel/v2}/types/query.pb.go (83%) rename modules/core/{packet-server => 04-channel/v2}/types/query.pb.gw.go (99%) delete mode 100644 modules/core/packet-server/keeper/events.go delete mode 100644 modules/core/packet-server/keeper/keeper_test.go delete mode 100644 modules/core/packet-server/types/codec.go delete mode 100644 modules/core/packet-server/types/msgs.go delete mode 100644 modules/core/packet-server/types/tx.pb.go rename proto/ibc/core/{packetserver/v1 => channel/v2}/query.proto (80%) delete mode 100644 proto/ibc/core/packetserver/v1/tx.proto diff --git a/e2e/testsuite/codec.go b/e2e/testsuite/codec.go index 5de0570cd18..cb90333b30a 100644 --- a/e2e/testsuite/codec.go +++ b/e2e/testsuite/codec.go @@ -32,7 +32,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -70,7 +70,7 @@ func codecAndEncodingConfig() (*codec.ProtoCodec, testutil.TestEncodingConfig) { connectiontypes.RegisterInterfaces(cfg.InterfaceRegistry) ibctmtypes.RegisterInterfaces(cfg.InterfaceRegistry) wasmtypes.RegisterInterfaces(cfg.InterfaceRegistry) - packetservertypes.RegisterInterfaces(cfg.InterfaceRegistry) + channeltypesv2.RegisterInterfaces(cfg.InterfaceRegistry) // all other types upgradetypes.RegisterInterfaces(cfg.InterfaceRegistry) diff --git a/modules/core/packet-server/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go similarity index 100% rename from modules/core/packet-server/client/cli/cli.go rename to modules/core/04-channel/v2/client/cli/cli.go diff --git a/modules/core/packet-server/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go similarity index 95% rename from modules/core/packet-server/client/cli/query.go rename to modules/core/04-channel/v2/client/cli/query.go index 82e87400007..822284192b2 100644 --- a/modules/core/packet-server/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // getCmdQueryChannel defines the command to query the client information (creator and channel) for the given client ID. diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/04-channel/v2/client/cli/tx.go similarity index 95% rename from modules/core/packet-server/client/cli/tx.go rename to modules/core/04-channel/v2/client/cli/tx.go index a1180c24b87..746012fcb32 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/04-channel/v2/client/cli/tx.go @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC channel. diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 9d90ff5b36e..061826315e0 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -3,6 +3,8 @@ package keeper import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) @@ -25,3 +27,19 @@ func EmitAcknowledgePacketEvents(ctx context.Context, packet channeltypesv2.Pack func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } + +// EmitCreateChannelEvent emits a channel create event. +func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + channeltypesv2.EventTypeCreateChannel, + sdk.NewAttribute(channeltypesv2.AttributeKeyChannelID, channelID), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, channeltypesv2.AttributeValueCategory), + ), + }) +} diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go similarity index 95% rename from modules/core/packet-server/keeper/grpc_query.go rename to modules/core/04-channel/v2/keeper/grpc_query.go index bc0182180bf..fde351da818 100644 --- a/modules/core/packet-server/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) var _ types.QueryServer = (*queryServer)(nil) diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go similarity index 78% rename from modules/core/packet-server/keeper/grpc_query_test.go rename to modules/core/04-channel/v2/keeper/grpc_query_test.go index 79a2987c789..ad50fe3c6ba 100644 --- a/modules/core/packet-server/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -6,9 +6,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -28,8 +28,8 @@ func (suite *KeeperTestSuite) TestQueryChannel() { "success", func() { ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstChannelID, expCreator) - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(ctx, ibctesting.FirstChannelID, expCreator) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) req = &types.QueryChannelRequest{ ChannelId: ibctesting.FirstChannelID, @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() { func() { expCreator = "" - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, expChannel) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, expChannel) req = &types.QueryChannelRequest{ ChannelId: ibctesting.FirstChannelID, @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() { func() { expChannel = types.Channel{} - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expCreator) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expCreator) req = &types.QueryChannelRequest{ ChannelId: ibctesting.FirstChannelID, @@ -100,7 +100,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() { tc.malleate() - queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.PacketServerKeeper) + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) res, err := queryServer.Channel(suite.chainA.GetContext(), req) expPass := tc.expError == nil diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 0d2d00a6da9..7cb64278ff8 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -79,6 +79,29 @@ func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channe return channel, true } +// GetCreator returns the creator of the client. +func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + bz := k.ChannelStore(sdkCtx, clientID).Get([]byte(types.CreatorKey)) + if len(bz) == 0 { + return "", false + } + + return string(bz), true +} + +// SetCreator sets the creator of the client. +func (k *Keeper) SetCreator(ctx context.Context, clientID, creator string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + k.ChannelStore(sdkCtx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) +} + +// DeleteCreator deletes the creator associated with the client. +func (k *Keeper) DeleteCreator(ctx context.Context, clientID string) { + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 + k.ChannelStore(sdkCtx, clientID).Delete([]byte(types.CreatorKey)) +} + // GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. func (k *Keeper) GetPacketReceipt(ctx context.Context, channelID string, sequence uint64) ([]byte, bool) { store := k.storeService.OpenKVStore(ctx) diff --git a/modules/core/04-channel/v2/keeper/keeper_test.go b/modules/core/04-channel/v2/keeper/keeper_test.go index 80363d813d7..93580d13d77 100644 --- a/modules/core/04-channel/v2/keeper/keeper_test.go +++ b/modules/core/04-channel/v2/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypes2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -107,3 +108,47 @@ func (suite *KeeperTestSuite) TestAliasV1Channel() { }) } } + +func (suite *KeeperTestSuite) TestSetChannel() { + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + channel := channeltypes2.Channel{ + ClientId: ibctesting.FirstClientID, + MerklePathPrefix: merklePathPrefix, + } + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, channel) + + retrievedChannel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID) + suite.Require().True(found, "GetChannel does not return channel") + suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") + + // Channel not yet stored for another client. + retrievedChannel, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetChannel unexpectedly returned a channel") + suite.Require().Equal(channeltypes2.Channel{}, retrievedChannel, "Channel retrieved not empty") +} + +func (suite *KeeperTestSuite) TestSetCreator() { + clientID := ibctesting.FirstClientID + expectedCreator := "test-creator" + + // Set the creator for the client + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), clientID, expectedCreator) + + // Retrieve the creator from the store + retrievedCreator, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), clientID) + + // Verify that the retrieved creator matches the expected creator + suite.Require().True(found, "GetCreator did not return stored creator") + suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") + + // Verify non stored creator is not found + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Empty(retrievedCreator, "Creator is not empty") + + // Verify that the creator is deleted from the store + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), clientID) + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), clientID) + suite.Require().False(found, "GetCreator unexpectedly returned a creator") + suite.Require().Empty(retrievedCreator, "Creator is not empty") +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 740ebb02daa..d86b87e3432 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -9,6 +9,7 @@ import ( channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) var _ channeltypesv2.MsgServer = &Keeper{} @@ -135,3 +136,46 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil } + +// CreateChannel defines a rpc handler method for MsgCreateChannel +func (k *Keeper) CreateChannel(goCtx context.Context, msg *channeltypesv2.MsgCreateChannel) (*channeltypesv2.MsgCreateChannelResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + channelID := k.channelKeeperV1.GenerateChannelIdentifier(ctx) + + // Initialize channel with empty counterparty channel identifier. + channel := channeltypesv2.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + k.SetChannel(ctx, channelID, channel) + + k.SetCreator(ctx, channelID, msg.Signer) + + k.EmitCreateChannelEvent(goCtx, channelID) + + return &channeltypesv2.MsgCreateChannelResponse{ChannelId: channelID}, nil +} + +// ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. +func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *channeltypesv2.MsgProvideCounterparty) (*channeltypesv2.MsgProvideCounterpartyResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + creator, found := k.GetCreator(ctx, msg.ChannelId) + if !found { + return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") + } + + if creator != msg.Signer { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) + } + + channel, ok := k.GetChannel(ctx, msg.ChannelId) + if !ok { + return nil, errorsmod.Wrapf(channeltypesv2.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) + } + + channel.CounterpartyChannelId = msg.CounterpartyChannelId + k.SetChannel(ctx, msg.ChannelId, channel) + // Delete client creator from state as it is not needed after this point. + k.DeleteCreator(ctx, msg.ChannelId) + + return &channeltypesv2.MsgProvideCounterpartyResponse{}, nil +} diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 1f4aabd1c86..4fd61d3f2e3 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -9,6 +9,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" @@ -111,3 +112,73 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { }) } } + +func (suite *KeeperTestSuite) TestProvideCounterparty() { + var ( + path *ibctesting.Path + msg *channeltypesv2.MsgProvideCounterparty + ) + cases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() { + // set it before handler + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, channeltypesv2.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + }, + nil, + }, + + { + "failure: signer does not match creator", + func() { + msg.Signer = path.EndpointB.Chain.SenderAccount.GetAddress().String() + }, + ibcerrors.ErrUnauthorized, + }, + /* // Account sequence mismatch, expected 5, got 6. :thinking: + { + "failure: counterparty does not already exists", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) + }, + channeltypesv2.ErrInvalidChannel, + }, + */ + } + + for _, tc := range cases { + tc := tc + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupClients() + + suite.Require().NoError(path.EndpointA.CreateChannel()) + suite.Require().NoError(path.EndpointB.CreateChannel()) + + signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() + msg = channeltypesv2.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) + + tc.malleate() + + res, err := path.EndpointA.Chain.SendMsgs(msg) + + expPass := tc.expError == nil + if expPass { + suite.Require().NotNil(res) + suite.Require().Nil(err) + + // Assert counterparty channel id filled in and creator deleted + channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) + + _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().False(found) + } else { + suite.Require().Error(err) + } + } +} diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index a3ac7e3401e..360b1611de6 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -14,7 +14,6 @@ import ( channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // sendPacket constructs a packet from the input arguments, writes a packet commitment to state @@ -31,7 +30,7 @@ func (k *Keeper) sendPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceChannel) if !ok { - return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) + return 0, "", errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, sourceChannel) } } @@ -107,7 +106,7 @@ func (k *Keeper) recvPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) + return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.DestinationChannel) } } if channel.CounterpartyChannelId != packet.SourceChannel { @@ -135,7 +134,7 @@ func (k *Keeper) recvPacket( } path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) commitment := channeltypesv2.CommitPacket(packet) @@ -166,7 +165,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa // that the packet was indeed sent by our counterparty. channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) + return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.SourceChannel) } if channel.CounterpartyChannelId != packet.DestinationChannel { @@ -194,7 +193,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa } path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -237,7 +236,7 @@ func (k *Keeper) timeoutPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceChannel) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) + return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.DestinationChannel) } } if channel.CounterpartyChannelId != packet.DestinationChannel { @@ -275,7 +274,7 @@ func (k *Keeper) timeoutPacket( // verify packet receipt absence path := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/packet-server/module.go b/modules/core/04-channel/v2/module.go similarity index 75% rename from modules/core/packet-server/module.go rename to modules/core/04-channel/v2/module.go index c695542ca50..9bc3ad94699 100644 --- a/modules/core/packet-server/module.go +++ b/modules/core/04-channel/v2/module.go @@ -3,8 +3,8 @@ package client import ( "github.com/spf13/cobra" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/client/cli" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/client/cli" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) // Name returns the IBC client name diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index 1053c8b64d6..79941f59175 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -14,5 +14,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgRecvPacket{}, &MsgTimeout{}, &MsgAcknowledgement{}, + &MsgCreateChannel{}, + &MsgProvideCounterparty{}, ) } diff --git a/modules/core/packet-server/types/events.go b/modules/core/04-channel/v2/types/events.go similarity index 100% rename from modules/core/packet-server/types/events.go rename to modules/core/04-channel/v2/types/events.go diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index 965f010716e..af3f68c5449 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -8,4 +8,9 @@ const ( // the channel key is imported from types instead of host because // the channel key is not a part of the ics-24 host specification ChannelKey = "channel" + + // CreatorKey is the key used to store the client creator in the client store + // the creator key is imported from types instead of host because + // the creator key is not a part of the ics-24 host specification + CreatorKey = "creator" ) diff --git a/modules/core/packet-server/types/merkle.go b/modules/core/04-channel/v2/types/merkle.go similarity index 100% rename from modules/core/packet-server/types/merkle.go rename to modules/core/04-channel/v2/types/merkle.go diff --git a/modules/core/packet-server/types/merkle_test.go b/modules/core/04-channel/v2/types/merkle_test.go similarity index 78% rename from modules/core/packet-server/types/merkle_test.go rename to modules/core/04-channel/v2/types/merkle_test.go index 46c75dd2303..8990d05a83d 100644 --- a/modules/core/packet-server/types/merkle_test.go +++ b/modules/core/04-channel/v2/types/merkle_test.go @@ -1,35 +1,13 @@ package types_test import ( - "testing" - - "github.com/stretchr/testify/suite" - + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -type TypesTestSuite struct { - suite.Suite - - coordinator *ibctesting.Coordinator - chainA *ibctesting.TestChain - chainB *ibctesting.TestChain -} - -func (s *TypesTestSuite) SetupTest() { - s.coordinator = ibctesting.NewCoordinator(s.T(), 2) - s.chainA = s.coordinator.GetChain(ibctesting.GetChainID(1)) - s.chainB = s.coordinator.GetChain(ibctesting.GetChainID(2)) -} - -func TestTypesTestSuite(t *testing.T) { - suite.Run(t, new(TypesTestSuite)) -} - func (s *TypesTestSuite) TestBuildMerklePath() { path := ibctesting.NewPath(s.chainA, s.chainB) path.SetupV2() diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index f2b52aaf802..936157cc5c7 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -1,5 +1,75 @@ package types +import ( + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" +) + +var ( + _ sdk.Msg = (*MsgProvideCounterparty)(nil) + _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) + + _ sdk.Msg = (*MsgCreateChannel)(nil) + _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) +) + +// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance +func NewMsgProvideCounterparty(channelID, counterpartyChannelID string, signer string) *MsgProvideCounterparty { + return &MsgProvideCounterparty{ + Signer: signer, + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, + } +} + +// ValidateBasic performs basic checks on a MsgProvideCounterparty. +func (msg *MsgProvideCounterparty) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + return err + } + + if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { + return err + } + + return nil +} + +// NewMsgCreateChannel creates a new MsgCreateChannel instance +func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgCreateChannel { + return &MsgCreateChannel{ + Signer: signer, + ClientId: clientID, + MerklePathPrefix: merklePathPrefix, + } +} + +// ValidateBasic performs basic checks on a MsgCreateChannel. +func (msg *MsgCreateChannel) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + return err + } + + if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { + return err + } + + return nil +} + // NewMsgSendPacket creates a new MsgSendPacket instance. func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer string, packetData ...PacketData) *MsgSendPacket { return &MsgSendPacket{ diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go similarity index 81% rename from modules/core/packet-server/types/msgs_test.go rename to modules/core/04-channel/v2/types/msgs_test.go index c6af4cf8684..48ce0d511a1 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -2,14 +2,35 @@ package types_test import ( "errors" + "testing" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) +type TypesTestSuite struct { + suite.Suite + + coordinator *ibctesting.Coordinator + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain +} + +func (s *TypesTestSuite) SetupTest() { + s.coordinator = ibctesting.NewCoordinator(s.T(), 2) + s.chainA = s.coordinator.GetChain(ibctesting.GetChainID(1)) + s.chainB = s.coordinator.GetChain(ibctesting.GetChainID(2)) +} + +func TestTypesTestSuite(t *testing.T) { + suite.Run(t, new(TypesTestSuite)) +} + // TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { var msg *types.MsgProvideCounterparty diff --git a/modules/core/packet-server/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go similarity index 83% rename from modules/core/packet-server/types/query.pb.go rename to modules/core/04-channel/v2/types/query.pb.go index 694ab5b79ba..04c4360c60d 100644 --- a/modules/core/packet-server/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/packetserver/v1/query.proto +// source: ibc/core/channel/v2/query.proto package types @@ -38,7 +38,7 @@ func (m *QueryChannelRequest) Reset() { *m = QueryChannelRequest{} } func (m *QueryChannelRequest) String() string { return proto.CompactTextString(m) } func (*QueryChannelRequest) ProtoMessage() {} func (*QueryChannelRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7ac0ae50eee8e6db, []int{0} + return fileDescriptor_a328cba4986edcab, []int{0} } func (m *QueryChannelRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -84,7 +84,7 @@ func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } func (m *QueryChannelResponse) String() string { return proto.CompactTextString(m) } func (*QueryChannelResponse) ProtoMessage() {} func (*QueryChannelResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7ac0ae50eee8e6db, []int{1} + return fileDescriptor_a328cba4986edcab, []int{1} } func (m *QueryChannelResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -128,38 +128,36 @@ func (m *QueryChannelResponse) GetChannel() Channel { } func init() { - proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.packetserver.v1.QueryChannelRequest") - proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.packetserver.v1.QueryChannelResponse") -} - -func init() { - proto.RegisterFile("ibc/core/packetserver/v1/query.proto", fileDescriptor_7ac0ae50eee8e6db) -} - -var fileDescriptor_7ac0ae50eee8e6db = []byte{ - // 351 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0x45, 0x2d, 0x8d, 0x5b, 0xec, 0x70, 0x14, 0x3d, 0x6b, 0x11, 0xa9, 0x48, 0x13, - 0x5a, 0x5d, 0x04, 0x17, 0xeb, 0xe4, 0x68, 0x07, 0x07, 0x17, 0xb9, 0x4b, 0xc3, 0xf5, 0xb0, 0xbd, - 0x77, 0x4d, 0x72, 0x07, 0x45, 0x5c, 0xfc, 0x04, 0x82, 0xa3, 0xb3, 0xdf, 0xa5, 0x63, 0xc1, 0xc5, - 0x49, 0xa4, 0xf5, 0x83, 0xc8, 0xf5, 0xd2, 0x5a, 0xc1, 0x03, 0xb7, 0x97, 0x97, 0xff, 0xff, 0x97, - 0xf7, 0xf2, 0xc7, 0xfb, 0x81, 0xc7, 0x19, 0x07, 0x29, 0x58, 0xe4, 0xf2, 0x3b, 0xa1, 0x95, 0x90, - 0x89, 0x90, 0x2c, 0x69, 0xb2, 0x61, 0x2c, 0xe4, 0x88, 0x46, 0x12, 0x34, 0x10, 0x3b, 0xf0, 0x38, - 0x4d, 0x55, 0x74, 0x55, 0x45, 0x93, 0x66, 0xe5, 0x20, 0xd7, 0xcf, 0x7b, 0x6e, 0x18, 0x8a, 0x7e, - 0x46, 0xa8, 0x6c, 0xfb, 0x00, 0x7e, 0x5f, 0x30, 0x37, 0x0a, 0x98, 0x1b, 0x86, 0xa0, 0x5d, 0x1d, - 0x40, 0xa8, 0xcc, 0x6d, 0xd9, 0x07, 0x1f, 0xe6, 0x25, 0x4b, 0xab, 0xac, 0x5b, 0x3b, 0xc1, 0x5b, - 0x57, 0xe9, 0x10, 0x17, 0x19, 0xa9, 0x23, 0x86, 0xb1, 0x50, 0x9a, 0xec, 0x60, 0x6c, 0xd8, 0xb7, - 0x41, 0xd7, 0x46, 0x55, 0x54, 0x2f, 0x75, 0x4a, 0xa6, 0x73, 0xd9, 0xad, 0x29, 0x5c, 0xfe, 0xed, - 0x52, 0x11, 0x84, 0x4a, 0x10, 0x1b, 0x17, 0xb9, 0x14, 0xae, 0x06, 0x69, 0x3c, 0x8b, 0x23, 0x39, - 0xc7, 0x45, 0x63, 0xb7, 0x0b, 0x55, 0x54, 0xdf, 0x6c, 0xed, 0xd1, 0xbc, 0x7d, 0xa9, 0xa1, 0xb6, - 0xd7, 0xc6, 0x1f, 0xbb, 0x56, 0x67, 0xe1, 0x6b, 0xbd, 0x22, 0xbc, 0x3e, 0x7f, 0x95, 0xbc, 0x20, - 0x5c, 0x34, 0x22, 0xd2, 0xc8, 0xe7, 0xfc, 0xb1, 0x58, 0x85, 0xfe, 0x57, 0x9e, 0x6d, 0x54, 0x6b, - 0x3e, 0xbe, 0x7d, 0x3d, 0x17, 0x8e, 0xc8, 0x21, 0x5b, 0x86, 0x60, 0xe6, 0x61, 0x49, 0x6b, 0x59, - 0xde, 0xff, 0x7c, 0xd6, 0x43, 0xfb, 0x7a, 0x3c, 0x75, 0xd0, 0x64, 0xea, 0xa0, 0xcf, 0xa9, 0x83, - 0x9e, 0x66, 0x8e, 0x35, 0x99, 0x39, 0xd6, 0xfb, 0xcc, 0xb1, 0x6e, 0xce, 0xfc, 0x40, 0xf7, 0x62, - 0x8f, 0x72, 0x18, 0x30, 0x0e, 0x6a, 0x00, 0x2a, 0xa5, 0x36, 0x7c, 0x60, 0xc9, 0x29, 0x1b, 0x40, - 0x37, 0xee, 0x0b, 0xb5, 0x1a, 0x74, 0xc3, 0x24, 0xad, 0x47, 0x91, 0x50, 0xde, 0xc6, 0x3c, 0xb1, - 0xe3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xe3, 0xea, 0xfa, 0x4f, 0x02, 0x00, 0x00, + proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") + proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } + +var fileDescriptor_a328cba4986edcab = []byte{ + // 339 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0x48, 0xcc, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0xd2, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xce, 0x4c, 0x4a, + 0xd6, 0x03, 0x29, 0xd0, 0x83, 0x2a, 0xd0, 0x2b, 0x33, 0x92, 0x52, 0xc4, 0xa6, 0x0b, 0x26, 0x0f, + 0xd6, 0x27, 0x25, 0x93, 0x9e, 0x9f, 0x9f, 0x9e, 0x93, 0xaa, 0x9f, 0x58, 0x90, 0xa9, 0x9f, 0x98, + 0x97, 0x97, 0x5f, 0x92, 0x58, 0x92, 0x99, 0x9f, 0x57, 0x0c, 0x95, 0x15, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x33, 0xf5, 0x41, 0x2c, 0x88, 0xa8, 0x92, 0x09, 0x97, 0x70, 0x20, 0xc8, 0x6a, 0x67, 0x88, + 0x49, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0xb2, 0x5c, 0x5c, 0x50, 0xb3, 0xe3, 0x33, + 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x38, 0xa1, 0x22, 0x9e, 0x29, 0x4a, 0x79, 0x5c, + 0x22, 0xa8, 0xba, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x24, 0xb8, 0xd8, 0x93, 0x8b, 0x52, + 0x13, 0x4b, 0xf2, 0x8b, 0xa0, 0x7a, 0x60, 0x5c, 0x21, 0x1b, 0x2e, 0x76, 0xa8, 0x76, 0x09, 0x26, + 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x19, 0x3d, 0x2c, 0xbe, 0xd4, 0x83, 0x1a, 0xe8, 0xc4, 0x72, 0xe2, + 0x9e, 0x3c, 0x43, 0x10, 0x4c, 0x8b, 0xd1, 0x6c, 0x46, 0x2e, 0x56, 0xb0, 0x85, 0x42, 0x13, 0x19, + 0xb9, 0xd8, 0xa1, 0x8a, 0x84, 0x34, 0xb0, 0x1a, 0x81, 0xc5, 0x3b, 0x52, 0x9a, 0x44, 0xa8, 0x84, + 0x78, 0x41, 0xc9, 0xb0, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0xda, 0x42, 0x9a, 0xfa, 0x78, 0x02, 0x5c, + 0xbf, 0x1a, 0x11, 0x3a, 0xb5, 0x4e, 0x61, 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, 0x65, 0x93, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, + 0x9c, 0x9b, 0x5f, 0x0c, 0x32, 0x55, 0x37, 0x3d, 0x5f, 0xbf, 0xcc, 0x52, 0x3f, 0x37, 0x3f, 0xa5, + 0x34, 0x27, 0xb5, 0x18, 0x62, 0x87, 0x81, 0x89, 0x2e, 0x92, 0x35, 0x25, 0x95, 0x05, 0xa9, 0xc5, + 0x49, 0x6c, 0xe0, 0x28, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x69, 0x95, 0xfc, 0x31, + 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -188,7 +186,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) { out := new(QueryChannelResponse) - err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Channel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/Channel", in, out, opts...) if err != nil { return nil, err } @@ -223,7 +221,7 @@ func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.packetserver.v1.Query/Channel", + FullMethod: "/ibc.core.channel.v2.Query/Channel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Channel(ctx, req.(*QueryChannelRequest)) @@ -232,7 +230,7 @@ func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(inter } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.packetserver.v1.Query", + ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -241,7 +239,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "ibc/core/packetserver/v1/query.proto", + Metadata: "ibc/core/channel/v2/query.proto", } func (m *QueryChannelRequest) Marshal() (dAtA []byte, err error) { diff --git a/modules/core/packet-server/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go similarity index 99% rename from modules/core/packet-server/types/query.pb.gw.go rename to modules/core/04-channel/v2/types/query.pb.gw.go index caea72e9575..6ed5d7819e6 100644 --- a/modules/core/packet-server/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: ibc/core/packetserver/v1/query.proto +// source: ibc/core/channel/v2/query.proto /* Package types is a reverse proxy. diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 0532c9c4c4a..b8b915f78bc 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -12,6 +12,7 @@ import ( proto "github.com/cosmos/gogoproto/proto" types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" types1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -349,6 +350,170 @@ func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +type MsgProvideCounterparty struct { + // unique identifier we will use to write all packet messages sent to counterparty + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // counterparty channel identifier + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } +func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterparty) ProtoMessage() {} +func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{8} +} +func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +} +func (m *MsgProvideCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +type MsgProvideCounterpartyResponse struct { +} + +func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } +func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterpartyResponse) ProtoMessage() {} +func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{9} +} +func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +} +func (m *MsgProvideCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo + +// MsgCreateChannel defines the message used to create a v2 Channel. +type MsgCreateChannel struct { + // the client identifier of the light client representing the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } +func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannel) ProtoMessage() {} +func (*MsgCreateChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{10} +} +func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannel.Merge(m, src) +} +func (m *MsgCreateChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +type MsgCreateChannelResponse struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } +func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannelResponse) ProtoMessage() {} +func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{11} +} +func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannelResponse.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 *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) +} +func (m *MsgCreateChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") @@ -358,58 +523,73 @@ func init() { proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v2.MsgTimeoutResponse") proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.core.channel.v2.MsgAcknowledgement") proto.RegisterType((*MsgAcknowledgementResponse)(nil), "ibc.core.channel.v2.MsgAcknowledgementResponse") + proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.channel.v2.MsgProvideCounterparty") + proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgProvideCounterpartyResponse") + proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") + proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 724 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 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- 0x2b, 0x6e, 0xab, 0xde, 0x83, 0x39, 0x4a, 0xda, 0x01, 0xc2, 0x35, 0x69, 0x98, 0x53, 0x8a, 0xca, - 0xe2, 0x15, 0x73, 0x56, 0x44, 0x37, 0x44, 0x50, 0x7d, 0x00, 0x57, 0x99, 0xe3, 0x62, 0xd2, 0x66, - 0xb5, 0xe8, 0x49, 0x99, 0xe5, 0xfa, 0xb9, 0xa9, 0xa2, 0xb2, 0x98, 0x32, 0xe7, 0x65, 0xa2, 0xda, - 0x8d, 0xab, 0x2f, 0x20, 0x23, 0x9a, 0xae, 0x35, 0x2c, 0x66, 0xe5, 0x92, 0xc5, 0xe4, 0x62, 0xa6, - 0x52, 0xd0, 0x47, 0x00, 0xd2, 0x45, 0x17, 0xcf, 0x2d, 0x66, 0xad, 0xa7, 0x0e, 0xfe, 0x16, 0x12, - 0x26, 0xf8, 0x71, 0x44, 0xbd, 0x09, 0x69, 0xea, 0xd8, 0x1e, 0x0e, 0x72, 0x29, 0xde, 0x93, 0xfc, - 0x5a, 0xcd, 0x7e, 0xfd, 0x59, 0x48, 0x7c, 0x39, 0xde, 0x5f, 0x92, 0x81, 0xd2, 0x0a, 0xdc, 0x18, - 0x98, 0x95, 0x89, 0xa9, 0x4f, 0x3c, 0x8a, 0x55, 0x0d, 0x2e, 0x53, 0xfc, 0xb1, 0x8d, 0x3d, 0x84, - 0xf9, 0xbc, 0x52, 0x66, 0xfc, 0xbd, 0x9a, 0x8a, 0x5c, 0x4a, 0x1d, 0x41, 0xc4, 0xc4, 0x28, 0x94, - 0x44, 0x56, 0x20, 0x2d, 0x7a, 0xe0, 0x23, 0x32, 0x95, 0xdb, 0xa7, 0x34, 0x2e, 0x9b, 0x96, 0x03, - 0xd4, 0xfb, 0x30, 0xef, 0x07, 0x84, 0x7c, 0xa8, 0x21, 0xe2, 0xba, 0x0e, 0x73, 0xb1, 0xc7, 0x38, - 0xa4, 0x19, 0x33, 0xcb, 0xe3, 0x1b, 0x71, 0x58, 0x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e, 0x82, 0x33, - 0xd6, 0x04, 0x81, 0x76, 0x92, 0xda, 0x84, 0xd7, 0xa6, 0xf2, 0x2d, 0x09, 0xc9, 0x4d, 0x6a, 0xab, - 0xdb, 0x00, 0x7d, 0xa7, 0x6c, 0x69, 0x24, 0xc6, 0x81, 0x33, 0x4b, 0x5b, 0x3a, 0x5b, 0x13, 0x37, - 0xbb, 0x0d, 0xd0, 0x77, 0x62, 0x8d, 0x75, 0xef, 0x69, 0xc6, 0xbb, 0x8f, 0x38, 0x14, 0xb6, 0xe0, - 0x52, 0xf7, 0x4f, 0x2e, 0x8c, 0x1b, 0x26, 0x05, 0xda, 0xc2, 0x19, 0x82, 0xd8, 0x74, 0x07, 0xb2, - 0xc3, 0x1b, 0x76, 0xec, 0xd8, 0x21, 0xa1, 0x66, 0x9c, 0x53, 0xd8, 0x2d, 0xa6, 0x4d, 0x7f, 0x3e, - 0xde, 0x5f, 0x52, 0xd6, 0xdf, 0x1c, 0x1c, 0xe5, 0x95, 0xc3, 0xa3, 0xbc, 0xf2, 0xef, 0x28, 0xaf, - 0xfc, 0xe8, 0xe4, 0x13, 0x87, 0x9d, 0x7c, 0xe2, 0x4f, 0x27, 0x9f, 0x78, 0xfb, 0xd4, 0x76, 0x58, - 0xb3, 0x5d, 0xd7, 0x11, 0x71, 0x0d, 0x79, 0x1b, 0x3b, 0x75, 0xb4, 0x6c, 0x13, 0x23, 0x5c, 0x31, - 0x5c, 0xd2, 0x68, 0xb7, 0x30, 0x15, 0x37, 0xe9, 0xa3, 0x27, 0xcb, 0xfd, 0xd7, 0xfd, 0x9e, 0x8f, - 0x69, 0x3d, 0xcd, 0x6f, 0xd3, 0xc7, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x8c, 0xff, 0x15, - 0x12, 0x08, 0x00, 0x00, + // 912 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0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 0xc8, 0x73, 0xbb, 0x10, 0x9e, 0x8b, 0xb4, + 0x62, 0xad, 0x71, 0x7b, 0x3f, 0x37, 0xab, 0x7d, 0x58, 0x11, 0xd0, 0x11, 0x06, 0xfe, 0x88, 0xb5, + 0x6a, 0x3c, 0x97, 0x56, 0xca, 0x25, 0x06, 0x9c, 0x6e, 0xeb, 0x5f, 0x71, 0x84, 0x4c, 0xd5, 0xe0, + 0x51, 0xc2, 0x74, 0x79, 0x81, 0xbe, 0xe7, 0x02, 0x15, 0x4d, 0xe6, 0x02, 0x3d, 0x82, 0xa5, 0x04, + 0xe9, 0x64, 0x2c, 0x9a, 0xbd, 0x61, 0xae, 0x57, 0x34, 0xbb, 0xad, 0x4f, 0xe1, 0x16, 0x87, 0xee, + 0x1f, 0xc5, 0x68, 0xc9, 0x30, 0xa9, 0xe2, 0x2f, 0x8b, 0x00, 0x03, 0xea, 0xef, 0x8b, 0x95, 0x70, + 0x25, 0x12, 0x4e, 0xa2, 0x04, 0x5d, 0x0c, 0x52, 0xf4, 0xce, 0x48, 0xf8, 0x75, 0x6e, 0xbe, 0x1a, + 0x09, 0x3f, 0x06, 0x35, 0xc2, 0x43, 0x66, 0x4f, 0x97, 0x85, 0x9d, 0xa0, 0x9b, 0x72, 0x39, 0xeb, + 0x56, 0x33, 0xf3, 0xec, 0x49, 0x47, 0x26, 0x5e, 0x49, 0xf0, 0x6b, 0xe7, 0x0b, 0xfe, 0x2d, 0xa8, + 0x85, 0x1e, 0x57, 0xad, 0xf6, 0x1f, 0x8b, 0x9c, 0xfd, 0xb1, 0x7b, 0x10, 0x91, 0x17, 0x63, 0xf4, + 0x7c, 0xe4, 0x4b, 0xea, 0x2d, 0x54, 0xdf, 0x87, 0x35, 0xe7, 0x2c, 0x1b, 0x17, 0xbd, 0x61, 0x7e, + 0x58, 0xc9, 0x31, 0x93, 0x59, 0x92, 0xcd, 0x52, 0xa8, 0x1d, 0x10, 0x52, 0xdb, 0x59, 0x12, 0x8f, + 0xcf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xb6, 0x2e, 0x05, 0xcb, 0x6b, 0x7a, 0x01, 0x37, 0xab, + 0xd6, 0xc6, 0xfd, 0x79, 0x2c, 0x15, 0x60, 0xed, 0xc1, 0xff, 0x00, 0xe7, 0x89, 0xbf, 0x03, 0x28, + 0x1d, 0xfb, 0xbd, 0x79, 0x14, 0x05, 0x46, 0xdb, 0xbc, 0x18, 0x53, 0x66, 0x2f, 0x1d, 0xa1, 0x73, + 0xd9, 0x0b, 0xcc, 0x7c, 0xf6, 0x8a, 0x53, 0x6a, 0x0f, 0xde, 0x99, 0x1e, 0x2d, 0x9d, 0x79, 0x61, + 0x12, 0xa0, 0xad, 0x5f, 0x00, 0xc8, 0x49, 0x0f, 0x60, 0x6d, 0x76, 0x07, 0x9d, 0x1b, 0x3b, 0x03, + 0xd4, 0x8c, 0x4b, 0x02, 0xa7, 0xc9, 0xb4, 0x6b, 0x3f, 0xbe, 0x3e, 0xde, 0x54, 0x9e, 0x3c, 0x7b, + 0x79, 0xd2, 0x56, 0x5e, 0x9d, 0xb4, 0x95, 0x7f, 0x4e, 0xda, 0xca, 0xaf, 0xa7, 0xed, 0x85, 0x57, + 0xa7, 0xed, 0x85, 0xbf, 0x4e, 0xdb, 0x0b, 0xdf, 0x7c, 0xee, 0x07, 0x6c, 0x34, 0x19, 0x66, 0x7f, + 0x8a, 0x21, 0xef, 0x91, 0xc1, 0xd0, 0xdd, 0xf2, 0x89, 0x91, 0xee, 0x18, 0x21, 0xf1, 0x26, 0x63, + 0xa4, 0xe2, 0x8a, 0xf7, 0xc9, 0xa7, 0x5b, 0xe5, 0x8b, 0xea, 0x51, 0x8c, 0x74, 0xb8, 0xc4, 0xaf, + 0x77, 0x0f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xbf, 0x8f, 0xe6, 0xcc, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -424,6 +604,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // CreateChannel defines a rpc handler method for MsgCreateChannel + CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -442,6 +626,24 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) { + out := new(MsgCreateChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/CreateChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { + out := new(MsgProvideCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/ProvideCounterparty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) { out := new(MsgSendPacketResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/SendPacket", in, out, opts...) @@ -480,6 +682,10 @@ func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, // MsgServer is the server API for Msg service. type MsgServer interface { + // CreateChannel defines a rpc handler method for MsgCreateChannel + CreateChannel(context.Context, *MsgCreateChannel) (*MsgCreateChannelResponse, error) + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -494,6 +700,12 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) CreateChannel(ctx context.Context, req *MsgCreateChannel) (*MsgCreateChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") +} +func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") +} func (*UnimplementedMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") } @@ -511,6 +723,42 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Msg/CreateChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateChannel(ctx, req.(*MsgCreateChannel)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgProvideCounterparty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ProvideCounterparty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Msg/ProvideCounterparty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SendPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSendPacket) if err := dec(in); err != nil { @@ -587,6 +835,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "CreateChannel", + Handler: _Msg_CreateChannel_Handler, + }, + { + MethodName: "ProvideCounterparty", + Handler: _Msg_ProvideCounterparty_Handler, + }, { MethodName: "SendPacket", Handler: _Msg_SendPacket_Handler, @@ -962,6 +1218,150 @@ func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *MsgProvideCounterparty) 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 *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterparty) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgProvideCounterpartyResponse) 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 *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateChannel) 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 *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateChannel) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateChannelResponse) 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 *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateChannelResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1115,22 +1515,84 @@ func (m *MsgAcknowledgementResponse) Size() (n int) { return n } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgSendPacket) 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 ErrIntOverflowTx - } +func (m *MsgProvideCounterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgProvideCounterpartyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSendPacket) 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 ErrIntOverflowTx + } if iNdEx >= l { return io.ErrUnexpectedEOF } @@ -2162,6 +2624,431 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgProvideCounterparty) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgProvideCounterpartyResponse) 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 ErrIntOverflowTx + } + 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: MsgProvideCounterpartyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateChannel) 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 ErrIntOverflowTx + } + 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: MsgCreateChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateChannel: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateChannelResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index 56f3ff765d3..7edaf621076 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -8,8 +8,8 @@ import ( ibcclient "github.com/cosmos/ibc-go/v9/modules/core/02-client" connection "github.com/cosmos/ibc-go/v9/modules/core/03-connection" channel "github.com/cosmos/ibc-go/v9/modules/core/04-channel" + channelv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" - packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server" ) // GetTxCmd returns the transaction commands for this module @@ -25,7 +25,7 @@ func GetTxCmd() *cobra.Command { ibcTxCmd.AddCommand( ibcclient.GetTxCmd(), channel.GetTxCmd(), - packetserver.GetTxCmd(), + channelv2.GetTxCmd(), ) return ibcTxCmd @@ -46,7 +46,7 @@ func GetQueryCmd() *cobra.Command { ibcclient.GetQueryCmd(), connection.GetQueryCmd(), channel.GetQueryCmd(), - packetserver.GetQueryCmd(), + channelv2.GetQueryCmd(), ) return ibcQueryCmd diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 9f4351369bc..a59bfc28490 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -16,8 +16,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/telemetry" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -26,7 +24,6 @@ var ( _ connectiontypes.MsgServer = (*Keeper)(nil) _ channeltypes.MsgServer = (*Keeper)(nil) _ channeltypes.PacketMsgServer = (*Keeper)(nil) - _ packetservertypes.MsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. @@ -140,49 +137,6 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI return &clienttypes.MsgIBCSoftwareUpgradeResponse{}, nil } -// CreateChannel defines a rpc handler method for MsgCreateChannel -func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.MsgCreateChannel) (*packetservertypes.MsgCreateChannelResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - channelID := k.ChannelKeeper.GenerateChannelIdentifier(ctx) - - // Initialize channel with empty counterparty channel identifier. - channel := packetservertypes.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) - k.PacketServerKeeper.SetChannel(ctx, channelID, channel) - - k.PacketServerKeeper.SetCreator(ctx, channelID, msg.Signer) - - packetserverkeeper.EmitCreateChannelEvent(goCtx, channelID) - - return &packetservertypes.MsgCreateChannelResponse{ChannelId: channelID}, nil -} - -// ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. -func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - creator, found := k.PacketServerKeeper.GetCreator(ctx, msg.ChannelId) - if !found { - return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") - } - - if creator != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) - } - - channel, ok := k.PacketServerKeeper.GetChannel(ctx, msg.ChannelId) - if !ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) - } - - channel.CounterpartyChannelId = msg.CounterpartyChannelId - k.PacketServerKeeper.SetChannel(ctx, msg.ChannelId, channel) - // Delete client creator from state as it is not needed after this point. - k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) - - return &packetservertypes.MsgProvideCounterpartyResponse{}, nil -} - // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. func (k *Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 404240f72d7..e101d57ed06 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1203,75 +1203,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { } } -func (suite *KeeperTestSuite) TestProvideCounterparty() { - var ( - path *ibctesting.Path - msg *packetservertypes.MsgProvideCounterparty - ) - cases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() { - // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) - }, - nil, - }, - { - "failure: signer does not match creator", - func() { - msg.Signer = ibctesting.TestAccAddress - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: counterparty does not already exists", - func() { - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.ChannelKey)) - }, - packetservertypes.ErrInvalidChannel, - }, - } - - for _, tc := range cases { - tc := tc - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupClients() - - suite.Require().NoError(path.EndpointA.CreateChannel()) - - signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) - - tc.malleate() - - ctx := suite.chainA.GetContext() - resp, err := suite.chainA.App.GetIBCKeeper().ProvideCounterparty(ctx, msg) - - expPass := tc.expError == nil - if expPass { - suite.Require().NotNil(resp) - suite.Require().Nil(err) - - // Assert counterparty channel id filled in and creator deleted - channel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) - - _, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) - suite.Require().False(found) - } else { - suite.Require().Nil(resp) - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - } -} - func (suite *KeeperTestSuite) TestUpgradeClient() { var ( path *ibctesting.Path diff --git a/modules/core/module.go b/modules/core/module.go index 29c1d2d8d04..c312604d7f3 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -28,8 +28,6 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" "github.com/cosmos/ibc-go/v9/modules/core/simulation" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -94,7 +92,6 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r if err != nil { panic(err) } - err = packetservertypes.RegisterQueryHandlerClient(context.Background(), mux, packetservertypes.NewQueryClient(clientCtx)) if err != nil { panic(err) } @@ -140,12 +137,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) channeltypesv2.RegisterMsgServer(cfg.MsgServer(), am.keeper.ChannelKeeperV2) - packetservertypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) channeltypes.RegisterQueryServer(cfg.QueryServer(), channelkeeper.NewQueryServer(am.keeper.ChannelKeeper)) - packetservertypes.RegisterQueryServer(cfg.QueryServer(), packetserverkeeper.NewQueryServer(am.keeper.PacketServerKeeper)) clientMigrator := clientkeeper.NewMigrator(am.keeper.ClientKeeper) if err := cfg.RegisterMigration(exported.ModuleName, 2, clientMigrator.Migrate2to3); err != nil { diff --git a/modules/core/packet-server/keeper/events.go b/modules/core/packet-server/keeper/events.go deleted file mode 100644 index 64f5c023205..00000000000 --- a/modules/core/packet-server/keeper/events.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" -) - -// EmitCreateChannelEvent emits a channel create event. -func EmitCreateChannelEvent(ctx context.Context, channelID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeCreateChannel, - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index b862b3e0ed5..eeeeec5aa3e 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -66,26 +66,3 @@ func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel k.cdc.MustUnmarshal(bz, &channel) return channel, true } - -// GetCreator returns the creator of the client. -func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - bz := k.ChannelStore(sdkCtx, clientID).Get([]byte(types.CreatorKey)) - if len(bz) == 0 { - return "", false - } - - return string(bz), true -} - -// SetCreator sets the creator of the client. -func (k *Keeper) SetCreator(ctx context.Context, clientID, creator string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) -} - -// DeleteCreator deletes the creator associated with the client. -func (k *Keeper) DeleteCreator(ctx context.Context, clientID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, clientID).Delete([]byte(types.CreatorKey)) -} diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go deleted file mode 100644 index 3c95dc45e0e..00000000000 --- a/modules/core/packet-server/keeper/keeper_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package keeper_test - -import ( - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" - ibctesting "github.com/cosmos/ibc-go/v9/testing" -) - -const testClientID = "tendermint-0" - -func (suite *KeeperTestSuite) TestSetChannel() { - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - channel := types.Channel{ - ClientId: testClientID, - MerklePathPrefix: merklePathPrefix, - } - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), testClientID, channel) - - retrievedChannel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), testClientID) - suite.Require().True(found, "GetChannel does not return channel") - suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") - - // Channel not yet stored for another client. - retrievedChannel, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) - suite.Require().False(found, "GetChannel unexpectedly returned a channel") - suite.Require().Equal(types.Channel{}, retrievedChannel, "Channel retrieved not empty") -} - -func (suite *KeeperTestSuite) TestSetCreator() { - clientID := ibctesting.FirstClientID - expectedCreator := "test-creator" - - // Set the creator for the client - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), clientID, expectedCreator) - - // Retrieve the creator from the store - retrievedCreator, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), clientID) - - // Verify that the retrieved creator matches the expected creator - suite.Require().True(found, "GetCreator did not return stored creator") - suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") - - // Verify non stored creator is not found - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), ibctesting.SecondClientID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") - - // Verify that the creator is deleted from the store - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.DeleteCreator(suite.chainA.GetContext(), clientID) - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), clientID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") -} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 9ad03fb70c8..40c279fa94d 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -12,6 +12,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" @@ -159,7 +160,7 @@ func (k Keeper) RecvPacket( } path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) commitment := channeltypes.CommitPacket(packet) @@ -290,7 +291,7 @@ func (k Keeper) AcknowledgePacket( } path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -373,7 +374,7 @@ func (k Keeper) TimeoutPacket( // verify packet receipt absence path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/packet-server/types/codec.go b/modules/core/packet-server/types/codec.go deleted file mode 100644 index 1c0bd85c7c2..00000000000 --- a/modules/core/packet-server/types/codec.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// RegisterInterfaces registers the client interfaces to protobuf Any. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgProvideCounterparty{}, - &MsgCreateChannel{}, - ) -} diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index fcbeb56d5e4..d1426569d57 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -8,9 +8,4 @@ const ( // the channel key is imported from types instead of host because // the channel key is not a part of the ics-24 host specification ChannelKey = "channel" - - // CreatorKey is the key used to store the client creator in the client store - // the creator key is imported from types instead of host because - // the creator key is not a part of the ics-24 host specification - CreatorKey = "creator" ) diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go deleted file mode 100644 index a291f62ab2d..00000000000 --- a/modules/core/packet-server/types/msgs.go +++ /dev/null @@ -1,68 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" -) - -var ( - _ sdk.Msg = (*MsgProvideCounterparty)(nil) - _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) -) - -// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(channelID, counterpartyChannelID string, signer string) *MsgProvideCounterparty { - return &MsgProvideCounterparty{ - Signer: signer, - ChannelId: channelID, - CounterpartyChannelId: counterpartyChannelID, - } -} - -// ValidateBasic performs basic checks on a MsgProvideCounterparty. -func (msg *MsgProvideCounterparty) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { - return err - } - - if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { - return err - } - - return nil -} - -// NewMsgCreateChannel creates a new MsgCreateChannel instance -func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgCreateChannel { - return &MsgCreateChannel{ - Signer: signer, - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, - } -} - -// ValidateBasic performs basic checks on a MsgCreateChannel. -func (msg *MsgCreateChannel) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { - return err - } - - if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return err - } - - return nil -} diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go deleted file mode 100644 index 22b052db787..00000000000 --- a/modules/core/packet-server/types/tx.pb.go +++ /dev/null @@ -1,1091 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/packetserver/v1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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 - -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -type MsgProvideCounterparty struct { - // unique identifier we will use to write all packet messages sent to counterparty - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // counterparty channel identifier - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } -func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterparty) ProtoMessage() {} -func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_3c556aec8b7966db, []int{0} -} -func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) -} -func (m *MsgProvideCounterparty) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -type MsgProvideCounterpartyResponse struct { -} - -func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } -func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterpartyResponse) ProtoMessage() {} -func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3c556aec8b7966db, []int{1} -} -func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) -} -func (m *MsgProvideCounterpartyResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo - -// MsgCreateChannel defines the message used to create a v2 Channel. -type MsgCreateChannel struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } -func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannel) ProtoMessage() {} -func (*MsgCreateChannel) Descriptor() ([]byte, []int) { - return fileDescriptor_3c556aec8b7966db, []int{2} -} -func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannel.Merge(m, src) -} -func (m *MsgCreateChannel) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateChannel) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo - -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -type MsgCreateChannelResponse struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } -func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannelResponse) ProtoMessage() {} -func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3c556aec8b7966db, []int{3} -} -func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateChannelResponse.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 *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) -} -func (m *MsgCreateChannelResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.packetserver.v1.MsgProvideCounterparty") - proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.packetserver.v1.MsgProvideCounterpartyResponse") - proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.packetserver.v1.MsgCreateChannel") - proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.packetserver.v1.MsgCreateChannelResponse") -} - -func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } - -var fileDescriptor_3c556aec8b7966db = []byte{ - // 468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 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 0xb9, 0x96, 0x44, 0x78, 0xaf, 0xfe, 0x37, - 0xe2, 0x4a, 0x83, 0x77, 0xeb, 0xc3, 0xe5, 0xb4, 0x8b, 0x0e, 0x8e, 0xce, 0x67, 0x3e, 0xba, 0x98, - 0xf9, 0xe8, 0xc7, 0xcc, 0x47, 0x9f, 0xe7, 0xbe, 0x73, 0x31, 0xf7, 0x9d, 0x6f, 0x73, 0xdf, 0x79, - 0xf7, 0x86, 0x0b, 0x3b, 0x9e, 0x44, 0xc5, 0x0f, 0xa4, 0xd5, 0xca, 0x8b, 0x88, 0xed, 0x72, 0x45, - 0xf3, 0xd7, 0x54, 0xaa, 0x78, 0x92, 0x80, 0x69, 0xde, 0xe0, 0x6e, 0x75, 0x84, 0xf6, 0x34, 0x03, - 0x13, 0xad, 0x97, 0x37, 0xf1, 0xe2, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x8b, 0x7a, 0x32, - 0xaa, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // CreateChannel defines a rpc handler method for MsgCreateChannel - CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) { - out := new(MsgCreateChannelResponse) - err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/CreateChannel", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { - out := new(MsgProvideCounterpartyResponse) - err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateChannel defines a rpc handler method for MsgCreateChannel - CreateChannel(context.Context, *MsgCreateChannel) (*MsgCreateChannelResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) CreateChannel(ctx context.Context, req *MsgCreateChannel) (*MsgCreateChannelResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") -} -func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateChannel) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateChannel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.packetserver.v1.Msg/CreateChannel", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateChannel(ctx, req.(*MsgCreateChannel)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgProvideCounterparty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ProvideCounterparty(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.packetserver.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateChannel", - Handler: _Msg_CreateChannel_Handler, - }, - { - MethodName: "ProvideCounterparty", - Handler: _Msg_ProvideCounterparty_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "ibc/core/packetserver/v1/tx.proto", -} - -func (m *MsgProvideCounterparty) 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 *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterparty) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a - } - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgProvideCounterpartyResponse) 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 *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgCreateChannel) 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 *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateChannel) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateChannelResponse) 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 *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateChannelResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgProvideCounterparty) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgProvideCounterpartyResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgCreateChannel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateChannelResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgProvideCounterparty) 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 ErrIntOverflowTx - } - 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: MsgProvideCounterparty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgProvideCounterpartyResponse) 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 ErrIntOverflowTx - } - 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: MsgProvideCounterpartyResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgCreateChannel) 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 ErrIntOverflowTx - } - 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: MsgCreateChannel: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannel: 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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 MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgCreateChannelResponse) 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 ErrIntOverflowTx - } - 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: MsgCreateChannelResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(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, ErrIntOverflowTx - } - 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, ErrIntOverflowTx - } - 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, ErrIntOverflowTx - } - 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, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index d805413f912..d704d725ea3 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -8,7 +8,6 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // RegisterInterfaces registers ibc types against interfaces using the global InterfaceRegistry. @@ -17,7 +16,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { clienttypes.RegisterInterfaces(registry) connectiontypes.RegisterInterfaces(registry) channeltypes.RegisterInterfaces(registry) - packetservertypes.RegisterInterfaces(registry) commitmenttypes.RegisterInterfaces(registry) channeltypesv2.RegisterInterfaces(registry) diff --git a/proto/ibc/core/packetserver/v1/query.proto b/proto/ibc/core/channel/v2/query.proto similarity index 80% rename from proto/ibc/core/packetserver/v1/query.proto rename to proto/ibc/core/channel/v2/query.proto index f429a185e87..072118099a8 100644 --- a/proto/ibc/core/packetserver/v1/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package ibc.core.packetserver.v1; +package ibc.core.channel.v2; -option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; -import "ibc/core/packetserver/v1/channel.proto"; +import "ibc/core/channel/v2/channel.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 771706b3efc..d72dbd9db2a 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -9,11 +9,18 @@ import "cosmos/msg/v1/msg.proto"; import "ibc/core/channel/v2/packet.proto"; import "ibc/core/channel/v1/tx.proto"; import "ibc/core/client/v1/client.proto"; +import "ibc/core/commitment/v2/commitment.proto"; // Msg defines the ibc/channel/v2 Msg service. service Msg { option (cosmos.msg.v1.service) = true; + // CreateChannel defines a rpc handler method for MsgCreateChannel + rpc CreateChannel(MsgCreateChannel) returns (MsgCreateChannelResponse); + + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); + // SendPacket defines a rpc handler method for MsgSendPacket. rpc SendPacket(MsgSendPacket) returns (MsgSendPacketResponse); @@ -103,3 +110,44 @@ message MsgAcknowledgementResponse { ibc.core.channel.v1.ResponseResultType result = 1; } + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +message MsgProvideCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // unique identifier we will use to write all packet messages sent to counterparty + string channel_id = 1; + // counterparty channel identifier + string counterparty_channel_id = 2; + // signer address + string signer = 3; +} + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +message MsgProvideCounterpartyResponse {} + +// MsgCreateChannel defines the message used to create a v2 Channel. +message MsgCreateChannel { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // the client identifier of the light client representing the counterparty chain + string client_id = 1; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +message MsgCreateChannelResponse { + option (gogoproto.goproto_getters) = false; + + string channel_id = 1; +} diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto deleted file mode 100644 index c179e9ae25c..00000000000 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ /dev/null @@ -1,62 +0,0 @@ - -syntax = "proto3"; - -package ibc.core.packetserver.v1; - -option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/commitment/v2/commitment.proto"; -import "cosmos/msg/v1/msg.proto"; - -// Msg defines the ibc/packetserver Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; - - // CreateChannel defines a rpc handler method for MsgCreateChannel - rpc CreateChannel(MsgCreateChannel) returns (MsgCreateChannelResponse); - - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); -} - -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -message MsgProvideCounterparty { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // unique identifier we will use to write all packet messages sent to counterparty - string channel_id = 1; - // counterparty channel identifier - string counterparty_channel_id = 2; - // signer address - string signer = 3; -} - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -message MsgProvideCounterpartyResponse {} - -// MsgCreateChannel defines the message used to create a v2 Channel. -message MsgCreateChannel { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; - // signer address - string signer = 3; -} - -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -message MsgCreateChannelResponse { - option (gogoproto.goproto_getters) = false; - - string channel_id = 1; -} diff --git a/testing/endpoint.go b/testing/endpoint.go index 05ad6c1e654..82f735ae78e 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -16,10 +16,10 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ) @@ -178,7 +178,7 @@ func (endpoint *Endpoint) FreezeClient() { // ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. func (endpoint *Endpoint) ProvideCounterparty() (err error) { - msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) @@ -188,7 +188,7 @@ func (endpoint *Endpoint) ProvideCounterparty() (err error) { // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { - msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // create channel res, err := endpoint.Chain.SendMsgs(msg) diff --git a/testing/events.go b/testing/events.go index 0fa3cfafb73..a4caaf46a9e 100644 --- a/testing/events.go +++ b/testing/events.go @@ -14,7 +14,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) // ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the @@ -48,7 +48,7 @@ func ParseConnectionIDFromEvents(events []abci.Event) (string, error) { // MsgChannelOpenTry or a MsgCreateChannel and returns the channel identifier. func ParseChannelIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { - if ev.Type == packetservertypes.EventTypeCreateChannel || ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { + if ev.Type == channeltypesv2.EventTypeCreateChannel || ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { if attribute, found := attributeByKey(ev.Attributes, channeltypes.AttributeKeyChannelID); found { return attribute.Value, nil } From 4ed754356977133fbfff835d53d3b6473a00e2f5 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 14 Oct 2024 11:30:17 +0100 Subject: [PATCH 068/172] chore: Add OnAcknowledgmentPacket to IBCModule V2 Interface (#7438) * Add OnAcknowledgmentPacket to IBCModule V2 Interface * chore: fix typo --- modules/core/api/module.go | 12 ++++++++++-- testing/mock/v2/ibc_app.go | 7 ++++--- testing/mock/v2/ibc_module.go | 14 ++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index f15dfad6611..8346d291663 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -31,8 +31,6 @@ type IBCModule interface { relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult - // OnAcknowledgementPacket - // OnTimeoutPacket is executed when a packet has timed out on the receiving chain. OnTimeoutPacket( ctx context.Context, @@ -41,4 +39,14 @@ type IBCModule interface { data channeltypesv2.PacketData, relayer sdk.AccAddress, ) error + + // OnAcknowledgementPacket is executed when a packet gets acknowledged + OnAcknowledgementPacket( + ctx context.Context, + sourceID string, + destinationID string, + data channeltypesv2.PacketData, + acknowledgement []byte, + relayer sdk.AccAddress, + ) error } diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index ddf4c67f115..21948faab3e 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,7 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 0e948daa471..cb797c592bc 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -49,14 +49,12 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati } } -// -// func (im IBCModule) OnAcknowledgementPacket() error { -// if im.IBCApp.OnAcknowledgementPacket != nil { -// return im.IBCApp.OnAcknowledgementPacket(...) -// } -// return nil -// } -// +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { + if im.IBCApp.OnAcknowledgementPacket != nil { + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowledgement, relayer) + } + return nil +} func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { From a539936471e22b91da7e15fe8a359a95566a89c3 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 14 Oct 2024 12:32:04 +0200 Subject: [PATCH 069/172] nit: reorder proto msgs (#7446) --- modules/core/04-channel/v2/types/tx.pb.go | 1461 +++++++++++---------- proto/ibc/core/channel/v2/tx.proto | 82 +- 2 files changed, 772 insertions(+), 771 deletions(-) diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index b8b915f78bc..df9610f29a7 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -32,6 +32,170 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgCreateChannel defines the message used to create a v2 Channel. +type MsgCreateChannel struct { + // the client identifier of the light client representing the counterparty chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } +func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannel) ProtoMessage() {} +func (*MsgCreateChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{0} +} +func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannel.Merge(m, src) +} +func (m *MsgCreateChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +type MsgCreateChannelResponse struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } +func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateChannelResponse) ProtoMessage() {} +func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{1} +} +func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateChannelResponse.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 *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) +} +func (m *MsgCreateChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +type MsgProvideCounterparty struct { + // unique identifier we will use to write all packet messages sent to counterparty + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // counterparty channel identifier + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } +func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterparty) ProtoMessage() {} +func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{2} +} +func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +} +func (m *MsgProvideCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +type MsgProvideCounterpartyResponse struct { +} + +func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } +func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterpartyResponse) ProtoMessage() {} +func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{3} +} +func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +} +func (m *MsgProvideCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo + // MsgSendPacket sends an outgoing IBC packet. type MsgSendPacket struct { SourceChannel string `protobuf:"bytes,1,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` @@ -44,7 +208,7 @@ func (m *MsgSendPacket) Reset() { *m = MsgSendPacket{} } func (m *MsgSendPacket) String() string { return proto.CompactTextString(m) } func (*MsgSendPacket) ProtoMessage() {} func (*MsgSendPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{0} + return fileDescriptor_d421c7119e969b99, []int{4} } func (m *MsgSendPacket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -82,7 +246,7 @@ func (m *MsgSendPacketResponse) Reset() { *m = MsgSendPacketResponse{} } func (m *MsgSendPacketResponse) String() string { return proto.CompactTextString(m) } func (*MsgSendPacketResponse) ProtoMessage() {} func (*MsgSendPacketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{1} + return fileDescriptor_d421c7119e969b99, []int{5} } func (m *MsgSendPacketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -123,7 +287,7 @@ func (m *MsgRecvPacket) Reset() { *m = MsgRecvPacket{} } func (m *MsgRecvPacket) String() string { return proto.CompactTextString(m) } func (*MsgRecvPacket) ProtoMessage() {} func (*MsgRecvPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{2} + return fileDescriptor_d421c7119e969b99, []int{6} } func (m *MsgRecvPacket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +325,7 @@ func (m *MsgRecvPacketResponse) Reset() { *m = MsgRecvPacketResponse{} } func (m *MsgRecvPacketResponse) String() string { return proto.CompactTextString(m) } func (*MsgRecvPacketResponse) ProtoMessage() {} func (*MsgRecvPacketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{3} + return fileDescriptor_d421c7119e969b99, []int{7} } func (m *MsgRecvPacketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,7 +367,7 @@ 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_d421c7119e969b99, []int{4} + return fileDescriptor_d421c7119e969b99, []int{8} } func (m *MsgTimeout) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -241,7 +405,7 @@ func (m *MsgTimeoutResponse) Reset() { *m = MsgTimeoutResponse{} } func (m *MsgTimeoutResponse) String() string { return proto.CompactTextString(m) } func (*MsgTimeoutResponse) ProtoMessage() {} func (*MsgTimeoutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{5} + return fileDescriptor_d421c7119e969b99, []int{9} } func (m *MsgTimeoutResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -283,7 +447,7 @@ 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_d421c7119e969b99, []int{6} + return fileDescriptor_d421c7119e969b99, []int{10} } func (m *MsgAcknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -300,199 +464,35 @@ func (m *MsgAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, 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 - -// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. -type MsgAcknowledgementResponse struct { - Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` -} - -func (m *MsgAcknowledgementResponse) Reset() { *m = MsgAcknowledgementResponse{} } -func (m *MsgAcknowledgementResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAcknowledgementResponse) ProtoMessage() {} -func (*MsgAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{7} -} -func (m *MsgAcknowledgementResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAcknowledgementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAcknowledgementResponse.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 *MsgAcknowledgementResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAcknowledgementResponse.Merge(m, src) -} -func (m *MsgAcknowledgementResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAcknowledgementResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo - -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -type MsgProvideCounterparty struct { - // unique identifier we will use to write all packet messages sent to counterparty - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // counterparty channel identifier - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } -func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterparty) ProtoMessage() {} -func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{8} -} -func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterparty.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 *MsgProvideCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) -} -func (m *MsgProvideCounterparty) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -type MsgProvideCounterpartyResponse struct { -} - -func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } -func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterpartyResponse) ProtoMessage() {} -func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{9} -} -func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterpartyResponse.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 *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) -} -func (m *MsgProvideCounterpartyResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo - -// MsgCreateChannel defines the message used to create a v2 Channel. -type MsgCreateChannel struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } -func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannel) ProtoMessage() {} -func (*MsgCreateChannel) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{10} -} -func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannel.Merge(m, src) +func (m *MsgAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAcknowledgement.Merge(m, src) } -func (m *MsgCreateChannel) XXX_Size() int { +func (m *MsgAcknowledgement) XXX_Size() int { return m.Size() } -func (m *MsgCreateChannel) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) +func (m *MsgAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAcknowledgement.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo +var xxx_messageInfo_MsgAcknowledgement proto.InternalMessageInfo -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -type MsgCreateChannelResponse struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. +type MsgAcknowledgementResponse struct { + Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` } -func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } -func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannelResponse) ProtoMessage() {} -func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { +func (m *MsgAcknowledgementResponse) Reset() { *m = MsgAcknowledgementResponse{} } +func (m *MsgAcknowledgementResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAcknowledgementResponse) ProtoMessage() {} +func (*MsgAcknowledgementResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d421c7119e969b99, []int{11} } -func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAcknowledgementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateChannelResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAcknowledgementResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -502,19 +502,23 @@ func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) +func (m *MsgAcknowledgementResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAcknowledgementResponse.Merge(m, src) } -func (m *MsgCreateChannelResponse) XXX_Size() int { +func (m *MsgAcknowledgementResponse) XXX_Size() int { return m.Size() } -func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) +func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAcknowledgementResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") + proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") + proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.channel.v2.MsgProvideCounterparty") + proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgProvideCounterpartyResponse") proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v2.MsgRecvPacket") @@ -523,18 +527,14 @@ func init() { proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v2.MsgTimeoutResponse") proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.core.channel.v2.MsgAcknowledgement") proto.RegisterType((*MsgAcknowledgementResponse)(nil), "ibc.core.channel.v2.MsgAcknowledgementResponse") - proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.channel.v2.MsgProvideCounterparty") - proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgProvideCounterpartyResponse") - proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") - proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 912 bytes of a gzipped FileDescriptorProto + // 914 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0x8e, 0xb3, 0xdb, 0xd0, 0xbc, 0x4d, 0x9a, 0xc5, 0xa5, 0xed, 0xca, 0x85, 0xdd, 0xd5, 0x8a, + 0x14, 0x5e, 0x27, 0xdb, 0xd0, 0xbc, 0x4d, 0x9a, 0xc5, 0xa5, 0xed, 0xca, 0x85, 0xdd, 0xd5, 0x8a, 0x2a, 0x21, 0x25, 0x36, 0x71, 0x11, 0x52, 0x2a, 0xa4, 0xaa, 0x5d, 0x84, 0xe8, 0x61, 0xa5, 0xc8, 0x09, 0x3d, 0x00, 0xc2, 0xf2, 0xda, 0xaf, 0x5e, 0x2b, 0x6b, 0x8f, 0xf1, 0xcc, 0xba, 0xc9, 0x0d, 0x71, 0xe2, 0x84, 0x38, 0x72, 0xe4, 0x27, 0xe4, 0xc0, 0x8f, 0xe8, 0xb1, 0x07, 0x0e, 0x9c, 0x10, @@ -545,51 +545,52 @@ var fileDescriptor_d421c7119e969b99 = []byte{ 0x37, 0xb2, 0x37, 0x01, 0xd5, 0xee, 0xb8, 0x84, 0x86, 0x84, 0x1a, 0x21, 0xf5, 0x8d, 0x74, 0x3b, 0x7b, 0x48, 0x47, 0xb7, 0x2a, 0x43, 0xec, 0xb8, 0x07, 0xc8, 0x24, 0xa2, 0xa2, 0x86, 0xed, 0xbc, 0x06, 0xad, 0x53, 0x78, 0xc7, 0x01, 0x46, 0x2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c, 0xc2, - 0x65, 0xd1, 0x32, 0x40, 0xfd, 0x08, 0x9a, 0x71, 0x42, 0xc8, 0x73, 0xbb, 0x10, 0x9e, 0x8b, 0xb4, - 0x62, 0xad, 0x71, 0x7b, 0x3f, 0x37, 0xab, 0x7d, 0x58, 0x11, 0xd0, 0x11, 0x06, 0xfe, 0x88, 0xb5, - 0x6a, 0x3c, 0x97, 0x56, 0xca, 0x25, 0x06, 0x9c, 0x6e, 0xeb, 0x5f, 0x71, 0x84, 0x4c, 0xd5, 0xe0, - 0x51, 0xc2, 0x74, 0x79, 0x81, 0xbe, 0xe7, 0x02, 0x15, 0x4d, 0xe6, 0x02, 0x3d, 0x82, 0xa5, 0x04, - 0xe9, 0x64, 0x2c, 0x9a, 0xbd, 0x61, 0xae, 0x57, 0x34, 0xbb, 0xad, 0x4f, 0xe1, 0x16, 0x87, 0xee, - 0x1f, 0xc5, 0x68, 0xc9, 0x30, 0xa9, 0xe2, 0x2f, 0x8b, 0x00, 0x03, 0xea, 0xef, 0x8b, 0x95, 0x70, - 0x25, 0x12, 0x4e, 0xa2, 0x04, 0x5d, 0x0c, 0x52, 0xf4, 0xce, 0x48, 0xf8, 0x75, 0x6e, 0xbe, 0x1a, - 0x09, 0x3f, 0x06, 0x35, 0xc2, 0x43, 0x66, 0x4f, 0x97, 0x85, 0x9d, 0xa0, 0x9b, 0x72, 0x39, 0xeb, - 0x56, 0x33, 0xf3, 0xec, 0x49, 0x47, 0x26, 0x5e, 0x49, 0xf0, 0x6b, 0xe7, 0x0b, 0xfe, 0x2d, 0xa8, - 0x85, 0x1e, 0x57, 0xad, 0xf6, 0x1f, 0x8b, 0x9c, 0xfd, 0xb1, 0x7b, 0x10, 0x91, 0x17, 0x63, 0xf4, - 0x7c, 0xe4, 0x4b, 0xea, 0x2d, 0x54, 0xdf, 0x87, 0x35, 0xe7, 0x2c, 0x1b, 0x17, 0xbd, 0x61, 0x7e, - 0x58, 0xc9, 0x31, 0x93, 0x59, 0x92, 0xc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c, 0x3d, 0x8b, 0xb4, 0xad, 0x4b, 0xc1, 0xf2, 0xaa, 0x5f, 0xc0, + 0xcd, 0xaa, 0x93, 0xe8, 0xfe, 0x3c, 0x96, 0x0a, 0xb0, 0xf6, 0xe0, 0x7f, 0x80, 0xf3, 0xc4, 0xdf, + 0x01, 0x94, 0x4e, 0x91, 0xde, 0x3c, 0x8a, 0x02, 0xa3, 0x6d, 0x5e, 0x8c, 0x29, 0xb3, 0x97, 0x76, + 0xe4, 0xb9, 0xec, 0x05, 0x66, 0x3e, 0x7b, 0xc5, 0xa6, 0xb7, 0x07, 0xef, 0x4c, 0x77, 0xaa, 0xce, + 0xbc, 0x30, 0x09, 0xd0, 0xd6, 0x2f, 0x00, 0xe4, 0xa4, 0x07, 0xb0, 0x36, 0xfb, 0x43, 0xce, 0x8d, + 0x9d, 0x01, 0x6a, 0xc6, 0x25, 0x81, 0xd3, 0x64, 0xda, 0xb5, 0x1f, 0x5f, 0x1f, 0x6f, 0x2a, 0x4f, + 0x9e, 0xbd, 0x3c, 0x69, 0x2b, 0xaf, 0x4e, 0xda, 0xca, 0x3f, 0x27, 0x6d, 0xe5, 0xd7, 0xd3, 0x76, + 0xed, 0xd5, 0x69, 0xbb, 0xf6, 0xd7, 0x69, 0xbb, 0xf6, 0xcd, 0xe7, 0x7e, 0xc0, 0x46, 0x93, 0x61, + 0x76, 0x91, 0x32, 0xe4, 0x3d, 0x32, 0x18, 0xba, 0x5b, 0x3e, 0x31, 0xd2, 0x1d, 0x23, 0x24, 0xde, + 0x64, 0x8c, 0x54, 0x5c, 0xf1, 0x3e, 0xf9, 0x74, 0xab, 0x7c, 0x51, 0x3d, 0x8a, 0x91, 0x0e, 0x97, + 0xf8, 0xf5, 0xee, 0xc1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdf, 0x03, 0x0a, 0xcc, 0x0a, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -864,7 +865,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/core/channel/v2/tx.proto", } -func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateChannel) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -874,12 +875,12 @@ func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSendPacket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -889,38 +890,29 @@ func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } - if len(m.PacketData) > 0 { - for iNdEx := len(m.PacketData) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PacketData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.TimeoutTimestamp != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) - i-- - dAtA[i] = 0x10 - } - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x12 + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgSendPacketResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateChannelResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -930,25 +922,27 @@ func (m *MsgSendPacketResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSendPacketResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSendPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Sequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { +func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -958,12 +952,12 @@ func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -973,39 +967,26 @@ func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x22 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a - if len(m.ProofCommitment) > 0 { - i -= len(m.ProofCommitment) - copy(dAtA[i:], m.ProofCommitment) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) i-- dAtA[i] = 0x12 } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1015,25 +996,20 @@ func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } -func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { +func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1043,12 +1019,12 @@ func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendPacket) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1058,44 +1034,38 @@ func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x2a - } - if m.NextSequenceRecv != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) - i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.PacketData) > 0 { + for iNdEx := len(m.PacketData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x1a - if len(m.ProofUnreceived) > 0 { - i -= len(m.ProofUnreceived) - copy(dAtA[i:], m.ProofUnreceived) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) + if m.TimeoutTimestamp != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgTimeoutResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSendPacketResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1105,25 +1075,25 @@ func (m *MsgTimeoutResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendPacketResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { +func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1133,12 +1103,12 @@ func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAcknowledgement) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1148,7 +1118,7 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } { size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) @@ -1159,24 +1129,14 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - if len(m.ProofAcked) > 0 { - i -= len(m.ProofAcked) - copy(dAtA[i:], m.ProofAcked) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) + dAtA[i] = 0x1a + if len(m.ProofCommitment) > 0 { + i -= len(m.ProofCommitment) + copy(dAtA[i:], m.ProofCommitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) i-- - dAtA[i] = 0x1a - } - { - size, err := m.Acknowledgement.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 + dAtA[i] = 0x12 + } { size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1190,7 +1150,7 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAcknowledgementResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1200,12 +1160,12 @@ func (m *MsgAcknowledgementResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1218,7 +1178,7 @@ func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { +func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1228,12 +1188,12 @@ func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1243,26 +1203,44 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + if m.NextSequenceRecv != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x20 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgTimeoutResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1272,20 +1250,25 @@ func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *MsgCreateChannel) Marshal() (dAtA []byte, err error) { +func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1295,12 +1278,12 @@ func (m *MsgCreateChannel) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAcknowledgement) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1310,10 +1293,27 @@ func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- + dAtA[i] = 0x2a + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ProofAcked) > 0 { + i -= len(m.ProofAcked) + copy(dAtA[i:], m.ProofAcked) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) + i-- dAtA[i] = 0x1a } { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Acknowledgement.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1322,17 +1322,20 @@ func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgCreateChannelResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAcknowledgementResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1342,22 +1345,20 @@ func (m *MsgCreateChannelResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAcknowledgementResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1373,25 +1374,18 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSendPacket) Size() (n int) { +func (m *MsgCreateChannel) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.SourceChannel) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.TimeoutTimestamp != 0 { - n += 1 + sovTx(uint64(m.TimeoutTimestamp)) - } - if len(m.PacketData) > 0 { - for _, e := range m.PacketData { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovTx(uint64(l)) l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1399,32 +1393,33 @@ func (m *MsgSendPacket) Size() (n int) { return n } -func (m *MsgSendPacketResponse) Size() (n int) { +func (m *MsgCreateChannelResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Sequence != 0 { - n += 1 + sovTx(uint64(m.Sequence)) + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgRecvPacket) Size() (n int) { +func (m *MsgProvideCounterparty) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofCommitment) + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CounterpartyChannelId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1432,34 +1427,33 @@ func (m *MsgRecvPacket) Size() (n int) { return n } -func (m *MsgRecvPacketResponse) Size() (n int) { +func (m *MsgProvideCounterpartyResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } return n } -func (m *MsgTimeout) Size() (n int) { +func (m *MsgSendPacket) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofUnreceived) + l = len(m.SourceChannel) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - if m.NextSequenceRecv != 0 { - n += 1 + sovTx(uint64(m.NextSequenceRecv)) + if m.TimeoutTimestamp != 0 { + n += 1 + sovTx(uint64(m.TimeoutTimestamp)) + } + if len(m.PacketData) > 0 { + for _, e := range m.PacketData { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } } l = len(m.Signer) if l > 0 { @@ -1468,19 +1462,19 @@ func (m *MsgTimeout) Size() (n int) { return n } -func (m *MsgTimeoutResponse) Size() (n int) { +func (m *MsgSendPacketResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) } return n } -func (m *MsgAcknowledgement) Size() (n int) { +func (m *MsgRecvPacket) Size() (n int) { if m == nil { return 0 } @@ -1488,9 +1482,7 @@ func (m *MsgAcknowledgement) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTx(uint64(l)) - l = m.Acknowledgement.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofAcked) + l = len(m.ProofCommitment) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1503,7 +1495,7 @@ func (m *MsgAcknowledgement) Size() (n int) { return n } -func (m *MsgAcknowledgementResponse) Size() (n int) { +func (m *MsgRecvPacketResponse) Size() (n int) { if m == nil { return 0 } @@ -1515,19 +1507,22 @@ func (m *MsgAcknowledgementResponse) Size() (n int) { return n } -func (m *MsgProvideCounterparty) Size() (n int) { +func (m *MsgTimeout) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ChannelId) + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofUnreceived) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + if m.NextSequenceRecv != 0 { + n += 1 + sovTx(uint64(m.NextSequenceRecv)) } l = len(m.Signer) if l > 0 { @@ -1536,26 +1531,33 @@ func (m *MsgProvideCounterparty) Size() (n int) { return n } -func (m *MsgProvideCounterpartyResponse) Size() (n int) { +func (m *MsgTimeoutResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } return n } -func (m *MsgCreateChannel) Size() (n int) { +func (m *MsgAcknowledgement) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ClientId) + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Acknowledgement.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofAcked) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.MerklePathPrefix.Size() + l = m.ProofHeight.Size() n += 1 + l + sovTx(uint64(l)) l = len(m.Signer) if l > 0 { @@ -1564,15 +1566,14 @@ func (m *MsgCreateChannel) Size() (n int) { return n } -func (m *MsgCreateChannelResponse) Size() (n int) { +func (m *MsgAcknowledgementResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) } return n } @@ -1583,7 +1584,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { +func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1606,15 +1607,15 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSendPacket: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateChannel: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSendPacket: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateChannel: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1639,33 +1640,14 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { if postIndex < 0 { return ErrInvalidLengthTx } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeoutTimestamp |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: + 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 PacketData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1692,12 +1674,11 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PacketData = append(m.PacketData, PacketData{}) - if err := m.PacketData[len(m.PacketData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -1750,7 +1731,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateChannelResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1773,17 +1754,17 @@ func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSendPacketResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateChannelResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSendPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateChannelResponse: 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) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } - m.Sequence = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1793,11 +1774,24 @@ func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1819,7 +1813,7 @@ func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { +func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1842,17 +1836,17 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRecvPacket: wiretype end group for non-group") + return fmt.Errorf("proto: MsgProvideCounterparty: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecvPacket: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgProvideCounterparty: 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) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1862,30 +1856,29 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofCommitment", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1895,60 +1888,25 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) - if m.ProofCommitment == nil { - m.ProofCommitment = []byte{} - } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.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) } @@ -2001,7 +1959,7 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { +func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2024,31 +1982,12 @@ func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRecvPacketResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecvPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= types1.ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2070,7 +2009,7 @@ func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgTimeout) Unmarshal(dAtA []byte) error { +func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2093,17 +2032,17 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgTimeout: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSendPacket: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeout: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSendPacket: 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) + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2113,30 +2052,29 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) } - var byteLen int + m.TimeoutTimestamp = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2146,29 +2084,14 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.TimeoutTimestamp |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUnreceived == nil { - m.ProofUnreceived = []byte{} - } - iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PacketData", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2195,30 +2118,12 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PacketData = append(m.PacketData, PacketData{}) + if err := m.PacketData[len(m.PacketData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex 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 ErrIntOverflowTx - } - 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) } @@ -2271,7 +2176,7 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSendPacketResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2294,17 +2199,17 @@ func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgTimeoutResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSendPacketResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSendPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - m.Result = 0 + m.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2314,7 +2219,7 @@ func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Result |= types1.ResponseResultType(b&0x7F) << shift + m.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2340,7 +2245,7 @@ func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { +func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2363,48 +2268,15 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAcknowledgement: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRecvPacket: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRecvPacket: 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2431,13 +2303,13 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Acknowledgement.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofCommitment", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2464,12 +2336,12 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) - if m.ProofAcked == nil { - m.ProofAcked = []byte{} + m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) + if m.ProofCommitment == nil { + m.ProofCommitment = []byte{} } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -2502,7 +2374,7 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -2555,7 +2427,7 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2578,10 +2450,10 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAcknowledgementResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRecvPacketResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRecvPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2624,7 +2496,7 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { +func (m *MsgTimeout) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2647,17 +2519,17 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterparty: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeout: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) + 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 ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2667,29 +2539,30 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + 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 CounterpartyChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2699,25 +2572,79 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} + } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 ErrIntOverflowTx + } + 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) } @@ -2770,7 +2697,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { +func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2793,12 +2720,31 @@ func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeoutResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= types1.ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2820,7 +2766,7 @@ func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { +func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2843,17 +2789,17 @@ func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateChannel: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAcknowledgement: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannel: illegal tag %d (wire type %d)", fieldNum, wire) + 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 ClientId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2863,27 +2809,28 @@ func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + 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 MerklePathPrefix", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgement", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2910,11 +2857,78 @@ func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Acknowledgement.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAcked == nil { + m.ProofAcked = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -2967,7 +2981,7 @@ func (m *MsgCreateChannel) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateChannelResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2990,17 +3004,17 @@ func (m *MsgCreateChannelResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateChannelResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAcknowledgementResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } - var stringLen uint64 + m.Result = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3010,24 +3024,11 @@ func (m *MsgCreateChannelResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Result |= types1.ResponseResultType(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index d72dbd9db2a..bd660849b88 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -34,6 +34,47 @@ service Msg { rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); } +// MsgCreateChannel defines the message used to create a v2 Channel. +message MsgCreateChannel { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // the client identifier of the light client representing the counterparty chain + string client_id = 1; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgCreateChannelResponse defines the Msg/CreateChannel response type. +message MsgCreateChannelResponse { + option (gogoproto.goproto_getters) = false; + + string channel_id = 1; +} + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +message MsgProvideCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // unique identifier we will use to write all packet messages sent to counterparty + string channel_id = 1; + // counterparty channel identifier + string counterparty_channel_id = 2; + // signer address + string signer = 3; +} + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +message MsgProvideCounterpartyResponse {} + // MsgSendPacket sends an outgoing IBC packet. message MsgSendPacket { option (cosmos.msg.v1.signer) = "signer"; @@ -110,44 +151,3 @@ message MsgAcknowledgementResponse { ibc.core.channel.v1.ResponseResultType result = 1; } - -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -message MsgProvideCounterparty { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // unique identifier we will use to write all packet messages sent to counterparty - string channel_id = 1; - // counterparty channel identifier - string counterparty_channel_id = 2; - // signer address - string signer = 3; -} - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -message MsgProvideCounterpartyResponse {} - -// MsgCreateChannel defines the message used to create a v2 Channel. -message MsgCreateChannel { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; - // signer address - string signer = 3; -} - -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -message MsgCreateChannelResponse { - option (gogoproto.goproto_getters) = false; - - string channel_id = 1; -} From a282c1adc592f0ce206b59e4ebfe0357a0e9d89c Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 14 Oct 2024 12:20:14 +0100 Subject: [PATCH 070/172] chore: fix naming of parameters sourceID/destinationID (#7448) * Add OnAcknowledgmentPacket to IBCModule V2 Interface * chore: fix typo * chore: PR feedback * chore: fix wrong merge conflict resolution --- modules/core/api/module.go | 16 ++++++++-------- testing/mock/v2/ibc_app.go | 8 ++++---- testing/mock/v2/ibc_module.go | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 8346d291663..077dc65e35e 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -16,8 +16,8 @@ type IBCModule interface { // for this specific application. OnSendPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress, @@ -25,8 +25,8 @@ type IBCModule interface { OnRecvPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult @@ -34,8 +34,8 @@ type IBCModule interface { // OnTimeoutPacket is executed when a packet has timed out on the receiving chain. OnTimeoutPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress, ) error @@ -43,8 +43,8 @@ type IBCModule interface { // OnAcknowledgementPacket is executed when a packet gets acknowledged OnAcknowledgementPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress, diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index 21948faab3e..74c6ca7c543 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,8 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error - OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error + OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index cb797c592bc..871b870bba4 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -32,16 +32,16 @@ func NewIBCModule() IBCModule { } } -func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { +func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { if im.IBCApp.OnSendPacket != nil { - return im.IBCApp.OnSendPacket(ctx, sourceID, destinationID, sequence, data, signer) + return im.IBCApp.OnSendPacket(ctx, sourceChannel, destinationChannel, sequence, data, signer) } return nil } -func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { +func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { if im.IBCApp.OnRecvPacket != nil { - return im.IBCApp.OnRecvPacket(ctx, sourceID, destinationID, data, relayer) + return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer) } return channeltypesv2.RecvPacketResult{ Status: channeltypesv2.PacketStatus_Success, @@ -49,16 +49,16 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati } } -func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { if im.IBCApp.OnAcknowledgementPacket != nil { - return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowledgement, relayer) + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceChannel, destinationChannel, data, acknowledgement, relayer) } return nil } -func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { +func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { - return im.IBCApp.OnTimeoutPacket(ctx, sourceID, destinationID, data, relayer) + return im.IBCApp.OnTimeoutPacket(ctx, sourceChannel, destinationChannel, data, relayer) } return nil } From 50ead0fa2e35ebe049ad1002b8fd371b5a2ae141 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 14 Oct 2024 12:55:06 +0100 Subject: [PATCH 071/172] Implement v2 RecvPacket rpc handler (#7421) * chore: added application callback to SendPacketV2 rpc * chore: adding additional msg server tests * chore: adding additional tests * chore: adding on recv handler * chore: add recv packet happy path * chore: added test for failed recv result * chore: adding additional tests * chore: misc cleanup on self review * chore: moved fn into packet.go and added no-op telemetry v2 functions * chore: addressing PR feedback * chore: add issue links * chore: ensure no-op case works as intended * chore: add NoOp test case * chore: fix ack v2 commitment * chore: PR feedback --------- Co-authored-by: bznein --- modules/core/04-channel/v2/keeper/events.go | 5 + modules/core/04-channel/v2/keeper/keeper.go | 18 +- .../core/04-channel/v2/keeper/msg_server.go | 104 ++++++++++-- .../04-channel/v2/keeper/msg_server_test.go | 155 ++++++++++++++++++ modules/core/04-channel/v2/keeper/packet.go | 49 +++++- modules/core/04-channel/v2/types/msgs.go | 11 ++ modules/core/internal/v2/telemetry/packet.go | 14 ++ modules/core/packet-server/keeper/relay.go | 8 +- 8 files changed, 335 insertions(+), 29 deletions(-) create mode 100644 modules/core/internal/v2/telemetry/packet.go diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 061826315e0..720fb93e11b 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -28,6 +28,11 @@ func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) // TODO: https://github.com/cosmos/ibc-go/issues/7386 } +// EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. +func EmitWriteAcknowledgementEvents(ctx context.Context, packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) { + // TODO: https://github.com/cosmos/ibc-go/issues/7386 +} + // EmitCreateChannelEvent emits a channel create event. func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 7cb64278ff8..f43ec9bb359 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -135,6 +135,16 @@ func (k *Keeper) SetPacketReceipt(ctx context.Context, channelID string, sequenc } } +// GetPacketAcknowledgement fetches the packet acknowledgement from the store. +func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) []byte { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(hostv2.PacketAcknowledgementKey(channelID, sequence)) + if err != nil { + panic(err) + } + return bz +} + // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC V2 specification. func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64, ackHash []byte) { @@ -146,13 +156,7 @@ func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, channelID string, // HasPacketAcknowledgement check if the packet ack hash is already on the store. func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) bool { - store := k.storeService.OpenKVStore(ctx) - found, err := store.Has(hostv2.PacketAcknowledgementKey(channelID, sequence)) - if err != nil { - panic(err) - } - - return found + return len(k.GetPacketAcknowledgement(ctx, channelID, sequence)) > 0 } // GetPacketCommitment returns the packet commitment hash under the commitment path. diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index d86b87e3432..71dd305023a 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "slices" errorsmod "cosmossdk.io/errors" @@ -10,6 +11,8 @@ import ( channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" + telemetryv2 "github.com/cosmos/ibc-go/v9/modules/core/internal/v2/telemetry" + coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) var _ channeltypesv2.MsgServer = &Keeper{} @@ -81,11 +84,6 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck // RecvPacket implements the PacketMsgServer RecvPacket method. func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - err := k.recvPacket(ctx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) - if err != nil { - sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "send packet failed")) - return nil, errorsmod.Wrapf(err, "receive packet failed for source id: %s and destination id: %s", msg.Packet.SourceChannel, msg.Packet.DestinationChannel) - } signer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -93,18 +91,73 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } - _ = signer + // Perform TAO verification + // + // If the packet was already received, perform a no-op + // Use a cached context to prevent accidental state changes + cacheCtx, writeFn := sdkCtx.CacheContext() + err = k.recvPacket(cacheCtx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) - // TODO: implement once app router is wired up. - // https://github.com/cosmos/ibc-go/issues/7384 - // for _, pd := range packet.PacketData { - // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnRecvPacket(ctx, packet, msg.ProofCommitment, msg.ProofHeight, signer) - // if err != nil { - // return nil, err - // } - // } + switch err { + case nil: + writeFn() + case channeltypesv1.ErrNoOpMsg: + // no-ops do not need event emission as they will be ignored + sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) + return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.NOOP}, nil + default: + sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) + return nil, errorsmod.Wrap(err, "receive packet verification failed") + } + + // build up the recv results for each application callback. + ack := channeltypesv2.Acknowledgement{ + AcknowledgementResults: []channeltypesv2.AcknowledgementResult{}, + } + for _, pd := range msg.Packet.Data { + // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful. + cacheCtx, writeFn = sdkCtx.CacheContext() + cb := k.Router.Route(pd.DestinationPort) + res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, signer) + + if res.Status != channeltypesv2.PacketStatus_Failure { + // write application state changes for asynchronous and successful acknowledgements + writeFn() + } else { + // Modify events in cached context to reflect unsuccessful acknowledgement + sdkCtx.EventManager().EmitEvents(convertToErrorEvents(cacheCtx.EventManager().Events())) + } + + ack.AcknowledgementResults = append(ack.AcknowledgementResults, channeltypesv2.AcknowledgementResult{ + AppName: pd.DestinationPort, + RecvPacketResult: res, + }) + } + + // note this should never happen as the packet data would have had to be empty. + if len(ack.AcknowledgementResults) == 0 { + sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) + return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) + } + + // NOTE: TBD how we will handle async acknowledgements with more than one packet data. + isAsync := slices.ContainsFunc(ack.AcknowledgementResults, func(ackResult channeltypesv2.AcknowledgementResult) bool { + return ackResult.RecvPacketResult.Status == channeltypesv2.PacketStatus_Async + }) + + if !isAsync { + // Set packet acknowledgement only if the acknowledgement is not async. + // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the + // acknowledgement is async. + if err := k.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { + return nil, err + } + } + + defer telemetryv2.ReportRecvPacket(msg.Packet) + + sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", channeltypesv1.SUCCESS.String()) return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil } @@ -179,3 +232,24 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *channeltypesv2. return &channeltypesv2.MsgProvideCounterpartyResponse{}, nil } + +// convertToErrorEvents converts all events to error events by appending the +// error attribute prefix to each event's attribute key. +// TODO: https://github.com/cosmos/ibc-go/issues/7436 +func convertToErrorEvents(events sdk.Events) sdk.Events { + if events == nil { + return nil + } + + newEvents := make(sdk.Events, len(events)) + for i, event := range events { + newAttributes := make([]sdk.Attribute, len(event.Attributes)) + for j, attribute := range event.Attributes { + newAttributes[j] = sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value) + } + + newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix+event.Type, newAttributes...) + } + + return newEvents +} diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 4fd61d3f2e3..23cae6248db 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -9,6 +9,8 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" @@ -113,6 +115,159 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { } } +func (suite *KeeperTestSuite) TestMsgRecvPacket() { + var ( + path *ibctesting.Path + msg *channeltypesv2.MsgRecvPacket + recvPacket channeltypesv2.Packet + expectedAck channeltypesv2.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + expError: nil, + }, + { + name: "success: failed recv result", + malleate: func() { + failedRecvResult := channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Failure, + Acknowledgement: mock.MockFailPacketData, + } + + // a failed ack should be returned by the application. + expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult + + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + return failedRecvResult + } + }, + }, + { + name: "success: async recv result", + malleate: func() { + asyncResult := channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Async, + Acknowledgement: nil, + } + + // an async ack should be returned by the application. + expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult + + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + return asyncResult + } + }, + }, + { + name: "success: NoOp", + malleate: func() { + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + expectedAck = channeltypesv2.Acknowledgement{} + }, + }, + { + name: "failure: counterparty not found", + malleate: func() { + // change the destination id to a non-existent channel. + recvPacket.DestinationChannel = "not-existent-channel" + }, + expError: channeltypesv2.ErrChannelNotFound, + }, + { + name: "failure: invalid proof", + malleate: func() { + // proof verification fails because the packet commitment is different due to a different sequence. + recvPacket.Sequence = 10 + }, + expError: commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + + res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket) + suite.Require().NoError(err) + suite.Require().NotNil(res) + + suite.Require().NoError(path.EndpointB.UpdateClient()) + + recvPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + + // default expected ack is a single successful recv result for moduleB. + expectedAck = channeltypesv2.Acknowledgement{ + AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + { + AppName: mockv2.ModuleNameB, + RecvPacketResult: channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Success, + Acknowledgement: mock.MockPacketData, + }, + }, + }, + } + + tc.malleate() + + // get proof of packet commitment from chainA + packetKey := hostv2.PacketCommitmentKey(recvPacket.SourceChannel, recvPacket.Sequence) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + msg = channeltypesv2.NewMsgRecvPacket(recvPacket, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) + + res, err = path.EndpointB.Chain.SendMsgs(msg) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + ck := path.EndpointB.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + // packet receipt should be written + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + suite.Require().True(ok) + + ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), recvPacket.DestinationChannel, recvPacket.Sequence) + + if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == channeltypesv2.PacketStatus_Async { + // ack should not be written for async app or if the packet receipt was already present. + suite.Require().False(ackWritten) + } else { // successful or failed acknowledgement + // ack should be written for synchronous app (default mock application behaviour). + suite.Require().True(ackWritten) + expectedBz := channeltypesv2.CommitAcknowledgement(expectedAck) + + actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), recvPacket.DestinationChannel, recvPacket.Sequence) + suite.Require().Equal(expectedBz, actualAckBz) + } + + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + suite.Require().False(ok) + } + }) + } +} + func (suite *KeeperTestSuite) TestProvideCounterparty() { var ( path *ibctesting.Path diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 360b1611de6..9eb230f15d5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -110,7 +110,7 @@ func (k *Keeper) recvPacket( } } if channel.CounterpartyChannelId != packet.SourceChannel { - return channeltypes.ErrInvalidChannelIdentifier + return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } clientID := channel.ClientId @@ -160,6 +160,48 @@ func (k *Keeper) recvPacket( return nil } +// WriteAcknowledgement writes the acknowledgement to the store. +func (k Keeper) WriteAcknowledgement( + ctx context.Context, + packet channeltypesv2.Packet, + ack channeltypesv2.Acknowledgement, +) error { + // Lookup channel associated with destination channel ID and ensure + // that the packet was indeed sent by our counterparty by verifying + // packet sender is our channel's counterparty channel id. + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) + if !ok { + return errorsmod.Wrapf(channeltypesv2.ErrChannelNotFound, "channel (%s) not found", packet.DestinationChannel) + } + + if channel.CounterpartyChannelId != packet.SourceChannel { + return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) + } + + // NOTE: IBC app modules might have written the acknowledgement synchronously on + // the OnRecvPacket callback so we need to check if the acknowledgement is already + // set on the store and return an error if so. + if k.HasPacketAcknowledgement(ctx, packet.DestinationChannel, packet.Sequence) { + return errorsmod.Wrapf(channeltypes.ErrAcknowledgementExists, "acknowledgement for channel %s, sequence %d already exists", packet.DestinationChannel, packet.Sequence) + } + + if _, found := k.GetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence); !found { + return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") + } + + // set the acknowledgement so that it can be verified on the other side + k.SetPacketAcknowledgement( + ctx, packet.DestinationChannel, packet.Sequence, + channeltypesv2.CommitAcknowledgement(ack), + ) + + k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest-channel", packet.DestinationChannel) + + EmitWriteAcknowledgementEvents(ctx, packet, ack) + + return nil +} + func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Packet, acknowledgement channeltypesv2.Acknowledgement, proof []byte, proofHeight exported.Height) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. @@ -169,8 +211,9 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa } if channel.CounterpartyChannelId != packet.DestinationChannel { - return channeltypes.ErrInvalidChannelIdentifier + return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } + clientID := channel.ClientId commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) @@ -240,7 +283,7 @@ func (k *Keeper) timeoutPacket( } } if channel.CounterpartyChannelId != packet.DestinationChannel { - return channeltypes.ErrInvalidChannelIdentifier + return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } clientID := channel.ClientId diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 936157cc5c7..fc227176185 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" @@ -79,3 +80,13 @@ func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer stri Signer: signer, } } + +// NewMsgRecvPacket creates a new MsgRecvPacket instance. +func NewMsgRecvPacket(packet Packet, proofCommitment []byte, proofHeight clienttypes.Height, signer string) *MsgRecvPacket { + return &MsgRecvPacket{ + Packet: packet, + ProofCommitment: proofCommitment, + ProofHeight: proofHeight, + Signer: signer, + } +} diff --git a/modules/core/internal/v2/telemetry/packet.go b/modules/core/internal/v2/telemetry/packet.go new file mode 100644 index 00000000000..7c5c8588247 --- /dev/null +++ b/modules/core/internal/v2/telemetry/packet.go @@ -0,0 +1,14 @@ +package telemetry + +import ( + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +// ReportRecvPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 +func ReportRecvPacket(packet channeltypesv2.Packet) {} + +// ReportTimeoutPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 +func ReportTimeoutPacket(packet channeltypesv2.Packet, timeoutType string) {} + +// ReportAcknowledgePacket TODO: https://github.com/cosmos/ibc-go/issues/7437 +func ReportAcknowledgePacket(packet channeltypesv2.Packet) {} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 40c279fa94d..334ea601a03 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -135,7 +135,7 @@ func (k Keeper) RecvPacket( } if channel.CounterpartyChannelId != packet.SourceChannel { - return "", channeltypes.ErrInvalidChannelIdentifier + return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } clientID := channel.ClientId @@ -211,7 +211,7 @@ func (k Keeper) WriteAcknowledgement( return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } if channel.CounterpartyChannelId != packet.SourceChannel { - return channeltypes.ErrInvalidChannelIdentifier + return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } // NOTE: IBC app modules might have written the acknowledgement synchronously on @@ -268,7 +268,7 @@ func (k Keeper) AcknowledgePacket( } if channel.CounterpartyChannelId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier + return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } clientID := channel.ClientId @@ -339,7 +339,7 @@ func (k Keeper) TimeoutPacket( } if channel.CounterpartyChannelId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier + return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } clientID := channel.ClientId From b49b466751851436bb9babddf031e658faab072a Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 14 Oct 2024 16:50:36 +0300 Subject: [PATCH 072/172] chore: Move initialization of next sequence send to create channel rpc handler. (#7449) --- modules/core/04-channel/v2/keeper/msg_server.go | 2 +- modules/core/04-channel/v2/keeper/msg_server_test.go | 6 +++++- modules/core/04-channel/v2/keeper/packet.go | 7 ++++--- modules/core/04-channel/v2/types/errors.go | 9 +++++---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 71dd305023a..9ddf7b44176 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -199,8 +199,8 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *channeltypesv2.MsgCre // Initialize channel with empty counterparty channel identifier. channel := channeltypesv2.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) k.SetChannel(ctx, channelID, channel) - k.SetCreator(ctx, channelID, msg.Signer) + k.SetNextSequenceSend(ctx, channelID, 1) k.EmitCreateChannelEvent(goCtx, channelID) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 23cae6248db..5bc2044858f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -330,8 +330,12 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().True(found) suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) + _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().False(found) + + seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(seq, uint64(1)) } else { suite.Require().Error(err) } diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 9eb230f15d5..706d5682f30 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -37,11 +37,12 @@ func (k *Keeper) sendPacket( destChannel := channel.CounterpartyChannelId clientID := channel.ClientId - // retrieve the sequence send for this channel - // if no packets have been sent yet, initialize the sequence to 1. sequence, found := k.GetNextSequenceSend(ctx, sourceChannel) if !found { - sequence = 1 + return 0, "", errorsmod.Wrapf( + channeltypesv2.ErrSequenceSendNotFound, + "source channel: %s", sourceChannel, + ) } // construct packet from given fields and channel state diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 7f56d8f8e34..18c70b70792 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,8 +5,9 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 5, "sequence send not found") ) From 063814c70acb488b4ff4e7b469ac4bde3d350d15 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 14 Oct 2024 15:30:30 +0100 Subject: [PATCH 073/172] chore: Implement v2 Acknowledgement rpc handler (#7452) * chore: added application callback to SendPacketV2 rpc * chore: adding additional msg server tests * chore: adding additional tests * chore: adding on recv handler * chore: add recv packet happy path * chore: added test for failed recv result * chore: adding additional tests * chore: misc cleanup on self review * chore: moved fn into packet.go and added no-op telemetry v2 functions * chore: implement Acknowledgment RPC handler * chore: add MsgAcknowledgment and test skeleton * wip * chore: fix set packet ack * add more test cases * merge conflicts * unneeded file! * removed duplicate method * revert error checking * chore: linter * PR feedback * typo --------- Co-authored-by: chatton --- .../core/04-channel/v2/keeper/msg_server.go | 23 +-- .../04-channel/v2/keeper/msg_server_test.go | 132 +++++++++++++++++- modules/core/04-channel/v2/types/msgs.go | 11 ++ testing/utils.go | 1 + 4 files changed, 155 insertions(+), 12 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 9ddf7b44176..123fd44310e 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -66,19 +66,20 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } - _ = relayer + recvResults := make(map[string]channeltypesv2.RecvPacketResult) + for _, r := range msg.Acknowledgement.AcknowledgementResults { + recvResults[r.AppName] = r.RecvPacketResult + } - // TODO: implement once app router is wired up. - // https://github.com/cosmos/ibc-go/issues/7384 - // for _, pd := range msg.PacketData { - // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnSendPacket(ctx, msg.SourceId, sequence, msg.TimeoutTimestamp, pd, signer) - // if err != nil { - // return nil, err - // } - // } + for _, pd := range msg.Packet.Data { + cbs := k.Router.Route(pd.SourcePort) + err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, recvResults[pd.DestinationPort].Acknowledgement, relayer) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) + } + } - return nil, nil + return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil } // RecvPacket implements the PacketMsgServer RecvPacket method. diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 5bc2044858f..83eb1e8b9ff 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "context" + "errors" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -286,7 +287,6 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { }, nil, }, - { "failure: signer does not match creator", func() { @@ -341,3 +341,133 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { } } } + +func (suite *KeeperTestSuite) TestMsgAcknowledgement() { + var ( + path *ibctesting.Path + msgAckPacket *channeltypesv2.MsgAcknowledgement + recvPacket channeltypesv2.Packet + ) + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "success: NoOp", + malleate: func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence, []byte{}) + + // Modify the callback to return an error. + // This way, we can verify that the callback is not executed in a No-op case. + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { + return errors.New("OnAcknowledgementPacket callback failed") + } + }, + }, + { + name: "failure: invalid signer", + malleate: func() { + msgAckPacket.Signer = "" + }, + expError: errors.New("empty address string is not allowed"), + }, + { + name: "failure: callback fails", + malleate: func() { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { + return errors.New("OnAcknowledgementPacket callback failed") + } + }, + expError: errors.New("OnAcknowledgementPacket callback failed"), + }, + { + name: "failure: counterparty not found", + malleate: func() { + // change the source id to a non-existent channel. + msgAckPacket.Packet.SourceChannel = "not-existent-channel" + }, + expError: channeltypesv2.ErrChannelNotFound, + }, + { + name: "failure: invalid commitment", + malleate: func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence, []byte("foo")) + }, + expError: channeltypesv2.ErrInvalidPacket, + }, + { + name: "failure: failed membership verification", + malleate: func() { + msgAckPacket.ProofHeight = clienttypes.ZeroHeight() + }, + expError: errors.New("failed packet acknowledgement verification"), + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + + // Send packet from A to B + msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NoError(path.EndpointB.UpdateClient()) + + // Receive packet on B + recvPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + // get proof of packet commitment from chainA + packetKey := hostv2.PacketCommitmentKey(recvPacket.SourceChannel, recvPacket.Sequence) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + // Construct msgRecvPacket to be sent to B + msgRecvPacket := channeltypesv2.NewMsgRecvPacket(recvPacket, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) + res, err = suite.chainB.SendMsgs(msgRecvPacket) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + // Construct expected acknowledgement + ack := channeltypesv2.Acknowledgement{ + AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + { + AppName: mockv2.ModuleNameB, + RecvPacketResult: channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Success, + Acknowledgement: mock.MockPacketData, + }, + }, + }, + } + + // Consttruct MsgAcknowledgement + packetKey = hostv2.PacketAcknowledgementKey(recvPacket.DestinationChannel, recvPacket.Sequence) + proof, proofHeight = path.EndpointB.QueryProof(packetKey) + msgAckPacket = channeltypesv2.NewMsgAcknowledgement(recvPacket, ack, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) + + tc.malleate() + + // Finally, acknowledge the packet on A + res, err = suite.chainA.SendMsgs(msgAckPacket) + + expPass := tc.expError == nil + + if expPass { + suite.Require().NoError(err) + suite.NotNil(res) + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index fc227176185..cb06c5f90ef 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -90,3 +90,14 @@ func NewMsgRecvPacket(packet Packet, proofCommitment []byte, proofHeight clientt Signer: signer, } } + +// NewMsgAcknowledgement creates a new MsgAcknowledgement instance +func NewMsgAcknowledgement(packet Packet, acknowledgement Acknowledgement, proofAcked []byte, proofHeight clienttypes.Height, signer string) *MsgAcknowledgement { + return &MsgAcknowledgement{ + Packet: packet, + Acknowledgement: acknowledgement, + ProofAcked: proofAcked, + ProofHeight: proofHeight, + Signer: signer, + } +} diff --git a/testing/utils.go b/testing/utils.go index 53d84ab559a..861bb54e1a6 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -87,6 +87,7 @@ func UnmarshalMsgResponses(cdc codec.Codec, data []byte, msgs ...codec.ProtoMars // RequireErrorIsOrContains verifies that the passed error is either a target error or contains its error message. func RequireErrorIsOrContains(t *testing.T, err, targetError error, msgAndArgs ...interface{}) { t.Helper() + require.Error(t, err) require.True( t, errors.Is(err, targetError) || From 6dc12494b707897281b41b1fd60ee26579cd9d6e Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 15 Oct 2024 12:08:11 +0300 Subject: [PATCH 074/172] chore: replace stale references to clientId. (#7457) --- .../core/04-channel/v2/client/cli/query.go | 14 +++++++------- modules/core/04-channel/v2/client/cli/tx.go | 6 +++--- modules/core/04-channel/v2/keeper/keeper.go | 18 +++++++++--------- .../core/04-channel/v2/keeper/keeper_test.go | 19 +++++++++---------- modules/core/04-channel/v2/keeper/packet.go | 4 ++-- .../core/04-channel/v2/types/merkle_test.go | 2 +- modules/core/04-channel/v2/types/msgs_test.go | 4 ++-- .../core/04-channel/v2/types/packet_test.go | 6 +++--- modules/core/04-channel/v2/types/tx.pb.go | 5 ++--- proto/ibc/core/channel/v2/tx.proto | 5 ++--- 10 files changed, 40 insertions(+), 43 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 822284192b2..3521430d225 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -13,24 +13,24 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// getCmdQueryChannel defines the command to query the client information (creator and channel) for the given client ID. +// getCmdQueryChannel defines the command to query the channel information (creator and channel) for the given channel ID. func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ - Use: "client [client-id]", - Short: "Query the information of a client.", - Long: "Query the client information (creator and channel) for the provided client ID.", - Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, exported.ModuleName, types.SubModuleName), + Use: "channel [channel-id]", + Short: "Query the information of a channel.", + Long: "Query the channel information (creator and channel) for the provided channel ID.", + Example: fmt.Sprintf("%s query %s %s channel [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } - clientID := args[0] + channelID := args[0] queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryChannelRequest{ChannelId: clientID} + req := &types.QueryChannelRequest{ChannelId: channelID} res, err := queryClient.Channel(cmd.Context(), req) if err != nil { diff --git a/modules/core/04-channel/v2/client/cli/tx.go b/modules/core/04-channel/v2/client/cli/tx.go index 746012fcb32..9ff268d4843 100644 --- a/modules/core/04-channel/v2/client/cli/tx.go +++ b/modules/core/04-channel/v2/client/cli/tx.go @@ -14,13 +14,13 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC channel. +// newProvideCounterpartyCmd defines the command to provide the counterparty channel identifier to an IBC channel. func newProvideCounterpartyCmd() *cobra.Command { cmd := &cobra.Command{ Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", Args: cobra.ExactArgs(2), - Short: "provide the counterparty channel id to an IBC channel end", - Long: `Provide the counterparty channel id to an IBC channel end specified by its channel ID.`, + Short: "provide the counterparty channel id to an IBC channel", + Long: `Provide the counterparty channel id to an IBC channel specified by its channel ID.`, Example: fmt.Sprintf("%s tx %s %s provide-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index f43ec9bb359..0880ed7b6e0 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -79,10 +79,10 @@ func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channe return channel, true } -// GetCreator returns the creator of the client. -func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) { +// GetCreator returns the creator of the channel. +func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - bz := k.ChannelStore(sdkCtx, clientID).Get([]byte(types.CreatorKey)) + bz := k.ChannelStore(sdkCtx, channelID).Get([]byte(types.CreatorKey)) if len(bz) == 0 { return "", false } @@ -90,16 +90,16 @@ func (k *Keeper) GetCreator(ctx context.Context, clientID string) (string, bool) return string(bz), true } -// SetCreator sets the creator of the client. -func (k *Keeper) SetCreator(ctx context.Context, clientID, creator string) { +// SetCreator sets the creator of the channel. +func (k *Keeper) SetCreator(ctx context.Context, channelID, creator string) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, clientID).Set([]byte(types.CreatorKey), []byte(creator)) + k.ChannelStore(sdkCtx, channelID).Set([]byte(types.CreatorKey), []byte(creator)) } -// DeleteCreator deletes the creator associated with the client. -func (k *Keeper) DeleteCreator(ctx context.Context, clientID string) { +// DeleteCreator deletes the creator associated with the channel. +func (k *Keeper) DeleteCreator(ctx context.Context, channelID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, clientID).Delete([]byte(types.CreatorKey)) + k.ChannelStore(sdkCtx, channelID).Delete([]byte(types.CreatorKey)) } // GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. diff --git a/modules/core/04-channel/v2/keeper/keeper_test.go b/modules/core/04-channel/v2/keeper/keeper_test.go index 93580d13d77..3521e3c789f 100644 --- a/modules/core/04-channel/v2/keeper/keeper_test.go +++ b/modules/core/04-channel/v2/keeper/keeper_test.go @@ -121,34 +121,33 @@ func (suite *KeeperTestSuite) TestSetChannel() { suite.Require().True(found, "GetChannel does not return channel") suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") - // Channel not yet stored for another client. - retrievedChannel, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) + // No channel stored under other channel identifier. + retrievedChannel, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.SecondChannelID) suite.Require().False(found, "GetChannel unexpectedly returned a channel") suite.Require().Equal(channeltypes2.Channel{}, retrievedChannel, "Channel retrieved not empty") } func (suite *KeeperTestSuite) TestSetCreator() { - clientID := ibctesting.FirstClientID expectedCreator := "test-creator" // Set the creator for the client - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), clientID, expectedCreator) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expectedCreator) // Retrieve the creator from the store - retrievedCreator, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), clientID) + retrievedCreator, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) // Verify that the retrieved creator matches the expected creator suite.Require().True(found, "GetCreator did not return stored creator") suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") - // Verify non stored creator is not found - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.SecondClientID) + // Verify that the creator is deleted from the store + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) suite.Require().False(found, "GetCreator unexpectedly returned a creator") suite.Require().Empty(retrievedCreator, "Creator is not empty") - // Verify that the creator is deleted from the store - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), clientID) - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), clientID) + // Verify non stored creator is not found + retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.SecondChannelID) suite.Require().False(found, "GetCreator unexpectedly returned a creator") suite.Require().Empty(retrievedCreator, "Creator is not empty") } diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 706d5682f30..5caa94b9772 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -148,7 +148,7 @@ func (k *Keeper) recvPacket( merklePath, commitment, ); err != nil { - return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) + return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", clientID) } // Set Packet Receipt to prevent timeout from occurring on counterparty @@ -328,7 +328,7 @@ func (k *Keeper) timeoutPacket( proof, merklePath, ); err != nil { - return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", clientID) } // delete packet commitment to prevent replay diff --git a/modules/core/04-channel/v2/types/merkle_test.go b/modules/core/04-channel/v2/types/merkle_test.go index 8990d05a83d..df239bc17d7 100644 --- a/modules/core/04-channel/v2/types/merkle_test.go +++ b/modules/core/04-channel/v2/types/merkle_test.go @@ -13,7 +13,7 @@ func (s *TypesTestSuite) TestBuildMerklePath() { path.SetupV2() prefixPath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - packetCommitmentKey := host.PacketCommitmentKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, 1) + packetCommitmentKey := host.PacketCommitmentKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, 1) testCases := []struct { name string diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 48ce0d511a1..6d867221b54 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -70,8 +70,8 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { for _, tc := range testCases { msg = types.NewMsgProvideCounterparty( - ibctesting.FirstClientID, - ibctesting.SecondClientID, + ibctesting.FirstChannelID, + ibctesting.SecondChannelID, ibctesting.TestAccAddress, ) diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index aad8539edc1..4f908d54a90 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/ibc-go/v9/testing/mock" ) -// TestValidate tests the Validate function of Packet +// TestValidate tests the Validate function of Payload func TestValidate(t *testing.T) { testCases := []struct { name string @@ -52,7 +52,7 @@ func TestValidate(t *testing.T) { } } -// TestValidateBasic tests the ValidateBasic functio of Packet +// TestValidateBasic tests the ValidateBasic function of Packet func TestValidateBasic(t *testing.T) { var packet types.Packet testCases := []struct { @@ -117,7 +117,7 @@ func TestValidateBasic(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - packet = types.NewPacket(1, ibctesting.FirstClientID, ibctesting.FirstClientID, uint64(time.Now().Unix()), types.PacketData{ + packet = types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, uint64(time.Now().Unix()), types.PacketData{ SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Payload: types.Payload{ diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index df9610f29a7..633a9c2e8dc 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -114,9 +114,8 @@ func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. +// MsgProvideCounterparty defines the message used to provide the counterparty channel +// identifier. type MsgProvideCounterparty struct { // unique identifier we will use to write all packet messages sent to counterparty ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index bd660849b88..90a0a0db653 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -56,9 +56,8 @@ message MsgCreateChannelResponse { string channel_id = 1; } -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. +// MsgProvideCounterparty defines the message used to provide the counterparty channel +// identifier. message MsgProvideCounterparty { option (cosmos.msg.v1.signer) = "signer"; From ef74ad66e8ac84f180c2593e70fee87ae0f85b56 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 15 Oct 2024 12:13:28 +0300 Subject: [PATCH 075/172] fix: start error code from 2. (#7458) --- modules/core/04-channel/v2/types/errors.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 18c70b70792..bb112a09696 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,9 +5,9 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 3, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 4, "invalid payload") - ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 5, "sequence send not found") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") ) From d670ab82010c059b345716da8cb93a513f39ddf3 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 15 Oct 2024 14:46:47 +0300 Subject: [PATCH 076/172] chore: add cli/tx for create channel. (#7460) --- modules/core/04-channel/v2/client/cli/cli.go | 3 +- modules/core/04-channel/v2/client/cli/tx.go | 50 +++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index 5c5a897b0f9..c725fe8ee12 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -36,7 +36,8 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - newProvideCounterpartyCmd(), + newCreateChannelTxCmd(), + newProvideCounterpartyTxCmd(), ) return txCmd diff --git a/modules/core/04-channel/v2/client/cli/tx.go b/modules/core/04-channel/v2/client/cli/tx.go index 9ff268d4843..418f01815e7 100644 --- a/modules/core/04-channel/v2/client/cli/tx.go +++ b/modules/core/04-channel/v2/client/cli/tx.go @@ -1,7 +1,9 @@ package cli import ( + "encoding/hex" "fmt" + "strings" "github.com/spf13/cobra" @@ -11,11 +13,42 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) +// newCreateChannelTxCmd defines the command to create an IBC channel/v2. +func newCreateChannelTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-channel [client-identifier] [merkle-path-prefix]", + Args: cobra.ExactArgs(2), + Short: "create an IBC channel/v2", + Long: `Creates an IBC channel/v2 using the client identifier representing the counterparty chain and the hex-encoded merkle path prefix under which the counterparty stores packet flow information.`, + Example: fmt.Sprintf("%s tx %s %s create-channel 07-tendermint-0 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + clientID := args[0] + merklePathPrefix, err := parseMerklePathPrefix(args[2]) + if err != nil { + return err + } + + msg := types.NewMsgCreateChannel(clientID, merklePathPrefix, clientCtx.GetFromAddress().String()) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + // newProvideCounterpartyCmd defines the command to provide the counterparty channel identifier to an IBC channel. -func newProvideCounterpartyCmd() *cobra.Command { +func newProvideCounterpartyTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", Args: cobra.ExactArgs(2), @@ -43,3 +76,18 @@ func newProvideCounterpartyCmd() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } + +// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. +func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { + var keyPath [][]byte + hexPrefixes := strings.Split(merklePathPrefixString, ",") + for _, hexPrefix := range hexPrefixes { + prefix, err := hex.DecodeString(hexPrefix) + if err != nil { + return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) + } + keyPath = append(keyPath, prefix) + } + + return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil +} From 8ed9222a58f0f7fa3306b520c8633582654230fb Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 15 Oct 2024 15:35:33 +0300 Subject: [PATCH 077/172] chore: remove stale references to packet-server in channel/v2. (#7451) --- modules/core/04-channel/v2/client/cli/cli.go | 10 +++++----- modules/core/04-channel/v2/keeper/grpc_query.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index c725fe8ee12..69952be9f81 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -5,14 +5,14 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) -// GetQueryCmd returns the query commands for the IBC packet-server. +// GetQueryCmd returns the query commands for the IBC channel/v2. func GetQueryCmd() *cobra.Command { queryCmd := &cobra.Command{ Use: types.SubModuleName, - Short: "IBC packet-server query subcommands", + Short: "IBC channel/v2 query subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -25,11 +25,11 @@ func GetQueryCmd() *cobra.Command { return queryCmd } -// NewTxCmd returns the command to submit transactions defined for the IBC packet-server. +// NewTxCmd returns the command to submit transactions defined for IBC channel/v2. func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: types.SubModuleName, - Short: "IBC packet-server transaction subcommands", + Short: "IBC channel/v2 transaction subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index fde351da818..10343b516ab 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -16,7 +16,7 @@ import ( var _ types.QueryServer = (*queryServer)(nil) -// queryServer implements the packet-server types.QueryServer interface. +// queryServer implements the channel/v2 types.QueryServer interface. type queryServer struct { *Keeper } From 68756ec3c5d3b7056b21dd271a81f4f287e8f0d8 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Tue, 15 Oct 2024 13:37:43 +0100 Subject: [PATCH 078/172] Remove duplication of ConvertToErrorEvents (#7467) * chore: move convert to errors to internal directory * chore: removed empty file --- .../core/04-channel/v2/keeper/msg_server.go | 25 ++----------------- modules/core/internal/errors/errors.go | 25 +++++++++++++++++++ modules/core/keeper/events_test.go | 5 ++-- modules/core/keeper/export_test.go | 9 ------- modules/core/keeper/msg_server.go | 25 ++----------------- modules/core/keeper/msg_server_test.go | 11 ++++---- 6 files changed, 36 insertions(+), 64 deletions(-) create mode 100644 modules/core/internal/errors/errors.go delete mode 100644 modules/core/keeper/export_test.go diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 123fd44310e..7356040ccee 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -11,8 +11,8 @@ import ( channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" + internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" telemetryv2 "github.com/cosmos/ibc-go/v9/modules/core/internal/v2/telemetry" - coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) var _ channeltypesv2.MsgServer = &Keeper{} @@ -127,7 +127,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack writeFn() } else { // Modify events in cached context to reflect unsuccessful acknowledgement - sdkCtx.EventManager().EmitEvents(convertToErrorEvents(cacheCtx.EventManager().Events())) + sdkCtx.EventManager().EmitEvents(internalerrors.ConvertToErrorEvents(cacheCtx.EventManager().Events())) } ack.AcknowledgementResults = append(ack.AcknowledgementResults, channeltypesv2.AcknowledgementResult{ @@ -233,24 +233,3 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *channeltypesv2. return &channeltypesv2.MsgProvideCounterpartyResponse{}, nil } - -// convertToErrorEvents converts all events to error events by appending the -// error attribute prefix to each event's attribute key. -// TODO: https://github.com/cosmos/ibc-go/issues/7436 -func convertToErrorEvents(events sdk.Events) sdk.Events { - if events == nil { - return nil - } - - newEvents := make(sdk.Events, len(events)) - for i, event := range events { - newAttributes := make([]sdk.Attribute, len(event.Attributes)) - for j, attribute := range event.Attributes { - newAttributes[j] = sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value) - } - - newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix+event.Type, newAttributes...) - } - - return newEvents -} diff --git a/modules/core/internal/errors/errors.go b/modules/core/internal/errors/errors.go new file mode 100644 index 00000000000..99acf8c02a5 --- /dev/null +++ b/modules/core/internal/errors/errors.go @@ -0,0 +1,25 @@ +package errors + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" +) + +// ConvertToErrorEvents converts all events to error events by appending the +// error attribute prefix to each event's attribute key. +func ConvertToErrorEvents(events sdk.Events) sdk.Events { + if events == nil { + return nil + } + + newEvents := make(sdk.Events, len(events)) + for i, event := range events { + newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix + event.Type) + for _, attribute := range event.Attributes { + newEvents[i] = newEvents[i].AppendAttributes(sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value)) + } + } + + return newEvents +} diff --git a/modules/core/keeper/events_test.go b/modules/core/keeper/events_test.go index 98915ac13c1..1143782ddc8 100644 --- a/modules/core/keeper/events_test.go +++ b/modules/core/keeper/events_test.go @@ -2,12 +2,11 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v9/modules/core/keeper" + internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -99,7 +98,7 @@ func TestConvertToErrorEvents(t *testing.T) { tc.malleate() - newEvents := keeper.ConvertToErrorEvents(events) + newEvents := internalerrors.ConvertToErrorEvents(events) require.Equal(t, expEvents, newEvents) }) } diff --git a/modules/core/keeper/export_test.go b/modules/core/keeper/export_test.go deleted file mode 100644 index 81d79ea7aa9..00000000000 --- a/modules/core/keeper/export_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package keeper - -import sdk "github.com/cosmos/cosmos-sdk/types" - -// ConvertToErrorEvents is a wrapper around convertToErrorEvents -// to allow the function to be directly called in tests. -func ConvertToErrorEvents(events sdk.Events) sdk.Events { - return convertToErrorEvents(events) -} diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index a59bfc28490..92348c0de03 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +14,8 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" + internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/telemetry" - coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) var ( @@ -442,7 +441,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack writeFn() } else { // Modify events in cached context to reflect unsuccessful acknowledgement - ctx.EventManager().EmitEvents(convertToErrorEvents(cacheCtx.EventManager().Events())) + ctx.EventManager().EmitEvents(internalerrors.ConvertToErrorEvents(cacheCtx.EventManager().Events())) } // Set packet acknowledgement only if the acknowledgement is not nil. @@ -999,26 +998,6 @@ func (k *Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.Ms return &channeltypes.MsgUpdateParamsResponse{}, nil } -// convertToErrorEvents converts all events to error events by appending the -// error attribute prefix to each event's attribute key. -func convertToErrorEvents(events sdk.Events) sdk.Events { - if events == nil { - return nil - } - - newEvents := make(sdk.Events, len(events)) - for i, event := range events { - newAttributes := make([]sdk.Attribute, len(event.Attributes)) - for j, attribute := range event.Attributes { - newAttributes[j] = sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value) - } - - newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix+event.Type, newAttributes...) - } - - return newEvents -} - // getPacketHandlerAndModule returns the appropriate packet handler // given the protocol version. An error is returned if the protocol // version is not supported. diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index e101d57ed06..bea3fccc45a 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,7 +19,7 @@ import ( host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/keeper" + internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -186,13 +185,13 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { if tc.expRevert { // context events should contain error events - suite.Require().Contains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + suite.Require().Contains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) } else { if tc.replay { // context should not contain application events suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) - suite.Require().NotContains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + suite.Require().NotContains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) } else { // context events should contain application events suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) @@ -353,13 +352,13 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { if tc.expRevert { // context events should contain error events - suite.Require().Contains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + suite.Require().Contains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) } else { if tc.replay { // context should not contain application events suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) - suite.Require().NotContains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) + suite.Require().NotContains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) } else { // context events should contain application events suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) From d7934722f7eaff32e3052bb5a8b8d3d41f427531 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 15 Oct 2024 13:50:40 +0100 Subject: [PATCH 079/172] chore: add ValidateBasic for MsgSendPacket (#7468) --- modules/core/04-channel/v2/types/errors.go | 1 + modules/core/04-channel/v2/types/msgs.go | 29 ++++++++ modules/core/04-channel/v2/types/msgs_test.go | 69 +++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index bb112a09696..2873867295b 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -10,4 +10,5 @@ var ( ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") + ErrInvalidPacketData = errorsmod.Register(SubModuleName, 7, "invalid packet data") ) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index cb06c5f90ef..4205d1099ce 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" @@ -81,6 +82,34 @@ func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer stri } } +// ValidateBasic performs basic checks on a MsgSendPacket. +func (msg *MsgSendPacket) ValidateBasic() error { + if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { + return err + } + + if msg.TimeoutTimestamp == 0 { + return errorsmod.Wrap(channeltypesv1.ErrInvalidTimeout, "timeout must not be 0") + } + + if len(msg.PacketData) != 1 { + return errorsmod.Wrapf(ErrInvalidPacketData, "packet data must be of length 1, got %d instead", len(msg.PacketData)) + } + + for _, pd := range msg.PacketData { + if err := pd.ValidateBasic(); err != nil { + return err + } + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + return nil +} + // NewMsgRecvPacket creates a new MsgRecvPacket instance. func NewMsgRecvPacket(packet Packet, proofCommitment []byte, proofHeight clienttypes.Height, signer string) *MsgRecvPacket { return &MsgRecvPacket{ diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 6d867221b54..208db17638c 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" @@ -142,3 +143,71 @@ func (s *TypesTestSuite) TestMsgCreateChannelValidateBasic() { } } } + +func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { + var msg *types.MsgSendPacket + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: invalid source channel", + malleate: func() { + msg.SourceChannel = "" + }, + expError: host.ErrInvalidID, + }, + { + name: "failure: invalid timestamp", + malleate: func() { + msg.TimeoutTimestamp = 0 + }, + expError: channeltypesv1.ErrInvalidTimeout, + }, + { + name: "failure: invalid length for packetdata", + malleate: func() { + msg.PacketData = []types.PacketData{} + }, + expError: types.ErrInvalidPacketData, + }, + { + name: "failure: invalid packetdata", + malleate: func() { + msg.PacketData[0].DestinationPort = "" + }, + expError: host.ErrInvalidID, + }, + { + name: "failure: invalid signer", + malleate: func() { + msg.Signer = "" + }, + expError: ibcerrors.ErrInvalidAddress, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + msg = types.NewMsgSendPacket( + ibctesting.FirstChannelID, s.chainA.GetTimeoutTimestamp(), + s.chainA.SenderAccount.GetAddress().String(), + types.PacketData{SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Payload: types.NewPayload("ics20-1", "json", ibctesting.MockPacketData)}, + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expError) + } + }) + } +} From 1682792b9428df0df33709b8192c8bae3b508f71 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Tue, 15 Oct 2024 13:55:33 +0100 Subject: [PATCH 080/172] Add helper functions for MsgSendPacket, MsgRecvPacket and MsgAcknowledgePacket (#7465) * chore: added msg send packet fucntion on endpoint * chore: added MsgRecvPacket to endpoint * chore: modify ack test to use new endpoint send and recv functions * chore: refactored msg ack to use new endpoint fn * chore: added test case to verify proof failure * Update testing/endpoint_v2.go Co-authored-by: DimitrisJim --------- Co-authored-by: DimitrisJim --- .../04-channel/v2/keeper/msg_server_test.go | 112 ++++++------------ testing/endpoint_v2.go | 58 +++++++++ 2 files changed, 95 insertions(+), 75 deletions(-) create mode 100644 testing/endpoint_v2.go diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 83eb1e8b9ff..a75dfdee074 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -11,7 +11,6 @@ import ( channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" @@ -20,9 +19,10 @@ import ( func (suite *KeeperTestSuite) TestMsgSendPacket() { var ( - path *ibctesting.Path - msg *channeltypesv2.MsgSendPacket - expectedPacket channeltypesv2.Packet + path *ibctesting.Path + expectedPacket channeltypesv2.Packet + timeoutTimestamp uint64 + packetData channeltypesv2.PacketData ) testCases := []struct { @@ -39,7 +39,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { name: "failure: timeout elapsed", malleate: func() { // ensure a message timeout. - msg.TimeoutTimestamp = uint64(1) + timeoutTimestamp = uint64(1) }, expError: channeltypesv1.ErrTimeoutElapsed, }, @@ -62,14 +62,14 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: counterparty not found", malleate: func() { - msg.SourceChannel = "foo" + path.EndpointA.ChannelID = "foo" }, expError: channeltypesv1.ErrChannelNotFound, }, { name: "failure: route to non existing app", malleate: func() { - msg.PacketData[0].SourcePort = "foo" + packetData.SourcePort = "foo" }, expError: fmt.Errorf("no route for foo"), }, @@ -84,19 +84,19 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() - msg = channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + timeoutTimestamp = suite.chainA.GetTimeoutTimestamp() + packetData = mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, packetData) tc.malleate() - res, err := path.EndpointA.Chain.SendMsgs(msg) + packet, err := path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) expPass := tc.expError == nil if expPass { suite.Require().NoError(err) - suite.Require().NotNil(res) + suite.Require().NotEmpty(packet) ck := path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 @@ -108,6 +108,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { suite.Require().True(ok) suite.Require().Equal(uint64(2), nextSequenceSend, "next sequence send was not incremented correctly") + suite.Require().Equal(expectedPacket, packet) + } else { suite.Require().Error(err) ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError) @@ -119,8 +121,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { func (suite *KeeperTestSuite) TestMsgRecvPacket() { var ( path *ibctesting.Path - msg *channeltypesv2.MsgRecvPacket - recvPacket channeltypesv2.Packet + packet channeltypesv2.Packet expectedAck channeltypesv2.Acknowledgement ) @@ -169,7 +170,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: NoOp", malleate: func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.SourceChannel, packet.Sequence) expectedAck = channeltypesv2.Acknowledgement{} }, }, @@ -177,7 +178,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "failure: counterparty not found", malleate: func() { // change the destination id to a non-existent channel. - recvPacket.DestinationChannel = "not-existent-channel" + packet.DestinationChannel = "not-existent-channel" }, expError: channeltypesv2.ErrChannelNotFound, }, @@ -185,7 +186,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "failure: invalid proof", malleate: func() { // proof verification fails because the packet commitment is different due to a different sequence. - recvPacket.Sequence = 10 + packet.Sequence = 10 }, expError: commitmenttypes.ErrInvalidProof, }, @@ -201,15 +202,10 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { path.SetupV2() timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() - msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) - res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket) + var err error + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().NoError(path.EndpointB.UpdateClient()) - - recvPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) // default expected ack is a single successful recv result for moduleB. expectedAck = channeltypesv2.Acknowledgement{ @@ -226,27 +222,19 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { tc.malleate() - // get proof of packet commitment from chainA - packetKey := hostv2.PacketCommitmentKey(recvPacket.SourceChannel, recvPacket.Sequence) - proof, proofHeight := path.EndpointA.QueryProof(packetKey) - - msg = channeltypesv2.NewMsgRecvPacket(recvPacket, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) - - res, err = path.EndpointB.Chain.SendMsgs(msg) - suite.Require().NoError(path.EndpointA.UpdateClient()) + err = path.EndpointB.MsgRecvPacket(packet) ck := path.EndpointB.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 expPass := tc.expError == nil if expPass { suite.Require().NoError(err) - suite.Require().NotNil(res) // packet receipt should be written - _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.SourceChannel, packet.Sequence) suite.Require().True(ok) - ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), recvPacket.DestinationChannel, recvPacket.Sequence) + ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == channeltypesv2.PacketStatus_Async { // ack should not be written for async app or if the packet receipt was already present. @@ -256,13 +244,13 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().True(ackWritten) expectedBz := channeltypesv2.CommitAcknowledgement(expectedAck) - actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), recvPacket.DestinationChannel, recvPacket.Sequence) + actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) suite.Require().Equal(expectedBz, actualAckBz) } } else { ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError) - _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.SourceChannel, packet.Sequence) suite.Require().False(ok) } }) @@ -344,9 +332,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { func (suite *KeeperTestSuite) TestMsgAcknowledgement() { var ( - path *ibctesting.Path - msgAckPacket *channeltypesv2.MsgAcknowledgement - recvPacket channeltypesv2.Packet + path *ibctesting.Path + packet channeltypesv2.Packet + ack channeltypesv2.Acknowledgement ) testCases := []struct { name string @@ -360,7 +348,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "success: NoOp", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence, []byte{}) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte{}) // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. @@ -369,13 +357,6 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { } }, }, - { - name: "failure: invalid signer", - malleate: func() { - msgAckPacket.Signer = "" - }, - expError: errors.New("empty address string is not allowed"), - }, { name: "failure: callback fails", malleate: func() { @@ -389,21 +370,21 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { name: "failure: counterparty not found", malleate: func() { // change the source id to a non-existent channel. - msgAckPacket.Packet.SourceChannel = "not-existent-channel" + packet.SourceChannel = "not-existent-channel" }, expError: channeltypesv2.ErrChannelNotFound, }, { name: "failure: invalid commitment", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence, []byte("foo")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) }, expError: channeltypesv2.ErrInvalidPacket, }, { name: "failure: failed membership verification", malleate: func() { - msgAckPacket.ProofHeight = clienttypes.ZeroHeight() + ack.AcknowledgementResults[0].RecvPacketResult.Acknowledgement = mock.MockFailPacketData }, expError: errors.New("failed packet acknowledgement verification"), }, @@ -417,28 +398,16 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + var err error // Send packet from A to B - msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) - res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket) + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().NoError(path.EndpointB.UpdateClient()) - // Receive packet on B - recvPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) - // get proof of packet commitment from chainA - packetKey := hostv2.PacketCommitmentKey(recvPacket.SourceChannel, recvPacket.Sequence) - proof, proofHeight := path.EndpointA.QueryProof(packetKey) - - // Construct msgRecvPacket to be sent to B - msgRecvPacket := channeltypesv2.NewMsgRecvPacket(recvPacket, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) - res, err = suite.chainB.SendMsgs(msgRecvPacket) + err = path.EndpointB.MsgRecvPacket(packet) suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().NoError(path.EndpointA.UpdateClient()) // Construct expected acknowledgement - ack := channeltypesv2.Acknowledgement{ + ack = channeltypesv2.Acknowledgement{ AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ { AppName: mockv2.ModuleNameB, @@ -450,21 +419,14 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { }, } - // Consttruct MsgAcknowledgement - packetKey = hostv2.PacketAcknowledgementKey(recvPacket.DestinationChannel, recvPacket.Sequence) - proof, proofHeight = path.EndpointB.QueryProof(packetKey) - msgAckPacket = channeltypesv2.NewMsgAcknowledgement(recvPacket, ack, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) - tc.malleate() // Finally, acknowledge the packet on A - res, err = suite.chainA.SendMsgs(msgAckPacket) + err = path.EndpointA.MsgAcknowledgePacket(packet, ack) expPass := tc.expError == nil - if expPass { suite.Require().NoError(err) - suite.NotNil(res) } else { ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) } diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go new file mode 100644 index 00000000000..6e2fac2dc79 --- /dev/null +++ b/testing/endpoint_v2.go @@ -0,0 +1,58 @@ +package ibctesting + +import ( + "github.com/stretchr/testify/require" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" +) + +// MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned. +func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, packetData channeltypesv2.PacketData) (channeltypesv2.Packet, error) { + msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), packetData) + + _, err := endpoint.Chain.SendMsgs(msgSendPacket) + if err != nil { + return channeltypesv2.Packet{}, err + } + + if err := endpoint.Counterparty.UpdateClient(); err != nil { + return channeltypesv2.Packet{}, err + } + + // TODO: parse the packet from events instead of manually constructing it. https://github.com/cosmos/ibc-go/issues/7459 + nextSequenceSend, ok := endpoint.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2.GetNextSequenceSend(endpoint.Chain.GetContext(), endpoint.ChannelID) + require.True(endpoint.Chain.TB, ok) + packet := channeltypesv2.NewPacket(nextSequenceSend-1, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, packetData) + + return packet, nil +} + +// MsgRecvPacket sends a MsgRecvPacket on the associated endpoint with the provided packet. +func (endpoint *Endpoint) MsgRecvPacket(packet channeltypesv2.Packet) error { + // get proof of packet commitment from chainA + packetKey := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) + proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) + + msg := channeltypesv2.NewMsgRecvPacket(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) + + if err := endpoint.Chain.sendMsgs(msg); err != nil { + return err + } + + return endpoint.Counterparty.UpdateClient() +} + +// MsgAcknowledgePacket sends a MsgAcknowledgement on the associated endpoint with the provided packet and ack. +func (endpoint *Endpoint) MsgAcknowledgePacket(packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) error { + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) + + msg := channeltypesv2.NewMsgAcknowledgement(packet, ack, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) + + if err := endpoint.Chain.sendMsgs(msg); err != nil { + return err + } + + return endpoint.Counterparty.UpdateClient() +} From e99b370638a90f0638b598fb977db99ff4055ebf Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 17 Oct 2024 11:59:58 +0100 Subject: [PATCH 081/172] chore: add ValidateBasic and test for MsgRecvPacket (#7470) * chore: add ValidateBasic and test for MsgRecvPacket * merge * chore: address reviews. --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/types/msgs.go | 22 ++++++- modules/core/04-channel/v2/types/msgs_test.go | 57 +++++++++++++++++++ modules/core/keeper/events_test.go | 1 + modules/core/keeper/msg_server.go | 1 + modules/core/keeper/msg_server_test.go | 1 + 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 4205d1099ce..2d1091c16f5 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -7,7 +7,8 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + commitmenttypesv1 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) @@ -18,6 +19,9 @@ var ( _ sdk.Msg = (*MsgCreateChannel)(nil) _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) + + _ sdk.Msg = (*MsgRecvPacket)(nil) + _ sdk.HasValidateBasic = (*MsgRecvPacket)(nil) ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance @@ -47,7 +51,7 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { } // NewMsgCreateChannel creates a new MsgCreateChannel instance -func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgCreateChannel { +func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypesv2.MerklePath, signer string) *MsgCreateChannel { return &MsgCreateChannel{ Signer: signer, ClientId: clientID, @@ -120,6 +124,20 @@ func NewMsgRecvPacket(packet Packet, proofCommitment []byte, proofHeight clientt } } +// ValidateBasic performs basic checks on a MsgRecvPacket. +func (msg *MsgRecvPacket) ValidateBasic() error { + if len(msg.ProofCommitment) == 0 { + return errorsmod.Wrap(commitmenttypesv1.ErrInvalidProof, "proof commitment can not be empty") + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + return msg.Packet.ValidateBasic() +} + // NewMsgAcknowledgement creates a new MsgAcknowledgement instance func NewMsgAcknowledgement(packet Packet, acknowledgement Acknowledgement, proofAcked []byte, proofHeight clienttypes.Height, signer string) *MsgAcknowledgement { return &MsgAcknowledgement{ diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 208db17638c..1cebdd19647 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -12,8 +12,11 @@ import ( host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) +var testProof = []byte("test") + type TypesTestSuite struct { suite.Suite @@ -211,3 +214,57 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { }) } } + +func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { + var msg *types.MsgRecvPacket + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: invalid packet", + malleate: func() { + msg.Packet.Data = []types.PacketData{} + }, + expError: types.ErrInvalidPacket, + }, + { + name: "failure: invalid proof commitment", + malleate: func() { + msg.ProofCommitment = []byte{} + }, + expError: commitmenttypes.ErrInvalidProof, + }, + { + name: "failure: invalid signer", + malleate: func() { + msg.Signer = "" + }, + expError: ibcerrors.ErrInvalidAddress, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + packet := types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + + msg = types.NewMsgRecvPacket(packet, testProof, s.chainA.GetTimeoutHeight(), s.chainA.SenderAccount.GetAddress().String()) + + tc.malleate() + + err := msg.ValidateBasic() + + expPass := tc.expError == nil + + if expPass { + s.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expError) + } + }) + } +} diff --git a/modules/core/keeper/events_test.go b/modules/core/keeper/events_test.go index 1143782ddc8..359322833f0 100644 --- a/modules/core/keeper/events_test.go +++ b/modules/core/keeper/events_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 92348c0de03..7b987945e61 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index bea3fccc45a..547d5702304 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" From 4074c585e91900601b721dc63c5cb2b71d152528 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 17 Oct 2024 12:27:24 +0100 Subject: [PATCH 082/172] chore: Implement v2 Timeout rpc handler (#7463) * msgTimeout test * better wording for comment * chore: use deletepacketcommitment instead of setting an empty one * typo * Update modules/core/04-channel/v2/keeper/msg_server_test.go Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> * chore: use deletepacketcommitment instead of setting an empty one * wip * chore: debugging timeout test * chore: removed unneeded proto field and added helper function for endpoint MsgTimeout --------- Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> Co-authored-by: chatton --- .../core/04-channel/v2/keeper/msg_server.go | 38 +++-- .../04-channel/v2/keeper/msg_server_test.go | 107 +++++++++++- modules/core/04-channel/v2/types/msgs.go | 10 ++ modules/core/04-channel/v2/types/tx.pb.go | 152 +++++++----------- proto/ibc/core/channel/v2/tx.proto | 9 +- testing/endpoint_v2.go | 14 ++ 6 files changed, 214 insertions(+), 116 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 7356040ccee..1d8add950d4 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -165,10 +165,6 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack // Timeout implements the PacketMsgServer Timeout method. func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - if err := k.timeoutPacket(ctx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { - sdkCtx.Logger().Error("Timeout packet failed", "source-channel", timeout.Packet.SourceChannel, "destination-channel", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) - return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s and destination id: %s", timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) - } signer, err := sdk.AccAddressFromBech32(timeout.Signer) if err != nil { @@ -176,17 +172,31 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } - _ = signer + cacheCtx, writeFn := sdkCtx.CacheContext() + if err := k.timeoutPacket(cacheCtx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { + sdkCtx.Logger().Error("Timeout packet failed", "source-channel", timeout.Packet.SourceChannel, "destination-channel", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) + return nil, errorsmod.Wrapf(err, "timeout packet failed for source id: %s and destination id: %s", timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) + } - // TODO: implement once app router is wired up. - // https://github.com/cosmos/ibc-go/issues/7384 - // for _, pd := range timeout.Packet.Data { - // cbs := k.PortKeeper.AppRouter.Route(pd.SourcePort) - // err := cbs.OnTimeoutPacket(timeout.Packet.SourceChannel, timeout.Packet.TimeoutTimestamp, signer) - // if err != nil { - // return err, err - // } - // } + switch err { + case nil: + writeFn() + case channeltypesv1.ErrNoOpMsg: + // no-ops do not need event emission as they will be ignored + sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) + return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.NOOP}, nil + default: + sdkCtx.Logger().Error("timeout failed", "source-channel", timeout.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) + return nil, errorsmod.Wrap(err, "timeout packet verification failed") + } + + for _, pd := range timeout.Packet.Data { + cbs := k.Router.Route(pd.SourcePort) + err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel, pd, signer) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed OnTimeoutPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) + } + } return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index a75dfdee074..e9cd0e562cb 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -62,7 +63,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: counterparty not found", malleate: func() { - path.EndpointA.ChannelID = "foo" + path.EndpointA.ChannelID = ibctesting.InvalidID }, expError: channeltypesv1.ErrChannelNotFound, }, @@ -178,7 +179,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "failure: counterparty not found", malleate: func() { // change the destination id to a non-existent channel. - packet.DestinationChannel = "not-existent-channel" + packet.DestinationChannel = ibctesting.InvalidID }, expError: channeltypesv2.ErrChannelNotFound, }, @@ -348,12 +349,12 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "success: NoOp", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte{}) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { - return errors.New("OnAcknowledgementPacket callback failed") + return mock.MockApplicationCallbackError } }, }, @@ -361,10 +362,10 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { name: "failure: callback fails", malleate: func() { path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { - return errors.New("OnAcknowledgementPacket callback failed") + return mock.MockApplicationCallbackError } }, - expError: errors.New("OnAcknowledgementPacket callback failed"), + expError: mock.MockApplicationCallbackError, }, { name: "failure: counterparty not found", @@ -433,3 +434,97 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { }) } } + +func (suite *KeeperTestSuite) TestMsgTimeout() { + var ( + path *ibctesting.Path + packet channeltypesv2.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: no-op", + malleate: func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + + // Modify the callback to return a different error. + // This way, we can verify that the callback is not executed in a No-op case. + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error { + return mock.MockApplicationCallbackError + } + }, + expError: channeltypesv1.ErrNoOpMsg, + }, + { + name: "failure: callback fails", + malleate: func() { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error { + return mock.MockApplicationCallbackError + } + }, + expError: mock.MockApplicationCallbackError, + }, + { + name: "failure: channel not found", + malleate: func() { + // change the source id to a non-existent channel. + packet.SourceChannel = "not-existent-channel" + }, + expError: channeltypesv2.ErrChannelNotFound, + }, + { + name: "failure: invalid commitment", + malleate: func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) + }, + expError: channeltypesv2.ErrInvalidPacket, + }, + { + name: "failure: unable to timeout if packet has been received", + malleate: func() { + err := path.EndpointB.MsgRecvPacket(packet) + suite.Require().NoError(err) + }, + expError: commitmenttypes.ErrInvalidProof, + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // Send packet from A to B + timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + mockData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + var err error + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockData) + suite.Require().NoError(err) + suite.Require().NotEmpty(packet) + + tc.malleate() + + suite.coordinator.IncrementTimeBy(time.Hour * 20) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + err = path.EndpointA.MsgTimeoutPacket(packet) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 2d1091c16f5..d48f0f653ee 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -148,3 +148,13 @@ func NewMsgAcknowledgement(packet Packet, acknowledgement Acknowledgement, proof Signer: signer, } } + +// NewMsgTimeout creates a new MsgTimeout instance +func NewMsgTimeout(packet Packet, proofUnreceived []byte, proofHeight clienttypes.Height, signer string) *MsgTimeout { + return &MsgTimeout{ + Packet: packet, + ProofUnreceived: proofUnreceived, + ProofHeight: proofHeight, + Signer: signer, + } +} diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 633a9c2e8dc..07d85dccd6c 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -355,11 +355,10 @@ var xxx_messageInfo_MsgRecvPacketResponse proto.InternalMessageInfo // MsgTimeout receives timed-out packet type MsgTimeout struct { - Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty"` - ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - NextSequenceRecv uint64 `protobuf:"varint,4,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty"` - Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty"` + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgTimeout) Reset() { *m = MsgTimeout{} } @@ -531,65 +530,63 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 914 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0x5e, 0x27, 0xdb, 0xd0, 0xbc, 0x4d, 0x9a, 0xc5, 0xa5, 0xed, 0xca, 0x85, 0xdd, 0xd5, 0x8a, - 0x2a, 0x21, 0x25, 0x36, 0x71, 0x11, 0x52, 0x2a, 0xa4, 0xaa, 0x5d, 0x84, 0xe8, 0x61, 0xa5, 0xc8, - 0x09, 0x3d, 0x00, 0xc2, 0xf2, 0xda, 0xaf, 0x5e, 0x2b, 0x6b, 0x8f, 0xf1, 0xcc, 0xba, 0xc9, 0x0d, - 0x71, 0xe2, 0x84, 0x38, 0x72, 0xe4, 0x27, 0xe4, 0xc0, 0x8f, 0xe8, 0xb1, 0x07, 0x0e, 0x9c, 0x10, - 0x4a, 0x0e, 0x95, 0xf8, 0x15, 0xc8, 0x33, 0xb3, 0xb6, 0xb3, 0xf5,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c6, 0x25, 0x81, 0xd3, 0x64, 0xda, 0xb5, 0x1f, 0x5f, 0x1f, 0x6f, 0x2a, 0x4f, - 0x9e, 0xbd, 0x3c, 0x69, 0x2b, 0xaf, 0x4e, 0xda, 0xca, 0x3f, 0x27, 0x6d, 0xe5, 0xd7, 0xd3, 0x76, - 0xed, 0xd5, 0x69, 0xbb, 0xf6, 0xd7, 0x69, 0xbb, 0xf6, 0xcd, 0xe7, 0x7e, 0xc0, 0x46, 0x93, 0x61, - 0x76, 0x91, 0x32, 0xe4, 0x3d, 0x32, 0x18, 0xba, 0x5b, 0x3e, 0x31, 0xd2, 0x1d, 0x23, 0x24, 0xde, - 0x64, 0x8c, 0x54, 0x5c, 0xf1, 0x3e, 0xf9, 0x74, 0xab, 0x7c, 0x51, 0x3d, 0x8a, 0x91, 0x0e, 0x97, - 0xf8, 0xf5, 0xee, 0xc1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdf, 0x03, 0x0a, 0xcc, 0x0a, - 0x00, 0x00, + // 885 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0x5e, 0x27, 0xdb, 0xd0, 0xbc, 0x4d, 0x9a, 0xe0, 0xd2, 0x76, 0xe5, 0xc2, 0xee, 0x6a, 0x45, + 0x95, 0x90, 0x2a, 0x36, 0x71, 0x11, 0x52, 0x2a, 0xa4, 0xaa, 0x5d, 0x84, 0xe8, 0x61, 0xa5, 0xc8, + 0x0d, 0x3d, 0x00, 0xc2, 0xf2, 0xda, 0xaf, 0x5e, 0x2b, 0x6b, 0x8f, 0xf1, 0x8c, 0xdd, 0xe6, 0x86, + 0x38, 0x71, 0xe4, 0xc8, 0x91, 0x9f, 0x90, 0x03, 0x3f, 0xa2, 0xc7, 0x1e, 0x38, 0x70, 0x42, 0x55, + 0x72, 0xa8, 0xc4, 0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, 0xf5, 0x71, 0x47, + 0xf9, 0xf5, 0xa4, 0xd3, 0x78, 0x75, 0xd2, 0x69, 0xfc, 0x75, 0xd2, 0x69, 0x7c, 0xfb, 0x85, 0x1f, + 0xb0, 0x71, 0x3a, 0xca, 0xaf, 0x46, 0x86, 0xbc, 0x19, 0x06, 0x23, 0x77, 0xdb, 0x27, 0x46, 0xb6, + 0x6b, 0x84, 0xc4, 0x4b, 0x27, 0x48, 0xc5, 0xa5, 0xed, 0xd3, 0xcf, 0xb6, 0xab, 0x57, 0xcf, 0xc3, + 0x18, 0xe9, 0x68, 0x89, 0x5f, 0xd8, 0xee, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x79, 0x25, 0xfe, + 0x36, 0x9e, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1204,11 +1201,6 @@ func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.NextSequenceRecv != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) - i-- - dAtA[i] = 0x20 - } { size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1520,9 +1512,6 @@ func (m *MsgTimeout) Size() (n int) { } l = m.ProofHeight.Size() n += 1 + l + sovTx(uint64(l)) - if m.NextSequenceRecv != 0 { - n += 1 + sovTx(uint64(m.NextSequenceRecv)) - } l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -2624,25 +2613,6 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - 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 ErrIntOverflowTx - } - 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) diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 90a0a0db653..b949b506412 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -117,11 +117,10 @@ message MsgTimeout { option (gogoproto.goproto_getters) = false; - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof_unreceived = 2; - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; - uint64 next_sequence_recv = 4; - string signer = 5; + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_unreceived = 2; + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; + string signer = 5; } // MsgTimeoutResponse defines the Msg/Timeout response type. diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index 6e2fac2dc79..506ce2b03f2 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -56,3 +56,17 @@ func (endpoint *Endpoint) MsgAcknowledgePacket(packet channeltypesv2.Packet, ack return endpoint.Counterparty.UpdateClient() } + +// MsgTimeoutPacket sends a MsgTimeout on the associated endpoint with the provided packet. +func (endpoint *Endpoint) MsgTimeoutPacket(packet channeltypesv2.Packet) error { + packetKey := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) + proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) + + msg := channeltypesv2.NewMsgTimeout(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) + + if err := endpoint.Chain.sendMsgs(msg); err != nil { + return err + } + + return endpoint.Counterparty.UpdateClient() +} From a3a61ff2c224dedab9a74d2ac5fe01d498e09256 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:11:19 +0200 Subject: [PATCH 083/172] channel/v2: Add Keeper Tests (#7456) * test progress * use export_test and fix send_packet * fix test build * in-progress fixing tests * remove test file * fix mockv2 acknowledgment * comment on export_test * appease linter * fix bug * fix nits and add test case * add writeAck tests * use existing endpoint test fns --- .../core/04-channel/v2/keeper/export_test.go | 70 ++ .../04-channel/v2/keeper/msg_server_test.go | 18 +- modules/core/04-channel/v2/keeper/packet.go | 65 +- .../core/04-channel/v2/keeper/packet_test.go | 605 +++++++++++++ modules/core/04-channel/v2/types/errors.go | 13 +- modules/core/04-channel/v2/types/packet.go | 9 + .../core/04-channel/v2/types/packet_test.go | 7 + modules/core/keeper/msg_server_test.go | 845 +++++++++--------- .../core/packet-server/keeper/relay_test.go | 643 ------------- testing/endpoint.go | 27 - testing/endpoint_v2.go | 24 +- testing/mock/v2/ibc_module.go | 6 +- testing/mock/v2/mock.go | 25 +- 13 files changed, 1202 insertions(+), 1155 deletions(-) create mode 100644 modules/core/04-channel/v2/keeper/export_test.go create mode 100644 modules/core/04-channel/v2/keeper/packet_test.go delete mode 100644 modules/core/packet-server/keeper/relay_test.go diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go new file mode 100644 index 00000000000..6cb135f2ea5 --- /dev/null +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -0,0 +1,70 @@ +package keeper + +/* + This file is to allow for unexported functions to be accessible to the testing package. +*/ + +import ( + "context" + + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" +) + +func (k *Keeper) SendPacketTest( + ctx context.Context, + sourceChannel string, + timeoutTimestamp uint64, + data []channeltypesv2.PacketData, +) (uint64, string, error) { + return k.sendPacket( + ctx, + sourceChannel, + timeoutTimestamp, + data, + ) +} + +func (k *Keeper) RecvPacketTest( + ctx context.Context, + packet channeltypesv2.Packet, + proof []byte, + proofHeight exported.Height, +) error { + return k.recvPacket( + ctx, + packet, + proof, + proofHeight, + ) +} + +func (k *Keeper) AcknowledgePacketTest( + ctx context.Context, + packet channeltypesv2.Packet, + acknowledgement channeltypesv2.Acknowledgement, + proof []byte, + proofHeight exported.Height, +) error { + return k.acknowledgePacket( + ctx, + packet, + acknowledgement, + proof, + proofHeight, + ) +} + +func (k *Keeper) TimeoutPacketTest( + ctx context.Context, + packet channeltypesv2.Packet, + proof []byte, + proofHeight exported.Height, +) error { + return k.timeoutPacket( + ctx, + packet, + proof, + proofHeight, + ) +} diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index e9cd0e562cb..2ebb99ca341 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -61,11 +61,11 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { expError: mock.MockApplicationCallbackError, }, { - name: "failure: counterparty not found", + name: "failure: channel not found", malleate: func() { path.EndpointA.ChannelID = ibctesting.InvalidID }, - expError: channeltypesv1.ErrChannelNotFound, + expError: channeltypesv2.ErrChannelNotFound, }, { name: "failure: route to non existing app", @@ -212,11 +212,8 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { expectedAck = channeltypesv2.Acknowledgement{ AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ { - AppName: mockv2.ModuleNameB, - RecvPacketResult: channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Success, - Acknowledgement: mock.MockPacketData, - }, + AppName: mockv2.ModuleNameB, + RecvPacketResult: mockv2.MockRecvPacketResult, }, }, } @@ -411,11 +408,8 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { ack = channeltypesv2.Acknowledgement{ AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ { - AppName: mockv2.ModuleNameB, - RecvPacketResult: channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Success, - Acknowledgement: mock.MockPacketData, - }, + AppName: mockv2.ModuleNameB, + RecvPacketResult: mockv2.MockRecvPacketResult, }, }, } diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 5caa94b9772..dccb5da46c8 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "strconv" + "time" errorsmod "cosmossdk.io/errors" @@ -11,7 +12,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -22,7 +23,7 @@ func (k *Keeper) sendPacket( ctx context.Context, sourceChannel string, timeoutTimestamp uint64, - data []channeltypesv2.PacketData, + data []types.PacketData, ) (uint64, string, error) { // Lookup channel associated with our source channel to retrieve the destination channel channel, ok := k.GetChannel(ctx, sourceChannel) @@ -30,7 +31,7 @@ func (k *Keeper) sendPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceChannel) if !ok { - return 0, "", errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, sourceChannel) + return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } } @@ -40,13 +41,13 @@ func (k *Keeper) sendPacket( sequence, found := k.GetNextSequenceSend(ctx, sourceChannel) if !found { return 0, "", errorsmod.Wrapf( - channeltypesv2.ErrSequenceSendNotFound, + types.ErrSequenceSendNotFound, "source channel: %s", sourceChannel, ) } // construct packet from given fields and channel state - packet := channeltypesv2.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, data...) + packet := types.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, data...) if err := packet.ValidateBasic(); err != nil { return 0, "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) @@ -68,12 +69,14 @@ func (k *Keeper) sendPacket( return 0, "", err } // check if packet is timed out on the receiving chain - timeout := channeltypes.NewTimeoutWithTimestamp(timeoutTimestamp) + // convert packet timeout to nanoseconds for now to use existing helper function + // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 + timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) if timeout.TimestampElapsed(latestTimestamp) { return 0, "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") } - commitment := channeltypesv2.CommitPacket(packet) + commitment := types.CommitPacket(packet) // bump the sequence and set the packet commitment, so it is provable by the counterparty k.SetNextSequenceSend(ctx, sourceChannel, sequence+1) @@ -95,7 +98,7 @@ func (k *Keeper) sendPacket( // to indicate to the counterparty successful delivery. func (k *Keeper) recvPacket( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { @@ -107,7 +110,7 @@ func (k *Keeper) recvPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } if channel.CounterpartyChannelId != packet.SourceChannel { @@ -118,7 +121,9 @@ func (k *Keeper) recvPacket( // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(sdkCtx.BlockTime().UnixNano()) - timeout := channeltypes.NewTimeoutWithTimestamp(packet.GetTimeoutTimestamp()) + // convert packet timeout to nanoseconds for now to use existing helper function + // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 + timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) if timeout.Elapsed(selfHeight, selfTimestamp) { return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") } @@ -135,9 +140,9 @@ func (k *Keeper) recvPacket( } path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) - commitment := channeltypesv2.CommitPacket(packet) + commitment := types.CommitPacket(packet) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -164,15 +169,15 @@ func (k *Keeper) recvPacket( // WriteAcknowledgement writes the acknowledgement to the store. func (k Keeper) WriteAcknowledgement( ctx context.Context, - packet channeltypesv2.Packet, - ack channeltypesv2.Acknowledgement, + packet types.Packet, + ack types.Acknowledgement, ) error { // Lookup channel associated with destination channel ID and ensure // that the packet was indeed sent by our counterparty by verifying // packet sender is our channel's counterparty channel id. channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - return errorsmod.Wrapf(channeltypesv2.ErrChannelNotFound, "channel (%s) not found", packet.DestinationChannel) + return errorsmod.Wrapf(types.ErrChannelNotFound, "channel (%s) not found", packet.DestinationChannel) } if channel.CounterpartyChannelId != packet.SourceChannel { @@ -190,10 +195,16 @@ func (k Keeper) WriteAcknowledgement( return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") } + // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 + + if len(ack.AcknowledgementResults) != len(packet.Data) { + return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of acknowledgement results %d does not match length of packet data %d", len(ack.AcknowledgementResults), len(packet.Data)) + } + // set the acknowledgement so that it can be verified on the other side k.SetPacketAcknowledgement( ctx, packet.DestinationChannel, packet.Sequence, - channeltypesv2.CommitAcknowledgement(ack), + types.CommitAcknowledgement(ack), ) k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest-channel", packet.DestinationChannel) @@ -203,12 +214,12 @@ func (k Keeper) WriteAcknowledgement( return nil } -func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Packet, acknowledgement channeltypesv2.Acknowledgement, proof []byte, proofHeight exported.Height) error { +func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, acknowledgement types.Acknowledgement, proof []byte, proofHeight exported.Height) error { // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.SourceChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } if channel.CounterpartyChannelId != packet.DestinationChannel { @@ -229,7 +240,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa return channeltypes.ErrNoOpMsg } - packetCommitment := channeltypesv2.CommitPacket(packet) + packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { @@ -237,7 +248,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa } path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -246,7 +257,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa 0, 0, proof, merklePath, - channeltypesv2.CommitAcknowledgement(acknowledgement), + types.CommitAcknowledgement(acknowledgement), ); err != nil { return errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) } @@ -269,7 +280,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet channeltypesv2.Pa // is deleted and the packet has completed its lifecycle. func (k *Keeper) timeoutPacket( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { @@ -280,7 +291,7 @@ func (k *Keeper) timeoutPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. channel, ok = k.convertV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceChannel) if !ok { - return errorsmod.Wrap(channeltypesv2.ErrChannelNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } if channel.CounterpartyChannelId != packet.DestinationChannel { @@ -294,7 +305,9 @@ func (k *Keeper) timeoutPacket( return err } - timeout := channeltypes.NewTimeoutWithTimestamp(packet.GetTimeoutTimestamp()) + // convert packet timeout to nanoseconds for now to use existing helper function + // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 + timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) if !timeout.Elapsed(clienttypes.ZeroHeight(), proofTimestamp) { return errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") } @@ -310,7 +323,7 @@ func (k *Keeper) timeoutPacket( return channeltypes.ErrNoOpMsg } - packetCommitment := channeltypesv2.CommitPacket(packet) + packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) @@ -318,7 +331,7 @@ func (k *Keeper) timeoutPacket( // verify packet receipt absence path := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go new file mode 100644 index 00000000000..2fb3d926d5d --- /dev/null +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -0,0 +1,605 @@ +package keeper_test + +import ( + "fmt" + "time" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" +) + +var unusedChannel = "channel-5" + +func (suite *KeeperTestSuite) TestSendPacket() { + var ( + path *ibctesting.Path + packet types.Packet + expSequence uint64 + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "success with later packet", + func() { + // send the same packet earlier so next packet send should be sequence 2 + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err) + expSequence = 2 + }, + nil, + }, + { + "channel not found", + func() { + packet.SourceChannel = ibctesting.InvalidID + }, + types.ErrChannelNotFound, + }, + { + "packet failed basic validation", + func() { + // invalid data + packet.Data = nil + }, + channeltypes.ErrInvalidPacket, + }, + { + "client status invalid", + func() { + path.EndpointA.FreezeClient() + }, + clienttypes.ErrClientNotActive, + }, + { + "client state zero height", func() { + clientState := path.EndpointA.GetClientState() + cs, ok := clientState.(*ibctm.ClientState) + suite.Require().True(ok) + + // force a consensus state into the store at height zero to allow client status check to pass. + consensusState := path.EndpointA.GetConsensusState(cs.LatestHeight) + path.EndpointA.SetConsensusState(consensusState, clienttypes.ZeroHeight()) + + cs.LatestHeight = clienttypes.ZeroHeight() + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, cs) + }, + clienttypes.ErrInvalidHeight, + }, + { + "timeout elapsed", func() { + packet.TimeoutTimestamp = 1 + }, + channeltypes.ErrTimeoutElapsed, + }, + } + + for i, tc := range testCases { + tc := tc + suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { + suite.SetupTest() // reset + + // create clients and set counterparties on both chains + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + // create standard packet that can be malleated + packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + timeoutTimestamp, packetData) + expSequence = 1 + + // malleate the test case + tc.malleate() + + // send packet + seq, destChannel, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Data) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + // verify send packet method instantiated packet with correct sequence and destination channel + suite.Require().Equal(expSequence, seq) + suite.Require().Equal(path.EndpointB.ChannelID, destChannel) + // verify send packet stored the packet commitment correctly + expCommitment := types.CommitPacket(packet) + suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, seq)) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Equal(uint64(0), seq) + suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, seq)) + + } + }) + } +} + +func (suite *KeeperTestSuite) TestRecvPacket() { + var ( + path *ibctesting.Path + err error + packet types.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: channel not found", + func() { + packet.DestinationChannel = ibctesting.InvalidID + }, + types.ErrChannelNotFound, + }, + { + "failure: client is not active", + func() { + path.EndpointB.FreezeClient() + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: counterparty channel identifier different than source channel", + func() { + packet.SourceChannel = unusedChannel + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has timed out", + func() { + suite.coordinator.IncrementTimeBy(time.Hour * 20) + }, + channeltypes.ErrTimeoutElapsed, + }, + { + "failure: packet already received", + func() { + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: verify membership failed", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("")) + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + // send packet + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) + suite.Require().NoError(err) + + tc.malleate() + + // get proof of v2 packet commitment from chainA + packetKey := hostv2.PacketCommitmentKey(packet.GetSourceChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + err = suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.RecvPacketTest(suite.chainB.GetContext(), packet, proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.Require().True(found) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestWriteAcknowledgement() { + var ( + packet types.Packet + ack types.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: channel not found", + func() { + packet.DestinationChannel = ibctesting.InvalidID + }, + types.ErrChannelNotFound, + }, + { + "failure: counterparty channel identifier different than source channel", + func() { + packet.SourceChannel = unusedChannel + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: ack already exists", + func() { + ackBz := types.CommitAcknowledgement(ack) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence, ackBz) + }, + channeltypes.ErrAcknowledgementExists, + }, + { + "failure: empty ack", + func() { + ack = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{}, + } + }, + types.ErrInvalidAcknowledgement, + }, + { + "failure: receipt not found for packet", + func() { + packet.Sequence = 2 + }, + channeltypes.ErrInvalidPacket, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + // create standard packet that can be malleated + packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + timeoutTimestamp, packetData) + + // create standard ack that can be malleated + ack = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{ + { + AppName: mockv2.ModuleNameB, + RecvPacketResult: mockv2.MockRecvPacketResult, + }, + }, + } + + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + + tc.malleate() + + err := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.WriteAcknowledgement(suite.chainB.GetContext(), packet, ack) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + ackCommitment := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.Require().Equal(types.CommitAcknowledgement(ack), ackCommitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestAcknowledgePacket() { + var ( + packet types.Packet + err error + ack = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{{ + AppName: mockv2.ModuleNameB, + RecvPacketResult: mockv2.MockRecvPacketResult, + }}, + } + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: channel not found", + func() { + packet.SourceChannel = ibctesting.InvalidID + }, + types.ErrChannelNotFound, + }, + { + "failure: counterparty channel identifier different than source channel", + func() { + packet.DestinationChannel = unusedChannel + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet commitment doesn't exist.", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: client status invalid", + func() { + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: packet commitment bytes differ", + func() { + // change packet data after send to acknowledge different packet + packet.Data[0].Payload.Value = []byte("different value") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: verify membership fails", + func() { + ack.AcknowledgementResults[0].RecvPacketResult = mockv2.MockFailRecvPacketResult + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + freezeClient = false + + packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + // send packet + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) + suite.Require().NoError(err) + + err = path.EndpointB.MsgRecvPacket(packet) + suite.Require().NoError(err) + + tc.malleate() + + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + proof, proofHeight := path.EndpointB.QueryProof(packetKey) + + if freezeClient { + path.EndpointA.FreezeClient() + } + + err = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.AcknowledgePacketTest(suite.chainA.GetContext(), packet, ack, proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + suite.Require().Empty(commitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestTimeoutPacket() { + var ( + path *ibctesting.Path + packet types.Packet + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() { + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + nil, + }, + { + "failure: channel not found", + func() { + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.SourceChannel = ibctesting.InvalidID + }, + types.ErrChannelNotFound, + }, + { + "failure: counterparty channel identifier different than source channel", + func() { + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.DestinationChannel = unusedChannel + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has not timed out yet", + func() { + packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + channeltypes.ErrTimeoutNotReached, + }, + { + "failure: packet already timed out", + func() {}, // equivalent to not sending packet at all + channeltypes.ErrNoOpMsg, + }, + { + "failure: packet does not match commitment", + func() { + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + + // try to timeout packet with different data + packet.Data[0].Payload.Value = []byte("different value") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: client status invalid", + func() { + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: verify non-membership failed", + func() { + // send packet + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err, "send packet failed") + + // set packet receipt to mock a valid past receive + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + // initialize freezeClient to false + freezeClient = false + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // create default packet with a timed out timestamp + packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) + + // test cases may mutate timeout values + packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + timeoutTimestamp, packetData) + + tc.malleate() + + // need to update chainA's client representing chainB to prove missing ack + // commit the changes and update the clients + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + // get proof of packet receipt absence from chainB + receiptKey := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) + proof, proofHeight := path.EndpointB.QueryProof(receiptKey) + + if freezeClient { + path.EndpointA.FreezeClient() + } + + err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.TimeoutPacketTest(suite.chainA.GetContext(), packet, proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.Require().Nil(commitment, "packet commitment not deleted") + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 2873867295b..1cf10763391 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,10 +5,11 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") - ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") - ErrInvalidPacketData = errorsmod.Register(SubModuleName, 7, "invalid packet data") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") + ErrInvalidPacketData = errorsmod.Register(SubModuleName, 7, "invalid packet data") + ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 8, "invalid acknowledgement") ) diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 81dd8905e14..8bddb98164f 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -19,6 +19,15 @@ func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeou } } +// NewPacketData constructs a new PacketData +func NewPacketData(sourcePort, destPort string, payload Payload) PacketData { + return PacketData{ + SourcePort: sourcePort, + DestinationPort: destPort, + Payload: payload, + } +} + // NewPayload constructs a new Payload func NewPayload(version, encoding string, value []byte) Payload { return Payload{ diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index 4f908d54a90..0f695a050d2 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -65,6 +65,13 @@ func TestValidateBasic(t *testing.T) { func() {}, nil, }, + { + "failure: packet data is nil", + func() { + packet.Data = nil + }, + types.ErrInvalidPacket, + }, { "failure: empty data", func() { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 547d5702304..693e93d8c50 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -21,7 +21,6 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -218,171 +217,171 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { } // tests the IBC handler receiving a packet using V2 protocol -func (suite *KeeperTestSuite) TestRecvPacketV2() { - var ( - packet channeltypes.Packet - path *ibctesting.Path - ) - - testCases := []struct { - name string - malleate func() - expErr error - expRevert bool - async bool // indicate no ack written - replay bool // indicate replay (no-op) - }{ - { - "success", - func() { - path.SetupV2() - - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - }, - nil, - false, - false, - false, - }, - { - "success: OnRecvPacket callback returns error acknowledgement", - func() { - path.SetupV2() - - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockFailPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - }, - nil, - true, - false, - false, - }, - { - "success: async acknowledgement", - func() { - path.SetupV2() - - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibcmock.MockAsyncPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - }, - nil, - false, - true, - false, - }, - { - "success no-op: packet already received (replay)", - func() { - // mock will panic if application callback is called twice on the same packet - path.SetupV2() - - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - }, - nil, - false, - false, - true, - }, - { - "channel does not exist", - func() { - // any non-nil value of packet is valid - suite.Require().NotNil(packet) - }, - packetservertypes.ErrChannelNotFound, - false, - false, - false, - }, - { - "packet not sent", - func() { - path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - }, - fmt.Errorf("receive packet verification failed"), - false, - false, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - path = ibctesting.NewPath(suite.chainA, suite.chainB) - - tc.malleate() - - var ( - proof []byte - proofHeight clienttypes.Height - ) - // get proof of packet commitment from chainA - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if path.EndpointA.ClientID != "" { - proof, proofHeight = path.EndpointA.QueryProof(packetKey) - } - - ctx := suite.chainB.GetContext() - msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) - res, err := suite.chainB.App.GetIBCKeeper().RecvPacket(ctx, msg) - - events := ctx.EventManager().Events() - - if tc.expErr == nil { - suite.Require().NoError(err) - - // replay should not fail since it will be treated as a no-op - _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) - suite.Require().NoError(err) - - if tc.expRevert { - // context events should contain error events - suite.Require().Contains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) - suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) - } else { - if tc.replay { - // context should not contain application events - suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) - suite.Require().NotContains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) - } else { - // context events should contain application events - suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) - } - } - - // verify if ack was written - ack, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - - if tc.async { - suite.Require().Nil(ack) - suite.Require().False(found) - } else { - suite.Require().NotNil(ack) - suite.Require().True(found) - } - } else { - suite.Require().ErrorContains(err, tc.expErr.Error()) - suite.Require().Nil(res) - } - }) - } -} +// func (suite *KeeperTestSuite) TestRecvPacketV2() { +// var ( +// packet channeltypes.Packet +// path *ibctesting.Path +// ) + +// testCases := []struct { +// name string +// malleate func() +// expErr error +// expRevert bool +// async bool // indicate no ack written +// replay bool // indicate replay (no-op) +// }{ +// { +// "success", +// func() { +// path.SetupV2() + +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// }, +// nil, +// false, +// false, +// false, +// }, +// { +// "success: OnRecvPacket callback returns error acknowledgement", +// func() { +// path.SetupV2() + +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockFailPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// }, +// nil, +// true, +// false, +// false, +// }, +// { +// "success: async acknowledgement", +// func() { +// path.SetupV2() + +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibcmock.MockAsyncPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// }, +// nil, +// false, +// true, +// false, +// }, +// { +// "success no-op: packet already received (replay)", +// func() { +// // mock will panic if application callback is called twice on the same packet +// path.SetupV2() + +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// err = path.EndpointB.RecvPacket(packet) +// suite.Require().NoError(err) +// }, +// nil, +// false, +// false, +// true, +// }, +// { +// "channel does not exist", +// func() { +// // any non-nil value of packet is valid +// suite.Require().NotNil(packet) +// }, +// packetservertypes.ErrChannelNotFound, +// false, +// false, +// false, +// }, +// { +// "packet not sent", +// func() { +// path.SetupV2() +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// }, +// fmt.Errorf("receive packet verification failed"), +// false, +// false, +// false, +// }, +// } + +// for _, tc := range testCases { +// tc := tc + +// suite.Run(tc.name, func() { +// suite.SetupTest() // reset +// path = ibctesting.NewPath(suite.chainA, suite.chainB) + +// tc.malleate() + +// var ( +// proof []byte +// proofHeight clienttypes.Height +// ) +// // get proof of packet commitment from chainA +// packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) +// if path.EndpointA.ClientID != "" { +// proof, proofHeight = path.EndpointA.QueryProof(packetKey) +// } + +// ctx := suite.chainB.GetContext() +// msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) +// res, err := suite.chainB.App.GetIBCKeeper().RecvPacket(ctx, msg) + +// events := ctx.EventManager().Events() + +// if tc.expErr == nil { +// suite.Require().NoError(err) + +// // replay should not fail since it will be treated as a no-op +// _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) +// suite.Require().NoError(err) + +// if tc.expRevert { +// // context events should contain error events +// suite.Require().Contains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) +// suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) +// } else { +// if tc.replay { +// // context should not contain application events +// suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) +// suite.Require().NotContains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) +// } else { +// // context events should contain application events +// suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) +// } +// } + +// // verify if ack was written +// ack, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + +// if tc.async { +// suite.Require().Nil(ack) +// suite.Require().False(found) +// } else { +// suite.Require().NotNil(ack) +// suite.Require().True(found) +// } +// } else { +// suite.Require().ErrorContains(err, tc.expErr.Error()) +// suite.Require().Nil(res) +// } +// }) +// } +// } func (suite *KeeperTestSuite) TestRecoverClient() { var msg *clienttypes.MsgRecoverClient @@ -618,131 +617,131 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { } // tests the IBC handler acknowledgement of a packet using protocol version V2 -func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { - var ( - packet channeltypes.Packet - signer string - path *ibctesting.Path - ) - - testCases := []struct { - name string - malleate func() - expError error - replay bool // indicate replay (no-op) - }{ - { - "success", - func() {}, - nil, - false, - }, - { - "invalid signer", - func() { - signer = "invalid-signer" - }, - errors.New("Invalid address for msg Signer"), - false, - }, - { - "port route does not exist", - func() { - packet.SourcePort = "invalid-port" - }, - porttypes.ErrInvalidRoute, - false, - }, - { - "acknowledge packet fails in packet handler", - func() { - packet.SourceChannel = "invalid-client" - }, - packetservertypes.ErrChannelNotFound, - false, - }, - { - "successful no-op: - packet already acknowledged (replay)", - func() { - err := path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) - suite.Require().NoError(err) - }, - nil, - true, - }, - { - "application callback returns error", - func() { - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnAcknowledgementPacket = func(ctx context.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error { - return fmt.Errorf("mock app callback failed") - } - }, - fmt.Errorf("mock app callback failed"), - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - signer = suite.chainA.SenderAccount.GetAddress().String() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - tc.malleate() - - var ( - proof []byte - proofHeight clienttypes.Height - ) - packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight = path.EndpointB.QueryProof(packetKey) - - msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement.Acknowledgement(), proof, proofHeight, signer) - - ctx := suite.chainA.GetContext() - res, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(ctx, msg) - - events := ctx.EventManager().Events() - - if tc.expError == nil { - suite.Require().NoError(err) - - // verify packet commitment was deleted on source chain - has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - suite.Require().False(has) - - if tc.replay { - // context should not contain application events - suite.Require().NotContains(events, ibcmock.NewMockAckPacketEvent()) - suite.Require().Equal(channeltypes.NOOP, res.Result) - } else { - // context events should contain application events - suite.Require().Contains(events, ibcmock.NewMockAckPacketEvent()) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - // replay should not error as it is treated as a no-op - res, err = suite.chainA.App.GetIBCKeeper().Acknowledgement(suite.chainA.GetContext(), msg) - suite.Require().NoError(err) - suite.Require().Equal(channeltypes.NOOP, res.Result) - } - } else { - suite.Require().ErrorContains(err, tc.expError.Error()) - suite.Require().Nil(res) - } - }) - } -} +// func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { +// var ( +// packet channeltypes.Packet +// signer string +// path *ibctesting.Path +// ) + +// testCases := []struct { +// name string +// malleate func() +// expError error +// replay bool // indicate replay (no-op) +// }{ +// { +// "success", +// func() {}, +// nil, +// false, +// }, +// { +// "invalid signer", +// func() { +// signer = "invalid-signer" +// }, +// errors.New("Invalid address for msg Signer"), +// false, +// }, +// { +// "port route does not exist", +// func() { +// packet.SourcePort = "invalid-port" +// }, +// porttypes.ErrInvalidRoute, +// false, +// }, +// { +// "acknowledge packet fails in packet handler", +// func() { +// packet.SourceChannel = "invalid-client" +// }, +// packetservertypes.ErrChannelNotFound, +// false, +// }, +// { +// "successful no-op: - packet already acknowledged (replay)", +// func() { +// err := path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) +// suite.Require().NoError(err) +// }, +// nil, +// true, +// }, +// { +// "application callback returns error", +// func() { +// suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnAcknowledgementPacket = func(ctx context.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error { +// return fmt.Errorf("mock app callback failed") +// } +// }, +// fmt.Errorf("mock app callback failed"), +// false, +// }, +// } + +// for _, tc := range testCases { +// tc := tc + +// suite.Run(tc.name, func() { +// suite.SetupTest() // reset +// signer = suite.chainA.SenderAccount.GetAddress().String() + +// path = ibctesting.NewPath(suite.chainA, suite.chainB) +// path.SetupV2() + +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// err = path.EndpointB.RecvPacket(packet) +// suite.Require().NoError(err) + +// tc.malleate() + +// var ( +// proof []byte +// proofHeight clienttypes.Height +// ) +// packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +// proof, proofHeight = path.EndpointB.QueryProof(packetKey) + +// msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement.Acknowledgement(), proof, proofHeight, signer) + +// ctx := suite.chainA.GetContext() +// res, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(ctx, msg) + +// events := ctx.EventManager().Events() + +// if tc.expError == nil { +// suite.Require().NoError(err) + +// // verify packet commitment was deleted on source chain +// has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) +// suite.Require().False(has) + +// if tc.replay { +// // context should not contain application events +// suite.Require().NotContains(events, ibcmock.NewMockAckPacketEvent()) +// suite.Require().Equal(channeltypes.NOOP, res.Result) +// } else { +// // context events should contain application events +// suite.Require().Contains(events, ibcmock.NewMockAckPacketEvent()) +// suite.Require().Equal(channeltypes.SUCCESS, res.Result) + +// // replay should not error as it is treated as a no-op +// res, err = suite.chainA.App.GetIBCKeeper().Acknowledgement(suite.chainA.GetContext(), msg) +// suite.Require().NoError(err) +// suite.Require().Equal(channeltypes.NOOP, res.Result) +// } +// } else { +// suite.Require().ErrorContains(err, tc.expError.Error()) +// suite.Require().Nil(res) +// } +// }) +// } +// } // tests the IBC handler timing out a packet on ordered and unordered channels. // It verifies that the deletion of a packet commitment occurs. It tests @@ -906,138 +905,138 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { // It verifies that the deletion of a packet commitment occurs. More // rigorous testing of 'TimeoutPacket' and 'TimeoutExecuted' can be found in // the packet-server/keeper/keeper_test.go. -func (suite *KeeperTestSuite) TestTimeoutPacketV2() { - var ( - packet channeltypes.Packet - packetKey []byte - path *ibctesting.Path - ) - - testCases := []struct { - name string - malleate func() - expErr error - noop bool // indicate no-op - }{ - { - "success", - func() { - path.SetupV2() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - // create packet commitment - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, ibcmock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - // need to update chainA client to prove missing ack - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp, ibcmock.Version) - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - }, - nil, - false, - }, - { - "success: timeout out of order packet", - func() { - // setup uses an UNORDERED channel - path.SetupV2() - - // attempts to timeout the last packet sent without timing out the first packet - // packet sequences begin at 1 - for i := uint64(1); i < maxSequence; i++ { - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - - // create packet commitment - sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) - } - - err := path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - }, - nil, - false, - }, - { - "success no-op: packet not sent", func() { - path.SetupV2() - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - }, - nil, - true, - }, - { - "channel does not exist", - func() { - // any non-nil value of packet is valid - suite.Require().NotNil(packet) - - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - }, - packetservertypes.ErrChannelNotFound, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - path = ibctesting.NewPath(suite.chainA, suite.chainB) - - tc.malleate() - - var ( - proof []byte - proofHeight clienttypes.Height - ) - if path.EndpointB.ClientID != "" { - proof, proofHeight = path.EndpointB.QueryProof(packetKey) - } - - ctx := suite.chainA.GetContext() - msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) - res, err := suite.chainA.App.GetIBCKeeper().Timeout(ctx, msg) - - events := ctx.EventManager().Events() - - if tc.expErr == nil { - suite.Require().NoError(err) - - // replay should not return an error as it is treated as a no-op - _, err := suite.chainA.App.GetIBCKeeper().Timeout(suite.chainA.GetContext(), msg) - suite.Require().NoError(err) - - // verify packet commitment was deleted on source chain - has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - suite.Require().False(has) - - if tc.noop { - // context should not contain application events - suite.Require().NotContains(events, ibcmock.NewMockTimeoutPacketEvent()) - } else { - // context should contain application events - suite.Require().Contains(events, ibcmock.NewMockTimeoutPacketEvent()) - } - - } else { - suite.Require().ErrorIs(err, tc.expErr) - suite.Require().Nil(res) - } - }) - } -} +// func (suite *KeeperTestSuite) TestTimeoutPacketV2() { +// var ( +// packet channeltypes.Packet +// packetKey []byte +// path *ibctesting.Path +// ) + +// testCases := []struct { +// name string +// malleate func() +// expErr error +// noop bool // indicate no-op +// }{ +// { +// "success", +// func() { +// path.SetupV2() + +// timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) +// timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + +// // create packet commitment +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, ibcmock.Version, ibctesting.MockPacketData) +// suite.Require().NoError(err) + +// // need to update chainA client to prove missing ack +// err = path.EndpointA.UpdateClient() +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp, ibcmock.Version) +// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +// }, +// nil, +// false, +// }, +// { +// "success: timeout out of order packet", +// func() { +// // setup uses an UNORDERED channel +// path.SetupV2() + +// // attempts to timeout the last packet sent without timing out the first packet +// // packet sequences begin at 1 +// for i := uint64(1); i < maxSequence; i++ { +// timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) + +// // create packet commitment +// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) +// suite.Require().NoError(err) + +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) +// } + +// err := path.EndpointA.UpdateClient() +// suite.Require().NoError(err) + +// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +// }, +// nil, +// false, +// }, +// { +// "success no-op: packet not sent", func() { +// path.SetupV2() +// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) +// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +// }, +// nil, +// true, +// }, +// { +// "channel does not exist", +// func() { +// // any non-nil value of packet is valid +// suite.Require().NotNil(packet) + +// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +// }, +// packetservertypes.ErrChannelNotFound, +// false, +// }, +// } + +// for _, tc := range testCases { +// tc := tc + +// suite.Run(tc.name, func() { +// suite.SetupTest() // reset +// path = ibctesting.NewPath(suite.chainA, suite.chainB) + +// tc.malleate() + +// var ( +// proof []byte +// proofHeight clienttypes.Height +// ) +// if path.EndpointB.ClientID != "" { +// proof, proofHeight = path.EndpointB.QueryProof(packetKey) +// } + +// ctx := suite.chainA.GetContext() +// msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) +// res, err := suite.chainA.App.GetIBCKeeper().Timeout(ctx, msg) + +// events := ctx.EventManager().Events() + +// if tc.expErr == nil { +// suite.Require().NoError(err) + +// // replay should not return an error as it is treated as a no-op +// _, err := suite.chainA.App.GetIBCKeeper().Timeout(suite.chainA.GetContext(), msg) +// suite.Require().NoError(err) + +// // verify packet commitment was deleted on source chain +// has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) +// suite.Require().False(has) + +// if tc.noop { +// // context should not contain application events +// suite.Require().NotContains(events, ibcmock.NewMockTimeoutPacketEvent()) +// } else { +// // context should contain application events +// suite.Require().Contains(events, ibcmock.NewMockTimeoutPacketEvent()) +// } + +// } else { +// suite.Require().ErrorIs(err, tc.expErr) +// suite.Require().Nil(res) +// } +// }) +// } +// } // tests the IBC handler timing out a packet via channel closure on ordered // and unordered channels. It verifies that the deletion of a packet diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go deleted file mode 100644 index e2fb7e8458b..00000000000 --- a/modules/core/packet-server/keeper/relay_test.go +++ /dev/null @@ -1,643 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - testifysuite "github.com/stretchr/testify/suite" - - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" - ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v9/testing" - "github.com/cosmos/ibc-go/v9/testing/mock" -) - -var ( - defaultTimeoutHeight = clienttypes.NewHeight(1, 100) - disabledTimeoutTimestamp = uint64(0) - unusedChannel = "channel-5" -) - -// KeeperTestSuite is a testing suite to test keeper functions. -type KeeperTestSuite struct { - testifysuite.Suite - - coordinator *ibctesting.Coordinator - - // testing chains used for convenience and readability - chainA *ibctesting.TestChain - chainB *ibctesting.TestChain -} - -// TestKeeperTestSuite runs all the tests within this package. -func TestKeeperTestSuite(t *testing.T) { - testifysuite.Run(t, new(KeeperTestSuite)) -} - -// SetupTest creates a coordinator with 2 test chains. -func (suite *KeeperTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - - // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) - suite.coordinator.CommitNBlocks(suite.chainA, 2) - suite.coordinator.CommitNBlocks(suite.chainB, 2) -} - -func (suite *KeeperTestSuite) TestSendPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "channel not found", - func() { - packet.SourceChannel = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "packet failed basic validation", - func() { - // invalid data - packet.Data = nil - }, - channeltypes.ErrInvalidPacket, - }, - { - "client status invalid", - func() { - path.EndpointA.FreezeClient() - }, - clienttypes.ErrClientNotActive, - }, - { - "client state zero height", func() { - clientState := path.EndpointA.GetClientState() - cs, ok := clientState.(*ibctm.ClientState) - suite.Require().True(ok) - - // force a consensus state into the store at height zero to allow client status check to pass. - consensusState := path.EndpointA.GetConsensusState(cs.LatestHeight) - path.EndpointA.SetConsensusState(consensusState, clienttypes.ZeroHeight()) - - cs.LatestHeight = clienttypes.ZeroHeight() - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, cs) - }, - clienttypes.ErrInvalidHeight, - }, - { - "timeout elapsed", func() { - packet.TimeoutTimestamp = 1 - }, - channeltypes.ErrTimeoutElapsed, - }, - } - - for i, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { - suite.SetupTest() // reset - - // create clients and set counterparties on both chains - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // create standard packet that can be malleated - packet = channeltypes.NewPacketWithVersion(mock.MockPacketData, 1, mock.PortID, - path.EndpointA.ChannelID, mock.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0, mock.Version) - - // malleate the test case - tc.malleate() - - // send packet - seq, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, - packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), seq) - expCommitment := channeltypes.CommitPacket(packet) - suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Equal(uint64(0), seq) - suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) - - } - }) - } -} - -func (suite *KeeperTestSuite) TestRecvPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not V2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: channel not found", - func() { - packet.DestinationChannel = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "failure: client is not active", - func() { - path.EndpointB.FreezeClient() - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: counterparty channel identifier different than source channel", - func() { - packet.SourceChannel = unusedChannel - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet has timed out", - func() { - packet.TimeoutHeight = clienttypes.ZeroHeight() - packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - }, - channeltypes.ErrTimeoutElapsed, - }, - { - "failure: packet already received", - func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - }, - channeltypes.ErrNoOpMsg, - }, - { - "failure: verify membership failed", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, []byte("")) - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) - }, - commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - - tc.malleate() - - // get proof of packet commitment from chainA - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointA.QueryProof(packetKey) - - _, err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), packet, proof, proofHeight) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().True(found) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteAcknowledgement() { - var ( - packet channeltypes.Packet - ack exported.Acknowledgement - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not IBC_VERSION_2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: channel not found", - func() { - packet.DestinationChannel = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "failure: counterparty channel identifier different than source channel", - func() { - packet.SourceChannel = unusedChannel - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: ack already exists", - func() { - ackBz := channeltypes.CommitAcknowledgement(ack.Acknowledgement()) - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence, ackBz) - }, - channeltypes.ErrAcknowledgementExists, - }, - { - "failure: ack is nil", - func() { - ack = nil - }, - channeltypes.ErrInvalidAcknowledgement, - }, - { - "failure: empty ack", - func() { - ack = mock.NewEmptyAcknowledgement() - }, - channeltypes.ErrInvalidAcknowledgement, - }, - { - "failure: receipt not found for packet", - func() { - packet.Sequence = 2 - }, - channeltypes.ErrInvalidPacket, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - ack = mock.MockAcknowledgement - - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - - tc.malleate() - - err := suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), packet, ack) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - ackCommitment, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().True(found) - suite.Require().Equal(channeltypes.CommitAcknowledgement(ack.Acknowledgement()), ackCommitment) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestAcknowledgePacket() { - var ( - packet channeltypes.Packet - ack = mock.MockAcknowledgement - freezeClient bool - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not IBC_VERSION_2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: channel not found", - func() { - packet.SourceChannel = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "failure: counterparty channel identifier different than source channel", - func() { - packet.DestinationChannel = unusedChannel - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet commitment doesn't exist.", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeper.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) - }, - channeltypes.ErrNoOpMsg, - }, - { - "failure: client status invalid", - func() { - freezeClient = true - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: packet commitment bytes differ", - func() { - packet.Data = []byte("") - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: verify membership fails", - func() { - ack = channeltypes.NewResultAcknowledgement([]byte("swapped acknowledgement")) - }, - commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - freezeClient = false - - // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - tc.malleate() - - packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointB.QueryProof(packetKey) - - if freezeClient { - path.EndpointA.FreezeClient() - } - - _, err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), packet, ack.Acknowledgement(), proof, proofHeight) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) - suite.Require().Empty(commitment) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestTimeoutPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - freezeClient bool - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success with timeout height", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - nil, - }, - { - "success with timeout timestamp", - func() { - // disable timeout height and set timeout timestamp to a past timestamp - packet.TimeoutHeight = clienttypes.Height{} - packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - nil, - }, - { - "failure: invalid protocol version", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - packet.AppVersion = "" - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: channel not found", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.SourceChannel = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "failure: counterparty channel identifier different than source channel", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.DestinationChannel = unusedChannel - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet has not timed out yet", - func() { - packet.TimeoutHeight = defaultTimeoutHeight - - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - channeltypes.ErrTimeoutNotReached, - }, - { - "failure: packet already timed out", - func() {}, // equivalent to not sending packet at all - channeltypes.ErrNoOpMsg, - }, - { - "failure: packet does not match commitment", - func() { - // send a different packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, []byte("different data")) - suite.Require().NoError(err, "send packet failed") - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: client status invalid", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - freezeClient = true - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: verify non-membership failed", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - // set packet receipt to mock a valid past receive - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - }, - commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - // initialize freezeClient to false - freezeClient = false - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // create default packet with a timed out height - // test cases may mutate timeout values - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) - - tc.malleate() - - // need to update chainA's client representing chainB to prove missing ack - // commit the changes and update the clients - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) - suite.Require().NoError(path.EndpointA.UpdateClient()) - - // get proof of packet receipt absence from chainB - receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointB.QueryProof(receiptKey) - - if freezeClient { - path.EndpointA.FreezeClient() - } - - _, err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, 0) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().Nil(commitment, "packet commitment not deleted") - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} diff --git a/testing/endpoint.go b/testing/endpoint.go index 82f735ae78e..cf4ade13155 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -468,33 +468,6 @@ func (endpoint *Endpoint) ChanCloseInit() error { return endpoint.Chain.sendMsgs(msg) } -// SendPacketV2 sends a packet through the packet server using the associated endpoint -// The counterparty client is updated so proofs can be sent to the counterparty chain. -// The packet sequence generated for the packet to be sent is returned. An error -// is returned if one occurs. -func (endpoint *Endpoint) SendPacketV2( - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, - version string, - data []byte, -) (uint64, error) { - // no need to send message, acting as a module - sequence, err := endpoint.Chain.App.GetPacketServer().SendPacket(endpoint.Chain.GetContext(), endpoint.ChannelID, endpoint.ChannelConfig.PortID, endpoint.Counterparty.ChannelConfig.PortID, timeoutHeight, timeoutTimestamp, version, data) - if err != nil { - return 0, err - } - - // commit changes since no message was sent - endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) - - err = endpoint.Counterparty.UpdateClient() - if err != nil { - return 0, err - } - - return sequence, nil -} - // SendPacket sends a packet through the channel keeper using the associated endpoint // The counterparty client is updated so proofs can be sent to the counterparty chain. // The packet sequence generated for the packet to be sent is returned. An error diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index 506ce2b03f2..e486e7a29d2 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -1,7 +1,9 @@ package ibctesting import ( - "github.com/stretchr/testify/require" + "github.com/cosmos/gogoproto/proto" + + sdk "github.com/cosmos/cosmos-sdk/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" @@ -11,7 +13,7 @@ import ( func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, packetData channeltypesv2.PacketData) (channeltypesv2.Packet, error) { msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), packetData) - _, err := endpoint.Chain.SendMsgs(msgSendPacket) + res, err := endpoint.Chain.SendMsgs(msgSendPacket) if err != nil { return channeltypesv2.Packet{}, err } @@ -20,10 +22,20 @@ func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, packetData chan return channeltypesv2.Packet{}, err } - // TODO: parse the packet from events instead of manually constructing it. https://github.com/cosmos/ibc-go/issues/7459 - nextSequenceSend, ok := endpoint.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2.GetNextSequenceSend(endpoint.Chain.GetContext(), endpoint.ChannelID) - require.True(endpoint.Chain.TB, ok) - packet := channeltypesv2.NewPacket(nextSequenceSend-1, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, packetData) + // TODO: parse the packet from events instead of from the response. https://github.com/cosmos/ibc-go/issues/7459 + // get sequence from msg response + var msgData sdk.TxMsgData + err = proto.Unmarshal(res.Data, &msgData) + if err != nil { + return channeltypesv2.Packet{}, err + } + msgResponse := msgData.MsgResponses[0] + var sendResponse channeltypesv2.MsgSendPacketResponse + err = proto.Unmarshal(msgResponse.Value, &sendResponse) + if err != nil { + return channeltypesv2.Packet{}, err + } + packet := channeltypesv2.NewPacket(sendResponse.Sequence, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, packetData) return packet, nil } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 871b870bba4..dcf891b2b51 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -7,7 +7,6 @@ import ( channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/api" - mockv1 "github.com/cosmos/ibc-go/v9/testing/mock" ) var _ api.IBCModule = (*IBCModule)(nil) @@ -43,10 +42,7 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, dest if im.IBCApp.OnRecvPacket != nil { return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer) } - return channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Success, - Acknowledgement: mockv1.MockPacketData, - } + return MockRecvPacketResult } func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { diff --git a/testing/mock/v2/mock.go b/testing/mock/v2/mock.go index 6ac92899672..c6403b12364 100644 --- a/testing/mock/v2/mock.go +++ b/testing/mock/v2/mock.go @@ -1,22 +1,33 @@ package mock import ( - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - "github.com/cosmos/ibc-go/v9/testing/mock" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + mockv1 "github.com/cosmos/ibc-go/v9/testing/mock" ) const ( ModuleName = "mockv2" ) -func NewMockPacketData(sourcePort, destPort string) types.PacketData { - return types.PacketData{ +var ( + MockRecvPacketResult = channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Success, + Acknowledgement: mockv1.MockAcknowledgement.Acknowledgement(), + } + MockFailRecvPacketResult = channeltypesv2.RecvPacketResult{ + Status: channeltypesv2.PacketStatus_Success, + Acknowledgement: mockv1.MockFailAcknowledgement.Acknowledgement(), + } +) + +func NewMockPacketData(sourcePort, destPort string) channeltypesv2.PacketData { + return channeltypesv2.PacketData{ SourcePort: sourcePort, DestinationPort: destPort, - Payload: types.Payload{ + Payload: channeltypesv2.Payload{ Encoding: "json", - Value: mock.MockPacketData, - Version: mock.Version, + Value: mockv1.MockPacketData, + Version: mockv1.Version, }, } } From 9b665ca550f2e7925e060daebdf46a49659ec1b4 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 18 Oct 2024 13:24:29 +0300 Subject: [PATCH 084/172] fix: timeout tests after timeout as seconds. (#7480) --- modules/core/04-channel/v2/keeper/msg_server_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 2ebb99ca341..46862d2efa4 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -484,8 +483,8 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { { name: "failure: unable to timeout if packet has been received", malleate: func() { - err := path.EndpointB.MsgRecvPacket(packet) - suite.Require().NoError(err) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.SourceChannel, packet.Sequence) + suite.Require().NoError(path.EndpointB.UpdateClient()) }, expError: commitmenttypes.ErrInvalidProof, }, @@ -498,7 +497,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { path.SetupV2() // Send packet from A to B - timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + timeoutTimestamp := uint64(suite.chainA.GetContext().BlockTime().Unix()) mockData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) var err error @@ -508,7 +507,6 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { tc.malleate() - suite.coordinator.IncrementTimeBy(time.Hour * 20) suite.Require().NoError(path.EndpointA.UpdateClient()) err = path.EndpointA.MsgTimeoutPacket(packet) From bad6098aaeff1fe09b1fa49e37237c9e9fa06c79 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 18 Oct 2024 13:47:21 +0300 Subject: [PATCH 085/172] chore: add validation for MsgAcknowledgement. (#7473) --- modules/core/04-channel/v2/types/msgs.go | 22 +++++++ modules/core/04-channel/v2/types/msgs_test.go | 58 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index d48f0f653ee..d588bd7b5d0 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -20,8 +20,14 @@ var ( _ sdk.Msg = (*MsgCreateChannel)(nil) _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) + _ sdk.Msg = (*MsgSendPacket)(nil) + _ sdk.HasValidateBasic = (*MsgSendPacket)(nil) + _ sdk.Msg = (*MsgRecvPacket)(nil) _ sdk.HasValidateBasic = (*MsgRecvPacket)(nil) + + _ sdk.Msg = (*MsgAcknowledgement)(nil) + _ sdk.HasValidateBasic = (*MsgAcknowledgement)(nil) ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance @@ -149,6 +155,22 @@ func NewMsgAcknowledgement(packet Packet, acknowledgement Acknowledgement, proof } } +// ValidateBasic performs basic checks on a MsgAcknowledgement. +func (msg *MsgAcknowledgement) ValidateBasic() error { + if len(msg.ProofAcked) == 0 { + return errorsmod.Wrap(commitmenttypesv1.ErrInvalidProof, "cannot submit an empty acknowledgement proof") + } + + // TODO: Add validation for ack object https://github.com/cosmos/ibc-go/issues/7472 + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + return msg.Packet.ValidateBasic() +} + // NewMsgTimeout creates a new MsgTimeout instance func NewMsgTimeout(packet Packet, proofUnreceived []byte, proofHeight clienttypes.Height, signer string) *MsgTimeout { return &MsgTimeout{ diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 1cebdd19647..c879d0a856c 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -268,3 +269,60 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { }) } } + +func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { + var msg *types.MsgAcknowledgement + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: invalid proof of acknowledgement", + malleate: func() { + msg.ProofAcked = []byte{} + }, + expError: commitmenttypes.ErrInvalidProof, + }, + { + name: "failure: invalid signer", + malleate: func() { + msg.Signer = "" + }, + expError: ibcerrors.ErrInvalidAddress, + }, + { + name: "failure: invalid packet", + malleate: func() { + msg.Packet.Sequence = 0 + }, + expError: types.ErrInvalidPacket, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + msg = types.NewMsgAcknowledgement( + types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)), + types.Acknowledgement{}, + testProof, + clienttypes.ZeroHeight(), + s.chainA.SenderAccount.GetAddress().String(), + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expError) + } + }) + } +} From 0a3b4be7f5cc3d8d1ec975068fa02d6a0d953faf Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 18 Oct 2024 14:15:48 +0300 Subject: [PATCH 086/172] chore: remove packet-server. (#7481) * chore: remove packet-server. * chore: remove commented out test funcs. --- modules/apps/callbacks/testing/simapp/app.go | 8 - modules/core/04-channel/keeper/keeper.go | 28 -- modules/core/04-channel/keeper/keeper_test.go | 77 --- modules/core/keeper/keeper.go | 28 +- modules/core/keeper/msg_server.go | 44 +- modules/core/keeper/msg_server_test.go | 431 ----------------- modules/core/packet-server/keeper/keeper.go | 68 --- modules/core/packet-server/keeper/relay.go | 398 ---------------- modules/core/packet-server/types/channel.go | 34 -- .../core/packet-server/types/channel.pb.go | 444 ------------------ .../core/packet-server/types/channel_test.go | 94 ---- modules/core/packet-server/types/errors.go | 10 - .../packet-server/types/expected_keepers.go | 58 --- modules/core/packet-server/types/keys.go | 11 - .../08-wasm/testing/simapp/app.go | 10 - proto/ibc/core/packetserver/v1/channel.proto | 26 - testing/simapp/app.go | 10 - testing/testing_app.go | 2 - 18 files changed, 16 insertions(+), 1765 deletions(-) delete mode 100644 modules/core/packet-server/keeper/keeper.go delete mode 100644 modules/core/packet-server/keeper/relay.go delete mode 100644 modules/core/packet-server/types/channel.go delete mode 100644 modules/core/packet-server/types/channel.pb.go delete mode 100644 modules/core/packet-server/types/channel_test.go delete mode 100644 modules/core/packet-server/types/errors.go delete mode 100644 modules/core/packet-server/types/expected_keepers.go delete mode 100644 modules/core/packet-server/types/keys.go delete mode 100644 proto/ibc/core/packetserver/v1/channel.proto diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 734089f645d..d73bcbcb648 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -120,7 +120,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -194,7 +193,6 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper CircuitKeeper circuitkeeper.Keeper - PacketServer *packetserverkeeper.Keeper // mock contract keeper used for testing MockContractKeeper *ContractKeeper @@ -376,7 +374,6 @@ func NewSimApp( app.IBCKeeper = ibckeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) // NOTE: The mock ContractKeeper is only created for testing. // Real applications should not use the mock ContractKeeper @@ -1005,11 +1002,6 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } -// GetPacketServer implements the TestingApp interface -func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { - return app.PacketServer -} - // GetTxConfig implements the TestingApp interface. func (app *SimApp) GetTxConfig() client.TxConfig { return app.txConfig diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 8e8bff09e3b..1dddc74e126 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -21,10 +21,8 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" - commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" - packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) var _ porttypes.ICS4Wrapper = (*Keeper)(nil) @@ -826,29 +824,3 @@ func (k *Keeper) PruneAcknowledgements(ctx context.Context, portID, channelID st return totalPruned, totalRemaining, nil } - -// GetV2Channel returns a version 2 channel for the given port and channel ID -// by converting the v1 channel into a version 2 channel -func (k *Keeper) GetV2Channel(ctx context.Context, portID, channelID string) (packetserver.Channel, bool) { - channel, ok := k.GetChannel(ctx, portID, channelID) - if !ok { - return packetserver.Channel{}, false - } - // Do not allow channel to be converted into a version 2 counterparty - // if the channel is not OPEN or if it is ORDERED - if channel.State != types.OPEN || channel.Ordering == types.ORDERED { - return packetserver.Channel{}, false - } - connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !ok { - return packetserver.Channel{}, false - } - merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - - channelv2 := packetserver.Channel{ - CounterpartyChannelId: channel.Counterparty.ChannelId, - ClientId: connection.ClientId, - MerklePathPrefix: merklePathPrefix, - } - return channelv2, true -} diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index ca57cf1c70a..ff343faa1e8 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -11,10 +11,8 @@ import ( transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" ) @@ -549,81 +547,6 @@ func (suite *KeeperTestSuite) TestUnsetParams() { }) } -func (suite *KeeperTestSuite) TestGetV2Channel() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expPass bool - }{ - { - "success", - func() {}, - true, - }, - { - "failure: channel not found", - func() { - path.EndpointA.ChannelID = "" - }, - false, - }, - { - "failure: channel not OPEN", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.TRYOPEN }) - }, - false, - }, - { - "failure: channel is ORDERED", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) - }, - false, - }, - { - "failure: connection not found", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{ibctesting.InvalidID} }) - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - // create a previously existing path on chainA to change the identifiers - // between the path between chainA and chainB - path1 := ibctesting.NewPath(suite.chainA, suite.chainC) - path1.Setup() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - tc.malleate() - - channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - - if tc.expPass { - suite.Require().True(found) - - merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expChannel := packetservertypes.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) - suite.Require().Equal(channel, expChannel) - } else { - suite.Require().False(found) - suite.Require().Equal(channel, packetservertypes.Channel{}) - } - }) - } -} - func (suite *KeeperTestSuite) TestPruneAcknowledgements() { var ( path *ibctesting.Path diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index a26fbcef482..7f5831d18b9 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -17,18 +17,16 @@ import ( portkeeper "github.com/cosmos/ibc-go/v9/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" "github.com/cosmos/ibc-go/v9/modules/core/api" - packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" "github.com/cosmos/ibc-go/v9/modules/core/types" ) // Keeper defines each ICS keeper for IBC type Keeper struct { - ClientKeeper *clientkeeper.Keeper - ConnectionKeeper *connectionkeeper.Keeper - ChannelKeeper *channelkeeper.Keeper - ChannelKeeperV2 *channelkeeperv2.Keeper - PacketServerKeeper *packetserver.Keeper - PortKeeper *portkeeper.Keeper + ClientKeeper *clientkeeper.Keeper + ConnectionKeeper *connectionkeeper.Keeper + ChannelKeeper *channelkeeper.Keeper + ChannelKeeperV2 *channelkeeperv2.Keeper + PortKeeper *portkeeper.Keeper cdc codec.BinaryCodec @@ -53,18 +51,16 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, storeService, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper() channelKeeper := channelkeeper.NewKeeper(cdc, storeService, clientKeeper, connectionKeeper) - packetKeeper := packetserver.NewKeeper(cdc, storeService, channelKeeper, clientKeeper) channelKeeperV2 := channelkeeperv2.NewKeeper(cdc, storeService, clientKeeper, channelKeeper, connectionKeeper) return &Keeper{ - cdc: cdc, - ClientKeeper: clientKeeper, - ConnectionKeeper: connectionKeeper, - ChannelKeeper: channelKeeper, - ChannelKeeperV2: channelKeeperV2, - PacketServerKeeper: packetKeeper, - PortKeeper: portKeeper, - authority: authority, + cdc: cdc, + ClientKeeper: clientKeeper, + ConnectionKeeper: connectionKeeper, + ChannelKeeper: channelKeeper, + ChannelKeeperV2: channelKeeperV2, + PortKeeper: portKeeper, + authority: authority, } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 7b987945e61..2faf86fc01f 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -3,7 +3,6 @@ package keeper import ( "context" "errors" - "fmt" errorsmod "cosmossdk.io/errors" @@ -391,7 +390,6 @@ func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Ms // RecvPacket defines a rpc handler method for MsgRecvPacket. func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (*channeltypes.MsgRecvPacketResponse, error) { - var packetHandler PacketHandler ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -400,12 +398,6 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) - if err != nil { - ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.DestinationPort, "channel-id", msg.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.Packet.DestinationPort) if !ok { @@ -418,7 +410,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // If the packet was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := packetHandler.RecvPacket(cacheCtx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) + channelVersion, err := k.ChannelKeeper.RecvPacket(cacheCtx, msg.Packet, msg.ProofCommitment, msg.ProofHeight) switch err { case nil: @@ -449,7 +441,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the // acknowledgement is nil. if ack != nil { - if err := packetHandler.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { + if err := k.ChannelKeeper.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { return nil, err } } @@ -463,7 +455,6 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack // Timeout defines a rpc handler method for MsgTimeout. func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { - var packetHandler PacketHandler ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -472,12 +463,6 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) - if err != nil { - ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.Packet.SourcePort) if !ok { @@ -490,7 +475,7 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* // If the timeout was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := packetHandler.TimeoutPacket(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) + channelVersion, err := k.ChannelKeeper.TimeoutPacket(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) switch err { case nil: @@ -572,7 +557,6 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime // Acknowledgement defines a rpc handler method for MsgAcknowledgement. func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { - var packetHandler PacketHandler ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -581,12 +565,6 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } - packetHandler, err = k.getPacketHandlerAndModule(msg.Packet.ProtocolVersion) - if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.Packet.SourcePort) if !ok { @@ -599,7 +577,7 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck // If the acknowledgement was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := packetHandler.AcknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + channelVersion, err := k.ChannelKeeper.AcknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) switch err { case nil: @@ -998,17 +976,3 @@ func (k *Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.Ms return &channeltypes.MsgUpdateParamsResponse{}, nil } - -// getPacketHandlerAndModule returns the appropriate packet handler -// given the protocol version. An error is returned if the protocol -// version is not supported. -func (k *Keeper) getPacketHandlerAndModule(protocolVersion channeltypes.IBCVersion) (PacketHandler, error) { - switch protocolVersion { - case channeltypes.IBC_VERSION_UNSPECIFIED, channeltypes.IBC_VERSION_1: - return k.ChannelKeeper, nil - case channeltypes.IBC_VERSION_2: - return k.PacketServerKeeper, nil - default: - return nil, fmt.Errorf("unsupported protocol %s", protocolVersion) - } -} diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 693e93d8c50..72b5f5a71b0 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -216,173 +216,6 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { } } -// tests the IBC handler receiving a packet using V2 protocol -// func (suite *KeeperTestSuite) TestRecvPacketV2() { -// var ( -// packet channeltypes.Packet -// path *ibctesting.Path -// ) - -// testCases := []struct { -// name string -// malleate func() -// expErr error -// expRevert bool -// async bool // indicate no ack written -// replay bool // indicate replay (no-op) -// }{ -// { -// "success", -// func() { -// path.SetupV2() - -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// }, -// nil, -// false, -// false, -// false, -// }, -// { -// "success: OnRecvPacket callback returns error acknowledgement", -// func() { -// path.SetupV2() - -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockFailPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockFailPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// }, -// nil, -// true, -// false, -// false, -// }, -// { -// "success: async acknowledgement", -// func() { -// path.SetupV2() - -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibcmock.MockAsyncPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibcmock.MockAsyncPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// }, -// nil, -// false, -// true, -// false, -// }, -// { -// "success no-op: packet already received (replay)", -// func() { -// // mock will panic if application callback is called twice on the same packet -// path.SetupV2() - -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// err = path.EndpointB.RecvPacket(packet) -// suite.Require().NoError(err) -// }, -// nil, -// false, -// false, -// true, -// }, -// { -// "channel does not exist", -// func() { -// // any non-nil value of packet is valid -// suite.Require().NotNil(packet) -// }, -// packetservertypes.ErrChannelNotFound, -// false, -// false, -// false, -// }, -// { -// "packet not sent", -// func() { -// path.SetupV2() -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// }, -// fmt.Errorf("receive packet verification failed"), -// false, -// false, -// false, -// }, -// } - -// for _, tc := range testCases { -// tc := tc - -// suite.Run(tc.name, func() { -// suite.SetupTest() // reset -// path = ibctesting.NewPath(suite.chainA, suite.chainB) - -// tc.malleate() - -// var ( -// proof []byte -// proofHeight clienttypes.Height -// ) -// // get proof of packet commitment from chainA -// packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) -// if path.EndpointA.ClientID != "" { -// proof, proofHeight = path.EndpointA.QueryProof(packetKey) -// } - -// ctx := suite.chainB.GetContext() -// msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) -// res, err := suite.chainB.App.GetIBCKeeper().RecvPacket(ctx, msg) - -// events := ctx.EventManager().Events() - -// if tc.expErr == nil { -// suite.Require().NoError(err) - -// // replay should not fail since it will be treated as a no-op -// _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) -// suite.Require().NoError(err) - -// if tc.expRevert { -// // context events should contain error events -// suite.Require().Contains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) -// suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) -// } else { -// if tc.replay { -// // context should not contain application events -// suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) -// suite.Require().NotContains(events, internalerrors.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) -// } else { -// // context events should contain application events -// suite.Require().Contains(events, ibcmock.NewMockRecvPacketEvent()) -// } -// } - -// // verify if ack was written -// ack, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - -// if tc.async { -// suite.Require().Nil(ack) -// suite.Require().False(found) -// } else { -// suite.Require().NotNil(ack) -// suite.Require().True(found) -// } -// } else { -// suite.Require().ErrorContains(err, tc.expErr.Error()) -// suite.Require().Nil(res) -// } -// }) -// } -// } - func (suite *KeeperTestSuite) TestRecoverClient() { var msg *clienttypes.MsgRecoverClient @@ -616,133 +449,6 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { } } -// tests the IBC handler acknowledgement of a packet using protocol version V2 -// func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { -// var ( -// packet channeltypes.Packet -// signer string -// path *ibctesting.Path -// ) - -// testCases := []struct { -// name string -// malleate func() -// expError error -// replay bool // indicate replay (no-op) -// }{ -// { -// "success", -// func() {}, -// nil, -// false, -// }, -// { -// "invalid signer", -// func() { -// signer = "invalid-signer" -// }, -// errors.New("Invalid address for msg Signer"), -// false, -// }, -// { -// "port route does not exist", -// func() { -// packet.SourcePort = "invalid-port" -// }, -// porttypes.ErrInvalidRoute, -// false, -// }, -// { -// "acknowledge packet fails in packet handler", -// func() { -// packet.SourceChannel = "invalid-client" -// }, -// packetservertypes.ErrChannelNotFound, -// false, -// }, -// { -// "successful no-op: - packet already acknowledged (replay)", -// func() { -// err := path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) -// suite.Require().NoError(err) -// }, -// nil, -// true, -// }, -// { -// "application callback returns error", -// func() { -// suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnAcknowledgementPacket = func(ctx context.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error { -// return fmt.Errorf("mock app callback failed") -// } -// }, -// fmt.Errorf("mock app callback failed"), -// false, -// }, -// } - -// for _, tc := range testCases { -// tc := tc - -// suite.Run(tc.name, func() { -// suite.SetupTest() // reset -// signer = suite.chainA.SenderAccount.GetAddress().String() - -// path = ibctesting.NewPath(suite.chainA, suite.chainB) -// path.SetupV2() - -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// err = path.EndpointB.RecvPacket(packet) -// suite.Require().NoError(err) - -// tc.malleate() - -// var ( -// proof []byte -// proofHeight clienttypes.Height -// ) -// packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) -// proof, proofHeight = path.EndpointB.QueryProof(packetKey) - -// msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement.Acknowledgement(), proof, proofHeight, signer) - -// ctx := suite.chainA.GetContext() -// res, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(ctx, msg) - -// events := ctx.EventManager().Events() - -// if tc.expError == nil { -// suite.Require().NoError(err) - -// // verify packet commitment was deleted on source chain -// has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) -// suite.Require().False(has) - -// if tc.replay { -// // context should not contain application events -// suite.Require().NotContains(events, ibcmock.NewMockAckPacketEvent()) -// suite.Require().Equal(channeltypes.NOOP, res.Result) -// } else { -// // context events should contain application events -// suite.Require().Contains(events, ibcmock.NewMockAckPacketEvent()) -// suite.Require().Equal(channeltypes.SUCCESS, res.Result) - -// // replay should not error as it is treated as a no-op -// res, err = suite.chainA.App.GetIBCKeeper().Acknowledgement(suite.chainA.GetContext(), msg) -// suite.Require().NoError(err) -// suite.Require().Equal(channeltypes.NOOP, res.Result) -// } -// } else { -// suite.Require().ErrorContains(err, tc.expError.Error()) -// suite.Require().Nil(res) -// } -// }) -// } -// } - // tests the IBC handler timing out a packet on ordered and unordered channels. // It verifies that the deletion of a packet commitment occurs. It tests // high level properties like ordering and basic sanity checks. More @@ -901,143 +607,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { } } -// tests the IBC handler timing out a packet for the V2 protocol. -// It verifies that the deletion of a packet commitment occurs. More -// rigorous testing of 'TimeoutPacket' and 'TimeoutExecuted' can be found in -// the packet-server/keeper/keeper_test.go. -// func (suite *KeeperTestSuite) TestTimeoutPacketV2() { -// var ( -// packet channeltypes.Packet -// packetKey []byte -// path *ibctesting.Path -// ) - -// testCases := []struct { -// name string -// malleate func() -// expErr error -// noop bool // indicate no-op -// }{ -// { -// "success", -// func() { -// path.SetupV2() - -// timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) -// timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - -// // create packet commitment -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, timeoutTimestamp, ibcmock.Version, ibctesting.MockPacketData) -// suite.Require().NoError(err) - -// // need to update chainA client to prove missing ack -// err = path.EndpointA.UpdateClient() -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp, ibcmock.Version) -// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) -// }, -// nil, -// false, -// }, -// { -// "success: timeout out of order packet", -// func() { -// // setup uses an UNORDERED channel -// path.SetupV2() - -// // attempts to timeout the last packet sent without timing out the first packet -// // packet sequences begin at 1 -// for i := uint64(1); i < maxSequence; i++ { -// timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - -// // create packet commitment -// sequence, err := path.EndpointA.SendPacketV2(timeoutHeight, 0, ibcmock.Version, ibctesting.MockPacketData) -// suite.Require().NoError(err) - -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0, ibcmock.Version) -// } - -// err := path.EndpointA.UpdateClient() -// suite.Require().NoError(err) - -// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) -// }, -// nil, -// false, -// }, -// { -// "success no-op: packet not sent", func() { -// path.SetupV2() -// packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(0, 1), 0, ibcmock.Version) -// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) -// }, -// nil, -// true, -// }, -// { -// "channel does not exist", -// func() { -// // any non-nil value of packet is valid -// suite.Require().NotNil(packet) - -// packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) -// }, -// packetservertypes.ErrChannelNotFound, -// false, -// }, -// } - -// for _, tc := range testCases { -// tc := tc - -// suite.Run(tc.name, func() { -// suite.SetupTest() // reset -// path = ibctesting.NewPath(suite.chainA, suite.chainB) - -// tc.malleate() - -// var ( -// proof []byte -// proofHeight clienttypes.Height -// ) -// if path.EndpointB.ClientID != "" { -// proof, proofHeight = path.EndpointB.QueryProof(packetKey) -// } - -// ctx := suite.chainA.GetContext() -// msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) -// res, err := suite.chainA.App.GetIBCKeeper().Timeout(ctx, msg) - -// events := ctx.EventManager().Events() - -// if tc.expErr == nil { -// suite.Require().NoError(err) - -// // replay should not return an error as it is treated as a no-op -// _, err := suite.chainA.App.GetIBCKeeper().Timeout(suite.chainA.GetContext(), msg) -// suite.Require().NoError(err) - -// // verify packet commitment was deleted on source chain -// has := suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) -// suite.Require().False(has) - -// if tc.noop { -// // context should not contain application events -// suite.Require().NotContains(events, ibcmock.NewMockTimeoutPacketEvent()) -// } else { -// // context should contain application events -// suite.Require().Contains(events, ibcmock.NewMockTimeoutPacketEvent()) -// } - -// } else { -// suite.Require().ErrorIs(err, tc.expErr) -// suite.Require().Nil(res) -// } -// }) -// } -// } - // tests the IBC handler timing out a packet via channel closure on ordered // and unordered channels. It verifies that the deletion of a packet // commitment occurs. It tests high level properties like ordering and basic diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go deleted file mode 100644 index eeeeec5aa3e..00000000000 --- a/modules/core/packet-server/keeper/keeper.go +++ /dev/null @@ -1,68 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - corestore "cosmossdk.io/core/store" - "cosmossdk.io/log" - "cosmossdk.io/store/prefix" - storetypes "cosmossdk.io/store/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" - - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" -) - -// Keeper defines the packet keeper. It wraps the client and channel keepers. -// It does not manage its own store. -type Keeper struct { - cdc codec.BinaryCodec - storeService corestore.KVStoreService - ChannelKeeper types.ChannelKeeper - ClientKeeper types.ClientKeeper -} - -// NewKeeper creates a new packet keeper -func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { - return &Keeper{ - cdc: cdc, - storeService: storeService, - ChannelKeeper: channelKeeper, - ClientKeeper: clientKeeper, - } -} - -// Logger returns a module-specific logger. -func (Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) -} - -func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.KVStore { - channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelStorePrefix, channelID)) - return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) -} - -// SetChannel sets the Channel for a given client identifier. -func (k *Keeper) SetChannel(ctx context.Context, clientID string, channel types.Channel) { - bz := k.cdc.MustMarshal(&channel) - k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) -} - -// GetChannel gets the Channel for a given client identifier. -func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel, bool) { - store := k.ChannelStore(ctx, clientID) - bz := store.Get([]byte(types.ChannelKey)) - if len(bz) == 0 { - return types.Channel{}, false - } - - var channel types.Channel - k.cdc.MustUnmarshal(bz, &channel) - return channel, true -} diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go deleted file mode 100644 index 334ea601a03..00000000000 --- a/modules/core/packet-server/keeper/relay.go +++ /dev/null @@ -1,398 +0,0 @@ -package keeper - -import ( - "bytes" - "context" - "strconv" - - errorsmod "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/exported" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" -) - -// SendPacket implements the packet sending logic required by a packet handler. -// It will generate a packet and store the commitment hash if all arguments provided are valid. -// The destination channel will be filled in using the channel information. -// The next sequence send will be initialized if this is the first packet sent for the given client. -func (k Keeper) SendPacket( - ctx context.Context, - sourceChannel string, - sourcePort string, - destPort string, - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, - version string, - data []byte, -) (uint64, error) { - // Lookup channel associated with our source channel to retrieve the destination channel - channel, ok := k.GetChannel(ctx, sourceChannel) - if !ok { - // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper - // for future use. - if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, sourcePort, sourceChannel); ok { - // we can key on just the source channel here since channel ids are globally unique - k.SetChannel(ctx, sourceChannel, channel) - } else { - // if neither a channel v2 nor channel v1 is found then simply return an error - return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) - } - } - destChannel := channel.CounterpartyChannelId - clientID := channel.ClientId - - // retrieve the sequence send for this channel - // if no packets have been sent yet, initialize the sequence to 1. - sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) - if !found { - sequence = 1 - } - - // construct packet from given fields and channel state - packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, - destPort, destChannel, timeoutHeight, timeoutTimestamp, version) - - if err := packet.ValidateBasic(); err != nil { - return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) - } - - // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) - } - - // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) - if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) - } - - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) - if err != nil { - return 0, err - } - - // check if packet is timed out on the receiving chain - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(latestHeight, latestTimestamp) { - return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") - } - - commitment := channeltypes.CommitPacket(packet) - - // bump the sequence and set the packet commitment so it is provable by the counterparty - k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) - k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - - k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) - - return sequence, nil -} - -// RecvPacket implements the packet receiving logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If the packet has already been received a no-op error is returned. -// The packet handler will verify that the packet has not timed out and that the -// counterparty stored a packet commitment. If successful, a packet receipt is stored -// to indicate to the counterparty successful delivery. -func (k Keeper) RecvPacket( - ctx context.Context, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // packetv2 := convert(packet) - - // Lookup channel associated with our channel and ensure - // that the packet was indeed sent by our channel. - channel, ok := k.GetChannel(ctx, packet.DestinationChannel) - if !ok { - // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper - // for future use. - if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, packet.DestinationPort, packet.DestinationChannel); ok { - // we can key on just the destination channel here since channel ids are globally unique - k.SetChannel(ctx, packet.DestinationChannel, channel) - } else { - // if neither a channel v1 nor channel v1 is found then simply return an error - return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) - } - } - - if channel.CounterpartyChannelId != packet.SourceChannel { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) - } - clientID := channel.ClientId - - // check if packet timed out by comparing it with the latest height of the chain - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(sdkCtx.BlockTime().UnixNano()) - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(selfHeight, selfTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") - } - - // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received - // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale - // by the increase of the recvStartSequence. - _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - if found { - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - // This error indicates that the packet has already been relayed. Core IBC will - // treat this error as a no-op in order to prevent an entire relay transaction - // from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) - - commitment := channeltypes.CommitPacket(packet) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - clientID, - proofHeight, - 0, 0, - proof, - merklePath, - commitment, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", clientID) - } - - // Set Packet Receipt to prevent timeout from occurring on counterparty - k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - - k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} - -// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement -// is written into state. -func (k Keeper) WriteAcknowledgement( - ctx context.Context, - packetI exported.PacketI, - ack exported.Acknowledgement, -) error { - packet, ok := packetI.(channeltypes.Packet) - if !ok { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) - } - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket - } - - // Lookup channel associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - channel, ok := k.GetChannel(ctx, packet.DestinationChannel) - if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) - } - if channel.CounterpartyChannelId != packet.SourceChannel { - return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) - } - - // NOTE: IBC app modules might have written the acknowledgement synchronously on - // the OnRecvPacket callback so we need to check if the acknowledgement is already - // set on the store and return an error if so. - if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { - return channeltypes.ErrAcknowledgementExists - } - - if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { - return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") - } - - if ack == nil { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") - } - - bz := ack.Acknowledgement() - if len(bz) == 0 { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") - } - - k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) - - k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) - - return nil -} - -// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// the acknowledgement provided is verified to have been stored by the counterparty. -// If successful, the packet commitment is deleted and the packet has completed its lifecycle. -func (k Keeper) AcknowledgePacket( - ctx context.Context, - packet channeltypes.Packet, - acknowledgement []byte, - proofAcked []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - channel, ok := k.GetChannel(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) - } - - if channel.CounterpartyChannelId != packet.DestinationChannel { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) - } - clientID := channel.ClientId - - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - if len(commitment) == 0 { - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - // This error indicates that the acknowledgement has already been relayed - // or there is a misconfigured relayer attempting to prove an acknowledgement - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) - } - - path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - clientID, - proofHeight, - 0, 0, - proofAcked, - merklePath, - channeltypes.CommitAcknowledgement(acknowledgement), - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) - } - - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) - - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} - -// TimeoutPacket implements the timeout logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// an absence proof of the packet receipt is performed to ensure that the packet -// was never delivered to the counterparty. If successful, the packet commitment -// is deleted and the packet has completed its lifecycle. -func (k Keeper) TimeoutPacket( - ctx context.Context, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, - _ uint64, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - // Lookup channel associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - channel, ok := k.GetChannel(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) - } - - if channel.CounterpartyChannelId != packet.DestinationChannel { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) - } - clientID := channel.ClientId - - // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) - if err != nil { - return "", err - } - - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") - } - - // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - - if len(commitment) == 0 { - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - // This error indicates that the timeout has already been relayed - // or there is a misconfigured relayer attempting to prove a timeout - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) - } - - // verify packet receipt absence - path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := channeltypesv2.BuildMerklePath(channel.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyNonMembership( - ctx, - clientID, - proofHeight, - 0, 0, - proof, - merklePath, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", clientID) - } - - // delete packet commitment to prevent replay - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} diff --git a/modules/core/packet-server/types/channel.go b/modules/core/packet-server/types/channel.go deleted file mode 100644 index 3a45be384fb..00000000000 --- a/modules/core/packet-server/types/channel.go +++ /dev/null @@ -1,34 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" -) - -// NewChannel creates a new Channel instance -func NewChannel(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Channel { - return Channel{ - ClientId: clientID, - CounterpartyChannelId: counterpartyChannelID, - MerklePathPrefix: merklePathPrefix, - } -} - -// Validate validates the Channel -func (c Channel) Validate() error { - if err := host.ClientIdentifierValidator(c.ClientId); err != nil { - return err - } - - if err := host.ChannelIdentifierValidator(c.CounterpartyChannelId); err != nil { - return err - } - - if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidChannel, err.Error()) - } - - return nil -} diff --git a/modules/core/packet-server/types/channel.pb.go b/modules/core/packet-server/types/channel.pb.go deleted file mode 100644 index 91dfcd17df5..00000000000 --- a/modules/core/packet-server/types/channel.pb.go +++ /dev/null @@ -1,444 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/packetserver/v1/channel.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - 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 - -// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol -// Each side will maintain its own Channel to create an IBC channel -// The channel will be referenced by a channelID which will be used to send packets -// to the counterparty -// The channel will contain the client identifier that will provide proof verification for the channel -// and the counterparty channel identifier that the other channel end will be using -// to send packets to our channel end. -type Channel struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the counterparty identifier that must be used by the packet - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` -} - -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_740f6a3702ba2291, []int{0} -} -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 - -func (m *Channel) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Channel) GetCounterpartyChannelId() string { - if m != nil { - return m.CounterpartyChannelId - } - return "" -} - -func (m *Channel) GetMerklePathPrefix() v2.MerklePath { - if m != nil { - return m.MerklePathPrefix - } - return v2.MerklePath{} -} - -func init() { - proto.RegisterType((*Channel)(nil), "ibc.core.packetserver.v1.Channel") -} - -func init() { - proto.RegisterFile("ibc/core/packetserver/v1/channel.proto", fileDescriptor_740f6a3702ba2291) -} - -var fileDescriptor_740f6a3702ba2291 = []byte{ - // 309 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcf, 0x4a, 0xc3, 0x30, - 0x1c, 0xc7, 0x1b, 0x15, 0x75, 0xf5, 0x22, 0x45, 0x71, 0x4c, 0x88, 0x63, 0x07, 0xdd, 0x65, 0x09, - 0x9b, 0x20, 0x08, 0x9e, 0xe6, 0x69, 0x07, 0x61, 0xec, 0xb0, 0x83, 0x97, 0xd2, 0xa6, 0x3f, 0xdb, - 0xb0, 0xa6, 0x09, 0x69, 0x16, 0xdc, 0x5b, 0xf8, 0x34, 0x3e, 0xc3, 0x8e, 0x3b, 0x7a, 0x12, 0xd9, - 0x5e, 0x44, 0xfa, 0x87, 0xd2, 0x5b, 0xf2, 0xcb, 0x27, 0x9f, 0x7c, 0xf3, 0x75, 0xef, 0x79, 0xc8, - 0x28, 0x93, 0x1a, 0xa8, 0x0a, 0xd8, 0x0a, 0x4c, 0x0e, 0xda, 0x82, 0xa6, 0x76, 0x4c, 0x59, 0x12, - 0x64, 0x19, 0xa4, 0x44, 0x69, 0x69, 0xa4, 0xd7, 0xe5, 0x21, 0x23, 0x05, 0x47, 0xda, 0x1c, 0xb1, - 0xe3, 0xde, 0x55, 0x2c, 0x63, 0x59, 0x42, 0xb4, 0x58, 0x55, 0x7c, 0xef, 0xa1, 0xf1, 0x32, 0x29, - 0x04, 0x37, 0x02, 0x32, 0x43, 0xed, 0xa4, 0xb5, 0xab, 0xc0, 0xc1, 0x37, 0x72, 0xcf, 0x5e, 0xab, - 0xa7, 0xbc, 0x5b, 0xb7, 0xc3, 0x52, 0x0e, 0x99, 0xf1, 0x79, 0xd4, 0x45, 0x7d, 0x34, 0xec, 0x2c, - 0xce, 0xab, 0xc1, 0x2c, 0xf2, 0x9e, 0xdc, 0x1b, 0x26, 0xd7, 0x99, 0x01, 0xad, 0x02, 0x6d, 0x36, - 0x7e, 0x9d, 0xaf, 0x40, 0x8f, 0x4a, 0xf4, 0xba, 0x7d, 0x5c, 0x2b, 0x67, 0x91, 0xb7, 0x74, 0x3d, - 0x01, 0x7a, 0x95, 0x82, 0xaf, 0x02, 0x93, 0xf8, 0x4a, 0xc3, 0x07, 0xff, 0xec, 0x1e, 0xf7, 0xd1, - 0xf0, 0x62, 0x32, 0x20, 0xcd, 0xb7, 0x5a, 0xc1, 0xec, 0x84, 0xbc, 0x95, 0x37, 0xe6, 0x81, 0x49, - 0xa6, 0x27, 0xdb, 0xdf, 0x3b, 0x67, 0x71, 0x29, 0x9a, 0xc9, 0xbc, 0x34, 0x4c, 0x97, 0xdb, 0x3d, - 0x46, 0xbb, 0x3d, 0x46, 0x7f, 0x7b, 0x8c, 0xbe, 0x0e, 0xd8, 0xd9, 0x1d, 0xb0, 0xf3, 0x73, 0xc0, - 0xce, 0xfb, 0x4b, 0xcc, 0x4d, 0xb2, 0x0e, 0x0b, 0x25, 0x65, 0x32, 0x17, 0x32, 0xa7, 0x3c, 0x64, - 0xa3, 0x58, 0x52, 0xfb, 0x4c, 0x85, 0x8c, 0xd6, 0x29, 0xe4, 0xed, 0xce, 0x47, 0x75, 0xe9, 0x66, - 0xa3, 0x20, 0x0f, 0x4f, 0xcb, 0x5e, 0x1e, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x94, 0x68, 0x6c, - 0x3f, 0x9a, 0x01, 0x00, 0x00, -} - -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 - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.CounterpartyChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { - offset -= sovChannel(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Channel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - -func sovChannel(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozChannel(x uint64) (n int) { - return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -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 ErrIntOverflowChannel - } - 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 != 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - 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 CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipChannel(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, ErrIntOverflowChannel - } - 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, ErrIntOverflowChannel - } - 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, ErrIntOverflowChannel - } - 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, ErrInvalidLengthChannel - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupChannel - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthChannel - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") -) diff --git a/modules/core/packet-server/types/channel_test.go b/modules/core/packet-server/types/channel_test.go deleted file mode 100644 index f5d6948a23b..00000000000 --- a/modules/core/packet-server/types/channel_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" - ibctesting "github.com/cosmos/ibc-go/v9/testing" -) - -func TestValidateChannel(t *testing.T) { - testCases := []struct { - name string - clientID string - channelID string - merklePathPrefix commitmenttypes.MerklePath - expError error - }{ - { - "success", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte("ibc")), - nil, - }, - { - "success with multiple element prefix", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), - nil, - }, - { - "success with multiple element prefix, last prefix empty", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), - nil, - }, - { - "success with single empty key prefix", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte("")), - nil, - }, - { - "failure: invalid client id", - "", - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte("ibc")), - host.ErrInvalidID, - }, - { - "failure: invalid channel id", - ibctesting.FirstClientID, - "", - commitmenttypes.NewMerklePath([]byte("ibc")), - host.ErrInvalidID, - }, - { - "failure: empty merkle path prefix", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath(), - types.ErrInvalidChannel, - }, - { - "failure: empty key in merkle path prefix first element", - ibctesting.FirstClientID, - ibctesting.FirstChannelID, - commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), - types.ErrInvalidChannel, - }, - } - - for _, tc := range testCases { - tc := tc - - channel := types.NewChannel(tc.clientID, tc.channelID, tc.merklePathPrefix) - err := channel.Validate() - - expPass := tc.expError == nil - if expPass { - require.NoError(t, err, tc.name) - } else { - require.Error(t, err, tc.name) - require.ErrorIs(t, err, tc.expError) - } - } -} diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go deleted file mode 100644 index 1c2d5cb3481..00000000000 --- a/modules/core/packet-server/types/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" -) - -var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") -) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go deleted file mode 100644 index 1fa932c4efd..00000000000 --- a/modules/core/packet-server/types/expected_keepers.go +++ /dev/null @@ -1,58 +0,0 @@ -package types - -import ( - "context" - - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v9/modules/core/exported" -) - -type ChannelKeeper interface { - // SetPacketCommitment writes the commitment hash under the commitment path - // This is a public path that is standardized by the IBC specification - SetPacketCommitment(ctx context.Context, portID string, channelID string, sequence uint64, commitment []byte) - - // GetPacketCommitment returns the packet commitment hash under the commitment path - GetPacketCommitment(ctx context.Context, portID string, channelID string, sequence uint64) []byte - - // DeletePacketCommitment deletes the packet commitment hash under the commitment path - DeletePacketCommitment(ctx context.Context, portID string, channelID string, sequence uint64) - - // SetNextSequenceSend writes the next send sequence under the sequence path - // This is a public path that is standardized by the IBC specification - SetNextSequenceSend(ctx context.Context, portID, channelID string, sequence uint64) - - // GetNextSequenceSend returns the next send sequence from the sequence path - GetNextSequenceSend(ctx context.Context, portID, channelID string) (uint64, bool) - - // SetPacketReceipt writes the packet receipt under the receipt path - // This is a public path that is standardized by the IBC specification - SetPacketReceipt(ctx context.Context, portID, channelID string, sequence uint64) - - // GetPacketReceipt returns the packet receipt from the packet receipt path - GetPacketReceipt(ctx context.Context, portID, channelID string, sequence uint64) (string, bool) - - // HasPacketAcknowledgement check if the packet ack hash is already on the store - HasPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64) bool - - // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path - // This is a public path that is standardized by the IBC specification - SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) - - // GetV2Channel returns a version 2 channel for a given portID and channel ID - GetV2Channel(ctx context.Context, portID, channelID string) (Channel, bool) -} - -type ClientKeeper interface { - // VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height. - VerifyMembership(ctx context.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error - // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. - VerifyNonMembership(ctx context.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error - // GetClientStatus returns the status of a client given the client ID - GetClientStatus(ctx context.Context, clientID string) exported.Status - // GetClientLatestHeight returns the latest height of a client given the client ID - GetClientLatestHeight(ctx context.Context, clientID string) clienttypes.Height - // GetClientTimestampAtHeight returns the timestamp for a given height on the client - // given its client ID and height - GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) -} diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go deleted file mode 100644 index d1426569d57..00000000000 --- a/modules/core/packet-server/types/keys.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -const ( - // SubModuleName defines the IBC packet server name. - SubModuleName = "packetserver" - - // ChannelKey is the key used to store channel in the client store. - // the channel key is imported from types instead of host because - // the channel key is not a part of the ics-24 host specification - ChannelKey = "channel" -) diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index aa725076150..6c63e87e97e 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -128,7 +128,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -203,7 +202,6 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper CircuitKeeper circuitkeeper.Keeper - PacketServer *packetserverkeeper.Keeper // make IBC modules public for test purposes // these modules are never directly routed to by the IBC Router @@ -384,9 +382,6 @@ func NewSimApp( appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // setup packet server keeper for Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) - govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -1056,11 +1051,6 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } -// GetPacketServer implements the TestingApp interface -func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { - return app.PacketServer -} - // GetWasmKeeper implements the TestingApp interface. func (app *SimApp) GetWasmKeeper() wasmkeeper.Keeper { return app.WasmClientKeeper diff --git a/proto/ibc/core/packetserver/v1/channel.proto b/proto/ibc/core/packetserver/v1/channel.proto deleted file mode 100644 index 8ff15c78023..00000000000 --- a/proto/ibc/core/packetserver/v1/channel.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package ibc.core.packetserver.v1; - -option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/commitment/v2/commitment.proto"; - -// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol -// Each side will maintain its own Channel to create an IBC channel -// The channel will be referenced by a channelID which will be used to send packets -// to the counterparty -// The channel will contain the client identifier that will provide proof verification for the channel -// and the counterparty channel identifier that the other channel end will be using -// to send packets to our channel end. -message Channel { - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the counterparty identifier that must be used by the packet - string counterparty_channel_id = 2; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; -} diff --git a/testing/simapp/app.go b/testing/simapp/app.go index d9b5cc38ea0..6ac8d9a87aa 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -108,7 +108,6 @@ import ( ibcapi "github.com/cosmos/ibc-go/v9/modules/core/api" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -175,7 +174,6 @@ type SimApp struct { ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper - PacketServer *packetserverkeeper.Keeper // make IBC modules public for test purposes // these modules are never directly routed to by the IBC Router @@ -343,9 +341,6 @@ func NewSimApp( appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // Setup packet server to call on Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) - govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -944,11 +939,6 @@ func (app *SimApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } -// GetPacketServer implements the TestingApp interface -func (app *SimApp) GetPacketServer() *packetserverkeeper.Keeper { - return app.PacketServer -} - // GetTxConfig implements the TestingApp interface. func (app *SimApp) GetTxConfig() client.TxConfig { return app.txConfig diff --git a/testing/testing_app.go b/testing/testing_app.go index b25630622a7..bdb99ec35fc 100644 --- a/testing/testing_app.go +++ b/testing/testing_app.go @@ -28,7 +28,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/ibc-go/v9/modules/core/keeper" - packetserverkeeper "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" "github.com/cosmos/ibc-go/v9/testing/simapp" ibctestingtypes "github.com/cosmos/ibc-go/v9/testing/types" ) @@ -43,7 +42,6 @@ type TestingApp interface { GetStakingKeeper() ibctestingtypes.StakingKeeper GetIBCKeeper() *keeper.Keeper GetTxConfig() client.TxConfig - GetPacketServer() *packetserverkeeper.Keeper // Implemented by SimApp AppCodec() codec.Codec From e77a0f4bfdd395dd5e5480a10e4a25dac8c6e4fd Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 18 Oct 2024 14:27:41 +0100 Subject: [PATCH 087/172] chore: add ValidateBasic for MsgTimeout in ChannelKeeper V2 (#7482) * chore: add ValidateBasic for MsgTimeout in ChannelKeeper V2 * rename --- modules/core/04-channel/v2/types/msgs.go | 17 ++++++ modules/core/04-channel/v2/types/msgs_test.go | 57 ++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index d588bd7b5d0..dc7537a5a93 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -26,6 +26,9 @@ var ( _ sdk.Msg = (*MsgRecvPacket)(nil) _ sdk.HasValidateBasic = (*MsgRecvPacket)(nil) + _ sdk.Msg = (*MsgTimeout)(nil) + _ sdk.HasValidateBasic = (*MsgTimeout)(nil) + _ sdk.Msg = (*MsgAcknowledgement)(nil) _ sdk.HasValidateBasic = (*MsgAcknowledgement)(nil) ) @@ -180,3 +183,17 @@ func NewMsgTimeout(packet Packet, proofUnreceived []byte, proofHeight clienttype Signer: signer, } } + +// ValidateBasic performs basic checks on a MsgTimeout +func (msg *MsgTimeout) ValidateBasic() error { + if len(msg.ProofUnreceived) == 0 { + return errorsmod.Wrap(commitmenttypesv1.ErrInvalidProof, "proof unreceived can not be empty") + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + return msg.Packet.ValidateBasic() +} diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index c879d0a856c..5536d6240bc 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -272,7 +272,6 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { var msg *types.MsgAcknowledgement - testCases := []struct { name string malleate func() @@ -326,3 +325,59 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { }) } } + +func (s *TypesTestSuite) TestMsgTimeoutValidateBasic() { + var msg *types.MsgTimeout + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: invalid signer", + malleate: func() { + msg.Signer = "" + }, + expError: ibcerrors.ErrInvalidAddress, + }, + { + name: "failure: invalid packet", + malleate: func() { + msg.Packet.Sequence = 0 + }, + expError: types.ErrInvalidPacket, + }, + { + name: "failure: invalid proof unreceived", + malleate: func() { + msg.ProofUnreceived = []byte{} + }, + expError: commitmenttypes.ErrInvalidProof, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + msg = types.NewMsgTimeout( + types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)), + testProof, + clienttypes.ZeroHeight(), + s.chainA.SenderAccount.GetAddress().String(), + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expError) + } + }) + } +} From aeb99808c0c2fb1f24d6d3364be208ac9c348bf8 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 21 Oct 2024 10:11:26 +0100 Subject: [PATCH 088/172] chore: rename PacketData to Payload (#7483) * chore: rename PacketData to Payload * Update modules/core/04-channel/v2/types/msgs.go Co-authored-by: Cian Hatton * Update proto/ibc/core/channel/v2/tx.proto Co-authored-by: Cian Hatton * Update modules/core/04-channel/v2/keeper/packet.go Co-authored-by: Cian Hatton * Update modules/core/04-channel/v2/keeper/msg_server_test.go Co-authored-by: Cian Hatton * Update modules/core/04-channel/v2/keeper/export_test.go Co-authored-by: Cian Hatton * fixes after renaming - PR feedback --------- Co-authored-by: Cian Hatton --- .../core/04-channel/v2/keeper/export_test.go | 4 +- .../core/04-channel/v2/keeper/msg_server.go | 4 +- .../04-channel/v2/keeper/msg_server_test.go | 30 +- modules/core/04-channel/v2/keeper/packet.go | 6 +- .../core/04-channel/v2/keeper/packet_test.go | 14 +- .../core/04-channel/v2/types/commitment.go | 12 +- modules/core/04-channel/v2/types/errors.go | 1 - modules/core/04-channel/v2/types/msgs.go | 10 +- modules/core/04-channel/v2/types/msgs_test.go | 18 +- modules/core/04-channel/v2/types/packet.go | 33 +- modules/core/04-channel/v2/types/packet.pb.go | 355 +++++------------- .../core/04-channel/v2/types/packet_test.go | 73 ++-- modules/core/04-channel/v2/types/tx.pb.go | 138 +++---- modules/core/api/module.go | 8 +- proto/ibc/core/channel/v2/packet.proto | 18 +- proto/ibc/core/channel/v2/tx.proto | 8 +- testing/endpoint_v2.go | 6 +- testing/mock/v2/ibc_app.go | 8 +- testing/mock/v2/ibc_module.go | 8 +- testing/mock/v2/mock.go | 12 +- 20 files changed, 273 insertions(+), 493 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index 6cb135f2ea5..d772eac3bef 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -15,13 +15,13 @@ func (k *Keeper) SendPacketTest( ctx context.Context, sourceChannel string, timeoutTimestamp uint64, - data []channeltypesv2.PacketData, + payloads []channeltypesv2.Payload, ) (uint64, string, error) { return k.sendPacket( ctx, sourceChannel, timeoutTimestamp, - data, + payloads, ) } diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 1d8add950d4..00d631bbe0f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -20,7 +20,7 @@ var _ channeltypesv2.MsgServer = &Keeper{} // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.PacketData) + sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) if err != nil { sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) @@ -32,7 +32,7 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } - for _, pd := range msg.PacketData { + for _, pd := range msg.Payloads { cbs := k.Router.Route(pd.SourcePort) err := cbs.OnSendPacket(ctx, msg.SourceChannel, destChannel, sequence, pd, signer) if err != nil { diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 46862d2efa4..d30d8d1d6d1 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -22,7 +22,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { path *ibctesting.Path expectedPacket channeltypesv2.Packet timeoutTimestamp uint64 - packetData channeltypesv2.PacketData + payload channeltypesv2.Payload ) testCases := []struct { @@ -53,7 +53,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: application callback error", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: route to non existing app", malleate: func() { - packetData.SourcePort = "foo" + payload.SourcePort = "foo" }, expError: fmt.Errorf("no route for foo"), }, @@ -85,13 +85,13 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { path.SetupV2() timeoutTimestamp = suite.chainA.GetTimeoutTimestamp() - packetData = mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload = mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, packetData) + expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) tc.malleate() - packet, err := path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) + packet, err := path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) expPass := tc.expError == nil if expPass { @@ -146,7 +146,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { // a failed ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { return failedRecvResult } }, @@ -162,7 +162,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { // an async ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { return asyncResult } }, @@ -204,7 +204,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() var err error - packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)) suite.Require().NoError(err) // default expected ack is a single successful recv result for moduleB. @@ -349,7 +349,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -357,7 +357,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -397,7 +397,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { var err error // Send packet from A to B - packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)) suite.Require().NoError(err) err = path.EndpointB.MsgRecvPacket(packet) @@ -450,7 +450,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // Modify the callback to return a different error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -459,7 +459,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -498,7 +498,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // Send packet from A to B timeoutTimestamp := uint64(suite.chainA.GetContext().BlockTime().Unix()) - mockData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + mockData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) var err error packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockData) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index dccb5da46c8..59190861f86 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -23,13 +23,13 @@ func (k *Keeper) sendPacket( ctx context.Context, sourceChannel string, timeoutTimestamp uint64, - data []types.PacketData, + payloads []types.Payload, ) (uint64, string, error) { // Lookup channel associated with our source channel to retrieve the destination channel channel, ok := k.GetChannel(ctx, sourceChannel) if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. - channel, ok = k.convertV1Channel(ctx, data[0].SourcePort, sourceChannel) + channel, ok = k.convertV1Channel(ctx, payloads[0].SourcePort, sourceChannel) if !ok { return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } @@ -47,7 +47,7 @@ func (k *Keeper) sendPacket( } // construct packet from given fields and channel state - packet := types.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, data...) + packet := types.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, payloads...) if err := packet.ValidateBasic(); err != nil { return 0, "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index 2fb3d926d5d..871aa3479c1 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -97,7 +97,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) @@ -204,7 +204,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) @@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) @@ -391,7 +391,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { "failure: packet commitment bytes differ", func() { // change packet data after send to acknowledge different packet - packet.Data[0].Payload.Value = []byte("different value") + packet.Data[0].Value = []byte("different value") }, channeltypes.ErrInvalidPacket, }, @@ -414,7 +414,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { freezeClient = false - packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) @@ -521,7 +521,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Require().NoError(err, "send packet failed") // try to timeout packet with different data - packet.Data[0].Payload.Value = []byte("different value") + packet.Data[0].Value = []byte("different value") }, channeltypes.ErrInvalidPacket, }, @@ -564,7 +564,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { path.SetupV2() // create default packet with a timed out timestamp - packetData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB) + packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 1bde0803ad8..8a14e77f91f 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -18,25 +18,25 @@ func CommitPacket(packet Packet) []byte { buf = append(buf, destIDHash[:]...) for _, data := range packet.Data { - buf = append(buf, hashPacketData(data)...) + buf = append(buf, hashPayload(data)...) } hash := sha256.Sum256(buf) return hash[:] } -// hashPacketData returns the hash of the packet data. -func hashPacketData(data PacketData) []byte { +// hashPayload returns the hash of the packet data. +func hashPayload(data Payload) []byte { var buf []byte sourceHash := sha256.Sum256([]byte(data.SourcePort)) buf = append(buf, sourceHash[:]...) destHash := sha256.Sum256([]byte(data.DestinationPort)) buf = append(buf, destHash[:]...) - payloadValueHash := sha256.Sum256(data.Payload.Value) + payloadValueHash := sha256.Sum256(data.Value) buf = append(buf, payloadValueHash[:]...) - payloadEncodingHash := sha256.Sum256([]byte(data.Payload.Encoding)) + payloadEncodingHash := sha256.Sum256([]byte(data.Encoding)) buf = append(buf, payloadEncodingHash[:]...) - payloadVersionHash := sha256.Sum256([]byte(data.Payload.Version)) + payloadVersionHash := sha256.Sum256([]byte(data.Version)) buf = append(buf, payloadVersionHash[:]...) hash := sha256.Sum256(buf) return hash[:] diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 1cf10763391..1e0eaa95c70 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -10,6 +10,5 @@ var ( ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") - ErrInvalidPacketData = errorsmod.Register(SubModuleName, 7, "invalid packet data") ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 8, "invalid acknowledgement") ) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index dc7537a5a93..45fdf38775e 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -86,11 +86,11 @@ func (msg *MsgCreateChannel) ValidateBasic() error { } // NewMsgSendPacket creates a new MsgSendPacket instance. -func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer string, packetData ...PacketData) *MsgSendPacket { +func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer string, payloads ...Payload) *MsgSendPacket { return &MsgSendPacket{ SourceChannel: sourceChannel, TimeoutTimestamp: timeoutTimestamp, - PacketData: packetData, + Payloads: payloads, Signer: signer, } } @@ -105,11 +105,11 @@ func (msg *MsgSendPacket) ValidateBasic() error { return errorsmod.Wrap(channeltypesv1.ErrInvalidTimeout, "timeout must not be 0") } - if len(msg.PacketData) != 1 { - return errorsmod.Wrapf(ErrInvalidPacketData, "packet data must be of length 1, got %d instead", len(msg.PacketData)) + if len(msg.Payloads) != 1 { + return errorsmod.Wrapf(ErrInvalidPayload, "payloads must be of length 1, got %d instead", len(msg.Payloads)) } - for _, pd := range msg.PacketData { + for _, pd := range msg.Payloads { if err := pd.ValidateBasic(); err != nil { return err } diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 5536d6240bc..a5bc812cc1d 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -174,16 +174,16 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { expError: channeltypesv1.ErrInvalidTimeout, }, { - name: "failure: invalid length for packetdata", + name: "failure: invalid length for payload", malleate: func() { - msg.PacketData = []types.PacketData{} + msg.Payloads = []types.Payload{} }, - expError: types.ErrInvalidPacketData, + expError: types.ErrInvalidPayload, }, { name: "failure: invalid packetdata", malleate: func() { - msg.PacketData[0].DestinationPort = "" + msg.Payloads[0].DestinationPort = "" }, expError: host.ErrInvalidID, }, @@ -200,7 +200,7 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { msg = types.NewMsgSendPacket( ibctesting.FirstChannelID, s.chainA.GetTimeoutTimestamp(), s.chainA.SenderAccount.GetAddress().String(), - types.PacketData{SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Payload: types.NewPayload("ics20-1", "json", ibctesting.MockPacketData)}, + types.Payload{SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Version: "ics20-1", Encoding: "json", Value: ibctesting.MockPacketData}, ) tc.malleate() @@ -230,7 +230,7 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { { name: "failure: invalid packet", malleate: func() { - msg.Packet.Data = []types.PacketData{} + msg.Packet.Data = []types.Payload{} }, expError: types.ErrInvalidPacket, }, @@ -251,7 +251,7 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { } for _, tc := range testCases { s.Run(tc.name, func() { - packet := types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)) + packet := types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)) msg = types.NewMsgRecvPacket(packet, testProof, s.chainA.GetTimeoutHeight(), s.chainA.SenderAccount.GetAddress().String()) @@ -306,7 +306,7 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { for _, tc := range testCases { s.Run(tc.name, func() { msg = types.NewMsgAcknowledgement( - types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)), + types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)), types.Acknowledgement{}, testProof, clienttypes.ZeroHeight(), @@ -363,7 +363,7 @@ func (s *TypesTestSuite) TestMsgTimeoutValidateBasic() { for _, tc := range testCases { s.Run(tc.name, func() { msg = types.NewMsgTimeout( - types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)), + types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)), testProof, clienttypes.ZeroHeight(), s.chainA.SenderAccount.GetAddress().String(), diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 8bddb98164f..c00e7a37e73 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -9,7 +9,7 @@ import ( ) // NewPacket constructs a new packet. -func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, data ...PacketData) Packet { +func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, data ...Payload) Packet { return Packet{ Sequence: sequence, SourceChannel: sourceChannel, @@ -19,21 +19,14 @@ func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeou } } -// NewPacketData constructs a new PacketData -func NewPacketData(sourcePort, destPort string, payload Payload) PacketData { - return PacketData{ +// NewPayload constructs a new PacketData +func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Payload { + return Payload{ SourcePort: sourcePort, DestinationPort: destPort, - Payload: payload, - } -} - -// NewPayload constructs a new Payload -func NewPayload(version, encoding string, value []byte) Payload { - return Payload{ - Version: version, - Encoding: encoding, - Value: value, + Version: version, + Encoding: encoding, + Value: value, } } @@ -66,22 +59,14 @@ func (p Packet) ValidateBasic() error { return nil } -// ValidateBasic validates a PacketData -func (p PacketData) ValidateBasic() error { +// ValidateBasic validates a Payload. +func (p Payload) ValidateBasic() error { if err := host.PortIdentifierValidator(p.SourcePort); err != nil { return errorsmod.Wrap(err, "invalid source port ID") } if err := host.PortIdentifierValidator(p.DestinationPort); err != nil { return errorsmod.Wrap(err, "invalid destination port ID") } - if err := p.Payload.Validate(); err != nil { - return err - } - return nil -} - -// Validate validates a Payload. -func (p Payload) Validate() error { if strings.TrimSpace(p.Version) == "" { return errorsmod.Wrap(ErrInvalidPayload, "payload version cannot be empty") } diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go index 7ec4ffaadb0..0811b9e52b4 100644 --- a/modules/core/04-channel/v2/types/packet.pb.go +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -72,7 +72,7 @@ type Packet struct { // timeout timestamp after which the packet times out. TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` // a list of packet data, each one for a specific application. - Data []PacketData `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` + Data []Payload `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` } func (m *Packet) Reset() { *m = Packet{} } @@ -136,92 +136,32 @@ func (m *Packet) GetTimeoutTimestamp() uint64 { return 0 } -func (m *Packet) GetData() []PacketData { +func (m *Packet) GetData() []Payload { if m != nil { return m.Data } return nil } -// PacketData contains the source and destination ports and payload for the application -type PacketData struct { +// Payload contains the source and destination ports and payload for the application (version, encoding, raw bytes) +type Payload struct { // specifies the source port of the packet. SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` // specifies the destination port of the packet. DestinationPort string `protobuf:"bytes,2,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` - // the payload to be sent to the application. - Payload Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload"` -} - -func (m *PacketData) Reset() { *m = PacketData{} } -func (m *PacketData) String() string { return proto.CompactTextString(m) } -func (*PacketData) ProtoMessage() {} -func (*PacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{1} -} -func (m *PacketData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PacketData.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 *PacketData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PacketData.Merge(m, src) -} -func (m *PacketData) XXX_Size() int { - return m.Size() -} -func (m *PacketData) XXX_DiscardUnknown() { - xxx_messageInfo_PacketData.DiscardUnknown(m) -} - -var xxx_messageInfo_PacketData proto.InternalMessageInfo - -func (m *PacketData) GetSourcePort() string { - if m != nil { - return m.SourcePort - } - return "" -} - -func (m *PacketData) GetDestinationPort() string { - if m != nil { - return m.DestinationPort - } - return "" -} - -func (m *PacketData) GetPayload() Payload { - if m != nil { - return m.Payload - } - return Payload{} -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -type Payload struct { // version of the specified application. - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` // the encoding used for the provided value. - Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"` + Encoding string `protobuf:"bytes,4,opt,name=encoding,proto3" json:"encoding,omitempty"` // the raw bytes for the payload. - Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` } func (m *Payload) Reset() { *m = Payload{} } func (m *Payload) String() string { return proto.CompactTextString(m) } func (*Payload) ProtoMessage() {} func (*Payload) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{2} + return fileDescriptor_2f814aba9ca97169, []int{1} } func (m *Payload) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -250,6 +190,20 @@ func (m *Payload) XXX_DiscardUnknown() { var xxx_messageInfo_Payload proto.InternalMessageInfo +func (m *Payload) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *Payload) GetDestinationPort() string { + if m != nil { + return m.DestinationPort + } + return "" +} + func (m *Payload) GetVersion() string { if m != nil { return m.Version @@ -280,7 +234,7 @@ func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } func (*Acknowledgement) ProtoMessage() {} func (*Acknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{3} + return fileDescriptor_2f814aba9ca97169, []int{2} } func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +280,7 @@ func (m *AcknowledgementResult) Reset() { *m = AcknowledgementResult{} } func (m *AcknowledgementResult) String() string { return proto.CompactTextString(m) } func (*AcknowledgementResult) ProtoMessage() {} func (*AcknowledgementResult) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{4} + return fileDescriptor_2f814aba9ca97169, []int{3} } func (m *AcknowledgementResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -381,7 +335,7 @@ func (m *RecvPacketResult) Reset() { *m = RecvPacketResult{} } func (m *RecvPacketResult) String() string { return proto.CompactTextString(m) } func (*RecvPacketResult) ProtoMessage() {} func (*RecvPacketResult) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{5} + return fileDescriptor_2f814aba9ca97169, []int{4} } func (m *RecvPacketResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -427,7 +381,6 @@ func (m *RecvPacketResult) GetAcknowledgement() []byte { func init() { proto.RegisterEnum("ibc.core.channel.v2.PacketStatus", PacketStatus_name, PacketStatus_value) proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") - proto.RegisterType((*PacketData)(nil), "ibc.core.channel.v2.PacketData") proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v2.Acknowledgement") proto.RegisterType((*AcknowledgementResult)(nil), "ibc.core.channel.v2.AcknowledgementResult") @@ -437,49 +390,48 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/packet.proto", fileDescriptor_2f814aba9ca97169) } var fileDescriptor_2f814aba9ca97169 = []byte{ - // 664 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xc1, 0x4e, 0xdb, 0x4a, - 0x14, 0x86, 0x63, 0x08, 0x04, 0x4e, 0xb8, 0xe0, 0x3b, 0xc0, 0xbd, 0x21, 0xba, 0x0a, 0xbe, 0x96, - 0x68, 0x53, 0x2a, 0xec, 0x2a, 0xed, 0x06, 0x89, 0x4d, 0x08, 0x41, 0x42, 0xad, 0xd2, 0xc8, 0x4e, - 0x2a, 0xd1, 0x8d, 0x35, 0x99, 0x8c, 0x82, 0x85, 0xed, 0x71, 0x3d, 0x63, 0x23, 0xa4, 0x3e, 0x01, - 0x52, 0xa5, 0xae, 0xba, 0xe3, 0x09, 0xfa, 0x22, 0x2c, 0x59, 0x76, 0x55, 0x55, 0xd0, 0x07, 0xa9, - 0x32, 0x76, 0x68, 0x92, 0xa6, 0x5d, 0x25, 0xe7, 0x3f, 0xdf, 0x99, 0xf9, 0x7f, 0xcf, 0x68, 0x40, - 0x73, 0x7b, 0xc4, 0x24, 0x2c, 0xa2, 0x26, 0x39, 0xc3, 0x41, 0x40, 0x3d, 0x33, 0xa9, 0x99, 0x21, - 0x26, 0xe7, 0x54, 0x18, 0x61, 0xc4, 0x04, 0x43, 0xeb, 0x6e, 0x8f, 0x18, 0x43, 0xc2, 0xc8, 0x08, - 0x23, 0xa9, 0x95, 0x37, 0x06, 0x6c, 0xc0, 0x64, 0xdf, 0x1c, 0xfe, 0x4b, 0x51, 0xfd, 0xbb, 0x02, - 0x8b, 0x6d, 0x39, 0x8b, 0xca, 0xb0, 0xc4, 0xe9, 0xbb, 0x98, 0x06, 0x84, 0x96, 0x14, 0x4d, 0xa9, - 0xe6, 0xad, 0x87, 0x1a, 0xed, 0xc0, 0x2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0xaa, 0x94, 0x8b, 0x57, 0xd7, 0x5a, 0xc1, 0x8e, 0x09, 0xa1, 0x9c, 0xff, 0xca, - 0x1d, 0xd7, 0x4f, 0x5e, 0x75, 0xad, 0xa6, 0x3a, 0x97, 0x72, 0xc7, 0xd8, 0xf5, 0xe2, 0x88, 0x22, - 0x1d, 0xd6, 0x27, 0xb9, 0xba, 0x7d, 0xda, 0x6a, 0xa8, 0xf3, 0xe5, 0xe5, 0xab, 0x6b, 0x6d, 0xa1, - 0xce, 0x2f, 0x03, 0x72, 0xf8, 0xe6, 0xe6, 0xae, 0xa2, 0xdc, 0xde, 0x55, 0x94, 0x6f, 0x77, 0x15, - 0xe5, 0xe3, 0x7d, 0x25, 0x77, 0x7b, 0x5f, 0xc9, 0x7d, 0xb9, 0xaf, 0xe4, 0xde, 0x1e, 0x0c, 0x5c, - 0x71, 0x16, 0xf7, 0x0c, 0xc2, 0x7c, 0x93, 0x30, 0xee, 0x33, 0x6e, 0xba, 0x3d, 0xb2, 0x37, 0x60, - 0x66, 0xb2, 0x6f, 0xfa, 0xac, 0x1f, 0x7b, 0x94, 0xa7, 0x4f, 0xd2, 0xb3, 0x17, 0x7b, 0x63, 0xaf, - 0x92, 0xb8, 0x0c, 0x29, 0xef, 0x2d, 0xca, 0xa7, 0xe6, 0xf9, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x4b, 0xd0, 0x86, 0x84, 0xb9, 0x04, 0x00, 0x00, + // 643 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0xb3, 0x6d, 0xd2, 0x34, 0x9b, 0xd2, 0x9a, 0x6d, 0x0b, 0x6e, 0x84, 0x52, 0x13, 0xa9, + 0x10, 0x8a, 0x6a, 0xa3, 0x80, 0x90, 0x2a, 0x71, 0x49, 0x43, 0x2a, 0x55, 0xa0, 0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3c, 0xd0, + 0x09, 0xf3, 0x0d, 0xc2, 0xb8, 0xcf, 0xb8, 0xe1, 0x0e, 0xc8, 0x9e, 0xc3, 0x8c, 0x64, 0xdf, 0xf0, + 0xd9, 0x30, 0xf6, 0x28, 0x4f, 0x77, 0xc8, 0x8b, 0x57, 0x7b, 0x13, 0x6b, 0x44, 0x9c, 0x87, 0x94, + 0x0f, 0x96, 0xe4, 0x6e, 0x78, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0x42, 0xe1, 0x97, 0xae, 0x6a, + 0x04, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -543,53 +495,6 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PacketData) 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 *PacketData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPacket(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.DestinationPort) > 0 { - i -= len(m.DestinationPort) - copy(dAtA[i:], m.DestinationPort) - i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationPort))) - i-- - dAtA[i] = 0x12 - } - if len(m.SourcePort) > 0 { - i -= len(m.SourcePort) - copy(dAtA[i:], m.SourcePort) - i = encodeVarintPacket(dAtA, i, uint64(len(m.SourcePort))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *Payload) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -615,20 +520,34 @@ func (m *Payload) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Value) i = encodeVarintPacket(dAtA, i, uint64(len(m.Value))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } if len(m.Encoding) > 0 { i -= len(m.Encoding) copy(dAtA[i:], m.Encoding) i = encodeVarintPacket(dAtA, i, uint64(len(m.Encoding))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x22 } if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) i = encodeVarintPacket(dAtA, i, uint64(len(m.Version))) i-- + dAtA[i] = 0x1a + } + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x12 + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintPacket(dAtA, i, uint64(len(m.SourcePort))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -786,7 +705,7 @@ func (m *Packet) Size() (n int) { return n } -func (m *PacketData) Size() (n int) { +func (m *Payload) Size() (n int) { if m == nil { return 0 } @@ -800,17 +719,6 @@ func (m *PacketData) Size() (n int) { if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - l = m.Payload.Size() - n += 1 + l + sovPacket(uint64(l)) - return n -} - -func (m *Payload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l l = len(m.Version) if l > 0 { n += 1 + l + sovPacket(uint64(l)) @@ -1038,7 +946,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data, PacketData{}) + m.Data = append(m.Data, Payload{}) if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1064,7 +972,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } return nil } -func (m *PacketData) Unmarshal(dAtA []byte) error { +func (m *Payload) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1087,10 +995,10 @@ func (m *PacketData) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PacketData: wiretype end group for non-group") + return fmt.Errorf("proto: Payload: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PacketData: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1158,89 +1066,6 @@ func (m *PacketData) Unmarshal(dAtA []byte) error { m.DestinationPort = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPacket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPacket - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPacket - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPacket(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPacket - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Payload) 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 ErrIntOverflowPacket - } - 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: Payload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Payload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } @@ -1272,7 +1097,7 @@ func (m *Payload) Unmarshal(dAtA []byte) error { } m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) } @@ -1304,7 +1129,7 @@ func (m *Payload) Unmarshal(dAtA []byte) error { } m.Encoding = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) } diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index 0f695a050d2..e00258d7a7f 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -12,46 +12,6 @@ import ( "github.com/cosmos/ibc-go/v9/testing/mock" ) -// TestValidate tests the Validate function of Payload -func TestValidate(t *testing.T) { - testCases := []struct { - name string - payload types.Payload - expErr error - }{ - { - "success", - types.NewPayload("ics20-v1", "json", mock.MockPacketData), - nil, - }, - { - "failure: empty version", - types.NewPayload("", "json", mock.MockPacketData), - types.ErrInvalidPayload, - }, - { - "failure: empty encoding", - types.NewPayload("ics20-v2", "", mock.MockPacketData), - types.ErrInvalidPayload, - }, - { - "failure: empty value", - types.NewPayload("ics20-v1", "json", []byte{}), - types.ErrInvalidPayload, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := tc.payload.Validate() - if tc.expErr == nil { - require.NoError(t, err) - } else { - require.ErrorIs(t, err, tc.expErr) - } - }) - } -} - // TestValidateBasic tests the ValidateBasic function of Packet func TestValidateBasic(t *testing.T) { var packet types.Packet @@ -75,7 +35,7 @@ func TestValidateBasic(t *testing.T) { { "failure: empty data", func() { - packet.Data = []types.PacketData{} + packet.Data = []types.Payload{} }, types.ErrInvalidPacket, }, @@ -121,17 +81,36 @@ func TestValidateBasic(t *testing.T) { }, types.ErrInvalidPacket, }, + { + "failure: empty version", + func() { + packet.Data[0].Version = "" + }, + types.ErrInvalidPayload, + }, + { + "failure: empty encoding", + func() { + packet.Data[0].Encoding = "" + }, + types.ErrInvalidPayload, + }, + { + "failure: empty value", + func() { + packet.Data[0].Value = []byte{} + }, + types.ErrInvalidPayload, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - packet = types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, uint64(time.Now().Unix()), types.PacketData{ + packet = types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, uint64(time.Now().Unix()), types.Payload{ SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, - Payload: types.Payload{ - Version: "ics20-v2", - Encoding: "json", - Value: mock.MockPacketData, - }, + Version: "ics20-v2", + Encoding: "json", + Value: mock.MockPacketData, }) tc.malleate() diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 07d85dccd6c..2359841ca7a 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -197,10 +197,10 @@ var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo // MsgSendPacket sends an outgoing IBC packet. type MsgSendPacket struct { - SourceChannel string `protobuf:"bytes,1,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` - TimeoutTimestamp uint64 `protobuf:"varint,2,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` - PacketData []PacketData `protobuf:"bytes,3,rep,name=packet_data,json=packetData,proto3" json:"packet_data"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + SourceChannel string `protobuf:"bytes,1,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + TimeoutTimestamp uint64 `protobuf:"varint,2,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` + Payloads []Payload `protobuf:"bytes,3,rep,name=payloads,proto3" json:"payloads"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgSendPacket) Reset() { *m = MsgSendPacket{} } @@ -530,63 +530,63 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 885 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0x5e, 0x27, 0xdb, 0xd0, 0xbc, 0x4d, 0x9a, 0xe0, 0xd2, 0x76, 0xe5, 0xc2, 0xee, 0x6a, 0x45, - 0x95, 0x90, 0x2a, 0x36, 0x71, 0x11, 0x52, 0x2a, 0xa4, 0xaa, 0x5d, 0x84, 0xe8, 0x61, 0xa5, 0xc8, - 0x0d, 0x3d, 0x00, 0xc2, 0xf2, 0xda, 0xaf, 0x5e, 0x2b, 0x6b, 0x8f, 0xf1, 0x8c, 0xdd, 0xe6, 0x86, - 0x38, 0x71, 0xe4, 0xc8, 0x91, 0x9f, 0x90, 0x03, 0x3f, 0xa2, 0xc7, 0x1e, 0x38, 0x70, 0x42, 0x55, - 0x72, 0xa8, 0xc4, 0xaf, 0x40, 0x9e, 0x99, 0xb5, 0x9d, 0xad, 0x37, 0x09, 0x22, 0x3d, 0xd9, 0x7e, - 0xef, 0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2, 0x69, 0x7c, 0xfb, 0x85, 0x1f, - 0xb0, 0x71, 0x3a, 0xca, 0xaf, 0x46, 0x86, 0xbc, 0x19, 0x06, 0x23, 0x77, 0xdb, 0x27, 0x46, 0xb6, - 0x6b, 0x84, 0xc4, 0x4b, 0x27, 0x48, 0xc5, 0xa5, 0xed, 0xd3, 0xcf, 0xb6, 0xab, 0x57, 0xcf, 0xc3, - 0x18, 0xe9, 0x68, 0x89, 0x5f, 0xd8, 0xee, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x79, 0x25, 0xfe, - 0x36, 0x9e, 0x0a, 0x00, 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x31, 0x6f, 0xdb, 0x46, + 0x14, 0x16, 0x6d, 0xc5, 0xb5, 0x9f, 0xec, 0xd8, 0x65, 0x9a, 0x44, 0x60, 0x52, 0x49, 0x10, 0x1a, + 0xd8, 0x75, 0x60, 0xb2, 0x66, 0x8a, 0x02, 0x0e, 0x8a, 0x06, 0x89, 0x96, 0x66, 0x10, 0x20, 0x30, + 0x6e, 0x86, 0xb6, 0xa8, 0x40, 0x91, 0x2f, 0x14, 0x61, 0x91, 0xc7, 0xf2, 0x48, 0x26, 0xda, 0x8a, + 0x4e, 0x1d, 0x3b, 0x76, 0xec, 0x4f, 0xf0, 0xd0, 0x1f, 0x91, 0xa1, 0x43, 0xc6, 0x4e, 0x45, 0x60, + 0x0d, 0x01, 0xfa, 0x2b, 0x0a, 0xde, 0x9d, 0x48, 0x4a, 0xa1, 0x62, 0x15, 0x55, 0x26, 0x92, 0xef, + 0x7d, 0xef, 0x7b, 0xef, 0x7d, 0xef, 0x78, 0x77, 0x70, 0xdb, 0x1d, 0x58, 0x9a, 0x45, 0x42, 0xd4, + 0xac, 0xa1, 0xe9, 0xfb, 0x38, 0xd2, 0x12, 0x5d, 0x8b, 0x5e, 0xa8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xec, 0x5b, 0x8c, 0x71, 0xc2, 0x95, 0x30, 0xd0, 0x4a, 0x84, 0x12, 0x27, + 0xb0, 0xc1, 0x7f, 0x22, 0x16, 0x51, 0xd3, 0x6f, 0x2d, 0xa8, 0x39, 0x85, 0x88, 0x92, 0x45, 0x80, + 0xfc, 0x29, 0xec, 0x05, 0x21, 0x21, 0xcf, 0xfa, 0xf9, 0xba, 0x65, 0xe2, 0x6c, 0x1b, 0xbb, 0xcc, + 0xde, 0xc9, 0xcc, 0x72, 0x07, 0xb6, 0x39, 0x74, 0x88, 0xae, 0x33, 0x8c, 0xd8, 0x48, 0x6b, 0xba, + 0x52, 0xc8, 0xc5, 0xff, 0xc4, 0xe4, 0x58, 0xfd, 0x9a, 0x21, 0x44, 0xaa, 0x1a, 0x8b, 0xe2, 0xa6, + 0xe5, 0x05, 0xfa, 0x81, 0x09, 0x94, 0x37, 0x99, 0x09, 0xf4, 0x00, 0x36, 0x42, 0xa4, 0xf1, 0x88, + 0x37, 0x7b, 0x55, 0xdf, 0x2f, 0x69, 0xf6, 0x58, 0x9d, 0xc2, 0x0d, 0x06, 0x3d, 0x1d, 0x07, 0x68, + 0x88, 0x30, 0xa1, 0xe2, 0x6b, 0x09, 0xa0, 0x4b, 0x9d, 0x53, 0xbe, 0x02, 0x56, 0x22, 0x61, 0xec, + 0x87, 0x68, 0xa1, 0x9b, 0xa0, 0x3d, 0x23, 0xe1, 0x37, 0x99, 0x79, 0xd5, 0x12, 0x5e, 0x79, 0xb7, + 0x84, 0xdf, 0x81, 0x9c, 0x77, 0xb8, 0x6a, 0xfd, 0xfe, 0x58, 0x63, 0xec, 0x0f, 0xad, 0x33, 0x9f, + 0x3c, 0x1f, 0xa1, 0xed, 0x20, 0x5b, 0x24, 0xff, 0x43, 0xc7, 0x53, 0xd8, 0x35, 0x67, 0xd9, 0xc4, + 0xee, 0xfa, 0x49, 0x29, 0xc7, 0x5c, 0x66, 0x41, 0x36, 0x4f, 0x21, 0x37, 0x81, 0x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, 0xf9, 0x65, 0xed, 0xb3, 0xcf, 0x8f, 0x8a, 0x57, 0xce, 0x71, 0x80, 0x74, + 0xb0, 0xc1, 0x2e, 0x6a, 0xf7, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x51, 0xcd, 0x7c, 0xd2, 0x96, + 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1032,10 +1032,10 @@ func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.PacketData) > 0 { - for iNdEx := len(m.PacketData) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Payloads) > 0 { + for iNdEx := len(m.Payloads) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.PacketData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Payloads[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1440,8 +1440,8 @@ func (m *MsgSendPacket) Size() (n int) { if m.TimeoutTimestamp != 0 { n += 1 + sovTx(uint64(m.TimeoutTimestamp)) } - if len(m.PacketData) > 0 { - for _, e := range m.PacketData { + if len(m.Payloads) > 0 { + for _, e := range m.Payloads { l = e.Size() n += 1 + l + sovTx(uint64(l)) } @@ -2079,7 +2079,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Payloads", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2106,8 +2106,8 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PacketData = append(m.PacketData, PacketData{}) - if err := m.PacketData[len(m.PacketData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Payloads = append(m.Payloads, Payload{}) + if err := m.Payloads[len(m.Payloads)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 077dc65e35e..1f86bfc5386 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -19,7 +19,7 @@ type IBCModule interface { sourceChannel string, destinationChannel string, sequence uint64, - data channeltypesv2.PacketData, + data channeltypesv2.Payload, signer sdk.AccAddress, ) error @@ -27,7 +27,7 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.PacketData, + data channeltypesv2.Payload, relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult @@ -36,7 +36,7 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.PacketData, + data channeltypesv2.Payload, relayer sdk.AccAddress, ) error @@ -45,7 +45,7 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.PacketData, + data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress, ) error diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto index 20d002d2e6e..dc545d329ea 100644 --- a/proto/ibc/core/channel/v2/packet.proto +++ b/proto/ibc/core/channel/v2/packet.proto @@ -20,27 +20,21 @@ message Packet { // timeout timestamp after which the packet times out. uint64 timeout_timestamp = 4; // a list of packet data, each one for a specific application. - repeated PacketData data = 5 [(gogoproto.nullable) = false]; + repeated Payload data = 5 [(gogoproto.nullable) = false]; } -// PacketData contains the source and destination ports and payload for the application -message PacketData { +// Payload contains the source and destination ports and payload for the application (version, encoding, raw bytes) +message Payload { // specifies the source port of the packet. string source_port = 1; // specifies the destination port of the packet. string destination_port = 2; - // the payload to be sent to the application. - Payload payload = 3 [(gogoproto.nullable) = false]; -} - -// Payload holds the version, encoding and raw bytes to be passed to an application -message Payload { // version of the specified application. - string version = 1; + string version = 3; // the encoding used for the provided value. - string encoding = 2; + string encoding = 4; // the raw bytes for the payload. - bytes value = 3; + bytes value = 5; } // Acknowledgement contains a list of all ack results associated with a single packet. diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index b949b506412..bd67ae3e12a 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -79,10 +79,10 @@ message MsgSendPacket { option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.goproto_getters) = false; - string source_channel = 1; - uint64 timeout_timestamp = 2; - repeated PacketData packet_data = 3 [(gogoproto.nullable) = false]; - string signer = 4; + string source_channel = 1; + uint64 timeout_timestamp = 2; + repeated Payload payloads = 3 [(gogoproto.nullable) = false]; + string signer = 4; } // MsgSendPacketResponse defines the Msg/SendPacket response type. diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index e486e7a29d2..57a9b98b2f5 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -10,8 +10,8 @@ import ( ) // MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned. -func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, packetData channeltypesv2.PacketData) (channeltypesv2.Packet, error) { - msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), packetData) +func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channeltypesv2.Payload) (channeltypesv2.Packet, error) { + msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), payload) res, err := endpoint.Chain.SendMsgs(msgSendPacket) if err != nil { @@ -35,7 +35,7 @@ func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, packetData chan if err != nil { return channeltypesv2.Packet{}, err } - packet := channeltypesv2.NewPacket(sendResponse.Sequence, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, packetData) + packet := channeltypesv2.NewPacket(sendResponse.Sequence, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, payload) return packet, nil } diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index 74c6ca7c543..a210285d40b 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,8 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error - OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error + OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index dcf891b2b51..2f44dad7350 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -31,28 +31,28 @@ func NewIBCModule() IBCModule { } } -func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { +func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error { if im.IBCApp.OnSendPacket != nil { return im.IBCApp.OnSendPacket(ctx, sourceChannel, destinationChannel, sequence, data, signer) } return nil } -func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { +func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { if im.IBCApp.OnRecvPacket != nil { return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer) } return MockRecvPacketResult } -func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error { if im.IBCApp.OnAcknowledgementPacket != nil { return im.IBCApp.OnAcknowledgementPacket(ctx, sourceChannel, destinationChannel, data, acknowledgement, relayer) } return nil } -func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { +func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { return im.IBCApp.OnTimeoutPacket(ctx, sourceChannel, destinationChannel, data, relayer) } diff --git a/testing/mock/v2/mock.go b/testing/mock/v2/mock.go index c6403b12364..41582217070 100644 --- a/testing/mock/v2/mock.go +++ b/testing/mock/v2/mock.go @@ -20,14 +20,12 @@ var ( } ) -func NewMockPacketData(sourcePort, destPort string) channeltypesv2.PacketData { - return channeltypesv2.PacketData{ +func NewMockPayload(sourcePort, destPort string) channeltypesv2.Payload { + return channeltypesv2.Payload{ SourcePort: sourcePort, DestinationPort: destPort, - Payload: channeltypesv2.Payload{ - Encoding: "json", - Value: mockv1.MockPacketData, - Version: mockv1.Version, - }, + Encoding: "json", + Value: mockv1.MockPacketData, + Version: mockv1.Version, } } From c2e20c683aee71252517f241e94527f52174152a Mon Sep 17 00:00:00 2001 From: chatton Date: Mon, 21 Oct 2024 11:20:30 +0100 Subject: [PATCH 089/172] chore: remove copyloopvar check --- .golangci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index dc20f7102ee..99a7c1eadf8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,6 @@ run: linters: disable-all: true enable: - - copyloopvar - errcheck - gci - goconst From 6078dda8f39072bdafac3d06cc4c136cb43e2a9b Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 21 Oct 2024 11:55:12 +0100 Subject: [PATCH 090/172] chore: further renaming of packetdata to payload (#7485) --- .../core/04-channel/v2/keeper/msg_server.go | 10 +- modules/core/04-channel/v2/keeper/packet.go | 14 +-- .../core/04-channel/v2/keeper/packet_test.go | 46 ++++---- .../core/04-channel/v2/types/commitment.go | 8 +- modules/core/04-channel/v2/types/msgs_test.go | 4 +- modules/core/04-channel/v2/types/packet.go | 14 +-- modules/core/04-channel/v2/types/packet.pb.go | 108 +++++++++--------- .../core/04-channel/v2/types/packet_test.go | 22 ++-- proto/ibc/core/channel/v2/packet.proto | 4 +- 9 files changed, 115 insertions(+), 115 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 00d631bbe0f..0d06ba8e792 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -71,7 +71,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck recvResults[r.AppName] = r.RecvPacketResult } - for _, pd := range msg.Packet.Data { + for _, pd := range msg.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, recvResults[pd.DestinationPort].Acknowledgement, relayer) if err != nil { @@ -116,7 +116,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack AcknowledgementResults: []channeltypesv2.AcknowledgementResult{}, } - for _, pd := range msg.Packet.Data { + for _, pd := range msg.Packet.Payloads { // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful. cacheCtx, writeFn = sdkCtx.CacheContext() cb := k.Router.Route(pd.DestinationPort) @@ -136,13 +136,13 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack }) } - // note this should never happen as the packet data would have had to be empty. + // note this should never happen as the payload would have had to be empty. if len(ack.AcknowledgementResults) == 0 { sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) } - // NOTE: TBD how we will handle async acknowledgements with more than one packet data. + // NOTE: TBD how we will handle async acknowledgements with more than one payload. isAsync := slices.ContainsFunc(ack.AcknowledgementResults, func(ackResult channeltypesv2.AcknowledgementResult) bool { return ackResult.RecvPacketResult.Status == channeltypesv2.PacketStatus_Async }) @@ -190,7 +190,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout return nil, errorsmod.Wrap(err, "timeout packet verification failed") } - for _, pd := range timeout.Packet.Data { + for _, pd := range timeout.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel, pd, signer) if err != nil { diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 59190861f86..d625b5f71ff 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -28,7 +28,7 @@ func (k *Keeper) sendPacket( // Lookup channel associated with our source channel to retrieve the destination channel channel, ok := k.GetChannel(ctx, sourceChannel) if !ok { - // TODO: figure out how aliasing will work when more than one packet data is sent. + // TODO: figure out how aliasing will work when more than one payload is sent. channel, ok = k.convertV1Channel(ctx, payloads[0].SourcePort, sourceChannel) if !ok { return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) @@ -107,8 +107,8 @@ func (k *Keeper) recvPacket( // packet sender is our channel's counterparty channel id. channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - // TODO: figure out how aliasing will work when more than one packet data is sent. - channel, ok = k.convertV1Channel(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) + // TODO: figure out how aliasing will work when more than one payload is sent. + channel, ok = k.convertV1Channel(ctx, packet.Payloads[0].DestinationPort, packet.DestinationChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } @@ -197,8 +197,8 @@ func (k Keeper) WriteAcknowledgement( // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 - if len(ack.AcknowledgementResults) != len(packet.Data) { - return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of acknowledgement results %d does not match length of packet data %d", len(ack.AcknowledgementResults), len(packet.Data)) + if len(ack.AcknowledgementResults) != len(packet.Payloads) { + return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of acknowledgement results %d does not match length of payload %d", len(ack.AcknowledgementResults), len(packet.Payloads)) } // set the acknowledgement so that it can be verified on the other side @@ -288,8 +288,8 @@ func (k *Keeper) timeoutPacket( // that the packet was indeed sent by our counterparty. channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - // TODO: figure out how aliasing will work when more than one packet data is sent. - channel, ok = k.convertV1Channel(ctx, packet.Data[0].SourcePort, packet.SourceChannel) + // TODO: figure out how aliasing will work when more than one payload is sent. + channel, ok = k.convertV1Channel(ctx, packet.Payloads[0].SourcePort, packet.SourceChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index 871aa3479c1..a01c5959f64 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { "success with later packet", func() { // send the same packet earlier so next packet send should be sequence 2 - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Data) + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err) expSequence = 2 }, @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { "packet failed basic validation", func() { // invalid data - packet.Data = nil + packet.Payloads = nil }, channeltypes.ErrInvalidPacket, }, @@ -97,20 +97,20 @@ func (suite *KeeperTestSuite) TestSendPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // create standard packet that can be malleated packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, - timeoutTimestamp, packetData) + timeoutTimestamp, payload) expSequence = 1 // malleate the test case tc.malleate() // send packet - seq, destChannel, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Data) + seq, destChannel, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Payloads) expPass := tc.expError == nil if expPass { @@ -204,12 +204,12 @@ func (suite *KeeperTestSuite) TestRecvPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // send packet - packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) suite.Require().NoError(err) tc.malleate() @@ -298,13 +298,13 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // create standard packet that can be malleated packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, - timeoutTimestamp, packetData) + timeoutTimestamp, payload) // create standard ack that can be malleated ack = types.Acknowledgement{ @@ -390,8 +390,8 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { { "failure: packet commitment bytes differ", func() { - // change packet data after send to acknowledge different packet - packet.Data[0].Value = []byte("different value") + // change payload after send to acknowledge different packet + packet.Payloads[0].Value = []byte("different value") }, channeltypes.ErrInvalidPacket, }, @@ -414,12 +414,12 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { freezeClient = false - packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // send packet - packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, packetData) + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) suite.Require().NoError(err) err = path.EndpointB.MsgRecvPacket(packet) @@ -467,7 +467,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { func() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") }, nil, @@ -477,7 +477,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { func() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") packet.SourceChannel = ibctesting.InvalidID @@ -489,7 +489,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { func() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") packet.DestinationChannel = unusedChannel @@ -503,7 +503,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") }, channeltypes.ErrTimeoutNotReached, @@ -517,11 +517,11 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { "failure: packet does not match commitment", func() { _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") // try to timeout packet with different data - packet.Data[0].Value = []byte("different value") + packet.Payloads[0].Value = []byte("different value") }, channeltypes.ErrInvalidPacket, }, @@ -530,7 +530,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { func() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") freezeClient = true @@ -542,7 +542,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { func() { // send packet _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, - packet.TimeoutTimestamp, packet.Data) + packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") // set packet receipt to mock a valid past receive @@ -564,13 +564,13 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { path.SetupV2() // create default packet with a timed out timestamp - packetData := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) + payload := mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) // test cases may mutate timeout values packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, - timeoutTimestamp, packetData) + timeoutTimestamp, payload) tc.malleate() diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 8a14e77f91f..6d815f3da46 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -7,7 +7,7 @@ import ( ) // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(packetData) from a given packet. +// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(payload) from a given packet. // This results in a fixed length preimage. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. @@ -17,15 +17,15 @@ func CommitPacket(packet Packet) []byte { destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) buf = append(buf, destIDHash[:]...) - for _, data := range packet.Data { - buf = append(buf, hashPayload(data)...) + for _, payload := range packet.Payloads { + buf = append(buf, hashPayload(payload)...) } hash := sha256.Sum256(buf) return hash[:] } -// hashPayload returns the hash of the packet data. +// hashPayload returns the hash of the payload. func hashPayload(data Payload) []byte { var buf []byte sourceHash := sha256.Sum256([]byte(data.SourcePort)) diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index a5bc812cc1d..2e90f34a5ea 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -181,7 +181,7 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { expError: types.ErrInvalidPayload, }, { - name: "failure: invalid packetdata", + name: "failure: invalid payload", malleate: func() { msg.Payloads[0].DestinationPort = "" }, @@ -230,7 +230,7 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { { name: "failure: invalid packet", malleate: func() { - msg.Packet.Data = []types.Payload{} + msg.Packet.Payloads = []types.Payload{} }, expError: types.ErrInvalidPacket, }, diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index c00e7a37e73..8c602162fc9 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -9,17 +9,17 @@ import ( ) // NewPacket constructs a new packet. -func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, data ...Payload) Packet { +func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, payloads ...Payload) Packet { return Packet{ Sequence: sequence, SourceChannel: sourceChannel, DestinationChannel: destinationChannel, TimeoutTimestamp: timeoutTimestamp, - Data: data, + Payloads: payloads, } } -// NewPayload constructs a new PacketData +// NewPayload constructs a new Payload func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Payload { return Payload{ SourcePort: sourcePort, @@ -32,13 +32,13 @@ func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Pa // ValidateBasic validates that a Packet satisfies the basic requirements. func (p Packet) ValidateBasic() error { - if len(p.Data) == 0 { - return errorsmod.Wrap(ErrInvalidPacket, "packet data must not be empty") + if len(p.Payloads) == 0 { + return errorsmod.Wrap(ErrInvalidPacket, "payloads must not be empty") } - for _, pd := range p.Data { + for _, pd := range p.Payloads { if err := pd.ValidateBasic(); err != nil { - return errorsmod.Wrap(err, "invalid Packet Data") + return errorsmod.Wrap(err, "invalid Payload") } } diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go index 0811b9e52b4..a264047c3d6 100644 --- a/modules/core/04-channel/v2/types/packet.pb.go +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -71,8 +71,8 @@ type Packet struct { DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` // timeout timestamp after which the packet times out. TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` - // a list of packet data, each one for a specific application. - Data []Payload `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` + // a list of payloads, each one for a specific application. + Payloads []Payload `protobuf:"bytes,5,rep,name=payloads,proto3" json:"payloads"` } func (m *Packet) Reset() { *m = Packet{} } @@ -136,9 +136,9 @@ func (m *Packet) GetTimeoutTimestamp() uint64 { return 0 } -func (m *Packet) GetData() []Payload { +func (m *Packet) GetPayloads() []Payload { if m != nil { - return m.Data + return m.Payloads } return nil } @@ -390,48 +390,48 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/packet.proto", fileDescriptor_2f814aba9ca97169) } var fileDescriptor_2f814aba9ca97169 = []byte{ - // 643 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xb3, 0x6d, 0xd2, 0x34, 0x9b, 0xd2, 0x9a, 0x6d, 0x0b, 0x6e, 0x84, 0x52, 0x13, 0xa9, - 0x10, 0x8a, 0x6a, 0xa3, 0x80, 0x90, 0x2a, 0x71, 0x49, 0x43, 0x2a, 0x55, 0xa0, 0x10, 0xd9, 0x09, - 0x52, 0xb9, 0x58, 0x9b, 0xcd, 0xca, 0xb5, 0x6a, 0x7b, 0x8d, 0x77, 0xed, 0xaa, 0x12, 0x4f, 0x50, - 0x09, 0x89, 0x17, 0xe8, 0x81, 0x33, 0x2f, 0xd2, 0x63, 0x8f, 0x9c, 0x10, 0xb4, 0x2f, 0x82, 0xb2, - 0x76, 0xa3, 0x24, 0x84, 0x93, 0x3d, 0xff, 0x7c, 0xb3, 0x9e, 0x7f, 0xbc, 0x1a, 0xa8, 0xb9, 0x03, - 0x62, 0x10, 0x16, 0x51, 0x83, 0x9c, 0xe0, 0x20, 0xa0, 0x9e, 0x91, 0x34, 0x8c, 0x10, 0x93, 0x53, - 0x2a, 0xf4, 0x30, 0x62, 0x82, 0xa1, 0x75, 0x77, 0x40, 0xf4, 0x11, 0xa1, 0x67, 0x84, 0x9e, 0x34, - 0x2a, 0x1b, 0x0e, 0x73, 0x98, 0xcc, 0x1b, 0xa3, 0xb7, 0x14, 0xad, 0xfd, 0x01, 0x70, 0xa9, 0x2b, - 0x6b, 0x51, 0x05, 0x2e, 0x73, 0xfa, 0x39, 0xa6, 0x01, 0xa1, 0x2a, 0xd0, 0x40, 0x3d, 0x6f, 0x8e, - 0x63, 0xb4, 0x03, 0x57, 0x39, 0x8b, 0x23, 0x42, 0x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0x56, 0x16, 0x52, 0xee, 0x10, 0xbb, 0x5e, 0x1c, 0x51, 0x54, 0x83, 0xeb, 0xd3, - 0x5c, 0xd3, 0x3a, 0xee, 0xb4, 0x94, 0xc5, 0x4a, 0xe9, 0xe2, 0x52, 0x2b, 0x34, 0xf9, 0x79, 0x40, - 0x0e, 0x3e, 0x5e, 0xdd, 0x54, 0xc1, 0xf5, 0x4d, 0x15, 0xfc, 0xbe, 0xa9, 0x82, 0x6f, 0xb7, 0xd5, - 0xdc, 0xf5, 0x6d, 0x35, 0xf7, 0xf3, 0xb6, 0x9a, 0xfb, 0xf4, 0xc6, 0x71, 0xc5, 0x49, 0x3c, 0xd0, - 0x09, 0xf3, 0x0d, 0xc2, 0xb8, 0xcf, 0xb8, 0xe1, 0x0e, 0xc8, 0x9e, 0xc3, 0x8c, 0x64, 0xdf, 0xf0, - 0xd9, 0x30, 0xf6, 0x28, 0x4f, 0x77, 0xc8, 0x8b, 0x57, 0x7b, 0x13, 0x6b, 0x44, 0x9c, 0x87, 0x94, - 0x0f, 0x96, 0xe4, 0x6e, 0x78, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0x42, 0xe1, 0x97, 0xae, 0x6a, - 0x04, 0x00, 0x00, + // 645 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xc1, 0x6a, 0x13, 0x41, + 0x18, 0xc7, 0x33, 0x6d, 0xd2, 0x24, 0x93, 0xda, 0xae, 0xd3, 0x56, 0xb7, 0x41, 0xd2, 0x35, 0x50, + 0x8d, 0x95, 0xee, 0x4a, 0xf4, 0x52, 0x10, 0x21, 0x8d, 0x29, 0x14, 0x25, 0x86, 0xdd, 0x44, 0xa8, + 0x97, 0x65, 0x32, 0x19, 0xd2, 0xa5, 0xbb, 0x3b, 0xeb, 0xce, 0xec, 0x96, 0x82, 0x4f, 0x50, 0x10, + 0x7c, 0x81, 0x1e, 0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, 0x3c, 0x79, 0x4b, 0x5e, 0xbc, 0xda, 0x9f, 0x7a, 0x4e, 0xc4, 0x45, + 0x40, 0x79, 0x7f, 0x45, 0xbe, 0x11, 0x2f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x59, 0x03, + 0x6e, 0x72, 0x04, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -454,10 +454,10 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Data) > 0 { - for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Payloads) > 0 { + for iNdEx := len(m.Payloads) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Payloads[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -696,8 +696,8 @@ func (m *Packet) Size() (n int) { if m.TimeoutTimestamp != 0 { n += 1 + sovPacket(uint64(m.TimeoutTimestamp)) } - if len(m.Data) > 0 { - for _, e := range m.Data { + if len(m.Payloads) > 0 { + for _, e := range m.Payloads { l = e.Size() n += 1 + l + sovPacket(uint64(l)) } @@ -919,7 +919,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Payloads", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -946,8 +946,8 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data, Payload{}) - if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Payloads = append(m.Payloads, Payload{}) + if err := m.Payloads[len(m.Payloads)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index e00258d7a7f..0a8b079b0a5 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -26,30 +26,30 @@ func TestValidateBasic(t *testing.T) { nil, }, { - "failure: packet data is nil", + "failure: payloads is nil", func() { - packet.Data = nil + packet.Payloads = nil }, types.ErrInvalidPacket, }, { - "failure: empty data", + "failure: empty payload", func() { - packet.Data = []types.Payload{} + packet.Payloads = []types.Payload{} }, types.ErrInvalidPacket, }, { - "failure: invalid data source port ID", + "failure: invalid payload source port ID", func() { - packet.Data[0].SourcePort = "" + packet.Payloads[0].SourcePort = "" }, host.ErrInvalidID, }, { - "failure: invalid data dest port ID", + "failure: invalid payload dest port ID", func() { - packet.Data[0].DestinationPort = "" + packet.Payloads[0].DestinationPort = "" }, host.ErrInvalidID, }, @@ -84,21 +84,21 @@ func TestValidateBasic(t *testing.T) { { "failure: empty version", func() { - packet.Data[0].Version = "" + packet.Payloads[0].Version = "" }, types.ErrInvalidPayload, }, { "failure: empty encoding", func() { - packet.Data[0].Encoding = "" + packet.Payloads[0].Encoding = "" }, types.ErrInvalidPayload, }, { "failure: empty value", func() { - packet.Data[0].Value = []byte{} + packet.Payloads[0].Value = []byte{} }, types.ErrInvalidPayload, }, diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto index dc545d329ea..98d581915f9 100644 --- a/proto/ibc/core/channel/v2/packet.proto +++ b/proto/ibc/core/channel/v2/packet.proto @@ -19,8 +19,8 @@ message Packet { string destination_channel = 3; // timeout timestamp after which the packet times out. uint64 timeout_timestamp = 4; - // a list of packet data, each one for a specific application. - repeated Payload data = 5 [(gogoproto.nullable) = false]; + // a list of payloads, each one for a specific application. + repeated Payload payloads = 5 [(gogoproto.nullable) = false]; } // Payload contains the source and destination ports and payload for the application (version, encoding, raw bytes) From dd675cf161bdf4e372bc5104eef95b8d76a8db0c Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 21 Oct 2024 15:04:09 +0300 Subject: [PATCH 091/172] chore: generate distinct channel identifiers in testing library. (#7489) --- modules/core/04-channel/v2/keeper/msg_server_test.go | 4 ++-- testing/endpoint.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index d30d8d1d6d1..028489c8315 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -170,7 +170,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: NoOp", malleate: func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.SourceChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) expectedAck = channeltypesv2.Acknowledgement{} }, }, @@ -228,7 +228,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().NoError(err) // packet receipt should be written - _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.SourceChannel, packet.Sequence) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) suite.Require().True(ok) ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) diff --git a/testing/endpoint.go b/testing/endpoint.go index cf4ade13155..1c69b35dc32 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -188,6 +188,7 @@ func (endpoint *Endpoint) ProvideCounterparty() (err error) { // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { + endpoint.IncrementNextChannelSequence() msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // create channel From 1cf35395c03fd8aececdf6bd72017a7f9d1cc388 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 21 Oct 2024 15:19:52 +0300 Subject: [PATCH 092/172] chore: limit packet data to length of one. (#7484) --- modules/core/04-channel/v2/types/msgs_test.go | 28 +++++++++++++++++++ modules/core/04-channel/v2/types/packet.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 2e90f34a5ea..da7779f0602 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -175,6 +175,13 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { }, { name: "failure: invalid length for payload", + malleate: func() { + msg.Payloads = []types.Payload{{}, {}} + }, + expError: types.ErrInvalidPayload, + }, + { + name: "failure: invalid packetdata", malleate: func() { msg.Payloads = []types.Payload{} }, @@ -241,6 +248,13 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() { }, expError: commitmenttypes.ErrInvalidProof, }, + { + name: "failure: invalid length for packet payloads", + malleate: func() { + msg.Packet.Payloads = []types.Payload{{}, {}} + }, + expError: types.ErrInvalidPacket, + }, { name: "failure: invalid signer", malleate: func() { @@ -288,6 +302,13 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { }, expError: commitmenttypes.ErrInvalidProof, }, + { + name: "failure: invalid length for packet payloads", + malleate: func() { + msg.Packet.Payloads = []types.Payload{{}, {}} + }, + expError: types.ErrInvalidPacket, + }, { name: "failure: invalid signer", malleate: func() { @@ -345,6 +366,13 @@ func (s *TypesTestSuite) TestMsgTimeoutValidateBasic() { }, expError: ibcerrors.ErrInvalidAddress, }, + { + name: "failure: invalid length for packet payloads", + malleate: func() { + msg.Packet.Payloads = []types.Payload{{}, {}} + }, + expError: types.ErrInvalidPacket, + }, { name: "failure: invalid packet", malleate: func() { diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 8c602162fc9..7be9e0b326a 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -32,7 +32,7 @@ func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Pa // ValidateBasic validates that a Packet satisfies the basic requirements. func (p Packet) ValidateBasic() error { - if len(p.Payloads) == 0 { + if len(p.Payloads) != 1 { return errorsmod.Wrap(ErrInvalidPacket, "payloads must not be empty") } From cc51d29afaa243240fb2576de6f3f699cbda249e Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 21 Oct 2024 13:25:42 +0100 Subject: [PATCH 093/172] chore: remove fallback logic for GetChannel in timeout handler (#7490) * chore: remove fallback logic for GetChannel in timeout handler * Update modules/core/04-channel/v2/keeper/packet.go Co-authored-by: DimitrisJim --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/keeper/packet.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index d625b5f71ff..193fcadeb83 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -288,11 +288,7 @@ func (k *Keeper) timeoutPacket( // that the packet was indeed sent by our counterparty. channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - // TODO: figure out how aliasing will work when more than one payload is sent. - channel, ok = k.convertV1Channel(ctx, packet.Payloads[0].SourcePort, packet.SourceChannel) - if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) - } + return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } if channel.CounterpartyChannelId != packet.DestinationChannel { return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) From 1462fd2e92228d857c3e5d52d8d94e0ce5c78253 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 12:09:41 +0300 Subject: [PATCH 094/172] chore: remove unecessary KeyChannelStorePrefix (#7496) --- modules/core/04-channel/v2/keeper/keeper.go | 2 +- modules/core/24-host/channel_keys.go | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 0880ed7b6e0..d397f7d4bdd 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -56,7 +56,7 @@ func (Keeper) Logger(ctx context.Context) log.Logger { } func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.KVStore { - channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelStorePrefix, channelID)) + channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelPrefix, channelID)) return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index 49eed183c25..b988601a870 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -2,8 +2,6 @@ package host import "fmt" -var KeyChannelStorePrefix = []byte("channels") - const ( KeyChannelEndPrefix = "channelEnds" KeyChannelPrefix = "channels" From fb7509b16d72163dc5a843dfc8468f94033ecd75 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 12:19:43 +0300 Subject: [PATCH 095/172] tests: fix ProvideCounterparty test. (#7501) --- .../04-channel/v2/keeper/msg_server_test.go | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 028489c8315..58587d44b89 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -272,58 +272,66 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { }, nil, }, + { + "failure: creator not set", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) + }, + ibcerrors.ErrUnauthorized, + }, { "failure: signer does not match creator", func() { - msg.Signer = path.EndpointB.Chain.SenderAccount.GetAddress().String() + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID, ibctesting.TestAccAddress) }, ibcerrors.ErrUnauthorized, }, - /* // Account sequence mismatch, expected 5, got 6. :thinking: { - "failure: counterparty does not already exists", + "failure: channel must already exist", func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) }, channeltypesv2.ErrInvalidChannel, }, - */ } for _, tc := range cases { - tc := tc - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupClients() + suite.Run(tc.name, func() { + suite.SetupTest() - suite.Require().NoError(path.EndpointA.CreateChannel()) - suite.Require().NoError(path.EndpointB.CreateChannel()) + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupClients() - signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = channeltypesv2.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) + suite.Require().NoError(path.EndpointA.CreateChannel()) + suite.Require().NoError(path.EndpointB.CreateChannel()) - tc.malleate() + signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() + msg = channeltypesv2.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) - res, err := path.EndpointA.Chain.SendMsgs(msg) + tc.malleate() + + res, err := path.EndpointA.Chain.SendMsgs(msg) - expPass := tc.expError == nil - if expPass { - suite.Require().NotNil(res) - suite.Require().Nil(err) + expPass := tc.expError == nil + if expPass { + suite.Require().NotNil(res) + suite.Require().Nil(err) - // Assert counterparty channel id filled in and creator deleted - channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) + // Assert counterparty channel id filled in and creator deleted + channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().False(found) + _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().False(found) - seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(seq, uint64(1)) - } else { - suite.Require().Error(err) - } + seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(seq, uint64(1)) + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) + } + }) } } From 610bf85213a1c895a480b328bb23f32ca9f2e8c3 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 12:26:57 +0300 Subject: [PATCH 096/172] chore: clean up ctx unwrapping in channel/v2/keeper. (#7497) --- modules/core/04-channel/v2/keeper/keeper.go | 9 +++------ modules/core/04-channel/v2/types/keys.go | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index d397f7d4bdd..eb046b3cd5d 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -81,8 +81,7 @@ func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channe // GetCreator returns the creator of the channel. func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - bz := k.ChannelStore(sdkCtx, channelID).Get([]byte(types.CreatorKey)) + bz := k.ChannelStore(ctx, channelID).Get([]byte(types.CreatorKey)) if len(bz) == 0 { return "", false } @@ -92,14 +91,12 @@ func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool // SetCreator sets the creator of the channel. func (k *Keeper) SetCreator(ctx context.Context, channelID, creator string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, channelID).Set([]byte(types.CreatorKey), []byte(creator)) + k.ChannelStore(ctx, channelID).Set([]byte(types.CreatorKey), []byte(creator)) } // DeleteCreator deletes the creator associated with the channel. func (k *Keeper) DeleteCreator(ctx context.Context, channelID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.ChannelStore(sdkCtx, channelID).Delete([]byte(types.CreatorKey)) + k.ChannelStore(ctx, channelID).Delete([]byte(types.CreatorKey)) } // GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index af3f68c5449..f751a92b3f1 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -4,12 +4,12 @@ const ( // SubModuleName defines the channelv2 module name. SubModuleName = "channelv2" - // ChannelKey is the key used to store channel in the client store. + // ChannelKey is the key used to store channels in the channel store. // the channel key is imported from types instead of host because // the channel key is not a part of the ics-24 host specification ChannelKey = "channel" - // CreatorKey is the key used to store the client creator in the client store + // CreatorKey is the key used to store the channel creator in the channel store // the creator key is imported from types instead of host because // the creator key is not a part of the ics-24 host specification CreatorKey = "creator" From e0a60a025df2ab565dc79162024f315370582f08 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 12:56:54 +0300 Subject: [PATCH 097/172] chore: remove notion of protocol version, revert packet/v1 diffs. (#7498) --- modules/core/04-channel/types/channel.pb.go | 280 ++++--------------- modules/core/04-channel/types/msgs_test.go | 1 - modules/core/04-channel/types/packet.go | 98 +------ modules/core/04-channel/types/packet_test.go | 39 +-- proto/ibc/core/channel/v1/channel.proto | 21 -- 5 files changed, 65 insertions(+), 374 deletions(-) diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index 636f44c2bf1..2263ee69c4e 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -108,41 +108,6 @@ func (Order) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c3a07336710636a0, []int{1} } -// IBCVersion defines the version that the IBC packet intends to use. -// This allows asynchronous upgrades over time as unsupported IBC Versions -// will simply be rejected by the receiver and timed out on sender. -type IBCVersion int32 - -const ( - // zero-value for IBC version. - // This will be treated as a classic packet - IBC_VERSION_UNSPECIFIED IBCVersion = 0 - // IBC version 1 implements the Classic protocol - IBC_VERSION_1 IBCVersion = 1 - // IBC version 2 implements the Eureka protocol - IBC_VERSION_2 IBCVersion = 2 -) - -var IBCVersion_name = map[int32]string{ - 0: "IBC_VERSION_UNSPECIFIED", - 1: "IBC_VERSION_1", - 2: "IBC_VERSION_2", -} - -var IBCVersion_value = map[string]int32{ - "IBC_VERSION_UNSPECIFIED": 0, - "IBC_VERSION_1": 1, - "IBC_VERSION_2": 2, -} - -func (x IBCVersion) String() string { - return proto.EnumName(IBCVersion_name, int32(x)) -} - -func (IBCVersion) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{2} -} - // 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. @@ -313,12 +278,6 @@ type Packet struct { TimeoutHeight types.Height `protobuf:"bytes,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"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"` - // which IBC version to use to commit this packet - ProtocolVersion IBCVersion `protobuf:"varint,9,opt,name=protocol_version,json=protocolVersion,proto3,enum=ibc.core.channel.v1.IBCVersion" json:"protocol_version,omitempty"` - // version which application should use to process the packet data - AppVersion string `protobuf:"bytes,10,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` - // encoding to be used TODO clearer message - Encoding string `protobuf:"bytes,11,opt,name=encoding,proto3" json:"encoding,omitempty"` } func (m *Packet) Reset() { *m = Packet{} } @@ -647,7 +606,6 @@ func (m *Params) GetUpgradeTimeout() Timeout { func init() { proto.RegisterEnum("ibc.core.channel.v1.State", State_name, State_value) proto.RegisterEnum("ibc.core.channel.v1.Order", Order_name, Order_value) - proto.RegisterEnum("ibc.core.channel.v1.IBCVersion", IBCVersion_name, IBCVersion_value) proto.RegisterType((*Channel)(nil), "ibc.core.channel.v1.Channel") proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v1.IdentifiedChannel") proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v1.Counterparty") @@ -662,71 +620,66 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 1024 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0x8e, 0x53, 0xe7, 0xeb, 0x4d, 0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, 0xd4, 0x7b, 0x7b, 0x55, 0x97, 0xde, 0x5d, 0xd5, - 0xa5, 0x3f, 0xae, 0xea, 0xd2, 0x4f, 0xd7, 0xf5, 0xcc, 0xbb, 0xeb, 0x7a, 0xe6, 0xb7, 0xeb, 0x7a, - 0xe6, 0xc5, 0xe3, 0xa1, 0x4f, 0x2f, 0x26, 0xe7, 0x4d, 0x97, 0x8c, 0x5b, 0x2e, 0x89, 0xc7, 0x24, - 0x6e, 0xf9, 0xe7, 0xee, 0xc3, 0x21, 0x69, 0x5d, 0x3e, 0x6e, 0x8d, 0x89, 0x37, 0x19, 0xe1, 0x98, - 0x7f, 0x02, 0x3d, 0xfa, 0xfc, 0x61, 0xfa, 0x4d, 0x45, 0x5f, 0x87, 0x38, 0x3e, 0xcf, 0xb3, 0xe7, - 0xe6, 0xb3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x19, 0x54, 0x78, 0x4b, 0x74, 0x09, 0x00, 0x00, + // 937 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x6f, 0xe2, 0xc6, + 0x1b, 0xc6, 0xc4, 0xfc, 0x7b, 0x93, 0x80, 0x33, 0xf9, 0xfd, 0x52, 0xcb, 0x4a, 0xc1, 0x8b, 0x5a, + 0x95, 0x4d, 0xb5, 0xb0, 0xd9, 0x56, 0x55, 0xb7, 0xb7, 0x04, 0xbc, 0x8b, 0xb5, 0x14, 0x90, 0x81, + 0x43, 0xf7, 0x82, 0x8c, 0x3d, 0x05, 0x6b, 0xc1, 0x43, 0xed, 0x81, 0xd5, 0xaa, 0xe7, 0x4a, 0x2b, + 0x4e, 0xfd, 0x02, 0x48, 0x95, 0xfa, 0x15, 0xfa, 0x21, 0xf6, 0xb8, 0xc7, 0x3d, 0x55, 0x55, 0xf2, + 0x1d, 0x7a, 0xae, 0x3c, 0x33, 0x0e, 0x10, 0x45, 0x51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 0xb8, + 0xd5, 0x3d, 0x2b, 0x30, 0xc2, 0x51, 0x19, 0x0a, 0x9c, 0x35, 0x68, 0xb3, 0x5f, 0xa3, 0xa1, 0x48, + 0xda, 0xe1, 0x6a, 0xad, 0xe7, 0x6e, 0x80, 0xa8, 0x7d, 0xce, 0x89, 0x19, 0xa2, 0x7d, 0x61, 0x72, + 0xe1, 0xcb, 0xde, 0xbb, 0xab, 0xa2, 0xf4, 0xfe, 0xaa, 0x28, 0xfd, 0x71, 0x55, 0x94, 0x7e, 0xbe, + 0x2e, 0x26, 0xde, 0x5f, 0x17, 0x13, 0x1f, 0xae, 0x8b, 0x89, 0x97, 0x4f, 0xc7, 0x1e, 0x9d, 0x2c, + 0x46, 0x55, 0x87, 0xcc, 0x6a, 0x0e, 0x09, 0x67, 0x24, 0xac, 0x79, 0x23, 0xe7, 0xd1, 0x98, 0xd4, + 0x96, 0x4f, 0x6b, 0x33, 0xe2, 0x2e, 0xa6, 0x38, 0xe4, 0x9f, 0x08, 0x8f, 0xbf, 0x7c, 0x14, 0x7f, + 0x73, 0xd0, 0x37, 0x73, 0x1c, 0x8e, 0xd2, 0xec, 0x1b, 0xe1, 0x8b, 0xbf, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x39, 0xda, 0x3d, 0x84, 0x94, 0x08, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -928,25 +881,6 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Encoding) > 0 { - i -= len(m.Encoding) - copy(dAtA[i:], m.Encoding) - i = encodeVarintChannel(dAtA, i, uint64(len(m.Encoding))) - i-- - dAtA[i] = 0x5a - } - if len(m.AppVersion) > 0 { - i -= len(m.AppVersion) - copy(dAtA[i:], m.AppVersion) - i = encodeVarintChannel(dAtA, i, uint64(len(m.AppVersion))) - i-- - dAtA[i] = 0x52 - } - if m.ProtocolVersion != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProtocolVersion)) - i-- - dAtA[i] = 0x48 - } if m.TimeoutTimestamp != 0 { i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) i-- @@ -1363,17 +1297,6 @@ func (m *Packet) Size() (n int) { if m.TimeoutTimestamp != 0 { n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) } - if m.ProtocolVersion != 0 { - n += 1 + sovChannel(uint64(m.ProtocolVersion)) - } - l = len(m.AppVersion) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.Encoding) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } return n } @@ -2334,89 +2257,6 @@ func (m *Packet) Unmarshal(dAtA []byte) error { break } } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolVersion", wireType) - } - m.ProtocolVersion = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProtocolVersion |= IBCVersion(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AppVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Encoding = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipChannel(dAtA[iNdEx:]) diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 173131d73df..e660cf39bd4 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -64,7 +64,6 @@ var ( disabledTimeout = clienttypes.ZeroHeight() validPacketData = []byte("testdata") unknownPacketData = []byte("unknown") - validVersion = "ics-20" packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) invalidPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 71ff5bd62e9..b585f093e50 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -2,8 +2,6 @@ package types import ( "crypto/sha256" - "slices" - "strings" errorsmod "cosmossdk.io/errors" @@ -14,32 +12,13 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// CommitPacket returns the packet commitment bytes based on -// the ProtocolVersion specified in the Packet. The commitment -// must commit to all fields in the packet apart from the source port -// source channel and sequence (which will be committed to in the packet commitment key path) -// and the ProtocolVersion which is defining how to hash the packet fields. -// NOTE: The commitment MUST be a fixed length preimage to prevent relayers from being able -// to malleate the packet fields and create a commitment hash that matches the original packet. -func CommitPacket(packet Packet) []byte { - switch packet.ProtocolVersion { - case IBC_VERSION_UNSPECIFIED, IBC_VERSION_1: - return commitV1Packet(packet) - case IBC_VERSION_2: - // TODO: convert to PacketV2 and commit. - return commitV2Packet(packet) - default: - panic("unsupported version") - } -} - -// commitV1Packet returns the V1 packet commitment bytes. The commitment consists of: +// CommitPacket returns the packet commitment bytes. The commitment consists of: // sha256_hash(timeout_timestamp + timeout_height.RevisionNumber + timeout_height.RevisionHeight + sha256_hash(data)) // from a given packet. This results in a fixed length preimage. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. // NOTE: sdk.Uint64ToBigEndian sets the uint64 to a slice of length 8. -func commitV1Packet(packet Packet) []byte { +func CommitPacket(packet Packet) []byte { timeoutHeight := packet.GetTimeoutHeight() buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) @@ -57,50 +36,6 @@ func commitV1Packet(packet Packet) []byte { return hash[:] } -// commitV2Packet returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout_timestamp + timeout_height.RevisionNumber + timeout_height.RevisionHeight) -// + sha256_hash(destPort) + sha256_hash(destChannel) + sha256_hash(version) + sha256_hash(data)) -// from a given packet. This results in a fixed length preimage. -// NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able -// to malleate the packet fields and create a commitment hash that matches the original packet. -// NOTE: sdk.Uint64ToBigEndian sets the uint64 to a slice of length 8. -func commitV2Packet(packet Packet) []byte { - timeoutHeight := packet.GetTimeoutHeight() - - timeoutBuf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) - - // only hash the timeout height if it is non-zero. This will allow us to remove it entirely in the future - if !timeoutHeight.EQ(clienttypes.ZeroHeight()) { - revisionNumber := sdk.Uint64ToBigEndian(timeoutHeight.GetRevisionNumber()) - timeoutBuf = append(timeoutBuf, revisionNumber...) - - revisionHeight := sdk.Uint64ToBigEndian(timeoutHeight.GetRevisionHeight()) - timeoutBuf = append(timeoutBuf, revisionHeight...) - } - - // hash the timeout rather than using a fixed-size preimage directly - // this will allow more flexibility in the future with how timeouts are defined - timeoutHash := sha256.Sum256(timeoutBuf) - buf := timeoutHash[:] - - // hash the destination identifiers since we can no longer retrieve them from the channelEnd - portHash := sha256.Sum256([]byte(packet.GetDestPort())) - buf = append(buf, portHash[:]...) - destinationHash := sha256.Sum256([]byte(packet.GetDestChannel())) - buf = append(buf, destinationHash[:]...) - - // hash the app version. - versionHash := sha256.Sum256([]byte(packet.AppVersion)) - buf = append(buf, versionHash[:]...) - - // hash the data - dataHash := sha256.Sum256(packet.GetData()) - buf = append(buf, dataHash[:]...) - - hash := sha256.Sum256(buf) - return hash[:] -} - // CommitAcknowledgement returns the hash of commitment bytes func CommitAcknowledgement(data []byte) []byte { hash := sha256.Sum256(data) @@ -124,29 +59,6 @@ func NewPacket( DestinationChannel: destinationChannel, TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, - ProtocolVersion: IBC_VERSION_1, - Encoding: "json", - } -} - -func NewPacketWithVersion( - data []byte, - sequence uint64, sourcePort, sourceChannel, - destinationPort, destinationChannel string, - timeoutHeight clienttypes.Height, timeoutTimestamp uint64, - appVersion string, -) Packet { - return Packet{ - Data: data, - Sequence: sequence, - SourcePort: sourcePort, - SourceChannel: sourceChannel, - DestinationPort: destinationPort, - DestinationChannel: destinationChannel, - TimeoutHeight: timeoutHeight, - TimeoutTimestamp: timeoutTimestamp, - ProtocolVersion: IBC_VERSION_2, - AppVersion: appVersion, } } @@ -197,12 +109,6 @@ func (p Packet) ValidateBasic() error { if len(p.Data) == 0 { return errorsmod.Wrap(ErrInvalidPacket, "packet data bytes cannot be empty") } - if p.AppVersion != "" && slices.Contains([]IBCVersion{IBC_VERSION_UNSPECIFIED, IBC_VERSION_1}, p.ProtocolVersion) { - return errorsmod.Wrapf(ErrInvalidPacket, "app version cannot be specified when packet does not use protocol %s", IBC_VERSION_2) - } - if strings.TrimSpace(p.AppVersion) == "" && p.ProtocolVersion == IBC_VERSION_2 { - return errorsmod.Wrapf(ErrInvalidPacket, "app version must be specified when packet uses protocol %s", IBC_VERSION_2) - } return nil } diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index a030f813375..296ebb6d8ed 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -5,41 +5,13 @@ import ( "github.com/stretchr/testify/require" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) func TestCommitPacket(t *testing.T) { - // V1 packet1 commitment - packet1 := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - commitment1 := types.CommitPacket(packet1) - require.NotNil(t, commitment1) - - // V2 packet commitment with empty app version - packet2 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "") - commitment2 := types.CommitPacket(packet2) - require.NotNil(t, commitment2) - - // even though app version is empty for both packet1 and packet2 - // the commitment is different because we use Eureka protocol for packet2 - require.NotEqual(t, commitment1, commitment2) - - // V2 packet commitment with non-empty app version - packet3 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, validVersion) - commitment3 := types.CommitPacket(packet3) - require.NotNil(t, commitment3) - - require.NotEqual(t, commitment1, commitment3) - require.NotEqual(t, commitment2, commitment3) - - // V2 packet commitment with non-empty app version and zero timeout height - packet4 := types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.ZeroHeight(), timeoutTimestamp, validVersion) - commitment4 := types.CommitPacket(packet4) - require.NotNil(t, commitment4) - - require.NotEqual(t, commitment1, commitment4) - require.NotEqual(t, commitment2, commitment4) - require.NotEqual(t, commitment3, commitment4) + packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + commitment := types.CommitPacket(packet) + require.NotNil(t, commitment) } func TestPacketValidateBasic(t *testing.T) { @@ -58,11 +30,6 @@ func TestPacketValidateBasic(t *testing.T) { {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), false, "disabled both timeout height and timestamp"}, {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), true, "disabled timeout timestamp, valid timeout height"}, - {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, "version"), true, "valid v2 packet"}, - {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_1, "version", "json"}, false, "invalid specifying of app version with protocol version 1"}, - {types.Packet{1, portid, chanid, cpportid, cpchanid, validPacketData, timeoutHeight, timeoutTimestamp, types.IBC_VERSION_UNSPECIFIED, "version", "json"}, false, "invalid specifying of app version with unspecified protocol version"}, - {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, ""), false, "app version must be specified when packet uses protocol version 2"}, - {types.NewPacketWithVersion(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp, " "), false, "app version must be specified when packet uses protocol version 2"}, } for i, tc := range testCases { diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index 77b523c181f..78df62bdbb4 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -90,21 +90,6 @@ enum Order { ORDER_ORDERED = 2 [(gogoproto.enumvalue_customname) = "ORDERED"]; } -// IBCVersion defines the version that the IBC packet intends to use. -// This allows asynchronous upgrades over time as unsupported IBC Versions -// will simply be rejected by the receiver and timed out on sender. -enum IBCVersion { - option (gogoproto.goproto_enum_prefix) = false; - - // zero-value for IBC version. - // This will be treated as a classic packet - IBC_VERSION_UNSPECIFIED = 0; - // IBC version 1 implements the Classic protocol - IBC_VERSION_1 = 1; - // IBC version 2 implements the Eureka protocol - IBC_VERSION_2 = 2; -} - // Counterparty defines a channel end counterparty message Counterparty { option (gogoproto.goproto_getters) = false; @@ -137,12 +122,6 @@ message Packet { ibc.core.client.v1.Height timeout_height = 7 [(gogoproto.nullable) = false]; // block timestamp (in nanoseconds) after which the packet times out uint64 timeout_timestamp = 8; - // which IBC version to use to commit this packet - IBCVersion protocol_version = 9; - // version which application should use to process the packet data - string app_version = 10; - // encoding to be used TODO clearer message - string encoding = 11; } // PacketState defines the generic type necessary to retrieve and store From ead49f2feb3d07b94892ffe40ac936b443997109 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 13:18:11 +0300 Subject: [PATCH 098/172] chore: Undo split to packet-server in 04-channel/v1. Move v2 testing functions to endpoint_v2. Fix comments in module.go for channel/v2. (#7495) --- modules/core/02-client/types/keys.go | 5 - modules/core/04-channel/types/codec.go | 1 - modules/core/04-channel/types/tx.pb.go | 514 ++++++++++++------------- modules/core/04-channel/v2/module.go | 6 +- modules/core/keeper/msg_server.go | 7 +- modules/core/module.go | 1 - proto/ibc/core/channel/v1/tx.proto | 23 +- testing/endpoint.go | 28 -- testing/endpoint_v2.go | 29 ++ 9 files changed, 283 insertions(+), 331 deletions(-) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index 8619b7c3371..e0c23c96aaa 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -32,11 +32,6 @@ const ( // AllowAllClients is the value that if set in AllowedClients param // would allow any wired up light client modules to be allowed AllowAllClients = "*" - - // CounterpartyKey is the key used to store counterparty in the client store. - // the counterparty key is imported from types instead of host because - // the counterparty key is not a part of the ics-24 host specification - CounterpartyKey = "counterparty" ) // FormatClientIdentifier returns the client identifier with the sequence appended. diff --git a/modules/core/04-channel/types/codec.go b/modules/core/04-channel/types/codec.go index dbe7ac6934f..1b4fbef1493 100644 --- a/modules/core/04-channel/types/codec.go +++ b/modules/core/04-channel/types/codec.go @@ -41,7 +41,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) - msgservice.RegisterMsgServiceDesc(registry, &_PacketMsg_serviceDesc) } // SubModuleCdc references the global x/ibc/core/04-channel module codec. Note, the codec should diff --git a/modules/core/04-channel/types/tx.pb.go b/modules/core/04-channel/types/tx.pb.go index 87a92a47a61..a6d96fb510f 100644 --- a/modules/core/04-channel/types/tx.pb.go +++ b/modules/core/04-channel/types/tx.pb.go @@ -1675,131 +1675,131 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1983 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0x37, 0xf5, 0x19, 0x3d, 0x27, 0x91, 0x43, 0x39, 0xb1, 0x4c, 0xdb, 0x92, 0xa2, 0x16, 0x8d, - 0xd7, 0x4d, 0xa4, 0xb5, 0x37, 0x5b, 0x20, 0xc1, 0x02, 0xad, 0xa3, 0x2a, 0x5d, 0x03, 0x71, 0x6c, - 0x50, 0x56, 0xd1, 0xee, 0x16, 0x15, 0x64, 0x6a, 0x42, 0x11, 0x92, 0x48, 0x2e, 0x49, 0x69, 0xd7, - 0x05, 0x5a, 0x2c, 0x7a, 0x0a, 0x72, 0x58, 0xb4, 0xc0, 0x5e, 0x03, 0xb4, 0xe8, 0x3f, 0xb0, 0xe8, - 0xb1, 0x1f, 0x87, 0xde, 0xf6, 0x50, 0x14, 0x7b, 0x5c, 0x14, 0xe8, 0xa2, 0x48, 0x0e, 0xfb, 0x3f, - 0x14, 0x28, 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 0xe5, 0xeb, 0xc2, 0xd2, - 0x7b, 0x0f, 0x64, 0xc5, 0xea, 0x0e, 0x4f, 0x2b, 0x92, 0x36, 0xa8, 0xd2, 0x3f, 0x4d, 0x29, 0xa7, - 0xd2, 0x3d, 0x59, 0xab, 0x8e, 0x1e, 0x54, 0x07, 0x5a, 0x67, 0xd8, 0x47, 0x26, 0xf9, 0xb3, 0xd3, - 0x9b, 0xf7, 0xef, 0x39, 0xff, 0x77, 0xb2, 0xce, 0x74, 0x64, 0x9e, 0xa6, 0xf0, 0x7f, 0x9d, 0xde, - 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xdf, 0x5a, 0xd6, 0xb6, 0x25, 0x00, 0x00, + // 1972 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcf, 0x6f, 0xdb, 0xc8, + 0x15, 0x36, 0xf5, 0x33, 0x7e, 0x4e, 0xd6, 0x0a, 0xe5, 0xc4, 0x32, 0x6d, 0x4b, 0x8a, 0x5a, 0x34, + 0x5e, 0x37, 0x91, 0xd6, 0xde, 0xa4, 0x40, 0x82, 0x05, 0x5a, 0x47, 0x55, 0xba, 0x06, 0xe2, 0xd8, + 0xa0, 0xac, 0xa2, 0xdd, 0x2d, 0x2a, 0xc8, 0xd4, 0x84, 0x22, 0x24, 0x91, 0x5c, 0x92, 0xd2, 0xae, + 0x0b, 0xb4, 0x58, 0xf4, 0x14, 0xe4, 0xb0, 0x68, 0x81, 0xbd, 0x06, 0x68, 0xd1, 0x7f, 0x60, 0xcf, + 0xfd, 0x71, 0xe8, 0x6d, 0x4f, 0xc5, 0x1e, 0x17, 0x05, 0xba, 0x28, 0x92, 0x43, 0x2e, 0xfd, 0x0b, + 0x0a, 0x14, 0x28, 0x38, 0x33, 0xa4, 0x28, 0x72, 0x28, 0x51, 0x96, 0x6a, 0xf4, 0x26, 0xce, 0x7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, 0x07, 0x95, 0xbe, 0xd6, 0x1e, + 0xf4, 0x90, 0x49, 0xfe, 0xd7, 0xf4, 0xce, 0xbd, 0xbb, 0xce, 0x5f, 0x9b, 0xac, 0x73, 0x1d, 0x99, + 0x67, 0x29, 0xfc, 0xb7, 0xa6, 0x77, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x3a, 0xad, 0xa2, 0x63, + 0xa1, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1827,8 +1827,14 @@ type MsgClient interface { // ChannelCloseConfirm defines a rpc handler method for // MsgChannelCloseConfirm. ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. @@ -1911,6 +1917,15 @@ func (c *msgClient) ChannelCloseConfirm(ctx context.Context, in *MsgChannelClose return out, nil } +func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { + out := new(MsgRecvPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/RecvPacket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { out := new(MsgTimeoutOnCloseResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) @@ -1920,6 +1935,24 @@ func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, o return out, nil } +func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { + out := new(MsgTimeoutResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { + out := new(MsgAcknowledgementResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Acknowledgement", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) { out := new(MsgChannelUpgradeInitResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeInit", in, out, opts...) @@ -2016,8 +2049,14 @@ type MsgServer interface { // ChannelCloseConfirm defines a rpc handler method for // MsgChannelCloseConfirm. ChannelCloseConfirm(context.Context, *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. ChannelUpgradeInit(context.Context, *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. @@ -2060,9 +2099,18 @@ func (*UnimplementedMsgServer) ChannelCloseInit(ctx context.Context, req *MsgCha func (*UnimplementedMsgServer) ChannelCloseConfirm(ctx context.Context, req *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseConfirm not implemented") } +func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") +} func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") } +func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") +} +func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") +} func (*UnimplementedMsgServer) ChannelUpgradeInit(ctx context.Context, req *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeInit not implemented") } @@ -2203,6 +2251,24 @@ func _Msg_ChannelCloseConfirm_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRecvPacket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RecvPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/RecvPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgTimeoutOnClose) if err := dec(in); err != nil { @@ -2221,6 +2287,42 @@ func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeout) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Timeout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/Timeout", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAcknowledgement) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Acknowledgement(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/Acknowledgement", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_ChannelUpgradeInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgChannelUpgradeInit) if err := dec(in); err != nil { @@ -2411,10 +2513,22 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ChannelCloseConfirm", Handler: _Msg_ChannelCloseConfirm_Handler, }, + { + MethodName: "RecvPacket", + Handler: _Msg_RecvPacket_Handler, + }, { MethodName: "TimeoutOnClose", Handler: _Msg_TimeoutOnClose_Handler, }, + { + MethodName: "Timeout", + Handler: _Msg_Timeout_Handler, + }, + { + MethodName: "Acknowledgement", + Handler: _Msg_Acknowledgement_Handler, + }, { MethodName: "ChannelUpgradeInit", Handler: _Msg_ChannelUpgradeInit_Handler, @@ -2456,156 +2570,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/core/channel/v1/tx.proto", } -// PacketMsgClient is the client API for PacketMsg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type PacketMsgClient interface { - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) -} - -type packetMsgClient struct { - cc grpc1.ClientConn -} - -func NewPacketMsgClient(cc grpc1.ClientConn) PacketMsgClient { - return &packetMsgClient{cc} -} - -func (c *packetMsgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { - out := new(MsgRecvPacketResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/RecvPacket", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *packetMsgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { - out := new(MsgTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/Timeout", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *packetMsgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { - out := new(MsgAcknowledgementResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.PacketMsg/Acknowledgement", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PacketMsgServer is the server API for PacketMsg service. -type PacketMsgServer interface { - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) -} - -// UnimplementedPacketMsgServer can be embedded to have forward compatible implementations. -type UnimplementedPacketMsgServer struct { -} - -func (*UnimplementedPacketMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") -} -func (*UnimplementedPacketMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") -} -func (*UnimplementedPacketMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") -} - -func RegisterPacketMsgServer(s grpc1.Server, srv PacketMsgServer) { - s.RegisterService(&_PacketMsg_serviceDesc, srv) -} - -func _PacketMsg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRecvPacket) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PacketMsgServer).RecvPacket(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.PacketMsg/RecvPacket", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) - } - return interceptor(ctx, in, info, handler) -} - -func _PacketMsg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeout) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PacketMsgServer).Timeout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.PacketMsg/Timeout", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).Timeout(ctx, req.(*MsgTimeout)) - } - return interceptor(ctx, in, info, handler) -} - -func _PacketMsg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAcknowledgement) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PacketMsgServer).Acknowledgement(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.PacketMsg/Acknowledgement", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PacketMsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) - } - return interceptor(ctx, in, info, handler) -} - -var _PacketMsg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.channel.v1.PacketMsg", - HandlerType: (*PacketMsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "RecvPacket", - Handler: _PacketMsg_RecvPacket_Handler, - }, - { - MethodName: "Timeout", - Handler: _PacketMsg_Timeout_Handler, - }, - { - MethodName: "Acknowledgement", - Handler: _PacketMsg_Acknowledgement_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "ibc/core/channel/v1/tx.proto", -} - func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) diff --git a/modules/core/04-channel/v2/module.go b/modules/core/04-channel/v2/module.go index 9bc3ad94699..9f6fbf8f7d6 100644 --- a/modules/core/04-channel/v2/module.go +++ b/modules/core/04-channel/v2/module.go @@ -7,17 +7,17 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) -// Name returns the IBC client name +// Name returns the IBC channel/v2 name func Name() string { return types.SubModuleName } -// GetQueryCmd returns no root query command for the IBC client +// GetQueryCmd returns the root query command for IBC channels v2. func GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// GetTxCmd returns the root tx command for 02-client. +// GetTxCmd returns the root tx command for IBC channels v2. func GetTxCmd() *cobra.Command { return cli.NewTxCmd() } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 2faf86fc01f..396f89b5e9b 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -19,10 +19,9 @@ import ( ) var ( - _ clienttypes.MsgServer = (*Keeper)(nil) - _ connectiontypes.MsgServer = (*Keeper)(nil) - _ channeltypes.MsgServer = (*Keeper)(nil) - _ channeltypes.PacketMsgServer = (*Keeper)(nil) + _ clienttypes.MsgServer = (*Keeper)(nil) + _ connectiontypes.MsgServer = (*Keeper)(nil) + _ channeltypes.MsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. diff --git a/modules/core/module.go b/modules/core/module.go index c312604d7f3..6edba9b02c3 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -135,7 +135,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) - channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) channeltypesv2.RegisterMsgServer(cfg.MsgServer(), am.keeper.ChannelKeeperV2) clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index 729ffd09b28..611b4068088 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -33,9 +33,18 @@ service Msg { // MsgChannelCloseConfirm. rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse); + // RecvPacket defines a rpc handler method for MsgRecvPacket. + rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); + // Timeout defines a rpc handler method for MsgTimeout. + rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); + + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); + // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. rpc ChannelUpgradeInit(MsgChannelUpgradeInit) returns (MsgChannelUpgradeInitResponse); @@ -64,20 +73,6 @@ service Msg { rpc PruneAcknowledgements(MsgPruneAcknowledgements) returns (MsgPruneAcknowledgementsResponse); } -// PacketMsg defines the ibc/channel PacketMsg service. -service PacketMsg { - option (cosmos.msg.v1.service) = true; - - // RecvPacket defines a rpc handler method for MsgRecvPacket. - rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); - - // Timeout defines a rpc handler method for MsgTimeout. - rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); - - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); -} - // ResponseResultType defines the possible outcomes of the execution of a message enum ResponseResultType { option (gogoproto.goproto_enum_prefix) = false; diff --git a/testing/endpoint.go b/testing/endpoint.go index 1c69b35dc32..1fc0be299ed 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -16,7 +16,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -176,33 +175,6 @@ func (endpoint *Endpoint) FreezeClient() { endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, tmClientState) } -// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. -func (endpoint *Endpoint) ProvideCounterparty() (err error) { - msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) - - // setup counterparty - _, err = endpoint.Chain.SendMsgs(msg) - - return err -} - -// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. -func (endpoint *Endpoint) CreateChannel() (err error) { - endpoint.IncrementNextChannelSequence() - msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) - - // create channel - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events) - require.NoError(endpoint.Chain.TB, err) - - return nil -} - // UpgradeChain will upgrade a chain's chainID to the next revision number. // It will also update the counterparty client. // TODO: implement actual upgrade chain functionality via scheduling an upgrade diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index 57a9b98b2f5..f2cfcedc540 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -9,6 +9,35 @@ import ( hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) +// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. +func (endpoint *Endpoint) ProvideCounterparty() (err error) { + msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) + + // setup counterparty + _, err = endpoint.Chain.SendMsgs(msg) + + return err +} + +// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. +func (endpoint *Endpoint) CreateChannel() (err error) { + endpoint.IncrementNextChannelSequence() + msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + + // create channel + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events) + if err != nil { + return err + } + + return nil +} + // MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned. func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channeltypesv2.Payload) (channeltypesv2.Packet, error) { msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), payload) From 8b7889cb7013cc7a2c547f8341f9e8ed87fdb840 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 22 Oct 2024 13:25:50 +0300 Subject: [PATCH 099/172] chore: revert v1 event changes. (#7499) --- modules/core/04-channel/keeper/events.go | 164 +++++++++------------- modules/core/04-channel/keeper/packet.go | 14 +- modules/core/04-channel/keeper/timeout.go | 6 +- 3 files changed, 74 insertions(+), 110 deletions(-) diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index 0cb410a924c..b83af2a7c16 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -128,33 +128,25 @@ func emitChannelCloseConfirmEvent(ctx context.Context, portID string, channelID // emitSendPacketEvent emits an event with packet data along with other packet information for relayer // to pick up and relay to other chain -func EmitSendPacketEvent(ctx context.Context, packet types.Packet, channel *types.Channel, timeoutHeight exported.Height) { +func emitSendPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - eventAttributes := []sdk.Attribute{ - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - } - if channel != nil { - eventAttributes = append(eventAttributes, + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSendPacket, + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ) - } - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeSendPacket, - eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -163,35 +155,27 @@ func EmitSendPacketEvent(ctx context.Context, packet types.Packet, channel *type }) } -// EmitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet +// emitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet // is received for a certain sequence and for all duplicate receives. -func EmitRecvPacketEvent(ctx context.Context, packet types.Packet, channel *types.Channel) { +func emitRecvPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - eventAttributes := []sdk.Attribute{ - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - } - if channel != nil { - eventAttributes = append(eventAttributes, + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRecvPacket, + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ) - } - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRecvPacket, - eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -200,35 +184,27 @@ func EmitRecvPacketEvent(ctx context.Context, packet types.Packet, channel *type }) } -// EmitWriteAcknowledgementEvent emits an event that the relayer can query for -func EmitWriteAcknowledgementEvent(ctx context.Context, packet types.Packet, channel *types.Channel, acknowledgement []byte) { +// emitWriteAcknowledgementEvent emits an event that the relayer can query for +func emitWriteAcknowledgementEvent(ctx context.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - eventAttributes := []sdk.Attribute{ - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), - } - if channel != nil { - eventAttributes = append(eventAttributes, + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeWriteAck, + sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ) - } - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeWriteAck, - eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -237,34 +213,26 @@ func EmitWriteAcknowledgementEvent(ctx context.Context, packet types.Packet, cha }) } -// EmitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time +// emitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time // a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. -func EmitAcknowledgePacketEvent(ctx context.Context, packet types.Packet, channel *types.Channel) { +func emitAcknowledgePacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - eventAttributes := []sdk.Attribute{ - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - } - if channel != nil { - eventAttributes = append(eventAttributes, + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAcknowledgePacket, + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ) - } - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAcknowledgePacket, - eventAttributes..., ), sdk.NewEvent( sdk.EventTypeMessage, @@ -275,28 +243,24 @@ func EmitAcknowledgePacketEvent(ctx context.Context, packet types.Packet, channe // emitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet // is timed out for a certain sequence and for all duplicate timeouts. -func EmitTimeoutPacketEvent(ctx context.Context, packet types.Packet, channel *types.Channel) { +func emitTimeoutPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) { sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - eventAttributes := []sdk.Attribute{ - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - } - if channel != nil { - eventAttributes = append(eventAttributes, - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - ) - } sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, - eventAttributes..., + sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + // we only support 1-hop packets now, and that is the most important hop for a relayer + // (is it going to a chain I am connected to) + sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED + sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index bef9e7cad7c..89630094748 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -85,7 +85,7 @@ func (k *Keeper) SendPacket( k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - EmitSendPacketEvent(sdkCtx, packet, &channel, timeoutHeight) + emitSendPacketEvent(sdkCtx, packet, channel, timeoutHeight) k.Logger(ctx).Info( "packet sent", @@ -190,7 +190,7 @@ func (k *Keeper) RecvPacket( ) // emit an event that the relayer can query for - EmitRecvPacketEvent(sdkCtx, packet, &channel) + emitRecvPacketEvent(sdkCtx, packet, channel) return channel.Version, nil } @@ -215,7 +215,7 @@ func (k *Keeper) applyReplayProtection(ctx context.Context, packet types.Packet, // by the increase of the recvStartSequence. _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { - EmitRecvPacketEvent(sdkCtx, packet, &channel) + emitRecvPacketEvent(sdkCtx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -239,7 +239,7 @@ func (k *Keeper) applyReplayProtection(ctx context.Context, packet types.Packet, } if packet.GetSequence() < nextSequenceRecv { - EmitRecvPacketEvent(sdkCtx, packet, &channel) + emitRecvPacketEvent(sdkCtx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -335,7 +335,7 @@ func (k *Keeper) WriteAcknowledgement( ) sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - EmitWriteAcknowledgementEvent(sdkCtx, packet.(types.Packet), &channel, bz) + emitWriteAcknowledgementEvent(sdkCtx, packet.(types.Packet), channel, bz) return nil } @@ -392,7 +392,7 @@ func (k *Keeper) AcknowledgePacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitAcknowledgePacketEvent(ctx, packet, &channel) + emitAcknowledgePacketEvent(ctx, packet, channel) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -454,7 +454,7 @@ func (k *Keeper) AcknowledgePacket( ) // emit an event marking that we have processed the acknowledgement - EmitAcknowledgePacketEvent(ctx, packet, &channel) + emitAcknowledgePacketEvent(ctx, packet, channel) // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING { diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 84db359eb10..0e2b9817e05 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -70,7 +70,7 @@ func (k *Keeper) TimeoutPacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, &channel) + emitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -167,7 +167,7 @@ func (k *Keeper) timeoutExecuted( ) // emit an event marking that we have processed the timeout - EmitTimeoutPacketEvent(ctx, packet, &channel) + emitTimeoutPacketEvent(ctx, packet, channel) return nil } @@ -211,7 +211,7 @@ func (k *Keeper) TimeoutOnClose( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, &channel) + emitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to From 60f20f040514c004ba9215cc565f67e7f8b0688f Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 22 Oct 2024 11:51:48 +0100 Subject: [PATCH 100/172] chore: add tests for Channel.Validate (#7504) * chore: add tests for Channel.Validate * Update modules/core/04-channel/v2/types/channel_test.go Co-authored-by: DimitrisJim * Update modules/core/04-channel/v2/types/channel_test.go Co-authored-by: DimitrisJim --------- Co-authored-by: DimitrisJim --- .../core/04-channel/v2/types/channel_test.go | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 modules/core/04-channel/v2/types/channel_test.go diff --git a/modules/core/04-channel/v2/types/channel_test.go b/modules/core/04-channel/v2/types/channel_test.go new file mode 100644 index 00000000000..c6c71d9a157 --- /dev/null +++ b/modules/core/04-channel/v2/types/channel_test.go @@ -0,0 +1,58 @@ +package types_test + +import ( + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func (s *TypesTestSuite) TestValidateChannel() { + var c types.Channel + testCases := []struct { + name string + malleate func() + expErr error + }{ + { + name: "success", + malleate: func() {}, + }, + { + name: "failure: invalid ClientID", + malleate: func() { + c.ClientId = "" + }, + expErr: host.ErrInvalidID, + }, + { + name: "failure: invalid counterparty channel id", + malleate: func() { + c.CounterpartyChannelId = "" + }, + expErr: host.ErrInvalidID, + }, + { + name: "failure: invalid Merkle Path Prefix", + malleate: func() { + c.MerklePathPrefix.KeyPath = [][]byte{} + }, + expErr: types.ErrInvalidChannel, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + c = types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondClientID, ibctesting.MerklePath) + + tc.malleate() + + err := c.Validate() + + expPass := tc.expErr == nil + if expPass { + s.Require().NoError(err) + } else { + ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expErr) + } + }) + } +} From 3cb1e3cff756763b4d94f165c5bec129d1619a65 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Oct 2024 15:31:11 +0200 Subject: [PATCH 101/172] refactor: check timeouts directly in channel/v2 (#7464) * refactor: check timeouts directly * chore: add seconds to nanos conversion * rm stupid if * chore: regen protos * Update modules/core/04-channel/v2/keeper/packet.go Co-authored-by: DimitrisJim * Update modules/core/04-channel/v2/keeper/packet.go * chore: compare timeouts as was done in the olden days * chore: update comments and use secs in recvPacket Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> * chore: fix the compiler error breakage --------- Co-authored-by: DimitrisJim Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- .../04-channel/v2/keeper/msg_server_test.go | 6 +-- modules/core/04-channel/v2/keeper/packet.go | 39 ++++++++----------- modules/core/04-channel/v2/types/packet.go | 6 +++ modules/core/04-channel/v2/types/packet.pb.go | 2 +- proto/ibc/core/channel/v2/packet.proto | 2 +- testing/chain.go | 6 +++ 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 58587d44b89..f4072e4fec6 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - timeoutTimestamp = suite.chainA.GetTimeoutTimestamp() + timeoutTimestamp = suite.chainA.GetTimeoutTimestampSecs() payload = mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) @@ -201,7 +201,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + timeoutTimestamp := suite.chainA.GetTimeoutTimestampSecs() var err error packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)) @@ -401,7 +401,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - timeoutTimestamp := suite.chainA.GetTimeoutTimestamp() + timeoutTimestamp := suite.chainA.GetTimeoutTimestampSecs() var err error // Send packet from A to B diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 193fcadeb83..b4e0516307d 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "strconv" - "time" errorsmod "cosmossdk.io/errors" @@ -68,12 +67,12 @@ func (k *Keeper) sendPacket( if err != nil { return 0, "", err } - // check if packet is timed out on the receiving chain - // convert packet timeout to nanoseconds for now to use existing helper function - // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 - timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) - if timeout.TimestampElapsed(latestTimestamp) { - return 0, "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + + // client timestamps are in nanoseconds while packet timeouts are in seconds + // thus to compare them, we convert the packet timeout to nanoseconds + timeoutTimestamp = types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) + if latestTimestamp >= timeoutTimestamp { + return 0, "", errorsmod.Wrapf(channeltypes.ErrTimeoutElapsed, "latest timestamp: %d, timeout timestamp: %d", latestTimestamp, timeoutTimestamp) } commitment := types.CommitPacket(packet) @@ -102,9 +101,6 @@ func (k *Keeper) recvPacket( proof []byte, proofHeight exported.Height, ) error { - // Lookup channel associated with destination channel ID and ensure - // that the packet was indeed sent by our counterparty by verifying - // packet sender is our channel's counterparty channel id. channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { // TODO: figure out how aliasing will work when more than one payload is sent. @@ -113,19 +109,18 @@ func (k *Keeper) recvPacket( return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } + if channel.CounterpartyChannelId != packet.SourceChannel { return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } + clientID := channel.ClientId // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(sdkCtx.BlockTime().UnixNano()) - // convert packet timeout to nanoseconds for now to use existing helper function - // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 - timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) - if timeout.Elapsed(selfHeight, selfTimestamp) { - return errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + currentTimestamp := uint64(sdkCtx.BlockTime().Unix()) + if currentTimestamp >= packet.TimeoutTimestamp { + return errorsmod.Wrapf(channeltypes.ErrTimeoutElapsed, "current timestamp: %d, timeout timestamp: %d", currentTimestamp, packet.TimeoutTimestamp) } // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received @@ -284,15 +279,15 @@ func (k *Keeper) timeoutPacket( proof []byte, proofHeight exported.Height, ) error { - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } + if channel.CounterpartyChannelId != packet.DestinationChannel { return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } + clientID := channel.ClientId // check that timeout height or timeout timestamp has passed on the other end @@ -301,11 +296,9 @@ func (k *Keeper) timeoutPacket( return err } - // convert packet timeout to nanoseconds for now to use existing helper function - // TODO: Remove this workaround with Issue #7414: https://github.com/cosmos/ibc-go/issues/7414 - timeout := channeltypes.NewTimeoutWithTimestamp(uint64(time.Unix(int64(packet.GetTimeoutTimestamp()), 0).UnixNano())) - if !timeout.Elapsed(clienttypes.ZeroHeight(), proofTimestamp) { - return errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + timeoutTimestamp := types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) + if proofTimestamp < timeoutTimestamp { + return errorsmod.Wrapf(channeltypes.ErrTimeoutNotReached, "proof timestamp: %d, timeout timestamp: %d", proofTimestamp, timeoutTimestamp) } // check that the commitment has not been cleared and that it matches the packet sent by relayer diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 7be9e0b326a..1ba7722b925 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -2,6 +2,7 @@ package types import ( "strings" + "time" errorsmod "cosmossdk.io/errors" @@ -78,3 +79,8 @@ func (p Payload) ValidateBasic() error { } return nil } + +// TimeoutTimestampToNanos takes seconds as a uint64 and returns Unix nanoseconds as uint64. +func TimeoutTimestampToNanos(seconds uint64) uint64 { + return uint64(time.Unix(int64(seconds), 0).UnixNano()) +} diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go index a264047c3d6..a41a9d8256e 100644 --- a/modules/core/04-channel/v2/types/packet.pb.go +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -69,7 +69,7 @@ type Packet struct { SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` // identifies the receiving chain. DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` - // timeout timestamp after which the packet times out. + // timeout timestamp in seconds after which the packet times out. TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` // a list of payloads, each one for a specific application. Payloads []Payload `protobuf:"bytes,5,rep,name=payloads,proto3" json:"payloads"` diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto index 98d581915f9..fef2c588e5a 100644 --- a/proto/ibc/core/channel/v2/packet.proto +++ b/proto/ibc/core/channel/v2/packet.proto @@ -17,7 +17,7 @@ message Packet { string source_channel = 2; // identifies the receiving chain. string destination_channel = 3; - // timeout timestamp after which the packet times out. + // timeout timestamp in seconds after which the packet times out. uint64 timeout_timestamp = 4; // a list of payloads, each one for a specific application. repeated Payload payloads = 5 [(gogoproto.nullable) = false]; diff --git a/testing/chain.go b/testing/chain.go index a898b64fd3d..67ff41baf9e 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -557,6 +557,12 @@ func (chain *TestChain) GetTimeoutTimestamp() uint64 { return uint64(chain.GetContext().BlockTime().UnixNano()) + DefaultTimeoutTimestampDelta } +// GetTimeoutTimestampSecs is a convenience function which returns a IBC packet timeout timestamp in seconds +// to be used for testing. It returns the current block timestamp + default timestamp delta (1 hour). +func (chain *TestChain) GetTimeoutTimestampSecs() uint64 { + return uint64(chain.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) +} + // DeleteKey deletes the specified key from the ibc store. func (chain *TestChain) DeleteKey(key []byte) { storeKey := chain.GetSimApp().GetKey(exported.StoreKey) From 6f491352cfa9149cb3df6f15a1cead21d20d05f1 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Oct 2024 15:37:06 +0200 Subject: [PATCH 102/172] chore: rename apis to align with spec (#7511) * chore: rename apis to align with spec * nit: order interface assertions * chore: reorder the order of the order of functions --- modules/core/04-channel/v2/client/cli/cli.go | 2 +- modules/core/04-channel/v2/client/cli/tx.go | 14 +- .../core/04-channel/v2/keeper/msg_server.go | 171 ++++++------- .../04-channel/v2/keeper/msg_server_test.go | 162 ++++++------ modules/core/04-channel/v2/types/codec.go | 4 +- modules/core/04-channel/v2/types/msgs.go | 46 ++-- modules/core/04-channel/v2/types/msgs_test.go | 7 +- modules/core/04-channel/v2/types/tx.pb.go | 238 +++++++++--------- proto/ibc/core/channel/v2/tx.proto | 12 +- testing/endpoint_v2.go | 20 +- testing/path.go | 4 +- 11 files changed, 340 insertions(+), 340 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index 69952be9f81..ea4ac94f8cd 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -37,7 +37,7 @@ func NewTxCmd() *cobra.Command { txCmd.AddCommand( newCreateChannelTxCmd(), - newProvideCounterpartyTxCmd(), + newRegisterCounterpartyTxCmd(), ) return txCmd diff --git a/modules/core/04-channel/v2/client/cli/tx.go b/modules/core/04-channel/v2/client/cli/tx.go index 418f01815e7..6849a1476a9 100644 --- a/modules/core/04-channel/v2/client/cli/tx.go +++ b/modules/core/04-channel/v2/client/cli/tx.go @@ -47,14 +47,14 @@ func newCreateChannelTxCmd() *cobra.Command { return cmd } -// newProvideCounterpartyCmd defines the command to provide the counterparty channel identifier to an IBC channel. -func newProvideCounterpartyTxCmd() *cobra.Command { +// newRegisterCounterpartyCmd defines the command to provide the counterparty channel identifier to an IBC channel. +func newRegisterCounterpartyTxCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", + Use: "register-counterparty [channel-identifier] [counterparty-channel-identifier]", Args: cobra.ExactArgs(2), - Short: "provide the counterparty channel id to an IBC channel", - Long: `Provide the counterparty channel id to an IBC channel specified by its channel ID.`, - Example: fmt.Sprintf("%s tx %s %s provide-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), + Short: "Register the counterparty channel identifier for an IBC channel", + Long: `Register the counterparty channel identifier for an IBC channel specified by its channel ID.`, + Example: fmt.Sprintf("%s tx %s %s register-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -64,7 +64,7 @@ func newProvideCounterpartyTxCmd() *cobra.Command { channelID := args[0] counterpartyChannelID := args[1] - msg := types.MsgProvideCounterparty{ + msg := types.MsgRegisterCounterparty{ ChannelId: channelID, CounterpartyChannelId: counterpartyChannelID, Signer: clientCtx.GetFromAddress().String(), diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 0d06ba8e792..1acaf49e30c 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -17,7 +17,50 @@ import ( var _ channeltypesv2.MsgServer = &Keeper{} -// SendPacket implements the PacketMsgServer SendPacket method. +// CreateChannel defines a rpc handler method for MsgCreateChannel. +func (k *Keeper) CreateChannel(goCtx context.Context, msg *channeltypesv2.MsgCreateChannel) (*channeltypesv2.MsgCreateChannelResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + channelID := k.channelKeeperV1.GenerateChannelIdentifier(ctx) + + // Initialize channel with empty counterparty channel identifier. + channel := channeltypesv2.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + k.SetChannel(ctx, channelID, channel) + k.SetCreator(ctx, channelID, msg.Signer) + k.SetNextSequenceSend(ctx, channelID, 1) + + k.EmitCreateChannelEvent(goCtx, channelID) + + return &channeltypesv2.MsgCreateChannelResponse{ChannelId: channelID}, nil +} + +// RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. +func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *channeltypesv2.MsgRegisterCounterparty) (*channeltypesv2.MsgRegisterCounterpartyResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + creator, found := k.GetCreator(ctx, msg.ChannelId) + if !found { + return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") + } + + if creator != msg.Signer { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) + } + + channel, ok := k.GetChannel(ctx, msg.ChannelId) + if !ok { + return nil, errorsmod.Wrapf(channeltypesv2.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) + } + + channel.CounterpartyChannelId = msg.CounterpartyChannelId + k.SetChannel(ctx, msg.ChannelId, channel) + // Delete client creator from state as it is not needed after this point. + k.DeleteCreator(ctx, msg.ChannelId) + + return &channeltypesv2.MsgRegisterCounterpartyResponse{}, nil +} + +// SendPacket defines a rpc handler method for MsgSendPacket. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) @@ -43,46 +86,7 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil } -func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - relayer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - sdkCtx.Logger().Error("acknowledgement failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) - return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") - } - - cacheCtx, writeFn := sdkCtx.CacheContext() - err = k.acknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) - - switch err { - case nil: - writeFn() - case channeltypesv1.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored - sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) - return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil - default: - sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) - return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") - } - - recvResults := make(map[string]channeltypesv2.RecvPacketResult) - for _, r := range msg.Acknowledgement.AcknowledgementResults { - recvResults[r.AppName] = r.RecvPacketResult - } - - for _, pd := range msg.Packet.Payloads { - cbs := k.Router.Route(pd.SourcePort) - err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, recvResults[pd.DestinationPort].Acknowledgement, relayer) - if err != nil { - return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) - } - } - - return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil -} - -// RecvPacket implements the PacketMsgServer RecvPacket method. +// RecvPacket defines a rpc handler method for MsgRecvPacket. func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -162,7 +166,47 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil } -// Timeout implements the PacketMsgServer Timeout method. +// Acknowledgement defines an rpc handler method for MsgAcknowledgement. +func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + relayer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + sdkCtx.Logger().Error("acknowledgement failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") + } + + cacheCtx, writeFn := sdkCtx.CacheContext() + err = k.acknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + + switch err { + case nil: + writeFn() + case channeltypesv1.ErrNoOpMsg: + // no-ops do not need event emission as they will be ignored + sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) + return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil + default: + sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) + return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") + } + + recvResults := make(map[string]channeltypesv2.RecvPacketResult) + for _, r := range msg.Acknowledgement.AcknowledgementResults { + recvResults[r.AppName] = r.RecvPacketResult + } + + for _, pd := range msg.Packet.Payloads { + cbs := k.Router.Route(pd.SourcePort) + err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, recvResults[pd.DestinationPort].Acknowledgement, relayer) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) + } + } + + return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil +} + +// Timeout defines a rpc handler method for MsgTimeout. func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -200,46 +244,3 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil } - -// CreateChannel defines a rpc handler method for MsgCreateChannel -func (k *Keeper) CreateChannel(goCtx context.Context, msg *channeltypesv2.MsgCreateChannel) (*channeltypesv2.MsgCreateChannelResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - channelID := k.channelKeeperV1.GenerateChannelIdentifier(ctx) - - // Initialize channel with empty counterparty channel identifier. - channel := channeltypesv2.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) - k.SetChannel(ctx, channelID, channel) - k.SetCreator(ctx, channelID, msg.Signer) - k.SetNextSequenceSend(ctx, channelID, 1) - - k.EmitCreateChannelEvent(goCtx, channelID) - - return &channeltypesv2.MsgCreateChannelResponse{ChannelId: channelID}, nil -} - -// ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. -func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *channeltypesv2.MsgProvideCounterparty) (*channeltypesv2.MsgProvideCounterpartyResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - creator, found := k.GetCreator(ctx, msg.ChannelId) - if !found { - return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") - } - - if creator != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) - } - - channel, ok := k.GetChannel(ctx, msg.ChannelId) - if !ok { - return nil, errorsmod.Wrapf(channeltypesv2.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) - } - - channel.CounterpartyChannelId = msg.CounterpartyChannelId - k.SetChannel(ctx, msg.ChannelId, channel) - // Delete client creator from state as it is not needed after this point. - k.DeleteCreator(ctx, msg.ChannelId) - - return &channeltypesv2.MsgProvideCounterpartyResponse{}, nil -} diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index f4072e4fec6..fa690b8087e 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -17,6 +17,87 @@ import ( mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) +func (suite *KeeperTestSuite) TestRegisterCounterparty() { + var ( + path *ibctesting.Path + msg *channeltypesv2.MsgRegisterCounterparty + ) + cases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() { + // set it before handler + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, channeltypesv2.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + }, + nil, + }, + { + "failure: creator not set", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) + }, + ibcerrors.ErrUnauthorized, + }, + { + "failure: signer does not match creator", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID, ibctesting.TestAccAddress) + }, + ibcerrors.ErrUnauthorized, + }, + { + "failure: channel must already exist", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) + }, + channeltypesv2.ErrInvalidChannel, + }, + } + + for _, tc := range cases { + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupClients() + + suite.Require().NoError(path.EndpointA.CreateChannel()) + suite.Require().NoError(path.EndpointB.CreateChannel()) + + signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() + msg = channeltypesv2.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) + + tc.malleate() + + res, err := path.EndpointA.Chain.SendMsgs(msg) + + expPass := tc.expError == nil + if expPass { + suite.Require().NotNil(res) + suite.Require().Nil(err) + + // Assert counterparty channel id filled in and creator deleted + channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) + + _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().False(found) + + seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(seq, uint64(1)) + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) + } + }) + } +} + func (suite *KeeperTestSuite) TestMsgSendPacket() { var ( path *ibctesting.Path @@ -254,87 +335,6 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { } } -func (suite *KeeperTestSuite) TestProvideCounterparty() { - var ( - path *ibctesting.Path - msg *channeltypesv2.MsgProvideCounterparty - ) - cases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() { - // set it before handler - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, channeltypesv2.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) - }, - nil, - }, - { - "failure: creator not set", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: signer does not match creator", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID, ibctesting.TestAccAddress) - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: channel must already exist", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) - }, - channeltypesv2.ErrInvalidChannel, - }, - } - - for _, tc := range cases { - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupClients() - - suite.Require().NoError(path.EndpointA.CreateChannel()) - suite.Require().NoError(path.EndpointB.CreateChannel()) - - signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = channeltypesv2.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) - - tc.malleate() - - res, err := path.EndpointA.Chain.SendMsgs(msg) - - expPass := tc.expError == nil - if expPass { - suite.Require().NotNil(res) - suite.Require().Nil(err) - - // Assert counterparty channel id filled in and creator deleted - channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) - - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().False(found) - - seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(seq, uint64(1)) - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) - } - }) - } -} - func (suite *KeeperTestSuite) TestMsgAcknowledgement() { var ( path *ibctesting.Path diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index 79941f59175..788cdb30732 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -10,11 +10,11 @@ import ( func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgCreateChannel{}, + &MsgRegisterCounterparty{}, &MsgSendPacket{}, &MsgRecvPacket{}, &MsgTimeout{}, &MsgAcknowledgement{}, - &MsgCreateChannel{}, - &MsgProvideCounterparty{}, ) } diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 45fdf38775e..9c6f724e40d 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -14,12 +14,12 @@ import ( ) var ( - _ sdk.Msg = (*MsgProvideCounterparty)(nil) - _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) - _ sdk.Msg = (*MsgCreateChannel)(nil) _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) + _ sdk.Msg = (*MsgRegisterCounterparty)(nil) + _ sdk.HasValidateBasic = (*MsgRegisterCounterparty)(nil) + _ sdk.Msg = (*MsgSendPacket)(nil) _ sdk.HasValidateBasic = (*MsgSendPacket)(nil) @@ -33,52 +33,52 @@ var ( _ sdk.HasValidateBasic = (*MsgAcknowledgement)(nil) ) -// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(channelID, counterpartyChannelID string, signer string) *MsgProvideCounterparty { - return &MsgProvideCounterparty{ - Signer: signer, - ChannelId: channelID, - CounterpartyChannelId: counterpartyChannelID, +// NewMsgCreateChannel creates a new MsgCreateChannel instance +func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypesv2.MerklePath, signer string) *MsgCreateChannel { + return &MsgCreateChannel{ + Signer: signer, + ClientId: clientID, + MerklePathPrefix: merklePathPrefix, } } -// ValidateBasic performs basic checks on a MsgProvideCounterparty. -func (msg *MsgProvideCounterparty) ValidateBasic() error { +// ValidateBasic performs basic checks on a MsgCreateChannel. +func (msg *MsgCreateChannel) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) } - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { return err } - if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { + if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { return err } return nil } -// NewMsgCreateChannel creates a new MsgCreateChannel instance -func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypesv2.MerklePath, signer string) *MsgCreateChannel { - return &MsgCreateChannel{ - Signer: signer, - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, +// NewMsgRegisterCounterparty creates a new MsgRegisterCounterparty instance +func NewMsgRegisterCounterparty(channelID, counterpartyChannelID string, signer string) *MsgRegisterCounterparty { + return &MsgRegisterCounterparty{ + Signer: signer, + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, } } -// ValidateBasic performs basic checks on a MsgCreateChannel. -func (msg *MsgCreateChannel) ValidateBasic() error { +// ValidateBasic performs basic checks on a MsgRegisterCounterparty. +func (msg *MsgRegisterCounterparty) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) } - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { return err } - if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { + if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { return err } diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index da7779f0602..44e92c4e5a3 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -36,9 +36,8 @@ func TestTypesTestSuite(t *testing.T) { suite.Run(t, new(TypesTestSuite)) } -// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty -func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { - var msg *types.MsgProvideCounterparty +func (s *TypesTestSuite) TestMsgRegisterCounterpartyValidateBasic() { + var msg *types.MsgRegisterCounterparty testCases := []struct { name string @@ -74,7 +73,7 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { } for _, tc := range testCases { - msg = types.NewMsgProvideCounterparty( + msg = types.NewMsgRegisterCounterparty( ibctesting.FirstChannelID, ibctesting.SecondChannelID, ibctesting.TestAccAddress, diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index 2359841ca7a..b64d2c7be97 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -114,9 +114,9 @@ func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo -// MsgProvideCounterparty defines the message used to provide the counterparty channel +// MsgRegisterCounterparty defines the message used to provide the counterparty channel // identifier. -type MsgProvideCounterparty struct { +type MsgRegisterCounterparty struct { // unique identifier we will use to write all packet messages sent to counterparty ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` // counterparty channel identifier @@ -125,18 +125,18 @@ type MsgProvideCounterparty struct { Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } -func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } -func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterparty) ProtoMessage() {} -func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { +func (m *MsgRegisterCounterparty) Reset() { *m = MsgRegisterCounterparty{} } +func (m *MsgRegisterCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterparty) ProtoMessage() {} +func (*MsgRegisterCounterparty) Descriptor() ([]byte, []int) { return fileDescriptor_d421c7119e969b99, []int{2} } -func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterCounterparty) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgProvideCounterparty.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterCounterparty.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -146,34 +146,34 @@ func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *MsgProvideCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +func (m *MsgRegisterCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterparty.Merge(m, src) } -func (m *MsgProvideCounterparty) XXX_Size() int { +func (m *MsgRegisterCounterparty) XXX_Size() int { return m.Size() } -func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +func (m *MsgRegisterCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterparty.DiscardUnknown(m) } -var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterCounterparty proto.InternalMessageInfo -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -type MsgProvideCounterpartyResponse struct { +// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. +type MsgRegisterCounterpartyResponse struct { } -func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } -func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterpartyResponse) ProtoMessage() {} -func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { +func (m *MsgRegisterCounterpartyResponse) Reset() { *m = MsgRegisterCounterpartyResponse{} } +func (m *MsgRegisterCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterpartyResponse) ProtoMessage() {} +func (*MsgRegisterCounterpartyResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d421c7119e969b99, []int{3} } -func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterCounterpartyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgProvideCounterpartyResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterCounterpartyResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -183,17 +183,17 @@ func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +func (m *MsgRegisterCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterpartyResponse.Merge(m, src) } -func (m *MsgProvideCounterpartyResponse) XXX_Size() int { +func (m *MsgRegisterCounterpartyResponse) XXX_Size() int { return m.Size() } -func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +func (m *MsgRegisterCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterpartyResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterCounterpartyResponse proto.InternalMessageInfo // MsgSendPacket sends an outgoing IBC packet. type MsgSendPacket struct { @@ -515,8 +515,8 @@ var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") - proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.channel.v2.MsgProvideCounterparty") - proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgProvideCounterpartyResponse") + proto.RegisterType((*MsgRegisterCounterparty)(nil), "ibc.core.channel.v2.MsgRegisterCounterparty") + proto.RegisterType((*MsgRegisterCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgRegisterCounterpartyResponse") proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v2.MsgRecvPacket") @@ -530,63 +530,63 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 883 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x31, 0x6f, 0xdb, 0x46, - 0x14, 0x16, 0x6d, 0xc5, 0xb5, 0x9f, 0xec, 0xd8, 0x65, 0x9a, 0x44, 0x60, 0x52, 0x49, 0x10, 0x1a, - 0xd8, 0x75, 0x60, 0xb2, 0x66, 0x8a, 0x02, 0x0e, 0x8a, 0x06, 0x89, 0x96, 0x66, 0x10, 0x20, 0x30, - 0x6e, 0x86, 0xb6, 0xa8, 0x40, 0x91, 0x2f, 0x14, 0x61, 0x91, 0xc7, 0xf2, 0x48, 0x26, 0xda, 0x8a, - 0x4e, 0x1d, 0x3b, 0x76, 0xec, 0x4f, 0xf0, 0xd0, 0x1f, 0x91, 0xa1, 0x43, 0xc6, 0x4e, 0x45, 0x60, - 0x0d, 0x01, 0xfa, 0x2b, 0x0a, 0xde, 0x9d, 0x48, 0x4a, 0xa1, 0x62, 0x15, 0x55, 0x26, 0x92, 0xef, - 0x7d, 0xef, 0x7b, 0xef, 0x7d, 0xef, 0x78, 0x77, 0x70, 0xdb, 0x1d, 0x58, 0x9a, 0x45, 0x42, 0xd4, - 0xac, 0xa1, 0xe9, 0xfb, 0x38, 0xd2, 0x12, 0x5d, 0x8b, 0x5e, 0xa8, 0x41, 0x48, 0x22, 0x22, 0x5f, - 0x73, 0x07, 0x96, 0x9a, 0x7a, 0x55, 0xe1, 0x55, 0x13, 0x5d, 0xf9, 0xc8, 0x21, 0x0e, 0x61, 0x7e, - 0x2d, 0x7d, 0xe3, 0x50, 0xe5, 0xa6, 0x45, 0xa8, 0x47, 0xa8, 0xe6, 0x51, 0x47, 0x4b, 0x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- 0xb0, 0x33, 0x7b, 0xc0, 0xdd, 0x29, 0x55, 0x72, 0xfe, 0x54, 0x51, 0x8e, 0x96, 0x82, 0x65, 0x55, - 0x3f, 0x87, 0x6b, 0x65, 0x67, 0xca, 0xdd, 0x45, 0x2c, 0x25, 0x60, 0xe5, 0xde, 0x7f, 0x00, 0x67, - 0x89, 0xbf, 0x07, 0x28, 0x9c, 0x07, 0xed, 0x45, 0x14, 0x39, 0x46, 0x39, 0xbc, 0x1c, 0x53, 0x64, - 0x2f, 0xec, 0xb1, 0x0b, 0xd9, 0x73, 0xcc, 0x62, 0xf6, 0x92, 0x6d, 0xec, 0x09, 0x7c, 0x30, 0xdd, - 0x7b, 0x9a, 0x8b, 0xc2, 0x04, 0x40, 0xd9, 0xbf, 0x04, 0x90, 0x91, 0x9e, 0xc1, 0xee, 0xfc, 0x0f, - 0xb9, 0x30, 0x76, 0x0e, 0xa8, 0x68, 0x4b, 0x02, 0xa7, 0xc9, 0x94, 0x2b, 0x3f, 0xbd, 0x39, 0x3f, - 0x94, 0x1e, 0x3d, 0x7d, 0x79, 0xd1, 0x90, 0x5e, 0x5d, 0x34, 0xa4, 0xd7, 0x17, 0x0d, 0xe9, 0xd7, - 0x49, 0xa3, 0xf2, 0x6a, 0xd2, 0xa8, 0xfc, 0x35, 0x69, 0x54, 0xbe, 0xfd, 0xd2, 0x71, 0xa3, 0x61, - 0x3c, 0x48, 0xaf, 0x44, 0x9a, 0xb8, 0x11, 0xba, 0x03, 0xeb, 0xc8, 0x21, 0x5a, 0x72, 0xa2, 0x79, - 0xc4, 0x8e, 0x47, 0x48, 0xf9, 0x65, 0xed, 0xb3, 0xcf, 0x8f, 0x8a, 0x57, 0xce, 0x71, 0x80, 0x74, - 0xb0, 0xc1, 0x2e, 0x6a, 0xf7, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x51, 0xcd, 0x7c, 0xd2, 0x96, - 0x0a, 0x00, 0x00, + // 886 bytes of a gzipped FileDescriptorProto + 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x0a, 0xad, 0xdd, 0xfd, 0x2f, + 0xe8, 0x3c, 0xf7, 0xb7, 0x00, 0xa5, 0x23, 0xa1, 0x57, 0xc7, 0x51, 0x60, 0xb4, 0xed, 0x8b, 0x31, + 0x65, 0xf6, 0xd2, 0x36, 0xdb, 0xab, 0xaf, 0x30, 0xc3, 0xd4, 0xb3, 0x57, 0xec, 0x64, 0x8f, 0xe1, + 0xad, 0x6c, 0xfb, 0xe9, 0xd6, 0x85, 0x49, 0x80, 0xb6, 0x79, 0x01, 0x20, 0x27, 0x3d, 0x84, 0xd5, + 0xd9, 0x7f, 0xb2, 0x36, 0x76, 0x06, 0xa8, 0x19, 0x97, 0x04, 0x66, 0xc9, 0xb4, 0x6b, 0x3f, 0xbd, + 0x3a, 0xde, 0x56, 0x1e, 0x3e, 0x79, 0x7e, 0xd2, 0x51, 0x5e, 0x9c, 0x74, 0x94, 0x97, 0x27, 0x1d, + 0xe5, 0xd7, 0xd3, 0x4e, 0xe3, 0xc5, 0x69, 0xa7, 0xf1, 0xd7, 0x69, 0xa7, 0xf1, 0xf5, 0xe7, 0x9e, + 0xcf, 0xc6, 0xd3, 0x51, 0x7a, 0x2f, 0x32, 0xe4, 0xb5, 0xd0, 0x1f, 0x39, 0x3b, 0x1e, 0x31, 0x92, + 0x3d, 0x23, 0x20, 0xee, 0x74, 0x82, 0x54, 0xdc, 0xd8, 0x3e, 0xb9, 0xbb, 0x53, 0xbe, 0x77, 0x1e, + 0x45, 0x48, 0x47, 0x0b, 0xfc, 0xb6, 0xf6, 0xe9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xce, + 0x42, 0x56, 0x9b, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -603,8 +603,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // CreateChannel defines a rpc handler method for MsgCreateChannel CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -632,9 +632,9 @@ func (c *msgClient) CreateChannel(ctx context.Context, in *MsgCreateChannel, opt return out, nil } -func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { - out := new(MsgProvideCounterpartyResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/ProvideCounterparty", in, out, opts...) +func (c *msgClient) RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) { + out := new(MsgRegisterCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/RegisterCounterparty", in, out, opts...) if err != nil { return nil, err } @@ -681,8 +681,8 @@ func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, type MsgServer interface { // CreateChannel defines a rpc handler method for MsgCreateChannel CreateChannel(context.Context, *MsgCreateChannel) (*MsgCreateChannelResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + RegisterCounterparty(context.Context, *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -700,8 +700,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateChannel(ctx context.Context, req *MsgCreateChannel) (*MsgCreateChannelResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") } -func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") +func (*UnimplementedMsgServer) RegisterCounterparty(ctx context.Context, req *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterparty not implemented") } func (*UnimplementedMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") @@ -738,20 +738,20 @@ func _Msg_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgProvideCounterparty) +func _Msg_RegisterCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterCounterparty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).ProvideCounterparty(ctx, in) + return srv.(MsgServer).RegisterCounterparty(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v2.Msg/ProvideCounterparty", + FullMethod: "/ibc.core.channel.v2.Msg/RegisterCounterparty", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) + return srv.(MsgServer).RegisterCounterparty(ctx, req.(*MsgRegisterCounterparty)) } return interceptor(ctx, in, info, handler) } @@ -837,8 +837,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_CreateChannel_Handler, }, { - MethodName: "ProvideCounterparty", - Handler: _Msg_ProvideCounterparty_Handler, + MethodName: "RegisterCounterparty", + Handler: _Msg_RegisterCounterparty_Handler, }, { MethodName: "SendPacket", @@ -938,7 +938,7 @@ func (m *MsgCreateChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterCounterparty) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -948,12 +948,12 @@ func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterparty) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -982,7 +982,7 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterCounterpartyResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -992,12 +992,12 @@ func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1397,7 +1397,7 @@ func (m *MsgCreateChannelResponse) Size() (n int) { return n } -func (m *MsgProvideCounterparty) Size() (n int) { +func (m *MsgRegisterCounterparty) Size() (n int) { if m == nil { return 0 } @@ -1418,7 +1418,7 @@ func (m *MsgProvideCounterparty) Size() (n int) { return n } -func (m *MsgProvideCounterpartyResponse) Size() (n int) { +func (m *MsgRegisterCounterpartyResponse) Size() (n int) { if m == nil { return 0 } @@ -1801,7 +1801,7 @@ func (m *MsgCreateChannelResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterCounterparty) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1824,10 +1824,10 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterparty: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterCounterparty: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1947,7 +1947,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterCounterpartyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1970,10 +1970,10 @@ func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterCounterpartyResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index bd67ae3e12a..9276f8cdc67 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -18,8 +18,8 @@ service Msg { // CreateChannel defines a rpc handler method for MsgCreateChannel rpc CreateChannel(MsgCreateChannel) returns (MsgCreateChannelResponse); - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + rpc RegisterCounterparty(MsgRegisterCounterparty) returns (MsgRegisterCounterpartyResponse); // SendPacket defines a rpc handler method for MsgSendPacket. rpc SendPacket(MsgSendPacket) returns (MsgSendPacketResponse); @@ -56,9 +56,9 @@ message MsgCreateChannelResponse { string channel_id = 1; } -// MsgProvideCounterparty defines the message used to provide the counterparty channel +// MsgRegisterCounterparty defines the message used to provide the counterparty channel // identifier. -message MsgProvideCounterparty { +message MsgRegisterCounterparty { option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.goproto_getters) = false; @@ -71,8 +71,8 @@ message MsgProvideCounterparty { string signer = 3; } -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -message MsgProvideCounterpartyResponse {} +// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. +message MsgRegisterCounterpartyResponse {} // MsgSendPacket sends an outgoing IBC packet. message MsgSendPacket { diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index f2cfcedc540..b4efd98247b 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -9,16 +9,6 @@ import ( hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) -// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. -func (endpoint *Endpoint) ProvideCounterparty() (err error) { - msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) - - // setup counterparty - _, err = endpoint.Chain.SendMsgs(msg) - - return err -} - // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { endpoint.IncrementNextChannelSequence() @@ -38,6 +28,16 @@ func (endpoint *Endpoint) CreateChannel() (err error) { return nil } +// RegisterCounterparty will construct and execute a MsgRegisterCounterparty on the associated endpoint. +func (endpoint *Endpoint) RegisterCounterparty() (err error) { + msg := channeltypesv2.NewMsgRegisterCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) + + // setup counterparty + _, err = endpoint.Chain.SendMsgs(msg) + + return err +} + // MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned. func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channeltypesv2.Payload) (channeltypesv2.Packet, error) { msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), payload) diff --git a/testing/path.go b/testing/path.go index 85c5eaa9d1b..b31dec57ed9 100644 --- a/testing/path.go +++ b/testing/path.go @@ -175,11 +175,11 @@ func (path *Path) SetupClients() { // SetupCounterparties is a helper function to set the counterparties supporting ibc-eureka on both // chains. It assumes the caller does not anticipate any errors. func (path *Path) SetupCounterparties() { - if err := path.EndpointB.ProvideCounterparty(); err != nil { + if err := path.EndpointB.RegisterCounterparty(); err != nil { panic(err) } - if err := path.EndpointA.ProvideCounterparty(); err != nil { + if err := path.EndpointA.RegisterCounterparty(); err != nil { panic(err) } } From 4e5e5c30a374974d1443384a02b5b3fa34140084 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Oct 2024 16:11:00 +0200 Subject: [PATCH 103/172] chore: add v2 packet commitment query (#7494) * feat: add v2 packet commitment query * chore: add cli for packet commitment query with abci proof * chore: correct channel query url path, correct errors numbering --- modules/core/04-channel/v2/client/cli/abci.go | 26 + modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 54 +- .../core/04-channel/v2/keeper/grpc_query.go | 40 +- .../04-channel/v2/keeper/grpc_query_test.go | 104 ++++ modules/core/04-channel/v2/keeper/keeper.go | 6 + modules/core/04-channel/v2/types/errors.go | 13 +- modules/core/04-channel/v2/types/query.go | 35 ++ modules/core/04-channel/v2/types/query.pb.go | 584 +++++++++++++++++- .../core/04-channel/v2/types/query.pb.gw.go | 125 +++- proto/ibc/core/channel/v2/query.proto | 26 +- 11 files changed, 970 insertions(+), 44 deletions(-) create mode 100644 modules/core/04-channel/v2/client/cli/abci.go create mode 100644 modules/core/04-channel/v2/types/query.go diff --git a/modules/core/04-channel/v2/client/cli/abci.go b/modules/core/04-channel/v2/client/cli/abci.go new file mode 100644 index 00000000000..595a9f6da2c --- /dev/null +++ b/modules/core/04-channel/v2/client/cli/abci.go @@ -0,0 +1,26 @@ +package cli + +import ( + errorsmod "cosmossdk.io/errors" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + ibcclient "github.com/cosmos/ibc-go/v9/modules/core/client" +) + +func queryPacketCommitmentABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketCommitmentResponse, error) { + key := host.PacketCommitmentKey(channelID, sequence) + value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) + if err != nil { + return nil, err + } + + // check if packet commitment exists + if len(value) == 0 { + return nil, errorsmod.Wrapf(types.ErrPacketCommitmentNotFound, "channelID (%s), sequence (%d)", channelID, sequence) + } + + return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil +} diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index ea4ac94f8cd..ed5a66db7fd 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCmdQueryChannel(), + getCmdQueryPacketCommitment(), ) return queryCmd diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 3521430d225..c4d5236d781 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "github.com/spf13/cobra" @@ -26,13 +27,60 @@ func getCmdQueryChannel() *cobra.Command { if err != nil { return err } + channelID := args[0] queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Channel(cmd.Context(), types.NewQueryChannelRequest(channelID)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func getCmdQueryPacketCommitment() *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-commitment [channel-id] [sequence]", + Short: "Query a channel/v2 packet commitment", + Long: "Query a channel/v2 packet commitment by channel-id and sequence", + Example: fmt.Sprintf( + "%s query %s %s packet-commitment [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + seq, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } - req := &types.QueryChannelRequest{ChannelId: channelID} + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + if prove { + res, err := queryPacketCommitmentABCI(clientCtx, channelID, seq) + if err != nil { + return err + } - res, err := queryClient.Channel(cmd.Context(), req) + return clientCtx.PrintProto(res) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.PacketCommitment(cmd.Context(), types.NewQueryPacketCommitmentRequest(channelID, seq)) if err != nil { return err } @@ -40,6 +88,8 @@ func getCmdQueryChannel() *cobra.Command { return clientCtx.PrintProto(res) }, } + + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") flags.AddQueryFlagsToCmd(cmd) return cmd diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 10343b516ab..9939ea1bfb3 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -8,8 +8,7 @@ import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) @@ -38,12 +37,8 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques return nil, status.Error(codes.InvalidArgument, err.Error()) } - res := types.QueryChannelResponse{} - - sdkCtx := sdk.UnwrapSDKContext(ctx) - - creator, foundCreator := q.GetCreator(sdkCtx, req.ChannelId) - channel, foundChannel := q.GetChannel(sdkCtx, req.ChannelId) + creator, foundCreator := q.GetCreator(ctx, req.ChannelId) + channel, foundChannel := q.GetChannel(ctx, req.ChannelId) if !foundCreator && !foundChannel { return nil, status.Error( @@ -52,8 +47,31 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques ) } - res.Channel = channel - res.Creator = creator + return types.NewQueryChannelResponse(creator, channel), nil +} + +// PacketCommitment implements the Query/PacketCommitment gRPC method. +func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ClientIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if req.Sequence == 0 { + return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + commitment := q.GetPacketCommitment(ctx, req.ChannelId, req.Sequence) + if len(commitment) == 0 { + return nil, status.Error(codes.NotFound, "packet commitment hash not found") + } - return &res, nil + return types.NewQueryPacketCommitmentResponse(commitment, nil, clienttypes.GetSelfHeight(ctx)), nil } diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index ad50fe3c6ba..078be3acb65 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -116,3 +116,107 @@ func (suite *KeeperTestSuite) TestQueryChannel() { }) } } + +func (suite *KeeperTestSuite) TestQueryPacketCommitment() { + var ( + expCommitment []byte + path *ibctesting.Path + req *types.QueryPacketCommitmentRequest + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expCommitment = []byte("commitmentHash") + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, expCommitment) + + req = &types.QueryPacketCommitmentRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryPacketCommitmentRequest{ + ChannelId: "", + Sequence: 1, + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "invalid sequence", + func() { + req = &types.QueryPacketCommitmentRequest{ + ChannelId: ibctesting.FirstChannelID, + Sequence: 0, + } + }, + status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), + }, + { + "channel not found", + func() { + req = &types.QueryPacketCommitmentRequest{ + ChannelId: "channel-141", + Sequence: 1, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), + }, + { + "commitment not found", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + req = &types.QueryPacketCommitmentRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + status.Error(codes.NotFound, "packet commitment hash not found"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) + res, err := queryServer.PacketCommitment(suite.chainA.GetContext(), req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCommitment, res.Commitment) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index eb046b3cd5d..b5e81ee7cee 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -79,6 +79,12 @@ func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channe return channel, true } +// HasChannel returns true if a Channel exists for a given channel identifier, otherwise false. +func (k *Keeper) HasChannel(ctx context.Context, channelID string) bool { + store := k.ChannelStore(ctx, channelID) + return store.Has([]byte(types.ChannelKey)) +} + // GetCreator returns the creator of the channel. func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool) { bz := k.ChannelStore(ctx, channelID).Get([]byte(types.CreatorKey)) diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 1e0eaa95c70..39e4d078e8b 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,10 +5,11 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") - ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") - ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 8, "invalid acknowledgement") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") + ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") + ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") ) diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go new file mode 100644 index 00000000000..e9b90d70a55 --- /dev/null +++ b/modules/core/04-channel/v2/types/query.go @@ -0,0 +1,35 @@ +package types + +import clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + +// NewQueryChannelRequest creates and returns a new channel query request. +func NewQueryChannelRequest(channelID string) *QueryChannelRequest { + return &QueryChannelRequest{ + ChannelId: channelID, + } +} + +// NewQueryChannelResponse creates and returns a new channel query response. +func NewQueryChannelResponse(creator string, channel Channel) *QueryChannelResponse { + return &QueryChannelResponse{ + Creator: creator, + Channel: channel, + } +} + +// NewQueryPacketCommitmentRequest creates and returns a new packet commitment query request. +func NewQueryPacketCommitmentRequest(channelID string, sequence uint64) *QueryPacketCommitmentRequest { + return &QueryPacketCommitmentRequest{ + ChannelId: channelID, + Sequence: sequence, + } +} + +// NewQueryPacketCommitmentResponse creates and returns a new packet commitment query response. +func NewQueryPacketCommitmentResponse(commitmentHash []byte, proof []byte, proofHeight clienttypes.Height) *QueryPacketCommitmentResponse { + return &QueryPacketCommitmentResponse{ + Commitment: commitmentHash, + Proof: proof, + ProofHeight: proofHeight, + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 04c4360c60d..a27dc35bf10 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -127,37 +128,167 @@ func (m *QueryChannelResponse) GetChannel() Channel { return Channel{} } +// QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. +type QueryPacketCommitmentRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitmentRequest{} } +func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentRequest) ProtoMessage() {} +func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{2} +} +func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentRequest.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 *QueryPacketCommitmentRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentRequest.Merge(m, src) +} +func (m *QueryPacketCommitmentRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentRequest proto.InternalMessageInfo + +func (m *QueryPacketCommitmentRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryPacketCommitmentRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +// QueryPacketCommitmentResponse is the response type for the Query/PacketCommitment RPC method. +type QueryPacketCommitmentResponse struct { + // packet associated with the request fields + Commitment []byte `protobuf:"bytes,1,opt,name=commitment,proto3" json:"commitment,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommitmentResponse{} } +func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentResponse) ProtoMessage() {} +func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{3} +} +func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentResponse.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 *QueryPacketCommitmentResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentResponse.Merge(m, src) +} +func (m *QueryPacketCommitmentResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentResponse proto.InternalMessageInfo + +func (m *QueryPacketCommitmentResponse) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil +} + +func (m *QueryPacketCommitmentResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryPacketCommitmentResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") + proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") + proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 339 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0x48, 0xcc, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0xd2, -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a, 0x81, 0xc5, 0x3b, 0x52, 0x9a, 0x44, 0xa8, 0x84, - 0x78, 0x41, 0xc9, 0xb0, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0xda, 0x42, 0x9a, 0xfa, 0x78, 0x02, 0x5c, - 0xbf, 0x1a, 0x11, 0x3a, 0xb5, 0x4e, 0x61, 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, 0x65, 0x93, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, - 0x9c, 0x9b, 0x5f, 0x0c, 0x32, 0x55, 0x37, 0x3d, 0x5f, 0xbf, 0xcc, 0x52, 0x3f, 0x37, 0x3f, 0xa5, - 0x34, 0x27, 0xb5, 0x18, 0x62, 0x87, 0x81, 0x89, 0x2e, 0x92, 0x35, 0x25, 0x95, 0x05, 0xa9, 0xc5, - 0x49, 0x6c, 0xe0, 0x28, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x69, 0x95, 0xfc, 0x31, - 0x02, 0x00, 0x00, + // 494 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x85, 0x96, 0xd0, 0x6b, 0x06, 0x74, 0xcd, 0x10, 0x59, 0xa9, 0x5b, 0x3c, 0x05, 0x44, + 0x7d, 0xc4, 0x74, 0x41, 0xea, 0xd4, 0x2c, 0x85, 0xa9, 0x78, 0x40, 0x82, 0x25, 0x72, 0x2e, 0x87, + 0x73, 0x22, 0xbe, 0xe7, 0xfa, 0x2e, 0x96, 0xaa, 0xaa, 0x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x73, 0xd1, 0x8f, 0x99, 0x8b, 0x3e, 0xcc, 0xdd, 0xda, 0xf5, + 0xdc, 0xad, 0x7d, 0x9b, 0xbb, 0xb5, 0x37, 0x47, 0xb1, 0xd0, 0xe3, 0xe9, 0xd0, 0x67, 0x90, 0x50, + 0x06, 0x2a, 0x01, 0x55, 0x88, 0x1e, 0xc4, 0x40, 0xf3, 0x67, 0x34, 0x81, 0xd1, 0x74, 0xc2, 0x55, + 0x69, 0xe1, 0xc9, 0xe1, 0xc1, 0x92, 0x0b, 0x7d, 0x9e, 0x72, 0x35, 0xbc, 0x6b, 0xfe, 0xb4, 0xa7, + 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xaa, 0x63, 0x79, 0x19, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -174,6 +305,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Channel queries the counterparty of an IBC client. Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) + // PacketCommitment queries a stored packet commitment hash. + PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) } type queryClient struct { @@ -193,10 +326,21 @@ func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts return out, nil } +func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) { + out := new(QueryPacketCommitmentResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketCommitment", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Channel queries the counterparty of an IBC client. Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) + // PacketCommitment queries a stored packet commitment hash. + PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -206,6 +350,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") } +func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketCommitment not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -229,6 +376,24 @@ func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Query_PacketCommitment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketCommitmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketCommitment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/PacketCommitment", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketCommitment(ctx, req.(*QueryPacketCommitmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), @@ -237,6 +402,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Channel", Handler: _Query_Channel_Handler, }, + { + MethodName: "PacketCommitment", + Handler: _Query_PacketCommitment_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/query.proto", @@ -312,6 +481,88 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryPacketCommitmentRequest) 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 *QueryPacketCommitmentRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketCommitmentResponse) 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 *QueryPacketCommitmentResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -351,6 +602,41 @@ func (m *QueryChannelResponse) Size() (n int) { return n } +func (m *QueryPacketCommitmentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + return n +} + +func (m *QueryPacketCommitmentResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Commitment) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -554,6 +840,258 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPacketCommitmentRequest) 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 ErrIntOverflowQuery + } + 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: QueryPacketCommitmentRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentResponse) 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 ErrIntOverflowQuery + } + 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: QueryPacketCommitmentResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitment", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 6ed5d7819e6..f31a777498a 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -87,6 +87,82 @@ func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marsha } +func request_Query_PacketCommitment_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketCommitmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + msg, err := client.PacketCommitment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PacketCommitment_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketCommitmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + msg, err := server.PacketCommitment(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -116,6 +192,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PacketCommitment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PacketCommitment_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketCommitment_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -177,13 +276,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PacketCommitment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PacketCommitment_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketCommitment_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 2, 1, 0, 4, 1, 5, 4}, []string{"ibc", "core", "channel", "v2", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Channel_0 = runtime.ForwardResponseMessage + + forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 072118099a8..77e5e8a2331 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -5,6 +5,7 @@ package ibc.core.channel.v2; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; import "ibc/core/channel/v2/channel.proto"; +import "ibc/core/client/v1/client.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; @@ -12,7 +13,12 @@ import "gogoproto/gogo.proto"; service Query { // Channel queries the counterparty of an IBC client. rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channel/{channel_id}"; + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}"; + } + + // PacketCommitment queries a stored packet commitment hash. + rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}"; } } @@ -26,3 +32,21 @@ message QueryChannelResponse { string creator = 1; Channel channel = 2 [(gogoproto.nullable) = false]; } + +// QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. +message QueryPacketCommitmentRequest { + // channel unique identifier + string channel_id = 1; + // packet sequence + uint64 sequence = 2; +} + +// QueryPacketCommitmentResponse is the response type for the Query/PacketCommitment RPC method. +message QueryPacketCommitmentResponse { + // packet associated with the request fields + bytes commitment = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} \ No newline at end of file From 15877e8b8770186187a742452e50a47d818f6ae0 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Oct 2024 17:40:43 +0200 Subject: [PATCH 104/172] chore: impl packet acknowledgement query (#7507) * feat: add v2 packet commitment query * chore: add cli for packet commitment query with abci proof * chore: impl packet acknowledgement query * fix: update identifier validation in grpcs --- modules/core/04-channel/v2/client/cli/abci.go | 15 + modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 51 ++ .../core/04-channel/v2/keeper/grpc_query.go | 30 +- .../04-channel/v2/keeper/grpc_query_test.go | 104 +++ modules/core/04-channel/v2/types/errors.go | 1 + modules/core/04-channel/v2/types/query.go | 17 + modules/core/04-channel/v2/types/query.pb.go | 597 +++++++++++++++++- .../core/04-channel/v2/types/query.pb.gw.go | 123 ++++ proto/ibc/core/channel/v2/query.proto | 23 + 10 files changed, 928 insertions(+), 34 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/abci.go b/modules/core/04-channel/v2/client/cli/abci.go index 595a9f6da2c..b740156bf3c 100644 --- a/modules/core/04-channel/v2/client/cli/abci.go +++ b/modules/core/04-channel/v2/client/cli/abci.go @@ -24,3 +24,18 @@ func queryPacketCommitmentABCI(clientCtx client.Context, channelID string, seque return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil } + +func queryPacketAcknowledgementABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketAcknowledgementResponse, error) { + key := host.PacketAcknowledgementKey(channelID, sequence) + value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) + if err != nil { + return nil, err + } + + // check if packet commitment exists + if len(value) == 0 { + return nil, errorsmod.Wrapf(types.ErrAcknowledgementNotFound, "channelID (%s), sequence (%d)", channelID, sequence) + } + + return types.NewQueryPacketAcknowledgementResponse(value, proofBz, proofHeight), nil +} diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index ed5a66db7fd..8eff794ca3f 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -21,6 +21,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCmdQueryChannel(), getCmdQueryPacketCommitment(), + getCmdQueryPacketAcknowledgement(), ) return queryCmd diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index c4d5236d781..587b749b28b 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -94,3 +94,54 @@ func getCmdQueryPacketCommitment() *cobra.Command { return cmd } + +func getCmdQueryPacketAcknowledgement() *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-acknowledgement [channel-id] [sequence]", + Short: "Query a channel/v2 packet acknowledgement", + Long: "Query a channel/v2 packet acknowledgement by channel-id and sequence", + Example: fmt.Sprintf( + "%s query %s %s packet-acknowledgement [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + seq, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + if prove { + res, err := queryPacketAcknowledgementABCI(clientCtx, channelID, seq) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.PacketAcknowledgement(cmd.Context(), types.NewQueryPacketAcknowledgementRequest(channelID, seq)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 9939ea1bfb3..b578654589a 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -33,7 +33,7 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ClientIdentifierValidator(req.ChannelId); err != nil { + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -56,7 +56,7 @@ func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPack return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ClientIdentifierValidator(req.ChannelId); err != nil { + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -75,3 +75,29 @@ func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPack return types.NewQueryPacketCommitmentResponse(commitment, nil, clienttypes.GetSelfHeight(ctx)), nil } + +// PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method. +func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if req.Sequence == 0 { + return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + acknowledgement := q.GetPacketAcknowledgement(ctx, req.ChannelId, req.Sequence) + if len(acknowledgement) == 0 { + return nil, status.Error(codes.NotFound, "packet acknowledgement hash not found") + } + + return types.NewQueryPacketAcknowledgementResponse(acknowledgement, nil, clienttypes.GetSelfHeight(ctx)), nil +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 078be3acb65..b7ab81c9fda 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -220,3 +220,107 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }) } } + +func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { + var ( + expAcknowledgement []byte + path *ibctesting.Path + req *types.QueryPacketAcknowledgementRequest + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expAcknowledgement = []byte("acknowledgementHash") + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, expAcknowledgement) + + req = &types.QueryPacketAcknowledgementRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryPacketAcknowledgementRequest{ + ChannelId: "", + Sequence: 1, + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "invalid sequence", + func() { + req = &types.QueryPacketAcknowledgementRequest{ + ChannelId: ibctesting.FirstChannelID, + Sequence: 0, + } + }, + status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), + }, + { + "channel not found", + func() { + req = &types.QueryPacketAcknowledgementRequest{ + ChannelId: "channel-141", + Sequence: 1, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), + }, + { + "acknowledgement not found", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + req = &types.QueryPacketAcknowledgementRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + status.Error(codes.NotFound, "packet acknowledgement hash not found"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) + res, err := queryServer.PacketAcknowledgement(suite.chainA.GetContext(), req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expAcknowledgement, res.Acknowledgement) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 39e4d078e8b..7a1cabe9fc0 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -12,4 +12,5 @@ var ( ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") + ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 9, "packet acknowledgement not found") ) diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index e9b90d70a55..561ef0cbe55 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -33,3 +33,20 @@ func NewQueryPacketCommitmentResponse(commitmentHash []byte, proof []byte, proof ProofHeight: proofHeight, } } + +// NewQueryPacketAcknowledgementRequest creates and returns a new packet acknowledgement query request. +func NewQueryPacketAcknowledgementRequest(channelID string, sequence uint64) *QueryPacketAcknowledgementRequest { + return &QueryPacketAcknowledgementRequest{ + ChannelId: channelID, + Sequence: sequence, + } +} + +// NewQueryPacketAcknowledgementResponse creates and returns a new packet acknowledgement query response. +func NewQueryPacketAcknowledgementResponse(acknowledgementHash []byte, proof []byte, proofHeight clienttypes.Height) *QueryPacketAcknowledgementResponse { + return &QueryPacketAcknowledgementResponse{ + Acknowledgement: acknowledgementHash, + Proof: proof, + ProofHeight: proofHeight, + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index a27dc35bf10..cf9501c53d3 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -247,48 +247,174 @@ func (m *QueryPacketCommitmentResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. +type QueryPacketAcknowledgementRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAcknowledgementRequest{} } +func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} +func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{4} +} +func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketAcknowledgementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketAcknowledgementRequest.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 *QueryPacketAcknowledgementRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketAcknowledgementRequest.Merge(m, src) +} +func (m *QueryPacketAcknowledgementRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketAcknowledgementRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketAcknowledgementRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketAcknowledgementRequest proto.InternalMessageInfo + +func (m *QueryPacketAcknowledgementRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryPacketAcknowledgementRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +// QueryPacketAcknowledgementResponse is the response type for the Query/PacketAcknowledgement RPC method. +type QueryPacketAcknowledgementResponse struct { + // acknowledgement associated with the request fields + Acknowledgement []byte `protobuf:"bytes,1,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketAcknowledgementResponse{} } +func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} +func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{5} +} +func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketAcknowledgementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketAcknowledgementResponse.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 *QueryPacketAcknowledgementResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketAcknowledgementResponse.Merge(m, src) +} +func (m *QueryPacketAcknowledgementResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketAcknowledgementResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketAcknowledgementResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketAcknowledgementResponse proto.InternalMessageInfo + +func (m *QueryPacketAcknowledgementResponse) GetAcknowledgement() []byte { + if m != nil { + return m.Acknowledgement + } + return nil +} + +func (m *QueryPacketAcknowledgementResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryPacketAcknowledgementResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentResponse") + proto.RegisterType((*QueryPacketAcknowledgementRequest)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementRequest") + proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x3f, 0x6f, 0xd3, 0x40, - 0x14, 0xcf, 0x85, 0x96, 0xd0, 0x6b, 0x06, 0x74, 0xcd, 0x10, 0x59, 0xa9, 0x5b, 0x3c, 0x05, 0x44, - 0x7d, 0xc4, 0x74, 0x41, 0xea, 0xd4, 0x2c, 0x85, 0xa9, 0x78, 0x40, 0x82, 0x25, 0x72, 0x2e, 0x87, - 0x73, 0x22, 0xbe, 0xe7, 0xfa, 0x2e, 0x96, 0xaa, 0xaa, 0x0b, 0x9f, 0x00, 0xc1, 0xc6, 0x27, 0xaa, - 0xc4, 0x52, 0x89, 0x85, 0x09, 0xa1, 0x84, 0x89, 0x4f, 0x81, 0x7c, 0xbe, 0xb4, 0x01, 0x39, 0x28, - 0x6c, 0xef, 0x3d, 0xbf, 0xdf, 0x9f, 0xf7, 0xde, 0x19, 0xef, 0x89, 0x21, 0xa3, 0x0c, 0x32, 0x4e, - 0xd9, 0x38, 0x92, 0x92, 0x4f, 0x68, 0x1e, 0xd0, 0xb3, 0x29, 0xcf, 0xce, 0xfd, 0x34, 0x03, 0x0d, - 0x64, 0x47, 0x0c, 0x99, 0x5f, 0x34, 0xf8, 0xb6, 0xc1, 0xcf, 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1d, 0xaa, 0x63, 0x79, 0x19, 0x04, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6b, 0x13, 0x41, + 0x18, 0xcd, 0xd4, 0xd6, 0xd8, 0x69, 0x40, 0x99, 0x46, 0x08, 0x4b, 0xba, 0x6d, 0xf7, 0x14, 0xc5, + 0xee, 0x98, 0xb5, 0x28, 0x42, 0x2f, 0x36, 0x20, 0xd1, 0x83, 0xd4, 0x3d, 0x08, 0x7a, 0x30, 0x6c, + 0x26, 0xe3, 0x66, 0x69, 0x76, 0x66, 0xbb, 0x33, 0x89, 0x94, 0xd2, 0x8b, 0xbf, 0x40, 0xf4, 0xe6, + 0x3f, 0xf0, 0x87, 0x08, 0x05, 0x2f, 0x05, 0x2f, 0x3d, 0x89, 0x24, 0xfe, 0x10, 0xd9, 0xd9, 0x49, + 0xbb, 0x0d, 0x9b, 0x9a, 0x80, 0xde, 0x66, 0xbe, 0xf9, 0xde, 0xf7, 0xde, 0xfb, 0xf2, 0xb2, 0x70, + 0x3d, 0x68, 0x13, 0x4c, 0x78, 0x4c, 0x31, 0xe9, 0x7a, 0x8c, 0xd1, 0x1e, 0x1e, 0x38, 0xf8, 0xa0, + 0x4f, 0xe3, 0x43, 0x3b, 0x8a, 0xb9, 0xe4, 0x68, 0x35, 0x68, 0x13, 0x3b, 0x69, 0xb0, 0x75, 0x83, + 0x3d, 0x70, 0x8c, 0xcd, 0x3c, 0xd4, 0xf8, 0x5d, 0xe1, 0x8c, 0xcc, 0xe0, 0x5e, 0x40, 0x99, 0xc4, + 0x83, 0xba, 0x3e, 0xe9, 0x86, 0xaa, 0xcf, 0xb9, 0xdf, 0xa3, 0xd8, 0x8b, 0x02, 0xec, 0x31, 0xc6, + 0xa5, 0x27, 0x03, 0xce, 0x84, 0x7e, 0x2d, 0xfb, 0xdc, 0xe7, 0xea, 0x88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 0xc7, 0x38, 0xe4, 0x9d, 0x7e, 0x8f, 0x8a, 0x54, 0xc0, + 0xfd, 0xed, 0xad, 0x8c, 0x06, 0x79, 0x18, 0x51, 0xd1, 0xbe, 0xae, 0x3e, 0xa8, 0x0f, 0xfe, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x66, 0x70, 0x9b, 0xa5, 0x00, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -307,6 +433,8 @@ type QueryClient interface { Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) + // PacketAcknowledgement queries a stored acknowledgement commitment hash. + PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) } type queryClient struct { @@ -335,12 +463,23 @@ func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommi return out, nil } +func (c *queryClient) PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) { + out := new(QueryPacketAcknowledgementResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketAcknowledgement", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Channel queries the counterparty of an IBC client. Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) + // PacketAcknowledgement queries a stored acknowledgement commitment hash. + PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -353,6 +492,9 @@ func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelR func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketCommitment not implemented") } +func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketAcknowledgement not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -394,6 +536,24 @@ func _Query_PacketCommitment_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_PacketAcknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketAcknowledgementRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketAcknowledgement(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/PacketAcknowledgement", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketAcknowledgement(ctx, req.(*QueryPacketAcknowledgementRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), @@ -406,6 +566,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketCommitment", Handler: _Query_PacketCommitment_Handler, }, + { + MethodName: "PacketAcknowledgement", + Handler: _Query_PacketAcknowledgement_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/query.proto", @@ -563,6 +727,88 @@ func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryPacketAcknowledgementRequest) 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 *QueryPacketAcknowledgementRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketAcknowledgementRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketAcknowledgementResponse) 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 *QueryPacketAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Acknowledgement))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -637,6 +883,41 @@ func (m *QueryPacketCommitmentResponse) Size() (n int) { return n } +func (m *QueryPacketAcknowledgementRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + return n +} + +func (m *QueryPacketAcknowledgementResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Acknowledgement) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1092,6 +1373,258 @@ func (m *QueryPacketCommitmentResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPacketAcknowledgementRequest) 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 ErrIntOverflowQuery + } + 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: QueryPacketAcknowledgementRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketAcknowledgementRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketAcknowledgementResponse) 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 ErrIntOverflowQuery + } + 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: QueryPacketAcknowledgementResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index f31a777498a..03626cf677f 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -163,6 +163,82 @@ func local_request_Query_PacketCommitment_0(ctx context.Context, marshaler runti } +func request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketAcknowledgementRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + msg, err := client.PacketAcknowledgement(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketAcknowledgementRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + msg, err := server.PacketAcknowledgement(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -215,6 +291,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PacketAcknowledgement_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketAcknowledgement_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -296,6 +395,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PacketAcknowledgement_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketAcknowledgement_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -303,10 +422,14 @@ var ( pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "acknowledgements", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Channel_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage + + forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 77e5e8a2331..051789b3330 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -20,6 +20,11 @@ service Query { rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}"; } + + // PacketAcknowledgement queries a stored acknowledgement commitment hash. + rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/acknowledgements/{sequence}"; + } } // QueryChannelRequest is the request type for the Query/Channel RPC method @@ -49,4 +54,22 @@ message QueryPacketCommitmentResponse { bytes proof = 2; // height at which the proof was retrieved ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. +message QueryPacketAcknowledgementRequest { + // channel unique identifier + string channel_id = 1; + // packet sequence + uint64 sequence = 2; +} + +// QueryPacketAcknowledgementResponse is the response type for the Query/PacketAcknowledgement RPC method. +message QueryPacketAcknowledgementResponse { + // acknowledgement associated with the request fields + bytes acknowledgement = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } \ No newline at end of file From e752c0d4c048cd26401bb9351a71532a3278a184 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 29 Oct 2024 10:35:16 +0100 Subject: [PATCH 105/172] chore: remove creator field from channel query (#7523) --- .../core/04-channel/v2/client/cli/query.go | 3 +- .../core/04-channel/v2/keeper/grpc_query.go | 13 +- .../04-channel/v2/keeper/grpc_query_test.go | 44 +----- modules/core/04-channel/v2/types/query.go | 3 +- modules/core/04-channel/v2/types/query.pb.go | 130 ++++++------------ proto/ibc/core/channel/v2/query.proto | 4 +- 6 files changed, 56 insertions(+), 141 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 587b749b28b..7383673588d 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -19,7 +19,7 @@ func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ Use: "channel [channel-id]", Short: "Query the information of a channel.", - Long: "Query the channel information (creator and channel) for the provided channel ID.", + Long: "Query the channel information for the provided channel ID.", Example: fmt.Sprintf("%s query %s %s channel [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -39,6 +39,7 @@ func getCmdQueryChannel() *cobra.Command { return clientCtx.PrintProto(res) }, } + flags.AddQueryFlagsToCmd(cmd) return cmd diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index b578654589a..d904dfc5653 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -37,17 +37,12 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques return nil, status.Error(codes.InvalidArgument, err.Error()) } - creator, foundCreator := q.GetCreator(ctx, req.ChannelId) - channel, foundChannel := q.GetChannel(ctx, req.ChannelId) - - if !foundCreator && !foundChannel { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error(), - ) + channel, found := q.GetChannel(ctx, req.ChannelId) + if !found { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) } - return types.NewQueryChannelResponse(creator, channel), nil + return types.NewQueryChannelResponse(channel), nil } // PacketCommitment implements the Query/PacketCommitment gRPC method. diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index b7ab81c9fda..2397db44f5c 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -15,7 +15,6 @@ import ( func (suite *KeeperTestSuite) TestQueryChannel() { var ( req *types.QueryChannelRequest - expCreator string expChannel types.Channel ) @@ -28,7 +27,6 @@ func (suite *KeeperTestSuite) TestQueryChannel() { "success", func() { ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(ctx, ibctesting.FirstChannelID, expCreator) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) req = &types.QueryChannelRequest{ @@ -38,40 +36,21 @@ func (suite *KeeperTestSuite) TestQueryChannel() { nil, }, { - "success: no creator", - func() { - expCreator = "" - - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, expChannel) - - req = &types.QueryChannelRequest{ - ChannelId: ibctesting.FirstChannelID, - } - }, - nil, - }, - { - "success: no channel", + "req is nil", func() { - expChannel = types.Channel{} - - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expCreator) - - req = &types.QueryChannelRequest{ - ChannelId: ibctesting.FirstChannelID, - } + req = nil }, - nil, + status.Error(codes.InvalidArgument, "empty request"), }, { - "req is nil", + "invalid channelID", func() { - req = nil + req = &types.QueryChannelRequest{} }, - status.Error(codes.InvalidArgument, "empty request"), + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, { - "no creator and no channel", + "channel not found", func() { req = &types.QueryChannelRequest{ ChannelId: ibctesting.FirstChannelID, @@ -79,13 +58,6 @@ func (suite *KeeperTestSuite) TestQueryChannel() { }, status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", ibctesting.FirstChannelID)), }, - { - "invalid channelID", - func() { - req = &types.QueryChannelRequest{} - }, - status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), - }, } for _, tc := range testCases { @@ -94,7 +66,6 @@ func (suite *KeeperTestSuite) TestQueryChannel() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - expCreator = ibctesting.TestAccAddress merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) expChannel = types.Channel{ClientId: ibctesting.SecondClientID, CounterpartyChannelId: ibctesting.SecondChannelID, MerklePathPrefix: merklePathPrefix} @@ -107,7 +78,6 @@ func (suite *KeeperTestSuite) TestQueryChannel() { if expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(expCreator, res.Creator) suite.Require().Equal(expChannel, res.Channel) } else { suite.Require().ErrorIs(err, tc.expError) diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index 561ef0cbe55..472805ccb12 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -10,9 +10,8 @@ func NewQueryChannelRequest(channelID string) *QueryChannelRequest { } // NewQueryChannelResponse creates and returns a new channel query response. -func NewQueryChannelResponse(creator string, channel Channel) *QueryChannelResponse { +func NewQueryChannelResponse(channel Channel) *QueryChannelResponse { return &QueryChannelResponse{ - Creator: creator, Channel: channel, } } diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index cf9501c53d3..e160b78fede 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -77,8 +77,8 @@ func (m *QueryChannelRequest) GetChannelId() string { // QueryChannelRequest is the response type for the Query/Channel RPC method type QueryChannelResponse struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Channel Channel `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel"` + // the channel associated with the provided channel id + Channel Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel"` } func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } @@ -114,13 +114,6 @@ func (m *QueryChannelResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryChannelResponse proto.InternalMessageInfo -func (m *QueryChannelResponse) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - func (m *QueryChannelResponse) GetChannel() Channel { if m != nil { return m.Channel @@ -378,43 +371,43 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 572 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x18, 0xcd, 0xd4, 0xd6, 0xd8, 0x69, 0x40, 0x99, 0x46, 0x08, 0x4b, 0xba, 0x6d, 0xf7, 0x14, 0xc5, - 0xee, 0x98, 0xb5, 0x28, 0x42, 0x2f, 0x36, 0x20, 0xd1, 0x83, 0xd4, 0x3d, 0x08, 0x7a, 0x30, 0x6c, - 0x26, 0xe3, 0x66, 0x69, 0x76, 0x66, 0xbb, 0x33, 0x89, 0x94, 0xd2, 0x8b, 0xbf, 0x40, 0xf4, 0xe6, - 0x3f, 0xf0, 0x87, 0x08, 0x05, 0x2f, 0x05, 0x2f, 0x3d, 0x89, 0x24, 0xfe, 0x10, 0xd9, 0xd9, 0x49, - 0xbb, 0x0d, 0x9b, 0x9a, 0x80, 0xde, 0x66, 0xbe, 0xf9, 0xde, 0xf7, 0xde, 0xfb, 0xf2, 0xb2, 0x70, - 0x3d, 0x68, 0x13, 0x4c, 0x78, 0x4c, 0x31, 0xe9, 0x7a, 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09, 0xf4, 0xf0, 0x6f, 0xfa, 0xf2, 0x53, 0x6a, 0x3c, 0x9a, 0x1b, 0xa7, 0xcd, - 0xbd, 0x50, 0xe6, 0x9a, 0xe8, 0xe9, 0x1c, 0xe6, 0x26, 0x62, 0x99, 0xb5, 0xb6, 0xfb, 0xea, 0x64, - 0x68, 0x82, 0xd3, 0xa1, 0x09, 0x7e, 0x0d, 0x4d, 0xf0, 0x71, 0x64, 0x16, 0x4e, 0x47, 0x66, 0xe1, - 0x6c, 0x64, 0x16, 0xde, 0xec, 0xf8, 0x81, 0xec, 0xf6, 0xdb, 0x36, 0xe1, 0x21, 0x26, 0x5c, 0x84, - 0x5c, 0x24, 0x94, 0x5b, 0x3e, 0xc7, 0x83, 0xc7, 0x38, 0xe4, 0x9d, 0x7e, 0x8f, 0x8a, 0x54, 0xc0, - 0xfd, 0xed, 0xad, 0x8c, 0x06, 0x79, 0x18, 0x51, 0xd1, 0xbe, 0xae, 0x3e, 0xa8, 0x0f, 0xfe, 0x04, - 0x00, 0x00, 0xff, 0xff, 0x66, 0x70, 0x9b, 0xa5, 0x00, 0x06, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6b, 0x13, 0x4d, + 0x18, 0xce, 0xf4, 0x4b, 0xbf, 0xda, 0xb7, 0x01, 0x65, 0x1a, 0x21, 0x2c, 0xe9, 0xb6, 0xdd, 0x53, + 0x14, 0xbb, 0x63, 0xd6, 0xa2, 0x08, 0xbd, 0xd8, 0x80, 0x44, 0x0f, 0x52, 0x17, 0x11, 0xf4, 0x60, + 0xd8, 0x6c, 0xc6, 0xcd, 0xd2, 0xec, 0xcc, 0x36, 0x33, 0x89, 0x94, 0xd2, 0x8b, 0xbf, 0x40, 0xf4, + 0xe6, 0x3f, 0xf0, 0x87, 0x08, 0x05, 0x2f, 0x05, 0x2f, 0x3d, 0x89,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 0xd5, 0xac, 0x71, 0x91, 0x63, 0x41, 0x8e, + 0xc6, 0xb9, 0x38, 0xc6, 0x67, 0x08, 0x6e, 0x66, 0x66, 0x02, 0xdf, 0xff, 0x93, 0xbe, 0xec, 0x94, + 0x1a, 0x0f, 0xe6, 0xe6, 0x69, 0x73, 0xcf, 0x94, 0xb9, 0x3a, 0x7e, 0x3c, 0x87, 0xb9, 0x89, 0x58, + 0xa6, 0xad, 0xed, 0xbe, 0x3c, 0x19, 0x98, 0xe8, 0x74, 0x60, 0xa2, 0x9f, 0x03, 0x13, 0x7d, 0x18, + 0x9a, 0xb9, 0xd3, 0xa1, 0x99, 0x3b, 0x1b, 0x9a, 0xb9, 0xd7, 0x3b, 0x41, 0x28, 0xdb, 0xbd, 0xa6, + 0xed, 0xf3, 0x88, 0xf8, 0x5c, 0x44, 0x5c, 0x8c, 0x46, 0x6e, 0x05, 0x9c, 0xf4, 0x1f, 0x92, 0x88, + 0xb7, 0x7a, 0x1d, 0x2a, 0x12, 0x01, 0x77, 0xb7, 0xb7, 0x52, 0x1a, 0xe4, 0x61, 0x4c, 0x45, 0xf3, + 0x7f, 0xf5, 0xd9, 0xbc, 0xf7, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xa0, 0x9d, 0x85, 0xe6, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -634,14 +627,7 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -839,10 +825,6 @@ func (m *QueryChannelResponse) Size() (n int) { } var l int _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = m.Channel.Size() n += 1 + l + sovQuery(uint64(l)) return n @@ -1036,38 +1018,6 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) } diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 051789b3330..af37e19726b 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -34,8 +34,8 @@ message QueryChannelRequest { // QueryChannelRequest is the response type for the Query/Channel RPC method message QueryChannelResponse { - string creator = 1; - Channel channel = 2 [(gogoproto.nullable) = false]; + // the channel associated with the provided channel id + Channel channel = 1 [(gogoproto.nullable) = false]; } // QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. From a5bff0b0f3f34877e85fc80ffe8bf1048ea71695 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 29 Oct 2024 16:11:26 +0100 Subject: [PATCH 106/172] chore: impl packet receipt query (#7513) * feat: add v2 packet commitment query * chore: add cli for packet commitment query with abci proof * chore: impl packet acknowledgement query * fix: update identifier validation in grpcs * chore: impl packet receipt query --- modules/core/04-channel/v2/client/cli/abci.go | 11 + modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 51 ++ .../core/04-channel/v2/keeper/grpc_query.go | 23 + .../04-channel/v2/keeper/grpc_query_test.go | 105 +++ modules/core/04-channel/v2/types/query.go | 17 + modules/core/04-channel/v2/types/query.pb.go | 647 +++++++++++++++++- .../core/04-channel/v2/types/query.pb.gw.go | 143 +++- proto/ibc/core/channel/v2/query.proto | 29 +- 9 files changed, 987 insertions(+), 40 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/abci.go b/modules/core/04-channel/v2/client/cli/abci.go index b740156bf3c..942ca2a6ebf 100644 --- a/modules/core/04-channel/v2/client/cli/abci.go +++ b/modules/core/04-channel/v2/client/cli/abci.go @@ -39,3 +39,14 @@ func queryPacketAcknowledgementABCI(clientCtx client.Context, channelID string, return types.NewQueryPacketAcknowledgementResponse(value, proofBz, proofHeight), nil } + +func queryPacketReceiptABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketReceiptResponse, error) { + key := host.PacketReceiptKey(channelID, sequence) + + value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) + if err != nil { + return nil, err + } + + return types.NewQueryPacketReceiptResponse(value != nil, proofBz, proofHeight), nil +} diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index 8eff794ca3f..a9d985e72a0 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -22,6 +22,7 @@ func GetQueryCmd() *cobra.Command { getCmdQueryChannel(), getCmdQueryPacketCommitment(), getCmdQueryPacketAcknowledgement(), + getCmdQueryPacketReceipt(), ) return queryCmd diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 7383673588d..a6a1d7f0762 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -146,3 +146,54 @@ func getCmdQueryPacketAcknowledgement() *cobra.Command { return cmd } + +func getCmdQueryPacketReceipt() *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-receipt [channel-id] [sequence]", + Short: "Query a channel/v2 packet receipt", + Long: "Query a channel/v2 packet receipt by channel-id and sequence", + Example: fmt.Sprintf( + "%s query %s %s packet-receipt [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + seq, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + if prove { + res, err := queryPacketReceiptABCI(clientCtx, channelID, seq) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.PacketReceipt(cmd.Context(), types.NewQueryPacketReceiptRequest(channelID, seq)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index d904dfc5653..3106bc367cc 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -96,3 +96,26 @@ func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.Quer return types.NewQueryPacketAcknowledgementResponse(acknowledgement, nil, clienttypes.GetSelfHeight(ctx)), nil } + +// PacketReceipt implements the Query/PacketReceipt gRPC method. +func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if req.Sequence == 0 { + return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + hasReceipt := q.HasPacketReceipt(ctx, req.ChannelId, req.Sequence) + + return types.NewQueryPacketReceiptResponse(hasReceipt, nil, clienttypes.GetSelfHeight(ctx)), nil +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 2397db44f5c..e458128ce09 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -294,3 +294,108 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }) } } + +func (suite *KeeperTestSuite) TestQueryPacketReceipt() { + var ( + expReceipt bool + path *ibctesting.Path + req *types.QueryPacketReceiptRequest + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success with receipt", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1) + + expReceipt = true + req = &types.QueryPacketReceiptRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + nil, + }, + { + "success with no receipt", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expReceipt = false + req = &types.QueryPacketReceiptRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequence: 1, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryPacketReceiptRequest{ + ChannelId: "", + Sequence: 1, + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "invalid sequence", + func() { + req = &types.QueryPacketReceiptRequest{ + ChannelId: ibctesting.FirstChannelID, + Sequence: 0, + } + }, + status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), + }, + { + "channel not found", + func() { + req = &types.QueryPacketReceiptRequest{ + ChannelId: "channel-141", + Sequence: 1, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) + res, err := queryServer.PacketReceipt(suite.chainA.GetContext(), req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expReceipt, res.Received) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index 472805ccb12..985be5c6dd4 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -49,3 +49,20 @@ func NewQueryPacketAcknowledgementResponse(acknowledgementHash []byte, proof []b ProofHeight: proofHeight, } } + +// NewQueryPacketReceiptRequest creates and returns a new packet receipt query request. +func NewQueryPacketReceiptRequest(channelID string, sequence uint64) *QueryPacketReceiptRequest { + return &QueryPacketReceiptRequest{ + ChannelId: channelID, + Sequence: sequence, + } +} + +// NewQueryPacketReceiptResponse creates and returns a new packet receipt query response. +func NewQueryPacketReceiptResponse(exists bool, proof []byte, height clienttypes.Height) *QueryPacketReceiptResponse { + return &QueryPacketReceiptResponse{ + Received: exists, + Proof: proof, + ProofHeight: height, + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index e160b78fede..02e5f2a1b1b 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -359,6 +359,134 @@ func (m *QueryPacketAcknowledgementResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. +type QueryPacketReceiptRequest struct { + // port unique identifier + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptRequest{} } +func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketReceiptRequest) ProtoMessage() {} +func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{6} +} +func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketReceiptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketReceiptRequest.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 *QueryPacketReceiptRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketReceiptRequest.Merge(m, src) +} +func (m *QueryPacketReceiptRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketReceiptRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketReceiptRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketReceiptRequest proto.InternalMessageInfo + +func (m *QueryPacketReceiptRequest) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *QueryPacketReceiptRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryPacketReceiptRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +// QueryPacketReceiptResponse is the response type for the Query/PacketReceipt RPC method. +type QueryPacketReceiptResponse struct { + // success flag for if receipt exists + Received bool `protobuf:"varint,2,opt,name=received,proto3" json:"received,omitempty"` + // merkle proof of existence or absence + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptResponse{} } +func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketReceiptResponse) ProtoMessage() {} +func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{7} +} +func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketReceiptResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketReceiptResponse.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 *QueryPacketReceiptResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketReceiptResponse.Merge(m, src) +} +func (m *QueryPacketReceiptResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketReceiptResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketReceiptResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketReceiptResponse proto.InternalMessageInfo + +func (m *QueryPacketReceiptResponse) GetReceived() bool { + if m != nil { + return m.Received + } + return false +} + +func (m *QueryPacketReceiptResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryPacketReceiptResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") @@ -366,48 +494,55 @@ func init() { proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentResponse") proto.RegisterType((*QueryPacketAcknowledgementRequest)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementRequest") proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") + proto.RegisterType((*QueryPacketReceiptRequest)(nil), "ibc.core.channel.v2.QueryPacketReceiptRequest") + proto.RegisterType((*QueryPacketReceiptResponse)(nil), "ibc.core.channel.v2.QueryPacketReceiptResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 562 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6b, 0x13, 0x4d, - 0x18, 0xce, 0xf4, 0x4b, 0xbf, 0xda, 0xb7, 0x01, 0x65, 0x1a, 0x21, 0x2c, 0xe9, 0xb6, 0xdd, 0x53, - 0x14, 0xbb, 0x63, 0xd6, 0xa2, 0x08, 0xbd, 0xd8, 0x80, 0x44, 0x0f, 0x52, 0x17, 0x11, 0xf4, 0x60, - 0xd8, 0x6c, 0xc6, 0xcd, 0xd2, 0xec, 0xcc, 0x36, 0x33, 0x89, 0x94, 0xd2, 0x8b, 0xbf, 0x40, 0xf4, - 0xe6, 0x3f, 0xf0, 0x87, 0x08, 0x05, 0x2f, 0x05, 0x2f, 0x3d, 0x89, 0x24, 0xfe, 0x10, 0xc9, 0xec, - 0xa4, 0xdd, 0x86, 0x4d, 0x4d, 0x40, 0x6f, 0x33, 0xef, 0x3c, 0xcf, 0xfb, 0x3e, 0xcf, 0x9b, 0x27, - 0x0b, 0xeb, 0x61, 0xd3, 0x27, 0x3e,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0, 0xcf, 0xab, 0xaa, - 0x79, 0xc1, 0x4d, 0x55, 0x70, 0x11, 0x16, 0xe3, 0x2e, 0xe7, 0x6f, 0x55, 0xeb, 0x82, 0x9b, 0x5c, - 0x70, 0x0d, 0x0a, 0xea, 0xd0, 0x68, 0xd3, 0x30, 0x68, 0xcb, 0xd2, 0x7f, 0xca, 0xb5, 0x91, 0x72, - 0x9d, 0xfc, 0x40, 0xfd, 0xaa, 0x5d, 0x57, 0x08, 0xed, 0x79, 0x45, 0xb1, 0x92, 0x92, 0xf5, 0x06, - 0x36, 0x53, 0xda, 0x1e, 0xf9, 0xfb, 0x8c, 0xbf, 0xeb, 0xd0, 0x56, 0x40, 0xff, 0x92, 0xf9, 0x2f, - 0x08, 0xac, 0xab, 0x06, 0xe8, 0x0d, 0x54, 0xe0, 0xba, 0x77, 0xf9, 0x49, 0xaf, 0x61, 0xb2, 0xfc, - 0x0f, 0x77, 0xe1, 0x7c, 0xcd, 0xc3, 0xa2, 0xd2, 0x8a, 0x3f, 0x22, 0x58, 0xd2, 0x41, 0xc1, 0x95, - 0xcc, 0x18, 0x65, 0x04, 0xd7, 0xb8, 0x35, 0x03, 0x32, 0xf1, 0x6b, 0x39, 0xef, 0xbf, 0xff, 0xfa, - 0xb4, 0x70, 0x07, 0xdf, 0x26, 0x57, 0xfc, 0xf7, 0x04, 0x39, 0xba, 0x58, 0xfb, 0x31, 0xfe, 0x86, - 0xe0, 0xc6, 0x64, 0x84, 0x70, 0x75, 0xfa, 0xcc, 0x29, 0x51, 0x36, 0x9c, 0x79, 0x28, 0x5a, 0xef, - 0x9e, 0xd2, 0xfb, 0x14, 0xd7, 0x67, 0xd7, 0x4b, 0x62, 0xd5, 0xac, 0x71, 0x91, 0x63, 0x41, 0x8e, - 0xc6, 0xb9, 0x38, 0xc6, 0x67, 0x08, 0x6e, 0x66, 0x66, 0x02, 0xdf, 0xff, 0x93, 0xbe, 0xec, 0x94, - 0x1a, 0x0f, 0xe6, 0xe6, 0x69, 0x73, 0xcf, 0x94, 0xb9, 0x3a, 0x7e, 0x3c, 0x87, 0xb9, 0x89, 0x58, - 0xa6, 0xad, 0xed, 0xbe, 0x3c, 0x19, 0x98, 0xe8, 0x74, 0x60, 0xa2, 0x9f, 0x03, 0x13, 0x7d, 0x18, - 0x9a, 0xb9, 0xd3, 0xa1, 0x99, 0x3b, 0x1b, 0x9a, 0xb9, 0xd7, 0x3b, 0x41, 0x28, 0xdb, 0xbd, 0xa6, - 0xed, 0xf3, 0x88, 0xf8, 0x5c, 0x44, 0x5c, 0x8c, 0x46, 0x6e, 0x05, 0x9c, 0xf4, 0x1f, 0x92, 0x88, - 0xb7, 0x7a, 0x1d, 0x2a, 0x12, 0x01, 0x77, 0xb7, 0xb7, 0x52, 0x1a, 0xe4, 0x61, 0x4c, 0x45, 0xf3, - 0x7f, 0xf5, 0xd9, 0xbc, 0xf7, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xa0, 0x9d, 0x85, 0xe6, 0x05, - 0x00, 0x00, + // 654 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x4f, 0xd4, 0x40, + 0x14, 0xde, 0xe1, 0x37, 0x0f, 0x8c, 0x66, 0xc0, 0x88, 0x0d, 0x14, 0xe8, 0x69, 0x35, 0xd2, 0x91, + 0x95, 0x68, 0x4c, 0xb8, 0xc0, 0xc6, 0x08, 0x26, 0x26, 0xd8, 0x18, 0x13, 0x3d, 0x48, 0xba, 0xb3, + 0x63, 0xb7, 0x61, 0xdb, 0x29, 0xed, 0x6c, 0x0d, 0x21, 0x5c, 0xf8, 0x0b, 0x8c, 0xdc, 0xfc, 0x0f, + 0xfc, 0x2b, 0xbc, 0x92, 0x78, 0x21, 0xe1, 0xe2, 0xc9, 0x18, 0xf0, 0x0f, 0x31, 0x9d, 0x0e, 0xbb, + 0xdd, 0x4d, 0x77, 0xd9, 0x35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xb8, 0xb6, 0x92, 0xa1, 0x20, 0x0e, 0x02, 0x16, 0x55, 0xc6, 0xe4, 0x4f, 0xdf, 0xa3, + 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x39, 0x9c, 0xc7, 0xa2, 0xaa, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -428,6 +563,8 @@ type QueryClient interface { PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) + // PacketReceipt queries a stored packet receipt. + PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) } type queryClient struct { @@ -465,6 +602,15 @@ func (c *queryClient) PacketAcknowledgement(ctx context.Context, in *QueryPacket return out, nil } +func (c *queryClient) PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) { + out := new(QueryPacketReceiptResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketReceipt", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Channel queries the counterparty of an IBC client. @@ -473,6 +619,8 @@ type QueryServer interface { PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) + // PacketReceipt queries a stored packet receipt. + PacketReceipt(context.Context, *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -488,6 +636,9 @@ func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *Quer func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketAcknowledgement not implemented") } +func (*UnimplementedQueryServer) PacketReceipt(ctx context.Context, req *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketReceipt not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -547,6 +698,24 @@ func _Query_PacketAcknowledgement_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Query_PacketReceipt_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketReceiptRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketReceipt(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/PacketReceipt", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketReceipt(ctx, req.(*QueryPacketReceiptRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), @@ -563,6 +732,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketAcknowledgement", Handler: _Query_PacketAcknowledgement_Handler, }, + { + MethodName: "PacketReceipt", + Handler: _Query_PacketReceipt_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/query.proto", @@ -795,6 +968,98 @@ func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } +func (m *QueryPacketReceiptRequest) 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 *QueryPacketReceiptRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(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 = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketReceiptResponse) 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 *QueryPacketReceiptResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if m.Received { + i-- + if m.Received { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -900,6 +1165,44 @@ func (m *QueryPacketAcknowledgementResponse) Size() (n int) { return n } +func (m *QueryPacketReceiptRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + return n +} + +func (m *QueryPacketReceiptResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Received { + n += 2 + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1575,6 +1878,276 @@ func (m *QueryPacketAcknowledgementResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPacketReceiptRequest) 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 ErrIntOverflowQuery + } + 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: QueryPacketReceiptRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketReceiptRequest: 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketReceiptResponse) 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 ErrIntOverflowQuery + } + 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: QueryPacketReceiptResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketReceiptResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Received", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Received = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 03626cf677f..5a274f65b17 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -239,6 +239,100 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler } +var ( + filter_Query_PacketReceipt_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0, "sequence": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketReceiptRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketReceipt_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PacketReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketReceiptRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence") + } + + protoReq.Sequence, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketReceipt_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PacketReceipt(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -314,6 +408,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PacketReceipt_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -415,6 +532,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PacketReceipt_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -423,7 +560,9 @@ var ( pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "acknowledgements", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -432,4 +571,6 @@ var ( forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage + + forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index af37e19726b..6d731385164 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -23,7 +23,12 @@ service Query { // PacketAcknowledgement queries a stored acknowledgement commitment hash. rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/acknowledgements/{sequence}"; + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acks/{sequence}"; + } + + // PacketReceipt queries a stored packet receipt. + rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}"; } } @@ -72,4 +77,24 @@ message QueryPacketAcknowledgementResponse { bytes proof = 2; // height at which the proof was retrieved ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} + +// QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. +message QueryPacketReceiptRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // packet sequence + uint64 sequence = 3; +} + +// QueryPacketReceiptResponse is the response type for the Query/PacketReceipt RPC method. +message QueryPacketReceiptResponse { + // success flag for if receipt exists + bool received = 2; + // merkle proof of existence or absence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} From 28b6a890045de2c6a89b1751c6ac3de81da79c6c Mon Sep 17 00:00:00 2001 From: sangier <45793271+sangier@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:14:54 +0100 Subject: [PATCH 107/172] Add MaxTimeout condition (#7521) * enforce maxTimeout * fixes * fix error * run gofumpt * Apply review suggestions Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> * address review comments * errors * use time package --------- Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- .../core/04-channel/v2/keeper/msg_server.go | 14 ++++++++++ .../04-channel/v2/keeper/msg_server_test.go | 26 +++++++++++++++++++ modules/core/04-channel/v2/types/errors.go | 2 ++ modules/core/04-channel/v2/types/msgs.go | 4 +++ 4 files changed, 46 insertions(+) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 1acaf49e30c..883431f2fc8 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" "slices" + "time" errorsmod "cosmossdk.io/errors" @@ -63,12 +64,25 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *channeltypesv2 // SendPacket defines a rpc handler method for MsgSendPacket. func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) + sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) if err != nil { sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) } + // Note, the validate basic function in sendPacket does the timeoutTimestamp != 0 check and other stateless checks on the packet. + // timeoutTimestamp must be greater than current block time + timeout := time.Unix(int64(msg.TimeoutTimestamp), 0) + if timeout.Before(sdkCtx.BlockTime()) { + return nil, errorsmod.Wrap(channeltypesv2.ErrTimeoutTooLow, "timeout is less than the current block timestamp") + } + + // timeoutTimestamp must be less than current block time + MaxTimeoutDelta + if timeout.After(sdkCtx.BlockTime().Add(channeltypesv2.MaxTimeoutDelta)) { + return nil, errorsmod.Wrap(channeltypesv2.ErrMaxTimeoutDeltaExceeded, "timeout exceeds the maximum expected value") + } + signer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { sdkCtx.Logger().Error("send packet failed", "error", errorsmod.Wrap(err, "invalid address for msg Signer")) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index fa690b8087e..0d1b261512d 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -116,6 +117,15 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { malleate: func() {}, expError: nil, }, + { + name: "success: valid timeout timestamp", + malleate: func() { + // ensure a message timeout. + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta - 10*time.Second).Unix()) + expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + }, + expError: nil, + }, { name: "failure: timeout elapsed", malleate: func() { @@ -124,6 +134,22 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { }, expError: channeltypesv1.ErrTimeoutElapsed, }, + { + name: "failure: timeout timestamp exceeds max allowed input", + malleate: func() { + // ensure message timeout exceeds max allowed input. + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta + 10*time.Second).Unix()) + }, + expError: channeltypesv2.ErrMaxTimeoutDeltaExceeded, + }, + { + name: "failure: timeout timestamp less than current block timestamp", + malleate: func() { + // ensure message timeout exceeds max allowed input. + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) - 1 + }, + expError: channeltypesv2.ErrTimeoutTooLow, + }, { name: "failure: inactive client", malleate: func() { diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 7a1cabe9fc0..478440e3912 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -13,4 +13,6 @@ var ( ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 9, "packet acknowledgement not found") + ErrMaxTimeoutDeltaExceeded = errorsmod.Register(SubModuleName, 10, "timeoutTimestamp exceeds max allowed value") + ErrTimeoutTooLow = errorsmod.Register(SubModuleName, 11, "timeoutTimestamp is less than current block timestamp") ) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 9c6f724e40d..dfbcfee103b 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -1,6 +1,8 @@ package types import ( + "time" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,6 +15,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) +const MaxTimeoutDelta time.Duration = 24 * time.Hour + var ( _ sdk.Msg = (*MsgCreateChannel)(nil) _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) From 3c47bd7faf1ea6303b8fc459cc7e76bb6707ca0d Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 1 Nov 2024 11:14:14 +0000 Subject: [PATCH 108/172] chore: remove usage of v1 errors from v2 (#7528) * chore: remove usage of v1 errors from v2 * linter --- .../core/04-channel/v2/keeper/msg_server.go | 6 ++-- .../04-channel/v2/keeper/msg_server_test.go | 5 ++- modules/core/04-channel/v2/keeper/packet.go | 31 +++++++++---------- .../core/04-channel/v2/keeper/packet_test.go | 31 +++++++++---------- modules/core/04-channel/v2/types/errors.go | 13 ++++++-- modules/core/04-channel/v2/types/msgs.go | 3 +- modules/core/04-channel/v2/types/msgs_test.go | 3 +- 7 files changed, 48 insertions(+), 44 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 883431f2fc8..c74f0cbdf45 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -120,7 +120,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack switch err { case nil: writeFn() - case channeltypesv1.ErrNoOpMsg: + case channeltypesv2.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.NOOP}, nil @@ -195,7 +195,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck switch err { case nil: writeFn() - case channeltypesv1.ErrNoOpMsg: + case channeltypesv2.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil @@ -239,7 +239,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout switch err { case nil: writeFn() - case channeltypesv1.ErrNoOpMsg: + case channeltypesv2.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.NOOP}, nil diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 0d1b261512d..1b910ecea2f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -9,7 +9,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" @@ -132,7 +131,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure a message timeout. timeoutTimestamp = uint64(1) }, - expError: channeltypesv1.ErrTimeoutElapsed, + expError: channeltypesv2.ErrTimeoutElapsed, }, { name: "failure: timeout timestamp exceeds max allowed input", @@ -488,7 +487,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { return mock.MockApplicationCallbackError } }, - expError: channeltypesv1.ErrNoOpMsg, + expError: channeltypesv2.ErrNoOpMsg, }, { name: "failure: callback fails", diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index b4e0516307d..6ba078490c5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -10,7 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -49,7 +48,7 @@ func (k *Keeper) sendPacket( packet := types.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, payloads...) if err := packet.ValidateBasic(); err != nil { - return 0, "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) + return 0, "", errorsmod.Wrapf(types.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) } // check that the client of counterparty chain is still active @@ -72,7 +71,7 @@ func (k *Keeper) sendPacket( // thus to compare them, we convert the packet timeout to nanoseconds timeoutTimestamp = types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) if latestTimestamp >= timeoutTimestamp { - return 0, "", errorsmod.Wrapf(channeltypes.ErrTimeoutElapsed, "latest timestamp: %d, timeout timestamp: %d", latestTimestamp, timeoutTimestamp) + return 0, "", errorsmod.Wrapf(types.ErrTimeoutElapsed, "latest timestamp: %d, timeout timestamp: %d", latestTimestamp, timeoutTimestamp) } commitment := types.CommitPacket(packet) @@ -111,7 +110,7 @@ func (k *Keeper) recvPacket( } if channel.CounterpartyChannelId != packet.SourceChannel { - return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) + return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } clientID := channel.ClientId @@ -120,7 +119,7 @@ func (k *Keeper) recvPacket( sdkCtx := sdk.UnwrapSDKContext(ctx) currentTimestamp := uint64(sdkCtx.BlockTime().Unix()) if currentTimestamp >= packet.TimeoutTimestamp { - return errorsmod.Wrapf(channeltypes.ErrTimeoutElapsed, "current timestamp: %d, timeout timestamp: %d", currentTimestamp, packet.TimeoutTimestamp) + return errorsmod.Wrapf(types.ErrTimeoutElapsed, "current timestamp: %d, timeout timestamp: %d", currentTimestamp, packet.TimeoutTimestamp) } // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received @@ -131,7 +130,7 @@ func (k *Keeper) recvPacket( // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return types.ErrNoOpMsg } path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) @@ -176,18 +175,18 @@ func (k Keeper) WriteAcknowledgement( } if channel.CounterpartyChannelId != packet.SourceChannel { - return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) + return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) } // NOTE: IBC app modules might have written the acknowledgement synchronously on // the OnRecvPacket callback so we need to check if the acknowledgement is already // set on the store and return an error if so. if k.HasPacketAcknowledgement(ctx, packet.DestinationChannel, packet.Sequence) { - return errorsmod.Wrapf(channeltypes.ErrAcknowledgementExists, "acknowledgement for channel %s, sequence %d already exists", packet.DestinationChannel, packet.Sequence) + return errorsmod.Wrapf(types.ErrAcknowledgementExists, "acknowledgement for channel %s, sequence %d already exists", packet.DestinationChannel, packet.Sequence) } if _, found := k.GetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence); !found { - return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") + return errorsmod.Wrap(types.ErrInvalidPacket, "receipt not found for packet") } // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 @@ -218,7 +217,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack } if channel.CounterpartyChannelId != packet.DestinationChannel { - return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) + return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } clientID := channel.ClientId @@ -232,14 +231,14 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to // prevent an entire relay transaction from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return types.ErrNoOpMsg } packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + return errorsmod.Wrapf(types.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) } path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) @@ -285,7 +284,7 @@ func (k *Keeper) timeoutPacket( } if channel.CounterpartyChannelId != packet.DestinationChannel { - return errorsmod.Wrapf(channeltypes.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) + return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) } clientID := channel.ClientId @@ -298,7 +297,7 @@ func (k *Keeper) timeoutPacket( timeoutTimestamp := types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) if proofTimestamp < timeoutTimestamp { - return errorsmod.Wrapf(channeltypes.ErrTimeoutNotReached, "proof timestamp: %d, timeout timestamp: %d", proofTimestamp, timeoutTimestamp) + return errorsmod.Wrapf(types.ErrTimeoutNotReached, "proof timestamp: %d, timeout timestamp: %d", proofTimestamp, timeoutTimestamp) } // check that the commitment has not been cleared and that it matches the packet sent by relayer @@ -309,13 +308,13 @@ func (k *Keeper) timeoutPacket( // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to // prevent an entire relay transaction from failing and consuming unnecessary fees. - return channeltypes.ErrNoOpMsg + return types.ErrNoOpMsg } packetCommitment := types.CommitPacket(packet) // verify we sent the packet and haven't cleared it out yet if !bytes.Equal(commitment, packetCommitment) { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + return errorsmod.Wrapf(types.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) } // verify packet receipt absence diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index a01c5959f64..e93e2d97259 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -5,7 +5,6 @@ import ( "time" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" @@ -56,7 +55,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { // invalid data packet.Payloads = nil }, - channeltypes.ErrInvalidPacket, + types.ErrInvalidPacket, }, { "client status invalid", @@ -84,7 +83,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { "timeout elapsed", func() { packet.TimeoutTimestamp = 1 }, - channeltypes.ErrTimeoutElapsed, + types.ErrTimeoutElapsed, }, } @@ -168,21 +167,21 @@ func (suite *KeeperTestSuite) TestRecvPacket() { func() { packet.SourceChannel = unusedChannel }, - channeltypes.ErrInvalidChannelIdentifier, + types.ErrInvalidChannelIdentifier, }, { "failure: packet has timed out", func() { suite.coordinator.IncrementTimeBy(time.Hour * 20) }, - channeltypes.ErrTimeoutElapsed, + types.ErrTimeoutElapsed, }, { "failure: packet already received", func() { suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) }, - channeltypes.ErrNoOpMsg, + types.ErrNoOpMsg, }, { "failure: verify membership failed", @@ -262,7 +261,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { packet.SourceChannel = unusedChannel }, - channeltypes.ErrInvalidChannelIdentifier, + types.ErrInvalidChannelIdentifier, }, { "failure: ack already exists", @@ -270,7 +269,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { ackBz := types.CommitAcknowledgement(ack) suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence, ackBz) }, - channeltypes.ErrAcknowledgementExists, + types.ErrAcknowledgementExists, }, { "failure: empty ack", @@ -286,7 +285,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { packet.Sequence = 2 }, - channeltypes.ErrInvalidPacket, + types.ErrInvalidPacket, }, } @@ -371,14 +370,14 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { func() { packet.DestinationChannel = unusedChannel }, - channeltypes.ErrInvalidChannelIdentifier, + types.ErrInvalidChannelIdentifier, }, { "failure: packet commitment doesn't exist.", func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) }, - channeltypes.ErrNoOpMsg, + types.ErrNoOpMsg, }, { "failure: client status invalid", @@ -393,7 +392,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { // change payload after send to acknowledge different packet packet.Payloads[0].Value = []byte("different value") }, - channeltypes.ErrInvalidPacket, + types.ErrInvalidPacket, }, { "failure: verify membership fails", @@ -494,7 +493,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.DestinationChannel = unusedChannel }, - channeltypes.ErrInvalidChannelIdentifier, + types.ErrInvalidChannelIdentifier, }, { "failure: packet has not timed out yet", @@ -506,12 +505,12 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") }, - channeltypes.ErrTimeoutNotReached, + types.ErrTimeoutNotReached, }, { "failure: packet already timed out", func() {}, // equivalent to not sending packet at all - channeltypes.ErrNoOpMsg, + types.ErrNoOpMsg, }, { "failure: packet does not match commitment", @@ -523,7 +522,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // try to timeout packet with different data packet.Payloads[0].Value = []byte("different value") }, - channeltypes.ErrInvalidPacket, + types.ErrInvalidPacket, }, { "failure: client status invalid", diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 478440e3912..9e2ab0b4a79 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -13,6 +13,15 @@ var ( ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 9, "packet acknowledgement not found") - ErrMaxTimeoutDeltaExceeded = errorsmod.Register(SubModuleName, 10, "timeoutTimestamp exceeds max allowed value") - ErrTimeoutTooLow = errorsmod.Register(SubModuleName, 11, "timeoutTimestamp is less than current block timestamp") + + ErrMaxTimeoutDeltaExceeded = errorsmod.Register(SubModuleName, 10, "timeoutTimestamp exceeds max allowed value") + ErrTimeoutTooLow = errorsmod.Register(SubModuleName, 11, "timeoutTimestamp is less than current block timestamp") + ErrTimeoutElapsed = errorsmod.Register(SubModuleName, 12, "timeout elapsed") + + ErrInvalidChannelIdentifier = errorsmod.Register(SubModuleName, 13, "invalid channel identifier") + ErrAcknowledgementExists = errorsmod.Register(SubModuleName, 14, "acknowledgement for packet already exists") + ErrTimeoutNotReached = errorsmod.Register(SubModuleName, 15, "timeout not reached") + // Perform a no-op on the current Msg + ErrNoOpMsg = errorsmod.Register(SubModuleName, 16, "message is redundant, no-op will be performed") + ErrInvalidTimeout = errorsmod.Register(SubModuleName, 17, "invalid packet timeout") ) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index dfbcfee103b..b0a8d9cd9de 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypesv1 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" @@ -106,7 +105,7 @@ func (msg *MsgSendPacket) ValidateBasic() error { } if msg.TimeoutTimestamp == 0 { - return errorsmod.Wrap(channeltypesv1.ErrInvalidTimeout, "timeout must not be 0") + return errorsmod.Wrap(ErrInvalidTimeout, "timeout must not be 0") } if len(msg.Payloads) != 1 { diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 44e92c4e5a3..fd6f5ceaa0a 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/suite" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" @@ -170,7 +169,7 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { malleate: func() { msg.TimeoutTimestamp = 0 }, - expError: channeltypesv1.ErrInvalidTimeout, + expError: types.ErrInvalidTimeout, }, { name: "failure: invalid length for payload", From 1429f6d5ce4810b2e9e85f1ab4b74df50422eab9 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 4 Nov 2024 10:40:50 +0100 Subject: [PATCH 109/172] chore: reduce number of timeout errors, cleanup (#7529) --- .../core/04-channel/v2/keeper/msg_server.go | 70 +++++++++---------- .../04-channel/v2/keeper/msg_server_test.go | 4 +- modules/core/04-channel/v2/types/errors.go | 13 ++-- 3 files changed, 41 insertions(+), 46 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index c74f0cbdf45..6091a8e3029 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -10,33 +10,33 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" - telemetryv2 "github.com/cosmos/ibc-go/v9/modules/core/internal/v2/telemetry" + "github.com/cosmos/ibc-go/v9/modules/core/internal/v2/telemetry" ) -var _ channeltypesv2.MsgServer = &Keeper{} +var _ types.MsgServer = &Keeper{} // CreateChannel defines a rpc handler method for MsgCreateChannel. -func (k *Keeper) CreateChannel(goCtx context.Context, msg *channeltypesv2.MsgCreateChannel) (*channeltypesv2.MsgCreateChannelResponse, error) { +func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChannel) (*types.MsgCreateChannelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) channelID := k.channelKeeperV1.GenerateChannelIdentifier(ctx) // Initialize channel with empty counterparty channel identifier. - channel := channeltypesv2.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + channel := types.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) k.SetChannel(ctx, channelID, channel) k.SetCreator(ctx, channelID, msg.Signer) k.SetNextSequenceSend(ctx, channelID, 1) k.EmitCreateChannelEvent(goCtx, channelID) - return &channeltypesv2.MsgCreateChannelResponse{ChannelId: channelID}, nil + return &types.MsgCreateChannelResponse{ChannelId: channelID}, nil } // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. -func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *channeltypesv2.MsgRegisterCounterparty) (*channeltypesv2.MsgRegisterCounterpartyResponse, error) { +func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegisterCounterparty) (*types.MsgRegisterCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) creator, found := k.GetCreator(ctx, msg.ChannelId) @@ -50,7 +50,7 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *channeltypesv2 channel, ok := k.GetChannel(ctx, msg.ChannelId) if !ok { - return nil, errorsmod.Wrapf(channeltypesv2.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) + return nil, errorsmod.Wrapf(types.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) } channel.CounterpartyChannelId = msg.CounterpartyChannelId @@ -58,11 +58,11 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *channeltypesv2 // Delete client creator from state as it is not needed after this point. k.DeleteCreator(ctx, msg.ChannelId) - return &channeltypesv2.MsgRegisterCounterpartyResponse{}, nil + return &types.MsgRegisterCounterpartyResponse{}, nil } // SendPacket defines a rpc handler method for MsgSendPacket. -func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error) { +func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*types.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) @@ -75,12 +75,12 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack // timeoutTimestamp must be greater than current block time timeout := time.Unix(int64(msg.TimeoutTimestamp), 0) if timeout.Before(sdkCtx.BlockTime()) { - return nil, errorsmod.Wrap(channeltypesv2.ErrTimeoutTooLow, "timeout is less than the current block timestamp") + return nil, errorsmod.Wrap(types.ErrTimeoutElapsed, "timeout is less than the current block timestamp") } // timeoutTimestamp must be less than current block time + MaxTimeoutDelta - if timeout.After(sdkCtx.BlockTime().Add(channeltypesv2.MaxTimeoutDelta)) { - return nil, errorsmod.Wrap(channeltypesv2.ErrMaxTimeoutDeltaExceeded, "timeout exceeds the maximum expected value") + if timeout.After(sdkCtx.BlockTime().Add(types.MaxTimeoutDelta)) { + return nil, errorsmod.Wrap(types.ErrInvalidTimeout, "timeout exceeds the maximum expected value") } signer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -97,11 +97,11 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *channeltypesv2.MsgSendPack } } - return &channeltypesv2.MsgSendPacketResponse{Sequence: sequence}, nil + return &types.MsgSendPacketResponse{Sequence: sequence}, nil } // RecvPacket defines a rpc handler method for MsgRecvPacket. -func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPacket) (*channeltypesv2.MsgRecvPacketResponse, error) { +func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*types.MsgRecvPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) signer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -120,18 +120,18 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack switch err { case nil: writeFn() - case channeltypesv2.ErrNoOpMsg: + case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) - return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgRecvPacketResponse{Result: channeltypesv1.NOOP}, nil default: sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) return nil, errorsmod.Wrap(err, "receive packet verification failed") } // build up the recv results for each application callback. - ack := channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{}, + ack := types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{}, } for _, pd := range msg.Packet.Payloads { @@ -140,7 +140,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack cb := k.Router.Route(pd.DestinationPort) res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, signer) - if res.Status != channeltypesv2.PacketStatus_Failure { + if res.Status != types.PacketStatus_Failure { // write application state changes for asynchronous and successful acknowledgements writeFn() } else { @@ -148,7 +148,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack sdkCtx.EventManager().EmitEvents(internalerrors.ConvertToErrorEvents(cacheCtx.EventManager().Events())) } - ack.AcknowledgementResults = append(ack.AcknowledgementResults, channeltypesv2.AcknowledgementResult{ + ack.AcknowledgementResults = append(ack.AcknowledgementResults, types.AcknowledgementResult{ AppName: pd.DestinationPort, RecvPacketResult: res, }) @@ -157,12 +157,12 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack // note this should never happen as the payload would have had to be empty. if len(ack.AcknowledgementResults) == 0 { sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) - return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) + return &types.MsgRecvPacketResponse{Result: channeltypesv1.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) } // NOTE: TBD how we will handle async acknowledgements with more than one payload. - isAsync := slices.ContainsFunc(ack.AcknowledgementResults, func(ackResult channeltypesv2.AcknowledgementResult) bool { - return ackResult.RecvPacketResult.Status == channeltypesv2.PacketStatus_Async + isAsync := slices.ContainsFunc(ack.AcknowledgementResults, func(ackResult types.AcknowledgementResult) bool { + return ackResult.RecvPacketResult.Status == types.PacketStatus_Async }) if !isAsync { @@ -174,14 +174,14 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack } } - defer telemetryv2.ReportRecvPacket(msg.Packet) + defer telemetry.ReportRecvPacket(msg.Packet) sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", channeltypesv1.SUCCESS.String()) - return &channeltypesv2.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil + return &types.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil } // Acknowledgement defines an rpc handler method for MsgAcknowledgement. -func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAcknowledgement) (*channeltypesv2.MsgAcknowledgementResponse, error) { +func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgement) (*types.MsgAcknowledgementResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -195,16 +195,16 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck switch err { case nil: writeFn() - case channeltypesv2.ErrNoOpMsg: + case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) - return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil default: sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } - recvResults := make(map[string]channeltypesv2.RecvPacketResult) + recvResults := make(map[string]types.RecvPacketResult) for _, r := range msg.Acknowledgement.AcknowledgementResults { recvResults[r.AppName] = r.RecvPacketResult } @@ -217,11 +217,11 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypesv2.MsgAck } } - return &channeltypesv2.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil + return &types.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil } // Timeout defines a rpc handler method for MsgTimeout. -func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout) (*channeltypesv2.MsgTimeoutResponse, error) { +func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) signer, err := sdk.AccAddressFromBech32(timeout.Signer) @@ -239,10 +239,10 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout switch err { case nil: writeFn() - case channeltypesv2.ErrNoOpMsg: + case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) - return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgTimeoutResponse{Result: channeltypesv1.NOOP}, nil default: sdkCtx.Logger().Error("timeout failed", "source-channel", timeout.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) return nil, errorsmod.Wrap(err, "timeout packet verification failed") @@ -256,5 +256,5 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *channeltypesv2.MsgTimeout } } - return &channeltypesv2.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil + return &types.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 1b910ecea2f..b4b5d8c71c4 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -139,7 +139,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure message timeout exceeds max allowed input. timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta + 10*time.Second).Unix()) }, - expError: channeltypesv2.ErrMaxTimeoutDeltaExceeded, + expError: channeltypesv2.ErrInvalidTimeout, }, { name: "failure: timeout timestamp less than current block timestamp", @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure message timeout exceeds max allowed input. timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) - 1 }, - expError: channeltypesv2.ErrTimeoutTooLow, + expError: channeltypesv2.ErrTimeoutElapsed, }, { name: "failure: inactive client", diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index 9e2ab0b4a79..eb64f47e5ce 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -13,15 +13,10 @@ var ( ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 9, "packet acknowledgement not found") - - ErrMaxTimeoutDeltaExceeded = errorsmod.Register(SubModuleName, 10, "timeoutTimestamp exceeds max allowed value") - ErrTimeoutTooLow = errorsmod.Register(SubModuleName, 11, "timeoutTimestamp is less than current block timestamp") - ErrTimeoutElapsed = errorsmod.Register(SubModuleName, 12, "timeout elapsed") - + ErrInvalidTimeout = errorsmod.Register(SubModuleName, 10, "invalid packet timeout") + ErrTimeoutElapsed = errorsmod.Register(SubModuleName, 11, "timeout elapsed") + ErrTimeoutNotReached = errorsmod.Register(SubModuleName, 12, "timeout not reached") ErrInvalidChannelIdentifier = errorsmod.Register(SubModuleName, 13, "invalid channel identifier") ErrAcknowledgementExists = errorsmod.Register(SubModuleName, 14, "acknowledgement for packet already exists") - ErrTimeoutNotReached = errorsmod.Register(SubModuleName, 15, "timeout not reached") - // Perform a no-op on the current Msg - ErrNoOpMsg = errorsmod.Register(SubModuleName, 16, "message is redundant, no-op will be performed") - ErrInvalidTimeout = errorsmod.Register(SubModuleName, 17, "invalid packet timeout") + ErrNoOpMsg = errorsmod.Register(SubModuleName, 15, "message is redundant, no-op will be performed") ) From 870e83013ceaa4f98d4abbe177245522420146e5 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Mon, 4 Nov 2024 16:01:32 +0000 Subject: [PATCH 110/172] chore: add redundancy checks for V2 Msgs (#7509) * chore: add redundant checks for V2 Msgs * reintroduce tests --- modules/core/ante/ante.go | 31 +++++++++ modules/core/ante/ante_test.go | 123 +++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index 243a25f7442..1798df63566 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -7,6 +7,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" ) @@ -89,6 +90,36 @@ func (rrd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } + case *channeltypesv2.MsgTimeout: + response, err := rrd.k.ChannelKeeperV2.Timeout(ctx, msg) + if err != nil { + return ctx, err + } + + if response.Result == channeltypes.NOOP { + redundancies++ + } + packetMsgs++ + case *channeltypesv2.MsgAcknowledgement: + response, err := rrd.k.ChannelKeeperV2.Acknowledgement(ctx, msg) + if err != nil { + return ctx, err + } + + if response.Result == channeltypes.NOOP { + redundancies++ + } + packetMsgs++ + case *channeltypesv2.MsgRecvPacket: + response, err := rrd.k.ChannelKeeperV2.RecvPacket(ctx, msg) + if err != nil { + return ctx, err + } + + if response.Result == channeltypes.NOOP { + redundancies++ + } + packetMsgs++ default: // if the multiMsg tx has a msg that is not a packet msg or update msg, then we will not return error // regardless of if all packet messages are redundant. This ensures that non-packet messages get processed diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 1543e5803f4..5fb941c6532 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "testing" + "time" "github.com/stretchr/testify/require" testifysuite "github.com/stretchr/testify/suite" @@ -13,12 +14,15 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/ante" "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) type AnteTestSuite struct { @@ -74,6 +78,25 @@ func (suite *AnteTestSuite) createRecvPacketMessage(isRedundant bool) *channelty return channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) } +// createRecvPacketMessageV2 creates a V2 RecvPacket message for a packet sent from chain A to chain B. +func (suite *AnteTestSuite) createRecvPacketMessageV2(isRedundant bool) *channeltypesv2.MsgRecvPacket { + packet, err := suite.path.EndpointA.MsgSendPacket(suite.chainA.GetTimeoutTimestamp(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) + suite.Require().NoError(err) + + if isRedundant { + err = suite.path.EndpointB.MsgRecvPacket(packet) + suite.Require().NoError(err) + } + + err = suite.path.EndpointB.UpdateClient() + suite.Require().NoError(err) + + packetKey := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) + proof, proofHeight := suite.chainA.QueryProof(packetKey) + + return channeltypesv2.NewMsgRecvPacket(packet, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) +} + // createAcknowledgementMessage creates an Acknowledgement message for a packet sent from chain B to chain A. func (suite *AnteTestSuite) createAcknowledgementMessage(isRedundant bool) sdk.Msg { sequence, err := suite.path.EndpointB.SendPacket(clienttypes.NewHeight(2, 0), 0, ibctesting.MockPacketData) @@ -97,6 +120,33 @@ func (suite *AnteTestSuite) createAcknowledgementMessage(isRedundant bool) sdk.M return channeltypes.NewMsgAcknowledgement(packet, ibctesting.MockAcknowledgement, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) } +// createAcknowledgementMessageV2 creates a V2 Acknowledgement message for a packet sent from chain B to chain A. +func (suite *AnteTestSuite) createAcknowledgementMessageV2(isRedundant bool) *channeltypesv2.MsgAcknowledgement { + packet, err := suite.path.EndpointB.MsgSendPacket(suite.chainB.GetTimeoutTimestamp(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) + suite.Require().NoError(err) + + err = suite.path.EndpointA.MsgRecvPacket(packet) + suite.Require().NoError(err) + + ack := channeltypesv2.Acknowledgement{ + AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + { + AppName: mock.ModuleNameB, + RecvPacketResult: mock.MockRecvPacketResult, + }, + }, + } + if isRedundant { + err = suite.path.EndpointB.MsgAcknowledgePacket(packet, ack) + suite.Require().NoError(err) + } + + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + proof, proofHeight := suite.chainA.QueryProof(packetKey) + + return channeltypesv2.NewMsgAcknowledgement(packet, ack, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) +} + // createTimeoutMessage creates an Timeout message for a packet sent from chain B to chain A. func (suite *AnteTestSuite) createTimeoutMessage(isRedundant bool) sdk.Msg { height := suite.chainA.LatestCommittedHeader.GetHeight() @@ -126,6 +176,27 @@ func (suite *AnteTestSuite) createTimeoutMessage(isRedundant bool) sdk.Msg { return channeltypes.NewMsgTimeout(packet, sequence, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) } +// createTimeoutMessageV2 creates a V2 Timeout message for a packet sent from chain B to chain A. +func (suite *AnteTestSuite) createTimeoutMessageV2(isRedundant bool) *channeltypesv2.MsgTimeout { + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) + packet, err := suite.path.EndpointB.MsgSendPacket(timeoutTimestamp, mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) + suite.Require().NoError(err) + + suite.coordinator.IncrementTimeBy(time.Hour) + err = suite.path.EndpointB.UpdateClient() + suite.Require().NoError(err) + + if isRedundant { + err = suite.path.EndpointB.MsgTimeoutPacket(packet) + suite.Require().NoError(err) + } + + packetKey := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) + proof, proofHeight := suite.chainA.QueryProof(packetKey) + + return channeltypesv2.NewMsgTimeout(packet, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) +} + // createTimeoutOnCloseMessage creates an TimeoutOnClose message for a packet sent from chain B to chain A. func (suite *AnteTestSuite) createTimeoutOnCloseMessage(isRedundant bool) sdk.Msg { height := suite.chainA.LatestCommittedHeader.GetHeight() @@ -193,6 +264,15 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { }, nil, }, + { + "success on one new V2 RecvPacket message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + // the RecvPacket message has not been submitted to the chain yet, so it will succeed + return []sdk.Msg{suite.createRecvPacketMessageV2(false)} + }, + nil, + }, { "success on one new Acknowledgement message", func(suite *AnteTestSuite) []sdk.Msg { @@ -201,6 +281,15 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { }, nil, }, + { + "success on one new V2 Acknowledgement message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + // the Acknowledgement message has not been submitted to the chain yet, so it will succeed + return []sdk.Msg{suite.createAcknowledgementMessageV2(false)} + }, + nil, + }, { "success on one new Timeout message", func(suite *AnteTestSuite) []sdk.Msg { @@ -209,6 +298,15 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { }, nil, }, + { + "success on one new Timeout V2 message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + // the Timeout message has not been submitted to the chain yet, so it will succeed + return []sdk.Msg{suite.createTimeoutMessageV2(false)} + }, + nil, + }, { "success on one new TimeoutOnClose message", func(suite *AnteTestSuite) []sdk.Msg { @@ -368,6 +466,14 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { }, channeltypes.ErrRedundantTx, }, + { + "no success on one redundant V2 RecvPacket message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + return []sdk.Msg{suite.createRecvPacketMessageV2(true)} + }, + channeltypes.ErrRedundantTx, + }, { "no success on three redundant messages of each type", func(suite *AnteTestSuite) []sdk.Msg { @@ -555,6 +661,15 @@ func (suite *AnteTestSuite) TestAnteDecoratorReCheckTx() { }, nil, }, + { + "success on one new V2 RecvPacket message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + // the RecvPacket message has not been submitted to the chain yet, so it will succeed + return []sdk.Msg{suite.createRecvPacketMessageV2(false)} + }, + nil, + }, { "success on one redundant and one new RecvPacket message", func(suite *AnteTestSuite) []sdk.Msg { @@ -595,6 +710,14 @@ func (suite *AnteTestSuite) TestAnteDecoratorReCheckTx() { }, channeltypes.ErrRedundantTx, }, + { + "no success on one redundant V2 RecvPacket message", + func(suite *AnteTestSuite) []sdk.Msg { + suite.path.SetupV2() + return []sdk.Msg{suite.createRecvPacketMessageV2(true)} + }, + channeltypes.ErrRedundantTx, + }, } for _, tc := range testCases { From 09d14d696ede6cc928278288c9bec76e8b505303 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 5 Nov 2024 08:40:22 +0000 Subject: [PATCH 111/172] chore: create ResultType for ChannelV2 (#7534) * chore: lockin v0.50.10 (#7532) * chore: create ResultType for ChannelV2 * move redundancy chgecks to new result type * empty commit * Revert "chore: lockin v0.50.10 (#7532)" This reverts commit 5911185351c8fc2f4c0495fd818272c23817e675. * Fix timeout in ante tests for V2 --------- Co-authored-by: Damian Nolan --- .../core/04-channel/v2/keeper/msg_server.go | 17 +- modules/core/04-channel/v2/types/tx.pb.go | 171 +++++++++++------- modules/core/ante/ante.go | 6 +- modules/core/ante/ante_test.go | 4 +- proto/ibc/core/channel/v2/tx.proto | 21 ++- 5 files changed, 137 insertions(+), 82 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 6091a8e3029..c4623150ea1 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -9,7 +9,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" @@ -123,7 +122,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) - return &types.MsgRecvPacketResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgRecvPacketResponse{Result: types.NOOP}, nil default: sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) return nil, errorsmod.Wrap(err, "receive packet verification failed") @@ -157,7 +156,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // note this should never happen as the payload would have had to be empty. if len(ack.AcknowledgementResults) == 0 { sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) - return &types.MsgRecvPacketResponse{Result: channeltypesv1.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) + return &types.MsgRecvPacketResponse{Result: types.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) } // NOTE: TBD how we will handle async acknowledgements with more than one payload. @@ -176,8 +175,8 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ defer telemetry.ReportRecvPacket(msg.Packet) - sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", channeltypesv1.SUCCESS.String()) - return &types.MsgRecvPacketResponse{Result: channeltypesv1.SUCCESS}, nil + sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", types.SUCCESS.String()) + return &types.MsgRecvPacketResponse{Result: types.SUCCESS}, nil } // Acknowledgement defines an rpc handler method for MsgAcknowledgement. @@ -198,7 +197,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) - return &types.MsgAcknowledgementResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgAcknowledgementResponse{Result: types.NOOP}, nil default: sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") @@ -217,7 +216,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem } } - return &types.MsgAcknowledgementResponse{Result: channeltypesv1.SUCCESS}, nil + return &types.MsgAcknowledgementResponse{Result: types.SUCCESS}, nil } // Timeout defines a rpc handler method for MsgTimeout. @@ -242,7 +241,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) - return &types.MsgTimeoutResponse{Result: channeltypesv1.NOOP}, nil + return &types.MsgTimeoutResponse{Result: types.NOOP}, nil default: sdkCtx.Logger().Error("timeout failed", "source-channel", timeout.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) return nil, errorsmod.Wrap(err, "timeout packet verification failed") @@ -256,5 +255,5 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types } } - return &types.MsgTimeoutResponse{Result: channeltypesv1.SUCCESS}, nil + return &types.MsgTimeoutResponse{Result: types.SUCCESS}, nil } diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index b64d2c7be97..b40a86332a0 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -11,7 +11,6 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - types1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -32,6 +31,42 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// ResponseResultType defines the possible outcomes of the execution of a message +type ResponseResultType int32 + +const ( + // Default zero value enumeration + UNSPECIFIED ResponseResultType = 0 + // The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + NOOP ResponseResultType = 1 + // The message was executed successfully + SUCCESS ResponseResultType = 2 + // The message was executed unsuccessfully + FAILURE ResponseResultType = 3 +) + +var ResponseResultType_name = map[int32]string{ + 0: "RESPONSE_RESULT_TYPE_UNSPECIFIED", + 1: "RESPONSE_RESULT_TYPE_NOOP", + 2: "RESPONSE_RESULT_TYPE_SUCCESS", + 3: "RESPONSE_RESULT_TYPE_FAILURE", +} + +var ResponseResultType_value = map[string]int32{ + "RESPONSE_RESULT_TYPE_UNSPECIFIED": 0, + "RESPONSE_RESULT_TYPE_NOOP": 1, + "RESPONSE_RESULT_TYPE_SUCCESS": 2, + "RESPONSE_RESULT_TYPE_FAILURE": 3, +} + +func (x ResponseResultType) String() string { + return proto.EnumName(ResponseResultType_name, int32(x)) +} + +func (ResponseResultType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_d421c7119e969b99, []int{0} +} + // MsgCreateChannel defines the message used to create a v2 Channel. type MsgCreateChannel struct { // the client identifier of the light client representing the counterparty chain @@ -317,7 +352,7 @@ var xxx_messageInfo_MsgRecvPacket proto.InternalMessageInfo // MsgRecvPacketResponse defines the Msg/RecvPacket response type. type MsgRecvPacketResponse struct { - Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` + Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v2.ResponseResultType" json:"result,omitempty"` } func (m *MsgRecvPacketResponse) Reset() { *m = MsgRecvPacketResponse{} } @@ -396,7 +431,7 @@ var xxx_messageInfo_MsgTimeout proto.InternalMessageInfo // MsgTimeoutResponse defines the Msg/Timeout response type. type MsgTimeoutResponse struct { - Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` + Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v2.ResponseResultType" json:"result,omitempty"` } func (m *MsgTimeoutResponse) Reset() { *m = MsgTimeoutResponse{} } @@ -476,7 +511,7 @@ var xxx_messageInfo_MsgAcknowledgement proto.InternalMessageInfo // MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. type MsgAcknowledgementResponse struct { - Result types1.ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` + Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v2.ResponseResultType" json:"result,omitempty"` } func (m *MsgAcknowledgementResponse) Reset() { *m = MsgAcknowledgementResponse{} } @@ -513,6 +548,7 @@ func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo func init() { + proto.RegisterEnum("ibc.core.channel.v2.ResponseResultType", ResponseResultType_name, ResponseResultType_value) proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") proto.RegisterType((*MsgRegisterCounterparty)(nil), "ibc.core.channel.v2.MsgRegisterCounterparty") @@ -530,63 +566,70 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 886 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x5f, 0x27, 0xdb, 0x90, 0xbc, 0x4d, 0x9a, 0x60, 0x5a, 0xb2, 0x72, 0xcb, 0x6e, 0x58, 0x51, - 0x25, 0x04, 0x62, 0x13, 0x53, 0x21, 0xa5, 0x42, 0x54, 0xed, 0x5e, 0xe8, 0x61, 0xa5, 0xc8, 0x0d, - 0x3d, 0x00, 0x62, 0xe5, 0xb5, 0x5f, 0xbd, 0x56, 0xd6, 0x1e, 0xe3, 0x99, 0x35, 0x0d, 0x27, 0xc4, - 0x89, 0x23, 0x57, 0x6e, 0x7c, 0x84, 0x1c, 0xf8, 0x10, 0x3d, 0x70, 0xe8, 0x91, 0x13, 0xaa, 0x92, - 0x43, 0x4f, 0x7c, 0x07, 0xe4, 0x99, 0xf1, 0x9f, 0x6c, 0xed, 0x24, 0x88, 0xf4, 0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 0xa7, 0xf1, 0xd7, 0x69, 0xa7, 0xf1, 0xf5, 0xe7, 0x9e, - 0xcf, 0xc6, 0xd3, 0x51, 0x7a, 0x2f, 0x32, 0xe4, 0xb5, 0xd0, 0x1f, 0x39, 0x3b, 0x1e, 0x31, 0x92, - 0x3d, 0x23, 0x20, 0xee, 0x74, 0x82, 0x54, 0xdc, 0xd8, 0x3e, 0xb9, 0xbb, 0x53, 0xbe, 0x77, 0x1e, - 0x45, 0x48, 0x47, 0x0b, 0xfc, 0xb6, 0xf6, 0xe9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xce, - 0x42, 0x56, 0x9b, 0x0a, 0x00, 0x00, + // 993 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xc7, 0xe3, 0x26, 0xeb, 0xda, 0x27, 0xed, 0x12, 0xcc, 0x46, 0x83, 0x57, 0x92, 0x10, 0x31, + 0xb5, 0x14, 0x1a, 0x33, 0x33, 0x90, 0x3a, 0x21, 0xa6, 0x2e, 0x64, 0x22, 0xd2, 0xd2, 0x46, 0x4e, + 0x32, 0x89, 0x17, 0x61, 0x39, 0xce, 0x99, 0x63, 0x35, 0xf6, 0x31, 0x3e, 0x4e, 0x58, 0xb9, 0x42, + 0x5c, 0x4d, 0xbd, 0xe2, 0x96, 0x8b, 0x4a, 0x48, 0x7c, 0x81, 0x5e, 0xf0, 0x21, 0x76, 0xc1, 0xc5, + 0x2e, 0x77, 0x85, 0xa6, 0xf6, 0x62, 0x57, 0x7c, 0x07, 0xe4, 0x73, 0x4e, 0x1c, 0x37, 0xb5, 0xd7, + 0x22, 0xca, 0x55, 0xec, 0xe7, 0xfc, 0x9e, 0xb7, 0xff, 0x73, 0xe2, 0x73, 0x60, 0xd5, 0xea, 0x19, + 0xb2, 0x81, 0x3d, 0x24, 0x1b, 0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, 0x40, + 0xe4, 0xb4, 0xab, 0x24, 0xc5, 0x98, 0x32, 0xd2, 0xc6, 0xf9, 0x4c, 0x34, 0x7a, 0xe4, 0x04, 0xa9, + 0x24, 0x57, 0x38, 0x61, 0x92, 0xa3, 0xc7, 0x7c, 0xa4, 0xdb, 0x70, 0x75, 0xf2, 0x65, 0x2d, 0x25, + 0xb9, 0x71, 0x40, 0x5a, 0x3b, 0x07, 0x08, 0x83, 0xee, 0x41, 0x6e, 0xf6, 0x73, 0x93, 0xe8, 0x3b, + 0x03, 0x4a, 0xf2, 0x05, 0xc1, 0x49, 0x32, 0xe9, 0xca, 0x4f, 0xaf, 0x8e, 0x36, 0x84, 0xfb, 0x8f, + 0x9e, 0x1d, 0x17, 0x85, 0xe7, 0xc7, 0x45, 0xe1, 0xe5, 0x71, 0x51, 0xf8, 0xe5, 0xa4, 0x98, 0x7a, + 0x7e, 0x52, 0x4c, 0xbd, 0x38, 0x29, 0xa6, 0xbe, 0xfe, 0xcc, 0xb4, 0xfc, 0xc1, 0xa8, 0x17, 0x5c, + 0xf9, 0x64, 0x7e, 0xa7, 0xb5, 0x7a, 0xc6, 0xa6, 0x89, 0xe5, 0xf1, 0x96, 0x6c, 0xe3, 0xfe, 0x68, + 0x88, 0x08, 0xbb, 0x8c, 0x7e, 0x74, 0x67, 0x33, 0x7a, 0x69, 0xde, 0x77, 0x11, 0xe9, 0xcd, 0xd3, + 0x8b, 0xe8, 0xc7, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x1d, 0x8d, 0xa1, 0xe9, 0x58, 0x0b, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2458,7 +2501,7 @@ func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Result |= types1.ResponseResultType(b&0x7F) << shift + m.Result |= ResponseResultType(b&0x7F) << shift if b < 0x80 { break } @@ -2709,7 +2752,7 @@ func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Result |= types1.ResponseResultType(b&0x7F) << shift + m.Result |= ResponseResultType(b&0x7F) << shift if b < 0x80 { break } @@ -2993,7 +3036,7 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Result |= types1.ResponseResultType(b&0x7F) << shift + m.Result |= ResponseResultType(b&0x7F) << shift if b < 0x80 { break } diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index 1798df63566..d3620ebdec9 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -96,7 +96,7 @@ func (rrd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - if response.Result == channeltypes.NOOP { + if response.Result == channeltypesv2.NOOP { redundancies++ } packetMsgs++ @@ -106,7 +106,7 @@ func (rrd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - if response.Result == channeltypes.NOOP { + if response.Result == channeltypesv2.NOOP { redundancies++ } packetMsgs++ @@ -116,7 +116,7 @@ func (rrd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - if response.Result == channeltypes.NOOP { + if response.Result == channeltypesv2.NOOP { redundancies++ } packetMsgs++ diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 5fb941c6532..75e37659640 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -80,7 +80,7 @@ func (suite *AnteTestSuite) createRecvPacketMessage(isRedundant bool) *channelty // createRecvPacketMessageV2 creates a V2 RecvPacket message for a packet sent from chain A to chain B. func (suite *AnteTestSuite) createRecvPacketMessageV2(isRedundant bool) *channeltypesv2.MsgRecvPacket { - packet, err := suite.path.EndpointA.MsgSendPacket(suite.chainA.GetTimeoutTimestamp(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) + packet, err := suite.path.EndpointA.MsgSendPacket(suite.chainA.GetTimeoutTimestampSecs(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) suite.Require().NoError(err) if isRedundant { @@ -122,7 +122,7 @@ func (suite *AnteTestSuite) createAcknowledgementMessage(isRedundant bool) sdk.M // createAcknowledgementMessageV2 creates a V2 Acknowledgement message for a packet sent from chain B to chain A. func (suite *AnteTestSuite) createAcknowledgementMessageV2(isRedundant bool) *channeltypesv2.MsgAcknowledgement { - packet, err := suite.path.EndpointB.MsgSendPacket(suite.chainB.GetTimeoutTimestamp(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) + packet, err := suite.path.EndpointB.MsgSendPacket(suite.chainB.GetTimeoutTimestampSecs(), mock.NewMockPayload(mock.ModuleNameA, mock.ModuleNameB)) suite.Require().NoError(err) err = suite.path.EndpointA.MsgRecvPacket(packet) diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 9276f8cdc67..27eaa08c805 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -7,7 +7,6 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/type import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/core/channel/v2/packet.proto"; -import "ibc/core/channel/v1/tx.proto"; import "ibc/core/client/v1/client.proto"; import "ibc/core/commitment/v2/commitment.proto"; @@ -104,11 +103,25 @@ message MsgRecvPacket { string signer = 4; } +// ResponseResultType defines the possible outcomes of the execution of a message +enum ResponseResultType { + option (gogoproto.goproto_enum_prefix) = false; + + // Default zero value enumeration + RESPONSE_RESULT_TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; + // The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + RESPONSE_RESULT_TYPE_NOOP = 1 [(gogoproto.enumvalue_customname) = "NOOP"]; + // The message was executed successfully + RESPONSE_RESULT_TYPE_SUCCESS = 2 [(gogoproto.enumvalue_customname) = "SUCCESS"]; + // The message was executed unsuccessfully + RESPONSE_RESULT_TYPE_FAILURE = 3 [(gogoproto.enumvalue_customname) = "FAILURE"]; +} + // MsgRecvPacketResponse defines the Msg/RecvPacket response type. message MsgRecvPacketResponse { option (gogoproto.goproto_getters) = false; - ibc.core.channel.v1.ResponseResultType result = 1; + ResponseResultType result = 1; } // MsgTimeout receives timed-out packet @@ -127,7 +140,7 @@ message MsgTimeout { message MsgTimeoutResponse { option (gogoproto.goproto_getters) = false; - ibc.core.channel.v1.ResponseResultType result = 1; + ResponseResultType result = 1; } // MsgAcknowledgement receives incoming IBC acknowledgement. @@ -147,5 +160,5 @@ message MsgAcknowledgement { message MsgAcknowledgementResponse { option (gogoproto.goproto_getters) = false; - ibc.core.channel.v1.ResponseResultType result = 1; + ResponseResultType result = 1; } From e3b46ff0cdc055dc352b31db31cdb10985d02497 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 6 Nov 2024 12:50:07 +0200 Subject: [PATCH 112/172] feat: add protobuf files for channel/v2 genesis storage. (#7502) --- .../core/04-channel/v2/types/channel.pb.go | 256 +++- .../core/04-channel/v2/types/genesis.pb.go | 1043 +++++++++++++++++ proto/ibc/core/channel/v2/channel.proto | 10 + proto/ibc/core/channel/v2/genesis.proto | 40 + 4 files changed, 1329 insertions(+), 20 deletions(-) create mode 100644 modules/core/04-channel/v2/types/genesis.pb.go create mode 100644 proto/ibc/core/channel/v2/genesis.proto diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go index 8666e2f8517..8d3dafb35ae 100644 --- a/modules/core/04-channel/v2/types/channel.pb.go +++ b/modules/core/04-channel/v2/types/channel.pb.go @@ -97,33 +97,79 @@ func (m *Channel) GetMerklePathPrefix() v2.MerklePath { return v2.MerklePath{} } +// IdentifiedChannel defines a channel with an additional channel identifier field. +type IdentifiedChannel struct { + // channel identified. + Channel Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel"` + // channel identifier + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} } +func (m *IdentifiedChannel) String() string { return proto.CompactTextString(m) } +func (*IdentifiedChannel) ProtoMessage() {} +func (*IdentifiedChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_7e9b57d8f218397d, []int{1} +} +func (m *IdentifiedChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedChannel.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 *IdentifiedChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedChannel.Merge(m, src) +} +func (m *IdentifiedChannel) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedChannel) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedChannel proto.InternalMessageInfo + func init() { proto.RegisterType((*Channel)(nil), "ibc.core.channel.v2.Channel") + proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v2.IdentifiedChannel") } func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } var fileDescriptor_7e9b57d8f218397d = []byte{ - // 302 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0x83, 0x40, - 0x18, 0xc7, 0x39, 0x35, 0x6a, 0x71, 0x31, 0xa8, 0xb1, 0xa9, 0xc9, 0x59, 0xbb, 0xd8, 0xa5, 0x9c, - 0x41, 0x63, 0x62, 0xe2, 0x54, 0xa7, 0x0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0x8d, 0xd9, 0xa9, - 0xd8, 0x26, 0x53, 0x6d, 0x18, 0xcf, 0x97, 0x25, 0x46, 0xab, 0x12, 0xa3, 0xbf, 0x12, 0xa3, 0xaf, - 0x0a, 0x1b, 0xab, 0x0a, 0x1b, 0x3f, 0x15, 0x36, 0xde, 0x9e, 0x43, 0xae, 0xa2, 0xdc, 0xaf, 0x95, - 0x84, 0x42, 0x26, 0x20, 0x23, 0xdc, 0xa7, 0xa3, 0x10, 0x48, 0xf1, 0x44, 0x04, 0x04, 0x79, 0xcc, - 0xb2, 0xa6, 0x9b, 0xbb, 0x87, 0xd1, 0x4e, 0xd9, 0x6a, 0x91, 0xb2, 0xcc, 0x3f, 0xd4, 0xbd, 0xdc, - 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdc, 0xac, 0x74, 0x90, 0x01, 0x00, 0x00, + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0x3b, 0xf7, 0x92, 0xcb, 0x65, 0xd8, 0x68, 0xd5, 0x48, 0x50, 0x0b, 0xb2, 0x91, 0x0d, + 0x33, 0xa6, 0x1a, 0x13, 0x0d, 0x2b, 0x5c, 0xb1, 0x30, 0x21, 0x2c, 0x58, 0xb8, 0x69, 0xda, 0xe9, + 0xd0, 0x4e, 0xec, 0x74, 0x9a, 0x76, 0x68, 0xe4, 0x0d, 0x5c, 0xfa, 0x08, 0x3e, 0x85, 0xcf, 0xc0, + 0x92, 0xa5, 0x2b, 0x63, 0xe0, 0x45, 0x4c, 0xa7, 0x2d, 0x90, 0xe8, 0xee, 0xcc, 0x39, 0xff, 0xf9, + 0xf2, 0xff, 0x73, 0xe0, 0x39, 0x73, 0x08, 0x26, 0x22, 0xa6, 0x98, 0xf8, 0x76, 0x18, 0xd2, 0x00, + 0xa7, 0x66, 0x59, 0x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, 0x0c, 0xb0, 0x5c, 0x19, 0xe0, + 0x6b, 0x65, 0x80, 0xd7, 0xb5, 0xa1, 0x2d, 0xd7, 0x86, 0xf6, 0xb1, 0x36, 0xb4, 0xc7, 0xbe, 0xc7, + 0xa4, 0x3f, 0x73, 0xb2, 0x28, 0x98, 0x88, 0x84, 0x8b, 0x04, 0x33, 0x87, 0xf4, 0x3c, 0x81, 0xd3, + 0x5b, 0xcc, 0x85, 0x3b, 0x0b, 0x68, 0x92, 0xdf, 0xe4, 0xf2, 0xba, 0xb7, 0x73, 0x64, 0x39, 0x8f, + 0x68, 0xe2, 0xfc, 0x53, 0xf7, 0xb8, 0xfa, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xc9, 0x7e, 0x8b, + 0x08, 0x02, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -173,6 +219,46 @@ func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IdentifiedChannel) 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 *IdentifiedChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedChannel) 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 = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { offset -= sovChannel(v) base := offset @@ -203,6 +289,21 @@ func (m *Channel) Size() (n int) { return n } +func (m *IdentifiedChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Channel.Size() + n += 1 + l + sovChannel(uint64(l)) + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -356,6 +457,121 @@ func (m *Channel) Unmarshal(dAtA []byte) error { } return nil } +func (m *IdentifiedChannel) 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 ErrIntOverflowChannel + } + 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: IdentifiedChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/genesis.pb.go b/modules/core/04-channel/v2/types/genesis.pb.go new file mode 100644 index 00000000000..2528c89d61f --- /dev/null +++ b/modules/core/04-channel/v2/types/genesis.pb.go @@ -0,0 +1,1043 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/channel/v2/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// GenesisState defines the ibc channel submodule's genesis state. +type GenesisState struct { + Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"` + Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"` + Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"` + Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"` + SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_b5d374f126f051c3, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetChannels() []IdentifiedChannel { + if m != nil { + return m.Channels + } + return nil +} + +func (m *GenesisState) GetAcknowledgements() []PacketState { + if m != nil { + return m.Acknowledgements + } + return nil +} + +func (m *GenesisState) GetCommitments() []PacketState { + if m != nil { + return m.Commitments + } + return nil +} + +func (m *GenesisState) GetReceipts() []PacketState { + if m != nil { + return m.Receipts + } + return nil +} + +func (m *GenesisState) GetSendSequences() []PacketSequence { + if m != nil { + return m.SendSequences + } + return nil +} + +// PacketState defines the generic type necessary to retrieve and store +// packet commitments, acknowledgements, and receipts. +// Caller is responsible for knowing the context necessary to interpret this +// state as a commitment, acknowledgement, or a receipt. +type PacketState struct { + // channel unique identifier. + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // embedded data that represents packet state. + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *PacketState) Reset() { *m = PacketState{} } +func (m *PacketState) String() string { return proto.CompactTextString(m) } +func (*PacketState) ProtoMessage() {} +func (*PacketState) Descriptor() ([]byte, []int) { + return fileDescriptor_b5d374f126f051c3, []int{1} +} +func (m *PacketState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketState.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 *PacketState) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketState.Merge(m, src) +} +func (m *PacketState) XXX_Size() int { + return m.Size() +} +func (m *PacketState) XXX_DiscardUnknown() { + xxx_messageInfo_PacketState.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketState proto.InternalMessageInfo + +// PacketSequence defines the genesis type necessary to retrieve and store next send sequences. +type PacketSequence struct { + // channel unique identifier. + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *PacketSequence) Reset() { *m = PacketSequence{} } +func (m *PacketSequence) String() string { return proto.CompactTextString(m) } +func (*PacketSequence) ProtoMessage() {} +func (*PacketSequence) Descriptor() ([]byte, []int) { + return fileDescriptor_b5d374f126f051c3, []int{2} +} +func (m *PacketSequence) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketSequence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketSequence.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 *PacketSequence) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketSequence.Merge(m, src) +} +func (m *PacketSequence) XXX_Size() int { + return m.Size() +} +func (m *PacketSequence) XXX_DiscardUnknown() { + xxx_messageInfo_PacketSequence.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketSequence proto.InternalMessageInfo + +func (m *PacketSequence) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *PacketSequence) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "ibc.core.channel.v2.GenesisState") + proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v2.PacketState") + proto.RegisterType((*PacketSequence)(nil), "ibc.core.channel.v2.PacketSequence") +} + +func init() { proto.RegisterFile("ibc/core/channel/v2/genesis.proto", fileDescriptor_b5d374f126f051c3) } + +var fileDescriptor_b5d374f126f051c3 = []byte{ + // 414 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xbf, 0xae, 0xd3, 0x30, + 0x14, 0xc6, 0xe3, 0x9b, 0x80, 0x7a, 0xdd, 0xcb, 0x15, 0x18, 0x86, 0x50, 0x89, 0x34, 0x14, 0x09, + 0x65, 0xb9, 0x31, 0x2a, 0x2c, 0x20, 0xa6, 0x30, 0x40, 0xc5, 0x52, 0x05, 0x89, 0x01, 0x09, 0x55, + 0x89, 0x7d, 0x48, 0xad, 0x36, 0x76, 0xa9, 0xdd, 0x22, 0xde, 0x80, 0x91, 0x47, 0x80, 0xb7, 0xe9, + 0xd8, 0x91, 0xa9, 0x42, 0xed, 0x5b, 0x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xf9, 0x40, 0xc3, 0xe7, + 0x19, 0x48, 0x06, 0xda, 0xbd, 0x51, 0x92, 0x1e, 0xfd, 0x8f, 0x54, 0x67, 0x6b, 0xd8, 0xad, 0x02, + 0xb0, 0x9d, 0xe9, 0x4e, 0x8a, 0x9b, 0x7b, 0x42, 0xf2, 0x00, 0xe3, 0x1a, 0x30, 0x10, 0xdc, 0x45, + 0x3e, 0x0a, 0xce, 0xe3, 0xf3, 0x7a, 0xd2, 0xe3, 0xa4, 0x85, 0x1b, 0x5b, 0xb5, 0x7b, 0xe6, 0xa3, + 0xc0, 0x89, 0x77, 0x77, 0x42, 0xb0, 0xc3, 0x13, 0x93, 0xb8, 0xb6, 0x8f, 0x82, 0x8b, 0xb8, 0x3c, + 0xbf, 0x70, 0xbe, 0xfd, 0x68, 0x5b, 0x9d, 0xb7, 0xf8, 0xf2, 0xdf, 0xaf, 0x5c, 0x43, 0x13, 0xbd, + 0x5f, 0xac, 0x3d, 0xb4, 0x5c, 0x7b, 0xe8, 0xf7, 0xda, 0x43, 0xdf, 0x37, 0x9e, 0xb5, 0xdc, 0x78, + 0xd6, 0xaf, 0x8d, 0x67, 0x7d, 0x78, 0x99, 0x09, 0x33, 0x9c, 0xa5, 0x21, 0x53, 0x39, 0x65, 0x4a, + 0xe7, 0x4a, 0x53, 0x91, 0xb2, 0xab, 0x4c, 0xd1, 0xf9, 0x73, 0x9a, 0x2b, 0x3e, 0x1b, 0x83, 0xae, + 0x36, 0xf6, 0xc9, 0xb3, 0xab, 0xbd, 0xa5, 0x35, 0x5f, 0x27, 0xa0, 0xd3, 0x9b, 0xe5, 0xce, 0x3e, + 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x16, 0xa3, 0xcb, 0xa2, 0x26, 0x03, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SendSequences) > 0 { + for iNdEx := len(m.SendSequences) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SendSequences[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Receipts) > 0 { + for iNdEx := len(m.Receipts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Receipts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Commitments) > 0 { + for iNdEx := len(m.Commitments) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commitments[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Acknowledgements) > 0 { + for iNdEx := len(m.Acknowledgements) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Acknowledgements[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Channels) > 0 { + for iNdEx := len(m.Channels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Channels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PacketState) 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 *PacketState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if m.Sequence != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PacketSequence) 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 *PacketSequence) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketSequence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Channels) > 0 { + for _, e := range m.Channels { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Acknowledgements) > 0 { + for _, e := range m.Acknowledgements { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Commitments) > 0 { + for _, e := range m.Commitments { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Receipts) > 0 { + for _, e := range m.Receipts { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.SendSequences) > 0 { + for _, e := range m.SendSequences { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *PacketState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovGenesis(uint64(m.Sequence)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *PacketSequence) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovGenesis(uint64(m.Sequence)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Channels = append(m.Channels, IdentifiedChannel{}) + if err := m.Channels[len(m.Channels)-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 Acknowledgements", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Acknowledgements = append(m.Acknowledgements, PacketState{}) + if err := m.Acknowledgements[len(m.Acknowledgements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitments", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commitments = append(m.Commitments, PacketState{}) + if err := m.Commitments[len(m.Commitments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receipts = append(m.Receipts, PacketState{}) + if err := m.Receipts[len(m.Receipts)-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 SendSequences", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SendSequences = append(m.SendSequences, PacketSequence{}) + if err := m.SendSequences[len(m.SendSequences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketState) 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 ErrIntOverflowGenesis + } + 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: PacketState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketSequence) 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 ErrIntOverflowGenesis + } + 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: PacketSequence: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketSequence: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto index 67a5a1871be..f3ac209cdd9 100644 --- a/proto/ibc/core/channel/v2/channel.proto +++ b/proto/ibc/core/channel/v2/channel.proto @@ -25,3 +25,13 @@ message Channel { // the final path. ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; } + +// IdentifiedChannel defines a channel with an additional channel identifier field. +message IdentifiedChannel { + option (gogoproto.goproto_getters) = false; + + // channel identified. + Channel channel = 1 [(gogoproto.nullable) = false]; + // channel identifier + string channel_id = 2; +} diff --git a/proto/ibc/core/channel/v2/genesis.proto b/proto/ibc/core/channel/v2/genesis.proto new file mode 100644 index 00000000000..ab2c2b73944 --- /dev/null +++ b/proto/ibc/core/channel/v2/genesis.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package ibc.core.channel.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/channel/v2/channel.proto"; + +// GenesisState defines the ibc channel submodule's genesis state. +message GenesisState { + repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; + repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; + repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; + repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; + repeated PacketSequence send_sequences = 5 [(gogoproto.nullable) = false]; +} + +// PacketState defines the generic type necessary to retrieve and store +// packet commitments, acknowledgements, and receipts. +// Caller is responsible for knowing the context necessary to interpret this +// state as a commitment, acknowledgement, or a receipt. +message PacketState { + option (gogoproto.goproto_getters) = false; + + // channel unique identifier. + string channel_id = 1; + // packet sequence. + uint64 sequence = 2; + // embedded data that represents packet state. + bytes data = 3; +} + +// PacketSequence defines the genesis type necessary to retrieve and store next send sequences. +message PacketSequence { + // channel unique identifier. + string channel_id = 1; + // packet sequence + uint64 sequence = 2; +} From c7670b39f220a8769b01ec5c7872d7ee92fd1291 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Wed, 6 Nov 2024 14:54:36 +0100 Subject: [PATCH 113/172] wire channel query server v2 (#7537) * wire channel query server v2 * register grpc gateway routes --- modules/core/module.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/module.go b/modules/core/module.go index 6edba9b02c3..32e2589d075 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -24,6 +24,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channelkeeperv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -92,6 +93,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r if err != nil { panic(err) } + err = channeltypesv2.RegisterQueryHandlerClient(context.Background(), mux, channeltypesv2.NewQueryClient(clientCtx)) if err != nil { panic(err) } @@ -140,6 +142,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) channeltypes.RegisterQueryServer(cfg.QueryServer(), channelkeeper.NewQueryServer(am.keeper.ChannelKeeper)) + channeltypesv2.RegisterQueryServer(cfg.QueryServer(), channelkeeperv2.NewQueryServer(am.keeper.ChannelKeeperV2)) clientMigrator := clientkeeper.NewMigrator(am.keeper.ClientKeeper) if err := cfg.RegisterMigration(exported.ModuleName, 2, clientMigrator.Migrate2to3); err != nil { From 9239d5dc569b712d90ecc321690ac51d934380f7 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 7 Nov 2024 11:12:35 +0100 Subject: [PATCH 114/172] fix: channel must exist before channel creator check (#7538) * fix: channel must exist before channel creator check * Update modules/core/04-channel/v2/keeper/msg_server.go Co-authored-by: DimitrisJim * fixed failing test --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/keeper/msg_server.go | 10 +++++----- modules/core/04-channel/v2/keeper/msg_server_test.go | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index c4623150ea1..6bda4404531 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -38,6 +38,11 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChanne func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegisterCounterparty) (*types.MsgRegisterCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + channel, ok := k.GetChannel(ctx, msg.ChannelId) + if !ok { + return nil, errorsmod.Wrapf(types.ErrChannelNotFound, "channel must exist for channel id %s", msg.ChannelId) + } + creator, found := k.GetCreator(ctx, msg.ChannelId) if !found { return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") @@ -47,11 +52,6 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegis return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) } - channel, ok := k.GetChannel(ctx, msg.ChannelId) - if !ok { - return nil, errorsmod.Wrapf(types.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) - } - channel.CounterpartyChannelId = msg.CounterpartyChannelId k.SetChannel(ctx, msg.ChannelId, channel) // Delete client creator from state as it is not needed after this point. diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index b4b5d8c71c4..2fa079e1e1f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -52,9 +52,10 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { { "failure: channel must already exist", func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) }, - channeltypesv2.ErrInvalidChannel, + channeltypesv2.ErrChannelNotFound, }, } From cae86e65b3f5740a2c7e35461dd25312869e4280 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 11 Nov 2024 12:50:30 +0100 Subject: [PATCH 115/172] feat: add paginated packet commitments query to channel/v2 (#7533) * feat: add paginated packet commitments query to channel/v2 * chore: add cli handler * chore: rm commented code * chore: make lint-fix --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 39 + .../core/04-channel/v2/keeper/grpc_query.go | 48 ++ .../04-channel/v2/keeper/grpc_query_test.go | 115 +++ modules/core/04-channel/v2/types/packet.go | 9 + modules/core/04-channel/v2/types/query.pb.go | 672 ++++++++++++++++-- .../core/04-channel/v2/types/query.pb.gw.go | 119 ++++ modules/core/24-host/v2/packet_keys.go | 5 + proto/ibc/core/channel/v2/query.proto | 25 + 9 files changed, 987 insertions(+), 46 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index a9d985e72a0..59d9dded017 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -21,6 +21,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCmdQueryChannel(), getCmdQueryPacketCommitment(), + getCmdQueryPacketCommitments(), getCmdQueryPacketAcknowledgement(), getCmdQueryPacketReceipt(), ) diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index a6a1d7f0762..c79d92dfd4c 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -96,6 +96,45 @@ func getCmdQueryPacketCommitment() *cobra.Command { return cmd } +func getCmdQueryPacketCommitments() *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-commitments [channel-id]", + Short: "Query all packet commitments associated with a channel", + Long: "Query all packet commitments associated with a channel", + Example: fmt.Sprintf("%s query %s %s packet-commitments [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + req := &types.QueryPacketCommitmentsRequest{ + ChannelId: args[0], + Pagination: pageReq, + } + + res, err := queryClient.PacketCommitments(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "packet commitments associated with a channel") + + return cmd +} + func getCmdQueryPacketAcknowledgement() *cobra.Command { cmd := &cobra.Command{ Use: "packet-acknowledgement [channel-id] [sequence]", diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 3106bc367cc..e72a5b3bbd9 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -2,15 +2,22 @@ package keeper import ( "context" + "strings" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/store/prefix" + + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) var _ types.QueryServer = (*queryServer)(nil) @@ -71,6 +78,47 @@ func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPack return types.NewQueryPacketCommitmentResponse(commitment, nil, clienttypes.GetSelfHeight(ctx)), nil } +// PacketCommitments implements the Query/PacketCommitments gRPC method +func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPacketCommitmentsRequest) (*types.QueryPacketCommitmentsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + var commitments []*types.PacketState + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), hostv2.PacketCommitmentPrefixKey(req.ChannelId)) + + pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + keySplit := strings.Split(string(key), "/") + + sequence := sdk.BigEndianToUint64([]byte(keySplit[len(keySplit)-1])) + if sequence == 0 { + return types.ErrInvalidPacket + } + + commitment := types.NewPacketState(req.ChannelId, sequence, value) + commitments = append(commitments, &commitment) + return nil + }) + if err != nil { + return nil, err + } + + selfHeight := clienttypes.GetSelfHeight(ctx) + return &types.QueryPacketCommitmentsResponse{ + Commitments: commitments, + Pagination: pageRes, + Height: selfHeight, + }, nil +} + // PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method. func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index e458128ce09..faecb9a2595 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -6,6 +6,8 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -191,6 +193,119 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { } } +func (suite *KeeperTestSuite) TestQueryPacketCommitments() { + var ( + req *types.QueryPacketCommitmentsRequest + expCommitments = []*types.PacketState{} + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments + for i := uint64(1); i <= 10; i++ { + pktStateCommitment := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ChannelId, pktStateCommitment.Sequence, pktStateCommitment.Data) + expCommitments = append(expCommitments, &pktStateCommitment) + } + + req = &types.QueryPacketCommitmentsRequest{ + ChannelId: path.EndpointA.ChannelID, + Pagination: &query.PageRequest{ + Key: nil, + Limit: 11, + CountTotal: true, + }, + } + }, + nil, + }, + { + "success: with pagination", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments + for i := uint64(1); i <= 10; i++ { + pktStateCommitment := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ChannelId, pktStateCommitment.Sequence, pktStateCommitment.Data) + expCommitments = append(expCommitments, &pktStateCommitment) + } + + limit := uint64(5) + expCommitments = expCommitments[:limit] + + req = &types.QueryPacketCommitmentsRequest{ + ChannelId: path.EndpointA.ChannelID, + Pagination: &query.PageRequest{ + Key: nil, + Limit: limit, + CountTotal: true, + }, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryPacketCommitmentsRequest{ + ChannelId: "", + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryPacketCommitmentsRequest{ + ChannelId: "channel-141", + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) + res, err := queryServer.PacketCommitments(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCommitments, res.Commitments) + } else { + suite.Require().Error(err) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { var ( expAcknowledgement []byte diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 1ba7722b925..42da61b2a15 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -84,3 +84,12 @@ func (p Payload) ValidateBasic() error { func TimeoutTimestampToNanos(seconds uint64) uint64 { return uint64(time.Unix(int64(seconds), 0).UnixNano()) } + +// NewPacketState creates and returns a new PacketState envelope type to encapsulate packet commitments, acks or receipts. +func NewPacketState(channelID string, sequence uint64, data []byte) PacketState { + return PacketState{ + ChannelId: channelID, + Sequence: sequence, + Data: data, + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 02e5f2a1b1b..897cd508b6d 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -240,6 +241,125 @@ func (m *QueryPacketCommitmentResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryPacketCommitmentsRequest is the request type for the Query/PacketCommitments RPC method. +type QueryPacketCommitmentsRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // pagination request + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommitmentsRequest{} } +func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentsRequest) ProtoMessage() {} +func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{4} +} +func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentsRequest.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 *QueryPacketCommitmentsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentsRequest.Merge(m, src) +} +func (m *QueryPacketCommitmentsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentsRequest proto.InternalMessageInfo + +func (m *QueryPacketCommitmentsRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryPacketCommitmentsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryPacketCommitmentResponse is the response type for the Query/PacketCommitment RPC method. +type QueryPacketCommitmentsResponse struct { + // collection of packet commitments for the requested channel identifier. + Commitments []*PacketState `protobuf:"bytes,1,rep,name=commitments,proto3" json:"commitments,omitempty"` + // pagination response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // query block height. + Height types.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"` +} + +func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommitmentsResponse{} } +func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentsResponse) ProtoMessage() {} +func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{5} +} +func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentsResponse.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 *QueryPacketCommitmentsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentsResponse.Merge(m, src) +} +func (m *QueryPacketCommitmentsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentsResponse proto.InternalMessageInfo + +func (m *QueryPacketCommitmentsResponse) GetCommitments() []*PacketState { + if m != nil { + return m.Commitments + } + return nil +} + +func (m *QueryPacketCommitmentsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryPacketCommitmentsResponse) GetHeight() types.Height { + if m != nil { + return m.Height + } + return types.Height{} +} + // QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. type QueryPacketAcknowledgementRequest struct { // channel unique identifier @@ -252,7 +372,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -309,7 +429,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -373,7 +493,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -437,7 +557,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -492,6 +612,8 @@ func init() { proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentResponse") + proto.RegisterType((*QueryPacketCommitmentsRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentsRequest") + proto.RegisterType((*QueryPacketCommitmentsResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentsResponse") proto.RegisterType((*QueryPacketAcknowledgementRequest)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementRequest") proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") proto.RegisterType((*QueryPacketReceiptRequest)(nil), "ibc.core.channel.v2.QueryPacketReceiptRequest") @@ -501,48 +623,58 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 654 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x4f, 0xd4, 0x40, - 0x14, 0xde, 0xe1, 0x37, 0x0f, 0x8c, 0x66, 0xc0, 0x88, 0x0d, 0x14, 0xe8, 0x69, 0x35, 0xd2, 0x91, - 0x95, 0x68, 0x4c, 0xb8, 0xc0, 0xc6, 0x08, 0x26, 0x26, 0xd8, 0x18, 0x13, 0x3d, 0x48, 0xba, 0xb3, - 0x63, 0xb7, 0x61, 0xdb, 0x29, 0xed, 0x6c, 0x0d, 0x21, 0x5c, 0xf8, 0x0b, 0x8c, 0xdc, 0xfc, 0x0f, - 0xfc, 0x2b, 0xbc, 0x92, 0x78, 0x21, 0xe1, 0xe2, 0xc9, 0x18, 0xf0, 0x0f, 0x31, 0x9d, 0x0e, 0xbb, - 0xdd, 0x4d, 0x77, 0xd9, 0x35, 0x7a, 0x9b, 0x79, 0xf3, 0xbe, 0xf7, 0xbe, 0xef, 0xa3, 0x1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4, 0x4f, 0xdf, 0xa3, - 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x39, 0x9c, 0xc7, 0xa2, 0xaa, 0x07, 0x00, 0x00, + // 810 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4d, 0x4f, 0x13, 0x5d, + 0x14, 0xc7, 0x7b, 0x29, 0x50, 0x38, 0xe5, 0xc9, 0xf3, 0x3c, 0x17, 0x8c, 0x75, 0x02, 0x43, 0x99, + 0x85, 0x56, 0x22, 0x73, 0xed, 0x40, 0x7c, 0x49, 0x30, 0x06, 0x1a, 0x04, 0x4c, 0x4c, 0x70, 0x34, + 0x26, 0xba, 0x90, 0x4c, 0xa7, 0xd7, 0xe9, 0x84, 0x76, 0xee, 0xd0, 0x99, 0xd6, 0x10, 0xc2, 0xc6, + 0x85, 0x6b, 0x23, 0x3b, 0xbf, 0x81, 0x9f, 0xc2, 0x85, 0x1b, 0x12, 0x37, 0x24, 0x6c, 0x5c, 0x19, + 0x03, 0x26, 0x7e, 0x0d, 0xd3, 0x3b, 0xb7, 0xed, 0xb4, 0x4e, 0x4b, 0xeb, 0xcb, 0xee, 0xde, 0xd3, + 0x73, 0xce, 0xfd, 0x9d, 0xff, 0x3d, 0xf7, 0x74, 0x60, 0xd6, 0xce, 0x9b, 0xc4, 0x64, 0x15, 0x4a, + 0xcc, 0xa2, 0xe1, 0x38, 0xb4, 0x44, 0x6a, 0x1a, 0xd9, 0xad, 0xd2, 0xca, 0x9e, 0xea, 0x56, 0x98, + 0xcf, 0xf0, 0xa4, 0x9d, 0x37, 0xd5, 0xba, 0x83, 0x2a, 0x1c, 0xd4, 0x9a, 0x26, 0xcd, 0x9b, 0xcc, + 0x2b, 0x33, 0x8f, 0xe4, 0x0d, 0x8f, 0x06, 0xde, 0xa4, 0x96, 0xcd, 0x53, 0xdf, 0xc8, 0x12, 0xd7, + 0xb0, 0x6c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0x43, 0x43, 0x22, 0x7d, 0xfb, 0x0b, 0xfa, 0x07, 0x9c, 0x7e, + 0x1d, 0xaf, 0x0d, 0x4e, 0x5f, 0x09, 0x52, 0x85, 0x2b, 0x58, 0x7d, 0x72, 0x74, 0x2a, 0xa3, 0xe3, + 0x53, 0x19, 0x7d, 0x3d, 0x95, 0xd1, 0x9b, 0x33, 0x39, 0x76, 0x7c, 0x26, 0xc7, 0x3e, 0x9f, 0xc9, + 0xb1, 0x67, 0xcb, 0x96, 0xed, 0x17, 0xab, 0x79, 0xd5, 0x64, 0x65, 0x22, 0x3e, 0xe0, 0xec, 0xbc, + 0xb9, 0x60, 0x31, 0x52, 0xbb, 0x4d, 0xca, 0xac, 0x50, 0x2d, 0x51, 0x2f, 0x38, 0xff, 0xfa, 0xd2, + 0x42, 0x08, 0xc1, 0xdf, 0x73, 0xa9, 0x97, 0x1f, 0xe5, 0xdf, 0x4c, 0x8b, 0x3f, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x78, 0xf5, 0x4d, 0xe9, 0x32, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -561,6 +693,8 @@ type QueryClient interface { Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) + // PacketCommitments queries a stored packet commitment hash. + PacketCommitments(ctx context.Context, in *QueryPacketCommitmentsRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentsResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. @@ -593,6 +727,15 @@ func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommi return out, nil } +func (c *queryClient) PacketCommitments(ctx context.Context, in *QueryPacketCommitmentsRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentsResponse, error) { + out := new(QueryPacketCommitmentsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketCommitments", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) { out := new(QueryPacketAcknowledgementResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketAcknowledgement", in, out, opts...) @@ -617,6 +760,8 @@ type QueryServer interface { Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) + // PacketCommitments queries a stored packet commitment hash. + PacketCommitments(context.Context, *QueryPacketCommitmentsRequest) (*QueryPacketCommitmentsResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. @@ -633,6 +778,9 @@ func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelR func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketCommitment not implemented") } +func (*UnimplementedQueryServer) PacketCommitments(ctx context.Context, req *QueryPacketCommitmentsRequest) (*QueryPacketCommitmentsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketCommitments not implemented") +} func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketAcknowledgement not implemented") } @@ -680,6 +828,24 @@ func _Query_PacketCommitment_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_PacketCommitments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketCommitmentsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketCommitments(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/PacketCommitments", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketCommitments(ctx, req.(*QueryPacketCommitmentsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_PacketAcknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryPacketAcknowledgementRequest) if err := dec(in); err != nil { @@ -728,6 +894,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketCommitment", Handler: _Query_PacketCommitment_Handler, }, + { + MethodName: "PacketCommitments", + Handler: _Query_PacketCommitments_Handler, + }, { MethodName: "PacketAcknowledgement", Handler: _Query_PacketAcknowledgement_Handler, @@ -886,6 +1056,107 @@ func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryPacketCommitmentsRequest) 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 *QueryPacketCommitmentsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketCommitmentsResponse) 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 *QueryPacketCommitmentsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Commitments) > 0 { + for iNdEx := len(m.Commitments) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commitments[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryPacketAcknowledgementRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1130,6 +1401,44 @@ func (m *QueryPacketCommitmentResponse) Size() (n int) { return n } +func (m *QueryPacketCommitmentsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPacketCommitmentsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Commitments) > 0 { + for _, e := range m.Commitments { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Height.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryPacketAcknowledgementRequest) Size() (n int) { if m == nil { return 0 @@ -1626,6 +1935,277 @@ func (m *QueryPacketCommitmentResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPacketCommitmentsRequest) 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 ErrIntOverflowQuery + } + 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: QueryPacketCommitmentsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentsResponse) 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 ErrIntOverflowQuery + } + 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: QueryPacketCommitmentsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitments", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commitments = append(m.Commitments, &PacketState{}) + if err := m.Commitments[len(m.Commitments)-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 Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryPacketAcknowledgementRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 5a274f65b17..07dbf642b72 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -163,6 +163,78 @@ func local_request_Query_PacketCommitment_0(ctx context.Context, marshaler runti } +var ( + filter_Query_PacketCommitments_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_PacketCommitments_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketCommitmentsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketCommitments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PacketCommitments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PacketCommitments_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketCommitmentsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketCommitments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PacketCommitments(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryPacketAcknowledgementRequest var metadata runtime.ServerMetadata @@ -385,6 +457,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PacketCommitments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PacketCommitments_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketCommitments_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -512,6 +607,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PacketCommitments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PacketCommitments_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketCommitments_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -560,6 +675,8 @@ var ( pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) @@ -570,6 +687,8 @@ var ( forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage + forward_Query_PacketCommitments_0 = runtime.ForwardResponseMessage + forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index a556df4de38..b7c540b2abd 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -17,6 +17,11 @@ func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) } +// PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. +func PacketCommitmentPrefixKey(channelID string) []byte { + return []byte(fmt.Sprintf("commitments/channels/%s", channelID)) +} + // PacketCommitmentKey returns the store key of under which a packet commitment is stored. func PacketCommitmentKey(channelID string, sequence uint64) []byte { return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 6d731385164..00b60fd6891 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -4,7 +4,9 @@ package ibc.core.channel.v2; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; +import "cosmos/base/query/v1beta1/pagination.proto"; import "ibc/core/channel/v2/channel.proto"; +import "ibc/core/channel/v2/genesis.proto"; import "ibc/core/client/v1/client.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; @@ -21,6 +23,11 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}"; } + // PacketCommitments queries a stored packet commitment hash. + rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments"; + } + // PacketAcknowledgement queries a stored acknowledgement commitment hash. rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acks/{sequence}"; @@ -61,6 +68,24 @@ message QueryPacketCommitmentResponse { ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } +// QueryPacketCommitmentsRequest is the request type for the Query/PacketCommitments RPC method. +message QueryPacketCommitmentsRequest { + // channel unique identifier + string channel_id = 1; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryPacketCommitmentResponse is the response type for the Query/PacketCommitment RPC method. +message QueryPacketCommitmentsResponse { + // collection of packet commitments for the requested channel identifier. + repeated ibc.core.channel.v2.PacketState commitments = 1; + // pagination response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height. + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + // QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. message QueryPacketAcknowledgementRequest { // channel unique identifier From b176e454d42b376c8f1131f0c46168ec2de9149a Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 11 Nov 2024 15:59:15 +0200 Subject: [PATCH 116/172] chore: revert re-ordering for v1 channel msg. --- modules/core/04-channel/types/tx.pb.go | 298 ++++++++++++------------- proto/ibc/core/channel/v1/tx.proto | 6 +- 2 files changed, 152 insertions(+), 152 deletions(-) diff --git a/modules/core/04-channel/types/tx.pb.go b/modules/core/04-channel/types/tx.pb.go index a6d96fb510f..71157b18e4b 100644 --- a/modules/core/04-channel/types/tx.pb.go +++ b/modules/core/04-channel/types/tx.pb.go @@ -1675,131 +1675,131 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1972 bytes of a gzipped FileDescriptorProto + // 1975 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcf, 0x6f, 0xdb, 0xc8, - 0x15, 0x36, 0xf5, 0x33, 0x7e, 0x4e, 0xd6, 0x0a, 0xe5, 0xc4, 0x32, 0x6d, 0x4b, 0x8a, 0x5a, 0x34, - 0x5e, 0x37, 0x91, 0xd6, 0xde, 0xa4, 0x40, 0x82, 0x05, 0x5a, 0x47, 0x55, 0xba, 0x06, 0xe2, 0xd8, - 0xa0, 0xac, 0xa2, 0xdd, 0x2d, 0x2a, 0xc8, 0xd4, 0x84, 0x22, 0x24, 0x91, 0x5c, 0x92, 0xd2, 0xae, - 0x0b, 0xb4, 0x58, 0xf4, 0x14, 0xe4, 0xb0, 0x68, 0x81, 0xbd, 0x06, 0x68, 0xd1, 0x7f, 0x60, 0xcf, - 0xfd, 0x71, 0xe8, 0x6d, 0x4f, 0xc5, 0x1e, 0x17, 0x05, 0xba, 0x28, 0x92, 0x43, 0x2e, 0xfd, 0x0b, - 0x0a, 0x14, 0x28, 0x38, 0x33, 0xa4, 0x28, 0x72, 0x28, 0x51, 0x96, 0x6a, 0xf4, 0x26, 0xce, 0x7c, - 0xf3, 0xde, 0xcc, 0xf7, 0xbd, 0x79, 0x9c, 0x37, 0x14, 0x6c, 0x29, 0x67, 0x52, 0x45, 0xd2, 0x0c, - 0x54, 0x91, 0x3a, 0x2d, 0x55, 0x45, 0xbd, 0xca, 0x70, 0xaf, 0x62, 0x7d, 0x52, 0xd6, 0x0d, 0xcd, - 0xd2, 0xf8, 0xac, 0x72, 0x26, 0x95, 0xed, 0xde, 0x32, 0xed, 0x2d, 0x0f, 0xf7, 0x84, 0x35, 0x59, - 0x93, 0x35, 0xdc, 0x5f, 0xb1, 0x7f, 0x11, 0xa8, 0xb0, 0x2e, 0x69, 0x66, 0x5f, 0x33, 0x2b, 0x7d, - 0x53, 0xb6, 0x4d, 0xf4, 0x4d, 0x99, 0x76, 0x14, 0x46, 0x1e, 0x7a, 0x0a, 0x52, 0x2d, 0xbb, 0x97, - 0xfc, 0xa2, 0x80, 0x5b, 0xac, 0x29, 0x38, 0xfe, 0x26, 0x40, 0x06, 0xba, 0x6c, 0xb4, 0xda, 0x88, - 0x40, 0x4a, 0x9f, 0x73, 0xc0, 0x1f, 0x99, 0x72, 0x95, 0xf4, 0x1f, 0xeb, 0x48, 0x3d, 0x54, 0x15, - 0x8b, 0x5f, 0x87, 0xb4, 0xae, 0x19, 0x56, 0x53, 0x69, 0xe7, 0xb8, 0x22, 0xb7, 0xb3, 0x2c, 0xa6, - 0xec, 0xc7, 0xc3, 0x36, 0xff, 0x1e, 0xa4, 0xa9, 0xad, 0x5c, 0xac, 0xc8, 0xed, 0xac, 0xec, 0x6f, - 0x95, 0x19, 0x8b, 0x2d, 0x53, 0x7b, 0x8f, 0x12, 0x5f, 0x7e, 0x53, 0x58, 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 0x82, 0xed, 0xb1, 0xe5, 0x43, 0xdf, 0x49, 0x4d, 0x13, 0x7d, 0x38, 0x40, 0xaa, 0x84, + 0x70, 0xfe, 0x27, 0xc4, 0x4d, 0x2f, 0xa8, 0x41, 0x30, 0x75, 0x0a, 0x09, 0x52, 0x58, 0x84, 0x3c, + 0x9b, 0x22, 0x97, 0xc5, 0xd7, 0x1c, 0x5c, 0x3b, 0x32, 0x65, 0x11, 0x49, 0xc3, 0x93, 0x96, 0xd4, + 0x45, 0x16, 0xff, 0x00, 0x52, 0x3a, 0xfe, 0x85, 0xb9, 0x5b, 0xd9, 0xdf, 0x64, 0x96, 0x69, 0x02, + 0xa6, 0x13, 0xa4, 0x03, 0xf8, 0xb7, 0x20, 0x43, 0x08, 0x92, 0xb4, 0x7e, 0x5f, 0xb1, 0xfa, 0x48, + 0xb5, 0x30, 0xc9, 0x57, 0xc5, 0x55, 0xdc, 0x5e, 0x75, 0x9b, 0x03, 0x5c, 0xc6, 0xe7, 0xe3, 0x32, + 0x31, 0x39, 0x95, 0x7e, 0x81, 0xd7, 0xef, 0x68, 0x92, 0x6e, 0xe5, 0xfd, 0x01, 0xa4, 0x0c, 0x64, + 0x0e, 0x7a, 0x64, 0xb2, 0x6f, 0xec, 0xdf, 0x66, 0x4e, 0xd6, 0x81, 0x8b, 0x18, 0x7a, 0x7a, 0xae, + 0x23, 0x91, 0x0e, 0xa3, 0x15, 0xf8, 0xd3, 0x18, 0xc0, 0x91, 0x29, 0x9f, 0x2a, 0x7d, 0xa4, 0x0d, + 0x16, 0x43, 0xe1, 0x40, 0x35, 0x90, 0x84, 0x94, 0x21, 0x6a, 0x8f, 0x51, 0xd8, 0x70, 0x9b, 0x17, + 0x43, 0xe1, 0x1d, 0xe0, 0x55, 0xf4, 0xb1, 0xe5, 0xa6, 0x59, 0xd3, 0x40, 0xd2, 0x10, 0xd3, 0x99, + 0x10, 0x33, 0x76, 0x8f, 0x93, 0x5c, 0x36, 0x79, 0xd1, 0x8b, 0xca, 0x07, 0x78, 0x0b, 0x45, 0xf9, + 0x58, 0x34, 0xdb, 0xff, 0x21, 0xef, 0x3b, 0x6a, 0xfd, 0x58, 0xc5, 0x89, 0x7d, 0x49, 0xa4, 0x17, + 0x60, 0x85, 0xa6, 0xb8, 0xed, 0x94, 0xd6, 0x08, 0x52, 0x35, 0x48, 0x18, 0x0b, 0x29, 0x12, 0x6c, + 0x55, 0x92, 0x53, 0x55, 0x49, 0xcd, 0x56, 0x52, 0xd2, 0x17, 0x28, 0x29, 0x67, 0xf8, 0x45, 0x39, + 0xce, 0xfd, 0xa2, 0x05, 0x7e, 0x1e, 0xc3, 0xe9, 0x73, 0x20, 0x75, 0x55, 0xed, 0xa3, 0x1e, 0x6a, + 0xcb, 0x08, 0xd7, 0x8c, 0x39, 0x14, 0xde, 0x81, 0xd5, 0xd6, 0xb8, 0x35, 0x47, 0x60, 0x5f, 0xf3, + 0x48, 0x60, 0x7b, 0x60, 0x7b, 0x4c, 0xe0, 0x03, 0xbb, 0xe5, 0x92, 0xdf, 0xce, 0x12, 0xde, 0xf5, + 0xfb, 0x98, 0x58, 0x34, 0xdf, 0x7f, 0x1a, 0xdb, 0xdf, 0xd0, 0x14, 0x98, 0xeb, 0x25, 0xff, 0x43, + 0x48, 0x3d, 0x53, 0x50, 0xaf, 0x6d, 0xd2, 0xaa, 0x54, 0x62, 0x06, 0x46, 0x3d, 0x3d, 0xc6, 0x48, + 0x47, 0x31, 0x32, 0x2e, 0x7a, 0x6d, 0xff, 0x94, 0xf3, 0x6e, 0x60, 0x3c, 0xc1, 0xbb, 0x2c, 0xbd, + 0x0b, 0x69, 0x9a, 0xfa, 0x34, 0x71, 0xb6, 0x26, 0x45, 0xe3, 0x9c, 0x3c, 0xe8, 0x10, 0xbb, 0x38, + 0x04, 0x16, 0x4e, 0x0c, 0x2f, 0x9c, 0xd5, 0x81, 0x6f, 0xb1, 0x10, 0x36, 0xff, 0x1b, 0x87, 0xb5, + 0x40, 0x40, 0x13, 0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x51, 0x44, 0x69, 0x6d, + 0x6c, 0x54, 0x69, 0xbd, 0x3b, 0xfd, 0xe0, 0xa4, 0x9d, 0xa5, 0x18, 0x71, 0xd2, 0xce, 0xc2, 0xbc, + 0x3f, 0x13, 0xdc, 0x75, 0xff, 0x4b, 0x58, 0x63, 0xee, 0x80, 0xef, 0x44, 0xe4, 0x10, 0xa3, 0x85, + 0x7b, 0xb3, 0xa0, 0x5d, 0xdf, 0x0a, 0x64, 0xc9, 0xde, 0x8c, 0xa2, 0xe8, 0x16, 0xf1, 0xbb, 0x61, + 0xc6, 0xbc, 0x1b, 0x39, 0xe1, 0x4e, 0x14, 0x94, 0x97, 0x65, 0xf6, 0x56, 0x2f, 0x94, 0x65, 0x26, + 0x3c, 0x9c, 0xe5, 0x89, 0x9b, 0x36, 0x21, 0xf9, 0xc9, 0x37, 0x9f, 0xef, 0x72, 0x8f, 0xea, 0x5f, + 0xbc, 0xca, 0x73, 0x5f, 0xbe, 0xca, 0x73, 0xff, 0x7a, 0x95, 0xe7, 0x7e, 0xfb, 0x3a, 0xbf, 0xf4, + 0xe5, 0xeb, 0xfc, 0xd2, 0x57, 0xaf, 0xf3, 0x4b, 0xef, 0x3f, 0x90, 0x15, 0xab, 0x33, 0x38, 0x2b, + 0x4b, 0x5a, 0xbf, 0x42, 0xff, 0x1f, 0xa5, 0x9c, 0x49, 0x77, 0x65, 0xad, 0x32, 0x7c, 0x50, 0xe9, + 0x6b, 0xed, 0x41, 0x0f, 0x99, 0xe4, 0x7f, 0x4d, 0x6f, 0xdf, 0xbb, 0xeb, 0xfc, 0xb5, 0xc9, 0x3a, + 0xd7, 0x91, 0x79, 0x96, 0xc2, 0x7f, 0x6b, 0x7a, 0xe7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5b, + 0x64, 0x1e, 0xc4, 0xa1, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1829,10 +1829,10 @@ type MsgClient interface { ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) // Timeout defines a rpc handler method for MsgTimeout. Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) // Acknowledgement defines a rpc handler method for MsgAcknowledgement. Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. @@ -1926,18 +1926,18 @@ func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...g return out, nil } -func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { - out := new(MsgTimeoutOnCloseResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) +func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { + out := new(MsgTimeoutResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { - out := new(MsgTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) +func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { + out := new(MsgTimeoutOnCloseResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) if err != nil { return nil, err } @@ -2051,10 +2051,10 @@ type MsgServer interface { ChannelCloseConfirm(context.Context, *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) // Timeout defines a rpc handler method for MsgTimeout. Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) // Acknowledgement defines a rpc handler method for MsgAcknowledgement. Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. @@ -2102,12 +2102,12 @@ func (*UnimplementedMsgServer) ChannelCloseConfirm(ctx context.Context, req *Msg func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") } -func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") -} func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") } +func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") +} func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") } @@ -2269,38 +2269,38 @@ func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } -func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeoutOnClose) +func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeout) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).TimeoutOnClose(ctx, in) + return srv.(MsgServer).Timeout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/TimeoutOnClose", + FullMethod: "/ibc.core.channel.v1.Msg/Timeout", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).TimeoutOnClose(ctx, req.(*MsgTimeoutOnClose)) + return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) } return interceptor(ctx, in, info, handler) } -func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeout) +func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeoutOnClose) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).Timeout(ctx, in) + return srv.(MsgServer).TimeoutOnClose(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/Timeout", + FullMethod: "/ibc.core.channel.v1.Msg/TimeoutOnClose", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) + return srv.(MsgServer).TimeoutOnClose(ctx, req.(*MsgTimeoutOnClose)) } return interceptor(ctx, in, info, handler) } @@ -2517,14 +2517,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RecvPacket", Handler: _Msg_RecvPacket_Handler, }, - { - MethodName: "TimeoutOnClose", - Handler: _Msg_TimeoutOnClose_Handler, - }, { MethodName: "Timeout", Handler: _Msg_Timeout_Handler, }, + { + MethodName: "TimeoutOnClose", + Handler: _Msg_TimeoutOnClose_Handler, + }, { MethodName: "Acknowledgement", Handler: _Msg_Acknowledgement_Handler, diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index 611b4068088..06e8523284a 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -36,12 +36,12 @@ service Msg { // RecvPacket defines a rpc handler method for MsgRecvPacket. rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); - // Timeout defines a rpc handler method for MsgTimeout. rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); From e769eeb2beebc6aa68d901c393fbd2b844ef17f0 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 11 Nov 2024 16:15:24 +0200 Subject: [PATCH 117/172] chore: revert exporting of deletePacketCommitment. --- modules/core/04-channel/keeper/keeper.go | 2 +- modules/core/04-channel/keeper/packet.go | 2 +- modules/core/04-channel/keeper/timeout.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 1dddc74e126..db81e134084 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -267,7 +267,7 @@ func (k *Keeper) SetPacketCommitment(ctx context.Context, portID, channelID stri } } -func (k *Keeper) DeletePacketCommitment(ctx context.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) deletePacketCommitment(ctx context.Context, portID, channelID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) if err := store.Delete(host.PacketCommitmentKey(portID, channelID, sequence)); err != nil { panic(err) diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 89630094748..4be14bbf330 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -441,7 +441,7 @@ func (k *Keeper) AcknowledgePacket( } // Delete packet commitment, since the packet has been acknowledged, the commitement is no longer necessary - k.DeletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // log that a packet has been acknowledged k.Logger(ctx).Info( diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 0e2b9817e05..b7d39b843c4 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -132,7 +132,7 @@ func (k *Keeper) timeoutExecuted( channel types.Channel, packet types.Packet, ) error { - k.DeletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING && channel.Ordering == types.UNORDERED { From 5b3ce55b37ed33a5ebb376b4ffa5471cddad5965 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Tue, 12 Nov 2024 08:19:57 +0100 Subject: [PATCH 118/172] Match commitment to specification (#7544) * fix hash * prepend hash with byte 0x02 * fix hash to spec * chore: update function documentation to align with implementation. --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/v2/keeper/keeper.go | 2 +- .../core/04-channel/v2/types/commitment.go | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index b5e81ee7cee..fe1ad9b8a23 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -133,7 +133,7 @@ func (k *Keeper) HasPacketReceipt(ctx context.Context, channelID string, sequenc // This is a public path that is standardized by the IBC V2 specification. func (k *Keeper) SetPacketReceipt(ctx context.Context, channelID string, sequence uint64) { store := k.storeService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketReceiptKey(channelID, sequence), []byte{byte(1)}); err != nil { + if err := store.Set(hostv2.PacketReceiptKey(channelID, sequence), []byte{byte(2)}); err != nil { panic(err) } } diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 6d815f3da46..721049ca83b 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -7,22 +7,28 @@ import ( ) // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// sha256_hash(timeout) + sha256_hash(destinationChannel) + sha256_hash(payload) from a given packet. +// 0x02 + sha256_hash(destinationChannel) + sha256_hash(timeout) + sha256_hash(payload) from a given packet. // This results in a fixed length preimage. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. func CommitPacket(packet Packet) []byte { - buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) - + var buf []byte destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) buf = append(buf, destIDHash[:]...) + timeoutBytes := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) + timeoutHash := sha256.Sum256(timeoutBytes) + buf = append(buf, timeoutHash[:]...) + + var appBytes []byte for _, payload := range packet.Payloads { - buf = append(buf, hashPayload(payload)...) + appBytes = append(appBytes, hashPayload(payload)...) } + appHash := sha256.Sum256(appBytes) + buf = append(buf, appHash[:]...) hash := sha256.Sum256(buf) - return hash[:] + return append([]byte{byte(2)}, hash[:]...) } // hashPayload returns the hash of the payload. @@ -32,12 +38,12 @@ func hashPayload(data Payload) []byte { buf = append(buf, sourceHash[:]...) destHash := sha256.Sum256([]byte(data.DestinationPort)) buf = append(buf, destHash[:]...) - payloadValueHash := sha256.Sum256(data.Value) - buf = append(buf, payloadValueHash[:]...) - payloadEncodingHash := sha256.Sum256([]byte(data.Encoding)) - buf = append(buf, payloadEncodingHash[:]...) payloadVersionHash := sha256.Sum256([]byte(data.Version)) buf = append(buf, payloadVersionHash[:]...) + payloadEncodingHash := sha256.Sum256([]byte(data.Encoding)) + buf = append(buf, payloadEncodingHash[:]...) + payloadValueHash := sha256.Sum256(data.Value) + buf = append(buf, payloadValueHash[:]...) hash := sha256.Sum256(buf) return hash[:] } @@ -51,5 +57,5 @@ func CommitAcknowledgement(acknowledgement Acknowledgement) []byte { } hash := sha256.Sum256(buf) - return hash[:] + return append([]byte{byte(2)}, hash[:]...) } From cb299784471e7c484dc124ab2b900ef7f98609df Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 14:54:00 +0200 Subject: [PATCH 119/172] chore: drop usage of 'channeltypesv2'. --- modules/core/04-channel/v2/keeper/events.go | 18 ++-- .../core/04-channel/v2/keeper/export_test.go | 12 +-- .../04-channel/v2/keeper/msg_server_test.go | 92 +++++++++---------- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 720fb93e11b..b20273d74bf 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -5,31 +5,31 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) // EmitSendPacketEvents emits events for the SendPacket handler. -func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitSendPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitRecvPacketEvents emits events for the RecvPacket handler. -func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitRecvPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitAcknowledgePacketEvents emits events for the AcknowledgePacket handler. -func EmitAcknowledgePacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. -func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. -func EmitWriteAcknowledgementEvents(ctx context.Context, packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) { +func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } @@ -39,12 +39,12 @@ func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - channeltypesv2.EventTypeCreateChannel, - sdk.NewAttribute(channeltypesv2.AttributeKeyChannelID, channelID), + types.EventTypeCreateChannel, + sdk.NewAttribute(types.AttributeKeyChannelID, channelID), ), sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypesv2.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), ), }) } diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index d772eac3bef..aae6048ed2a 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -7,7 +7,7 @@ package keeper import ( "context" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -15,7 +15,7 @@ func (k *Keeper) SendPacketTest( ctx context.Context, sourceChannel string, timeoutTimestamp uint64, - payloads []channeltypesv2.Payload, + payloads []types.Payload, ) (uint64, string, error) { return k.sendPacket( ctx, @@ -27,7 +27,7 @@ func (k *Keeper) SendPacketTest( func (k *Keeper) RecvPacketTest( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { @@ -41,8 +41,8 @@ func (k *Keeper) RecvPacketTest( func (k *Keeper) AcknowledgePacketTest( ctx context.Context, - packet channeltypesv2.Packet, - acknowledgement channeltypesv2.Acknowledgement, + packet types.Packet, + acknowledgement types.Acknowledgement, proof []byte, proofHeight exported.Height, ) error { @@ -57,7 +57,7 @@ func (k *Keeper) AcknowledgePacketTest( func (k *Keeper) TimeoutPacketTest( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 2fa079e1e1f..3ea899c28af 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -20,7 +20,7 @@ import ( func (suite *KeeperTestSuite) TestRegisterCounterparty() { var ( path *ibctesting.Path - msg *channeltypesv2.MsgRegisterCounterparty + msg *types.MsgRegisterCounterparty ) cases := []struct { name string @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, channeltypesv2.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, types.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, @@ -53,9 +53,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { "failure: channel must already exist", func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(types.ChannelKey)) }, - channeltypesv2.ErrChannelNotFound, + types.ErrChannelNotFound, }, } @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { suite.Require().NoError(path.EndpointB.CreateChannel()) signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = channeltypesv2.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) + msg = types.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) tc.malleate() @@ -102,9 +102,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { func (suite *KeeperTestSuite) TestMsgSendPacket() { var ( path *ibctesting.Path - expectedPacket channeltypesv2.Packet + expectedPacket types.Packet timeoutTimestamp uint64 - payload channeltypesv2.Payload + payload types.Payload ) testCases := []struct { @@ -121,8 +121,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { name: "success: valid timeout timestamp", malleate: func() { // ensure a message timeout. - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta - 10*time.Second).Unix()) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(types.MaxTimeoutDelta - 10*time.Second).Unix()) + expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) }, expError: nil, }, @@ -132,15 +132,15 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure a message timeout. timeoutTimestamp = uint64(1) }, - expError: channeltypesv2.ErrTimeoutElapsed, + expError: types.ErrTimeoutElapsed, }, { name: "failure: timeout timestamp exceeds max allowed input", malleate: func() { // ensure message timeout exceeds max allowed input. - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta + 10*time.Second).Unix()) + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(types.MaxTimeoutDelta + 10*time.Second).Unix()) }, - expError: channeltypesv2.ErrInvalidTimeout, + expError: types.ErrInvalidTimeout, }, { name: "failure: timeout timestamp less than current block timestamp", @@ -148,7 +148,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure message timeout exceeds max allowed input. timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) - 1 }, - expError: channeltypesv2.ErrTimeoutElapsed, + expError: types.ErrTimeoutElapsed, }, { name: "failure: inactive client", @@ -160,7 +160,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: application callback error", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data types.Payload, signer sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -171,7 +171,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { malleate: func() { path.EndpointA.ChannelID = ibctesting.InvalidID }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: route to non existing app", @@ -194,7 +194,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { timeoutTimestamp = suite.chainA.GetTimeoutTimestampSecs() payload = mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) tc.malleate() @@ -209,7 +209,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { packetCommitment := ck.GetPacketCommitment(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID, 1) suite.Require().NotNil(packetCommitment) - suite.Require().Equal(channeltypesv2.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") + suite.Require().Equal(types.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") nextSequenceSend, ok := ck.GetNextSequenceSend(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID) suite.Require().True(ok) @@ -228,8 +228,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { func (suite *KeeperTestSuite) TestMsgRecvPacket() { var ( path *ibctesting.Path - packet channeltypesv2.Packet - expectedAck channeltypesv2.Acknowledgement + packet types.Packet + expectedAck types.Acknowledgement ) testCases := []struct { @@ -245,15 +245,15 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: failed recv result", malleate: func() { - failedRecvResult := channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Failure, + failedRecvResult := types.RecvPacketResult{ + Status: types.PacketStatus_Failure, Acknowledgement: mock.MockFailPacketData, } // a failed ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { return failedRecvResult } }, @@ -261,15 +261,15 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: async recv result", malleate: func() { - asyncResult := channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Async, + asyncResult := types.RecvPacketResult{ + Status: types.PacketStatus_Async, Acknowledgement: nil, } // an async ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { return asyncResult } }, @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "success: NoOp", malleate: func() { suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) - expectedAck = channeltypesv2.Acknowledgement{} + expectedAck = types.Acknowledgement{} }, }, { @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { // change the destination id to a non-existent channel. packet.DestinationChannel = ibctesting.InvalidID }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid proof", @@ -315,8 +315,8 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().NoError(err) // default expected ack is a single successful recv result for moduleB. - expectedAck = channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + expectedAck = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{ { AppName: mockv2.ModuleNameB, RecvPacketResult: mockv2.MockRecvPacketResult, @@ -340,13 +340,13 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) - if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == channeltypesv2.PacketStatus_Async { + if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == types.PacketStatus_Async { // ack should not be written for async app or if the packet receipt was already present. suite.Require().False(ackWritten) } else { // successful or failed acknowledgement // ack should be written for synchronous app (default mock application behaviour). suite.Require().True(ackWritten) - expectedBz := channeltypesv2.CommitAcknowledgement(expectedAck) + expectedBz := types.CommitAcknowledgement(expectedAck) actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) suite.Require().Equal(expectedBz, actualAckBz) @@ -364,8 +364,8 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { func (suite *KeeperTestSuite) TestMsgAcknowledgement() { var ( path *ibctesting.Path - packet channeltypesv2.Packet - ack channeltypesv2.Acknowledgement + packet types.Packet + ack types.Acknowledgement ) testCases := []struct { name string @@ -383,7 +383,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -391,7 +391,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -403,14 +403,14 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // change the source id to a non-existent channel. packet.SourceChannel = "not-existent-channel" }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid commitment", malleate: func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) }, - expError: channeltypesv2.ErrInvalidPacket, + expError: types.ErrInvalidPacket, }, { name: "failure: failed membership verification", @@ -438,8 +438,8 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { suite.Require().NoError(err) // Construct expected acknowledgement - ack = channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + ack = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{ { AppName: mockv2.ModuleNameB, RecvPacketResult: mockv2.MockRecvPacketResult, @@ -465,7 +465,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { func (suite *KeeperTestSuite) TestMsgTimeout() { var ( path *ibctesting.Path - packet channeltypesv2.Packet + packet types.Packet ) testCases := []struct { @@ -484,16 +484,16 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // Modify the callback to return a different error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, - expError: channeltypesv2.ErrNoOpMsg, + expError: types.ErrNoOpMsg, }, { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -505,14 +505,14 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // change the source id to a non-existent channel. packet.SourceChannel = "not-existent-channel" }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid commitment", malleate: func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) }, - expError: channeltypesv2.ErrInvalidPacket, + expError: types.ErrInvalidPacket, }, { name: "failure: unable to timeout if packet has been received", From 5031af8893f1a74772173ecbdefc1ab48a043546 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 15:10:31 +0200 Subject: [PATCH 120/172] chore: fix post-merge test failure. --- modules/core/04-channel/types/packet_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index f889deb9ce4..f26192b8712 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) @@ -36,7 +37,7 @@ func TestCommitPacket(t *testing.T) { } for _, tc := range testCases { - testCommitment := types.CommitPacket(cdc, tc.packet) + testCommitment := types.CommitPacket(tc.packet) require.NotNil(t, testCommitment) require.NotEqual(t, commitment, testCommitment) From 00505238557a6d9eab1013e07e43a75f401680f8 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:38:31 +0100 Subject: [PATCH 121/172] ICS24: Change Provable keys (#7517) * refactor packet keys * provable keys * chore: fix packet commitments prefix function. --------- Co-authored-by: DimitrisJim --- modules/core/24-host/v2/packet_keys.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index b7c540b2abd..a95814198f8 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -6,25 +6,24 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// PacketReceiptKey returns the store key of under which a packet -// receipt is stored -func PacketReceiptKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) -} - -// PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. -func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) +// PacketCommitmentKey returns the store key of under which a packet commitment is stored. +func PacketCommitmentKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(1)), sdk.Uint64ToBigEndian(sequence)...) } // PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. func PacketCommitmentPrefixKey(channelID string) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s", channelID)) + return append([]byte(channelID), byte(1)) } -// PacketCommitmentKey returns the store key of under which a packet commitment is stored. -func PacketCommitmentKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) +// PacketReceiptKey returns the store key of under which a packet receipt is stored. +func PacketReceiptKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(2)), sdk.Uint64ToBigEndian(sequence)...) +} + +// PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. +func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(3)), sdk.Uint64ToBigEndian(sequence)...) } // NextSequenceSendKey returns the store key for the next sequence send of a given channelID. From d416dc36de108ae19eb76b2b81733ddc3f68c5c7 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 16:02:55 +0200 Subject: [PATCH 122/172] chore: amend event emitted for create channel. (#7557) --- modules/core/04-channel/v2/keeper/events.go | 5 +++-- modules/core/04-channel/v2/keeper/msg_server.go | 2 +- modules/core/04-channel/v2/types/events.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index b20273d74bf..1c2140d2835 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -33,14 +33,15 @@ func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac // TODO: https://github.com/cosmos/ibc-go/issues/7386 } -// EmitCreateChannelEvent emits a channel create event. -func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { +// emitCreateChannelEvent emits a channel create event. +func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreateChannel, sdk.NewAttribute(types.AttributeKeyChannelID, channelID), + sdk.NewAttribute(types.AttributeKeyClientID, clientID), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 6bda4404531..39d376aac30 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -29,7 +29,7 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChanne k.SetCreator(ctx, channelID, msg.Signer) k.SetNextSequenceSend(ctx, channelID, 1) - k.EmitCreateChannelEvent(goCtx, channelID) + k.emitCreateChannelEvent(goCtx, channelID, msg.ClientId) return &types.MsgCreateChannelResponse{ChannelId: channelID}, nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 6166f0422d1..78bf04df189 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -9,6 +9,7 @@ import ( // IBC channel events const ( AttributeKeyChannelID = "channel_id" + AttributeKeyClientID = "client_id" ) // IBC channel events vars From 6b237fcc1bc013a127f9ca301e392e3e5cccbc3a Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 16:44:59 +0200 Subject: [PATCH 123/172] chore: add event for register counterparty (#7556) --- modules/core/04-channel/v2/keeper/events.go | 18 ++++++++++++++++++ .../core/04-channel/v2/keeper/msg_server.go | 2 ++ modules/core/04-channel/v2/types/events.go | 8 +++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 1c2140d2835..7940cc15ff7 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -49,3 +49,21 @@ func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID s ), }) } + +// emitRegisterCounterpartyEvent emits a register counterparty event. +func (*Keeper) emitRegisterCounterpartyEvent(ctx context.Context, channelID string, channel types.Channel) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRegisterCounterparty, + sdk.NewAttribute(types.AttributeKeyChannelID, channelID), + sdk.NewAttribute(types.AttributeKeyClientID, channel.ClientId), + sdk.NewAttribute(types.AttributeKeyCounterpartyChannelID, channel.CounterpartyChannelId), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 39d376aac30..a4b6c19d9ff 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -57,6 +57,8 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegis // Delete client creator from state as it is not needed after this point. k.DeleteCreator(ctx, msg.ChannelId) + k.emitRegisterCounterpartyEvent(goCtx, msg.ChannelId, channel) + return &types.MsgRegisterCounterpartyResponse{}, nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 78bf04df189..35496926d0e 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -8,13 +8,15 @@ import ( // IBC channel events const ( - AttributeKeyChannelID = "channel_id" - AttributeKeyClientID = "client_id" + AttributeKeyChannelID = "channel_id" + AttributeKeyClientID = "client_id" + AttributeKeyCounterpartyChannelID = "counterparty_channel_id" ) // IBC channel events vars var ( - EventTypeCreateChannel = "create_channel" + EventTypeCreateChannel = "create_channel" + EventTypeRegisterCounterparty = "register_counterparty" AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) ) From 3abeb0b548134df0d65b8849527d9dae1e04fc6f Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 18:09:56 +0200 Subject: [PATCH 124/172] chore: add next sequence send query. (#7550) --- modules/core/04-channel/v2/client/cli/abci.go | 19 + modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 46 ++ .../core/04-channel/v2/keeper/grpc_query.go | 20 + .../04-channel/v2/keeper/grpc_query_test.go | 72 +++ modules/core/04-channel/v2/types/query.go | 18 + modules/core/04-channel/v2/types/query.pb.go | 599 ++++++++++++++++-- .../core/04-channel/v2/types/query.pb.gw.go | 101 +++ proto/ibc/core/channel/v2/query.proto | 21 + 9 files changed, 837 insertions(+), 60 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/abci.go b/modules/core/04-channel/v2/client/cli/abci.go index 942ca2a6ebf..5069eddf03e 100644 --- a/modules/core/04-channel/v2/client/cli/abci.go +++ b/modules/core/04-channel/v2/client/cli/abci.go @@ -1,6 +1,8 @@ package cli import ( + "encoding/binary" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client" @@ -10,6 +12,23 @@ import ( ibcclient "github.com/cosmos/ibc-go/v9/modules/core/client" ) +func queryNextSequenceSendABCI(clientCtx client.Context, channelID string) (*types.QueryNextSequenceSendResponse, error) { + key := host.NextSequenceSendKey(channelID) + value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) + if err != nil { + return nil, err + } + + // check if next sequence send exists + if len(value) == 0 { + return nil, errorsmod.Wrapf(types.ErrSequenceSendNotFound, "channelID (%s)", channelID) + } + + sequence := binary.BigEndian.Uint64(value) + + return types.NewQueryNextSequenceSendResponse(sequence, proofBz, proofHeight), nil +} + func queryPacketCommitmentABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketCommitmentResponse, error) { key := host.PacketCommitmentKey(channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index 59d9dded017..b759dd0e65f 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCmdQueryChannel(), + getCmdQueryNextSequenceSend(), getCmdQueryPacketCommitment(), getCmdQueryPacketCommitments(), getCmdQueryPacketAcknowledgement(), diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index c79d92dfd4c..f07e853e78d 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -45,6 +45,52 @@ func getCmdQueryChannel() *cobra.Command { return cmd } +// getCmdQueryNextSequenceSend defines the command to query a next send sequence for a given channel +func getCmdQueryNextSequenceSend() *cobra.Command { + cmd := &cobra.Command{ + Use: "next-sequence-send [channel-id]", + Short: "Query a next send sequence", + Long: "Query the next sequence send for a given channel", + Example: fmt.Sprintf( + "%s query %s %s next-sequence-send [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + channelID := args[0] + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + if prove { + res, err := queryNextSequenceSendABCI(clientCtx, channelID) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.NextSequenceSend(cmd.Context(), types.NewQueryNextSequenceSendRequest(channelID)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + func getCmdQueryPacketCommitment() *cobra.Command { cmd := &cobra.Command{ Use: "packet-commitment [channel-id] [sequence]", diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index e72a5b3bbd9..f11c1f5155b 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -52,6 +52,26 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques return types.NewQueryChannelResponse(channel), nil } +// NextSequenceSend implements the Query/NextSequenceSend gRPC method +func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + sequence, found := q.GetNextSequenceSend(ctx, req.ChannelId) + if !found { + return nil, status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrSequenceSendNotFound, "channel-id %s", req.ChannelId).Error(), + ) + } + return types.NewQueryNextSequenceSendResponse(sequence, nil, clienttypes.GetSelfHeight(ctx)), nil +} + // PacketCommitment implements the Query/PacketCommitment gRPC method. func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index faecb9a2595..40a2ba07b4c 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -514,3 +514,75 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { }) } } + +func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { + var ( + req *types.QueryNextSequenceSendRequest + expSeq uint64 + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + expSeq = 42 + seq := uint64(42) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq) + req = types.NewQueryNextSequenceSendRequest(path.EndpointA.ChannelID) + }, + nil, + }, + { + "req is nil", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = types.NewQueryNextSequenceSendRequest("") + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "sequence send not found", + func() { + req = types.NewQueryNextSequenceSendRequest(ibctesting.FirstChannelID) + }, + status.Error(codes.NotFound, fmt.Sprintf("channel-id %s: sequence send not found", ibctesting.FirstChannelID)), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.NextSequenceSend(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expSeq, res.NextSequenceSend) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index 985be5c6dd4..2a70a6481b2 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -16,6 +16,24 @@ func NewQueryChannelResponse(channel Channel) *QueryChannelResponse { } } +// NewQueryNextSequenceSendRequest creates a new next sequence send query. +func NewQueryNextSequenceSendRequest(channelID string) *QueryNextSequenceSendRequest { + return &QueryNextSequenceSendRequest{ + ChannelId: channelID, + } +} + +// NewQueryNextSequenceSendResponse creates a new QueryNextSequenceSendResponse instance +func NewQueryNextSequenceSendResponse( + sequence uint64, proof []byte, height clienttypes.Height, +) *QueryNextSequenceSendResponse { + return &QueryNextSequenceSendResponse{ + NextSequenceSend: sequence, + Proof: proof, + ProofHeight: height, + } +} + // NewQueryPacketCommitmentRequest creates and returns a new packet commitment query request. func NewQueryPacketCommitmentRequest(channelID string, sequence uint64) *QueryPacketCommitmentRequest { return &QueryPacketCommitmentRequest{ diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 897cd508b6d..e6213b0c5b1 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -122,6 +122,116 @@ func (m *QueryChannelResponse) GetChannel() Channel { return Channel{} } +// QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method +type QueryNextSequenceSendRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *QueryNextSequenceSendRequest) Reset() { *m = QueryNextSequenceSendRequest{} } +func (m *QueryNextSequenceSendRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNextSequenceSendRequest) ProtoMessage() {} +func (*QueryNextSequenceSendRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{2} +} +func (m *QueryNextSequenceSendRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextSequenceSendRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextSequenceSendRequest.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 *QueryNextSequenceSendRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextSequenceSendRequest.Merge(m, src) +} +func (m *QueryNextSequenceSendRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNextSequenceSendRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextSequenceSendRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextSequenceSendRequest proto.InternalMessageInfo + +func (m *QueryNextSequenceSendRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +// QueryNextSequenceSendResponse is the response type for the Query/QueryNextSequenceSend RPC method +type QueryNextSequenceSendResponse struct { + // next sequence send number + NextSequenceSend uint64 `protobuf:"varint,1,opt,name=next_sequence_send,json=nextSequenceSend,proto3" json:"next_sequence_send,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryNextSequenceSendResponse) Reset() { *m = QueryNextSequenceSendResponse{} } +func (m *QueryNextSequenceSendResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNextSequenceSendResponse) ProtoMessage() {} +func (*QueryNextSequenceSendResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{3} +} +func (m *QueryNextSequenceSendResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextSequenceSendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextSequenceSendResponse.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 *QueryNextSequenceSendResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextSequenceSendResponse.Merge(m, src) +} +func (m *QueryNextSequenceSendResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNextSequenceSendResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextSequenceSendResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextSequenceSendResponse proto.InternalMessageInfo + +func (m *QueryNextSequenceSendResponse) GetNextSequenceSend() uint64 { + if m != nil { + return m.NextSequenceSend + } + return 0 +} + +func (m *QueryNextSequenceSendResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryNextSequenceSendResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + // QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. type QueryPacketCommitmentRequest struct { // channel unique identifier @@ -134,7 +244,7 @@ func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitm func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentRequest) ProtoMessage() {} func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{2} + return fileDescriptor_a328cba4986edcab, []int{4} } func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -191,7 +301,7 @@ func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentResponse) ProtoMessage() {} func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{3} + return fileDescriptor_a328cba4986edcab, []int{5} } func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -253,7 +363,7 @@ func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsRequest) ProtoMessage() {} func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -310,7 +420,7 @@ func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommi func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsResponse) ProtoMessage() {} func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -372,7 +482,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -429,7 +539,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,7 +603,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{8} + return fileDescriptor_a328cba4986edcab, []int{10} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -557,7 +667,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{9} + return fileDescriptor_a328cba4986edcab, []int{11} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -610,6 +720,8 @@ func (m *QueryPacketReceiptResponse) GetProofHeight() types.Height { func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") + proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v2.QueryNextSequenceSendRequest") + proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v2.QueryNextSequenceSendResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentResponse") proto.RegisterType((*QueryPacketCommitmentsRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentsRequest") @@ -623,58 +735,63 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 810 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4d, 0x4f, 0x13, 0x5d, - 0x14, 0xc7, 0x7b, 0x29, 0x50, 0x38, 0xe5, 0xc9, 0xf3, 0x3c, 0x17, 0x8c, 0x75, 0x02, 0x43, 0x99, - 0x85, 0x56, 0x22, 0x73, 0xed, 0x40, 0x7c, 0x49, 0x30, 0x06, 0x1a, 0x04, 0x4c, 0x4c, 0x70, 0x34, - 0x26, 0xba, 0x90, 0x4c, 0xa7, 0xd7, 0xe9, 0x84, 0x76, 0xee, 0xd0, 0x99, 0xd6, 0x10, 0xc2, 0xc6, - 0x85, 0x6b, 0x23, 0x3b, 0xbf, 0x81, 0x9f, 0xc2, 0x85, 0x1b, 0x12, 0x37, 0x24, 0x6c, 0x5c, 0x19, - 0x03, 0x26, 0x7e, 0x0d, 0xd3, 0x3b, 0xb7, 0xed, 0xb4, 0x4e, 0x4b, 0xeb, 0xcb, 0xee, 0xde, 0xd3, - 0x73, 0xce, 0xfd, 0x9d, 0xff, 0x3d, 0xf7, 0x74, 0x60, 0xd6, 0xce, 0x9b, 0xc4, 0x64, 0x15, 0x4a, - 0xcc, 0xa2, 0xe1, 0x38, 0xb4, 0x44, 0x6a, 0x1a, 0xd9, 0xad, 0xd2, 0xca, 0x9e, 0xea, 0x56, 0x98, - 0xcf, 0xf0, 0xa4, 0x9d, 0x37, 0xd5, 0xba, 0x83, 0x2a, 0x1c, 0xd4, 0x9a, 0x26, 0xcd, 0x9b, 0xcc, - 0x2b, 0x33, 0x8f, 0xe4, 0x0d, 0x8f, 0x06, 0xde, 0xa4, 0x96, 0xcd, 0x53, 0xdf, 0xc8, 0x12, 0xd7, - 0xb0, 0x6c, 0xc7, 0xf0, 0x6d, 0xe6, 0x04, 0x09, 0xa4, 0xb9, 0xa8, 0x13, 0x1a, 0xb9, 0x7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 0x4e, 0x5f, 0x09, 0x52, 0x85, 0x2b, 0x58, 0x7d, 0x72, 0x74, 0x2a, 0xa3, 0xe3, - 0x53, 0x19, 0x7d, 0x3d, 0x95, 0xd1, 0x9b, 0x33, 0x39, 0x76, 0x7c, 0x26, 0xc7, 0x3e, 0x9f, 0xc9, - 0xb1, 0x67, 0xcb, 0x96, 0xed, 0x17, 0xab, 0x79, 0xd5, 0x64, 0x65, 0x22, 0x3e, 0xe0, 0xec, 0xbc, - 0xb9, 0x60, 0x31, 0x52, 0xbb, 0x4d, 0xca, 0xac, 0x50, 0x2d, 0x51, 0x2f, 0x38, 0xff, 0xfa, 0xd2, - 0x42, 0x08, 0xc1, 0xdf, 0x73, 0xa9, 0x97, 0x1f, 0xe5, 0xdf, 0x4c, 0x8b, 0x3f, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x78, 0xf5, 0x4d, 0xe9, 0x32, 0x0a, 0x00, 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x3d, 0xb1, 0x9b, 0x1f, 0xcf, 0x41, 0x84, 0x69, 0x10, 0x66, 0x95, 0x6e, 0xdd, 0x3d, + 0x80, 0xa9, 0xda, 0x1d, 0xbc, 0xad, 0xf8, 0x21, 0xb5, 0x42, 0x8d, 0x55, 0xda, 0x20, 0x81, 0xc2, + 0x06, 0x21, 0xc1, 0x01, 0x6b, 0xbd, 0x1e, 0xd6, 0xab, 0xd8, 0x33, 0x5b, 0xef, 0xd8, 0xb4, 0xaa, + 0x7a, 0xe1, 0xc0, 0x85, 0x0b, 0xa2, 0x37, 0xfe, 0x02, 0xf8, 0x2b, 0x40, 0xe2, 0x12, 0x89, 0x4b, + 0xa4, 0x5c, 0x38, 0x21, 0x94, 0x20, 0xf1, 0x6f, 0x20, 0xcf, 0x8c, 0xed, 0xb5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c, 0xcc, 0xfd, 0x7e, 0x66, 0xe6, 0x3e, 0xbf, 0x13, 0x84, 0xa2, 0xd5, 0x6b, + 0xd8, 0x3e, 0xef, 0x10, 0xfd, 0x6f, 0x3b, 0x6c, 0xf8, 0x37, 0x03, 0x4e, 0xfa, 0xef, 0x92, 0x0e, + 0x6f, 0xf6, 0xda, 0x34, 0x56, 0xfb, 0xbf, 0x79, 0xfb, 0x66, 0x02, 0x41, 0x3c, 0x89, 0x68, 0xdc, + 0x58, 0x95, 0x7f, 0x70, 0x6f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x7f, 0x40, 0x76, 0xdf, + 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -691,6 +808,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Channel queries the counterparty of an IBC client. Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) + // NextSequenceSend returns the next send sequence for a given channel. + NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) // PacketCommitments queries a stored packet commitment hash. @@ -718,6 +837,15 @@ func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts return out, nil } +func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { + out := new(QueryNextSequenceSendResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) { out := new(QueryPacketCommitmentResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketCommitment", in, out, opts...) @@ -758,6 +886,8 @@ func (c *queryClient) PacketReceipt(ctx context.Context, in *QueryPacketReceiptR type QueryServer interface { // Channel queries the counterparty of an IBC client. Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) + // NextSequenceSend returns the next send sequence for a given channel. + NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) // PacketCommitments queries a stored packet commitment hash. @@ -775,6 +905,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") } +func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") +} func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketCommitment not implemented") } @@ -810,6 +943,24 @@ func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNextSequenceSendRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NextSequenceSend(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/NextSequenceSend", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NextSequenceSend(ctx, req.(*QueryNextSequenceSendRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_PacketCommitment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryPacketCommitmentRequest) if err := dec(in); err != nil { @@ -890,6 +1041,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Channel", Handler: _Query_Channel_Handler, }, + { + MethodName: "NextSequenceSend", + Handler: _Query_NextSequenceSend_Handler, + }, { MethodName: "PacketCommitment", Handler: _Query_PacketCommitment_Handler, @@ -974,6 +1129,81 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryNextSequenceSendRequest) 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 *QueryNextSequenceSendRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextSequenceSendRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNextSequenceSendResponse) 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 *QueryNextSequenceSendResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextSequenceSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.NextSequenceSend != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NextSequenceSend)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *QueryPacketCommitmentRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1366,6 +1596,37 @@ func (m *QueryChannelResponse) Size() (n int) { return n } +func (m *QueryNextSequenceSendRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNextSequenceSendResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextSequenceSend != 0 { + n += 1 + sovQuery(uint64(m.NextSequenceSend)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryPacketCommitmentRequest) Size() (n int) { if m == nil { return 0 @@ -1683,6 +1944,224 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryNextSequenceSendRequest) 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 ErrIntOverflowQuery + } + 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: QueryNextSequenceSendRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextSequenceSendRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNextSequenceSendResponse) 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 ErrIntOverflowQuery + } + 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: QueryNextSequenceSendResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextSequenceSendResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceSend", wireType) + } + m.NextSequenceSend = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextSequenceSend |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryPacketCommitmentRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 07dbf642b72..7cbe955c0fb 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -87,6 +87,60 @@ func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marsha } +func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNextSequenceSendRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + msg, err := client.NextSequenceSend(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNextSequenceSendRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + msg, err := server.NextSequenceSend(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_PacketCommitment_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryPacketCommitmentRequest var metadata runtime.ServerMetadata @@ -434,6 +488,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NextSequenceSend_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NextSequenceSend_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketCommitment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -587,6 +664,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_NextSequenceSend_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NextSequenceSend_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketCommitment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -673,6 +770,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(false))) @@ -685,6 +784,8 @@ var ( var ( forward_Query_Channel_0 = runtime.ForwardResponseMessage + forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage + forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitments_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 00b60fd6891..f9df59fcfaf 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -18,6 +18,11 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}"; } + // NextSequenceSend returns the next send sequence for a given channel. + rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; + } + // PacketCommitment queries a stored packet commitment hash. rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}"; @@ -50,6 +55,22 @@ message QueryChannelResponse { Channel channel = 1 [(gogoproto.nullable) = false]; } +// QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method +message QueryNextSequenceSendRequest { + // channel unique identifier + string channel_id = 1; +} + +// QueryNextSequenceSendResponse is the response type for the Query/QueryNextSequenceSend RPC method +message QueryNextSequenceSendResponse { + // next sequence send number + uint64 next_sequence_send = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + // QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. message QueryPacketCommitmentRequest { // channel unique identifier From 43584bfc05d337cd761919f90659303b15789be8 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 18:28:43 +0200 Subject: [PATCH 125/172] chore: make AliasV1Channel a private function. --- modules/core/04-channel/v2/keeper/export_test.go | 5 +++++ modules/core/04-channel/v2/keeper/keeper.go | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index aae6048ed2a..6da7c89c873 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -68,3 +68,8 @@ func (k *Keeper) TimeoutPacketTest( proofHeight, ) } + +// AliasV1Channel is a wrapper around aliasV1Channel to allow its usage in tests. +func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { + return k.aliasV1Channel(ctx, portID, channelID) +} diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index fe1ad9b8a23..1b8d5398aba 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -213,9 +213,9 @@ func (k *Keeper) SetNextSequenceSend(ctx context.Context, channelID string, sequ } } -// AliasV1Channel returns a version 2 channel for the given port and channel ID +// aliasV1Channel returns a version 2 channel for the given port and channel ID // by converting the channel into a version 2 channel. -func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { +func (k *Keeper) aliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { channel, ok := k.channelKeeperV1.GetChannel(ctx, portID, channelID) if !ok { return types.Channel{}, false @@ -242,7 +242,7 @@ func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) ( // convertV1Channel attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it // to a v2 counterparty and stores it in the v2 channel keeper for future use func (k *Keeper) convertV1Channel(ctx context.Context, port, id string) (types.Channel, bool) { - if channel, ok := k.AliasV1Channel(ctx, port, id); ok { + if channel, ok := k.aliasV1Channel(ctx, port, id); ok { // we can key on just the channel here since channel ids are globally unique k.SetChannel(ctx, id, channel) return channel, true From 831a351d159e7220e104cd5e4e95018a138bcb50 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 18:45:43 +0200 Subject: [PATCH 126/172] nit: consistent import name for 24-host/v2 --- modules/core/04-channel/v2/client/cli/abci.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/abci.go b/modules/core/04-channel/v2/client/cli/abci.go index 5069eddf03e..d341e35b4e2 100644 --- a/modules/core/04-channel/v2/client/cli/abci.go +++ b/modules/core/04-channel/v2/client/cli/abci.go @@ -8,12 +8,12 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibcclient "github.com/cosmos/ibc-go/v9/modules/core/client" ) func queryNextSequenceSendABCI(clientCtx client.Context, channelID string) (*types.QueryNextSequenceSendResponse, error) { - key := host.NextSequenceSendKey(channelID) + key := hostv2.NextSequenceSendKey(channelID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { return nil, err @@ -30,7 +30,7 @@ func queryNextSequenceSendABCI(clientCtx client.Context, channelID string) (*typ } func queryPacketCommitmentABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketCommitmentResponse, error) { - key := host.PacketCommitmentKey(channelID, sequence) + key := hostv2.PacketCommitmentKey(channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { return nil, err @@ -45,7 +45,7 @@ func queryPacketCommitmentABCI(clientCtx client.Context, channelID string, seque } func queryPacketAcknowledgementABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketAcknowledgementResponse, error) { - key := host.PacketAcknowledgementKey(channelID, sequence) + key := hostv2.PacketAcknowledgementKey(channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { return nil, err @@ -60,7 +60,7 @@ func queryPacketAcknowledgementABCI(clientCtx client.Context, channelID string, } func queryPacketReceiptABCI(clientCtx client.Context, channelID string, sequence uint64) (*types.QueryPacketReceiptResponse, error) { - key := host.PacketReceiptKey(channelID, sequence) + key := hostv2.PacketReceiptKey(channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { From 595e98babf69f7e42e57b82db114d3cf538abbed Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:37:47 +0100 Subject: [PATCH 127/172] Simplify Acknowledgement structure (#7555) * simplify ack to array of byte arrays * simplify test * lint --- .../core/04-channel/v2/keeper/msg_server.go | 37 +- .../04-channel/v2/keeper/msg_server_test.go | 77 ++-- modules/core/04-channel/v2/keeper/packet.go | 4 +- .../core/04-channel/v2/keeper/packet_test.go | 16 +- .../core/04-channel/v2/types/commitment.go | 4 +- modules/core/04-channel/v2/types/packet.pb.go | 349 +++--------------- modules/core/ante/ante_test.go | 9 +- proto/ibc/core/channel/v2/packet.proto | 8 +- 8 files changed, 117 insertions(+), 387 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index a4b6c19d9ff..ba0fd05e17c 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "slices" "time" errorsmod "cosmossdk.io/errors" @@ -132,9 +131,10 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // build up the recv results for each application callback. ack := types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{}, + AppAcknowledgements: [][]byte{}, } + var isAsync bool for _, pd := range msg.Packet.Payloads { // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful. cacheCtx, writeFn = sdkCtx.CacheContext() @@ -149,23 +149,26 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ sdkCtx.EventManager().EmitEvents(internalerrors.ConvertToErrorEvents(cacheCtx.EventManager().Events())) } - ack.AcknowledgementResults = append(ack.AcknowledgementResults, types.AcknowledgementResult{ - AppName: pd.DestinationPort, - RecvPacketResult: res, - }) + if res.Status == types.PacketStatus_Async { + // Set packet acknowledgement to async if any of the acknowledgements are async. + isAsync = true + // Return error if there is more than 1 payload + // TODO: Handle case where there are multiple payloads + if len(msg.Packet.Payloads) > 1 { + return nil, errorsmod.Wrapf(types.ErrInvalidPacket, "packet with multiple payloads cannot have async acknowledgement") + } + } + + // append app acknowledgement to the overall acknowledgement + ack.AppAcknowledgements = append(ack.AppAcknowledgements, res.Acknowledgement) } // note this should never happen as the payload would have had to be empty. - if len(ack.AcknowledgementResults) == 0 { + if len(ack.AppAcknowledgements) == 0 { sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) return &types.MsgRecvPacketResponse{Result: types.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) } - // NOTE: TBD how we will handle async acknowledgements with more than one payload. - isAsync := slices.ContainsFunc(ack.AcknowledgementResults, func(ackResult types.AcknowledgementResult) bool { - return ackResult.RecvPacketResult.Status == types.PacketStatus_Async - }) - if !isAsync { // Set packet acknowledgement only if the acknowledgement is not async. // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the @@ -205,14 +208,10 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } - recvResults := make(map[string]types.RecvPacketResult) - for _, r := range msg.Acknowledgement.AcknowledgementResults { - recvResults[r.AppName] = r.RecvPacketResult - } - - for _, pd := range msg.Packet.Payloads { + for i, pd := range msg.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) - err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, recvResults[pd.DestinationPort].Acknowledgement, relayer) + ack := msg.Acknowledgement.AppAcknowledgements[i] + err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, ack, relayer) if err != nil { return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 3ea899c28af..339c0f3d92f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -227,59 +227,52 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { func (suite *KeeperTestSuite) TestMsgRecvPacket() { var ( - path *ibctesting.Path - packet types.Packet - expectedAck types.Acknowledgement + path *ibctesting.Path + packet types.Packet + expRecvRes types.RecvPacketResult ) testCases := []struct { - name string - malleate func() - expError error + name string + malleate func() + expError error + expAckWritten bool }{ { - name: "success", - malleate: func() {}, - expError: nil, + name: "success", + malleate: func() {}, + expError: nil, + expAckWritten: true, }, { name: "success: failed recv result", malleate: func() { - failedRecvResult := types.RecvPacketResult{ + expRecvRes = types.RecvPacketResult{ Status: types.PacketStatus_Failure, Acknowledgement: mock.MockFailPacketData, } - - // a failed ack should be returned by the application. - expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult - - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { - return failedRecvResult - } }, + expError: nil, + expAckWritten: true, }, { name: "success: async recv result", malleate: func() { - asyncResult := types.RecvPacketResult{ + expRecvRes = types.RecvPacketResult{ Status: types.PacketStatus_Async, Acknowledgement: nil, } - - // an async ack should be returned by the application. - expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult - - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { - return asyncResult - } }, + expError: nil, + expAckWritten: false, }, { name: "success: NoOp", malleate: func() { suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) - expectedAck = types.Acknowledgement{} }, + expError: nil, + expAckWritten: false, }, { name: "failure: counterparty not found", @@ -314,18 +307,19 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)) suite.Require().NoError(err) - // default expected ack is a single successful recv result for moduleB. - expectedAck = types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{ - { - AppName: mockv2.ModuleNameB, - RecvPacketResult: mockv2.MockRecvPacketResult, - }, - }, - } + // default expected receive result is a single successful recv result for moduleB. + expRecvRes = mockv2.MockRecvPacketResult tc.malleate() + // expectedAck is derived from the expected recv result. + expectedAck := types.Acknowledgement{AppAcknowledgements: [][]byte{expRecvRes.Acknowledgement}} + + // modify the callback to return the expected recv result. + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { + return expRecvRes + } + err = path.EndpointB.MsgRecvPacket(packet) ck := path.EndpointB.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 @@ -340,7 +334,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) - if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == types.PacketStatus_Async { + if !tc.expAckWritten { // ack should not be written for async app or if the packet receipt was already present. suite.Require().False(ackWritten) } else { // successful or failed acknowledgement @@ -415,7 +409,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "failure: failed membership verification", malleate: func() { - ack.AcknowledgementResults[0].RecvPacketResult.Acknowledgement = mock.MockFailPacketData + ack.AppAcknowledgements[0] = mock.MockFailPacketData }, expError: errors.New("failed packet acknowledgement verification"), }, @@ -438,14 +432,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { suite.Require().NoError(err) // Construct expected acknowledgement - ack = types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{ - { - AppName: mockv2.ModuleNameB, - RecvPacketResult: mockv2.MockRecvPacketResult, - }, - }, - } + ack = types.Acknowledgement{AppAcknowledgements: [][]byte{mockv2.MockRecvPacketResult.Acknowledgement}} tc.malleate() diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 6ba078490c5..d7e40d07fc2 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -191,8 +191,8 @@ func (k Keeper) WriteAcknowledgement( // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 - if len(ack.AcknowledgementResults) != len(packet.Payloads) { - return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of acknowledgement results %d does not match length of payload %d", len(ack.AcknowledgementResults), len(packet.Payloads)) + if len(ack.AppAcknowledgements) != len(packet.Payloads) { + return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of app acknowledgement %d does not match length of app payload %d", len(ack.AppAcknowledgements), len(packet.Payloads)) } // set the acknowledgement so that it can be verified on the other side diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index e93e2d97259..9f4988c240a 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -275,7 +275,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { "failure: empty ack", func() { ack = types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{}, + AppAcknowledgements: [][]byte{}, } }, types.ErrInvalidAcknowledgement, @@ -307,12 +307,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { // create standard ack that can be malleated ack = types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{ - { - AppName: mockv2.ModuleNameB, - RecvPacketResult: mockv2.MockRecvPacketResult, - }, - }, + AppAcknowledgements: [][]byte{mockv2.MockRecvPacketResult.Acknowledgement}, } suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) @@ -340,10 +335,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { packet types.Packet err error ack = types.Acknowledgement{ - AcknowledgementResults: []types.AcknowledgementResult{{ - AppName: mockv2.ModuleNameB, - RecvPacketResult: mockv2.MockRecvPacketResult, - }}, + AppAcknowledgements: [][]byte{mockv2.MockRecvPacketResult.Acknowledgement}, } freezeClient bool ) @@ -397,7 +389,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { { "failure: verify membership fails", func() { - ack.AcknowledgementResults[0].RecvPacketResult = mockv2.MockFailRecvPacketResult + ack.AppAcknowledgements[0] = mockv2.MockFailRecvPacketResult.Acknowledgement }, commitmenttypes.ErrInvalidProof, }, diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 721049ca83b..8078ab4123e 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -51,8 +51,8 @@ func hashPayload(data Payload) []byte { // CommitAcknowledgement returns the hash of the acknowledgement data. func CommitAcknowledgement(acknowledgement Acknowledgement) []byte { var buf []byte - for _, ack := range acknowledgement.GetAcknowledgementResults() { - hash := sha256.Sum256(ack.RecvPacketResult.GetAcknowledgement()) + for _, ack := range acknowledgement.GetAppAcknowledgements() { + hash := sha256.Sum256(ack) buf = append(buf, hash[:]...) } diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go index a41a9d8256e..cb14c1e8880 100644 --- a/modules/core/04-channel/v2/types/packet.pb.go +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -227,7 +227,7 @@ func (m *Payload) GetValue() []byte { // Acknowledgement contains a list of all ack results associated with a single packet. type Acknowledgement struct { - AcknowledgementResults []AcknowledgementResult `protobuf:"bytes,1,rep,name=acknowledgement_results,json=acknowledgementResults,proto3" json:"acknowledgement_results"` + AppAcknowledgements [][]byte `protobuf:"bytes,1,rep,name=app_acknowledgements,json=appAcknowledgements,proto3" json:"app_acknowledgements,omitempty"` } func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } @@ -263,66 +263,13 @@ func (m *Acknowledgement) XXX_DiscardUnknown() { var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo -func (m *Acknowledgement) GetAcknowledgementResults() []AcknowledgementResult { +func (m *Acknowledgement) GetAppAcknowledgements() [][]byte { if m != nil { - return m.AcknowledgementResults + return m.AppAcknowledgements } return nil } -// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. -type AcknowledgementResult struct { - AppName string `protobuf:"bytes,1,opt,name=app_name,json=appName,proto3" json:"app_name,omitempty"` - RecvPacketResult RecvPacketResult `protobuf:"bytes,2,opt,name=recv_packet_result,json=recvPacketResult,proto3" json:"recv_packet_result"` -} - -func (m *AcknowledgementResult) Reset() { *m = AcknowledgementResult{} } -func (m *AcknowledgementResult) String() string { return proto.CompactTextString(m) } -func (*AcknowledgementResult) ProtoMessage() {} -func (*AcknowledgementResult) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{3} -} -func (m *AcknowledgementResult) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AcknowledgementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AcknowledgementResult.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 *AcknowledgementResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_AcknowledgementResult.Merge(m, src) -} -func (m *AcknowledgementResult) XXX_Size() int { - return m.Size() -} -func (m *AcknowledgementResult) XXX_DiscardUnknown() { - xxx_messageInfo_AcknowledgementResult.DiscardUnknown(m) -} - -var xxx_messageInfo_AcknowledgementResult proto.InternalMessageInfo - -func (m *AcknowledgementResult) GetAppName() string { - if m != nil { - return m.AppName - } - return "" -} - -func (m *AcknowledgementResult) GetRecvPacketResult() RecvPacketResult { - if m != nil { - return m.RecvPacketResult - } - return RecvPacketResult{} -} - // RecvPacketResult speecifies the status of a packet as well as the acknowledgement bytes. type RecvPacketResult struct { // status of the packet @@ -335,7 +282,7 @@ func (m *RecvPacketResult) Reset() { *m = RecvPacketResult{} } func (m *RecvPacketResult) String() string { return proto.CompactTextString(m) } func (*RecvPacketResult) ProtoMessage() {} func (*RecvPacketResult) Descriptor() ([]byte, []int) { - return fileDescriptor_2f814aba9ca97169, []int{4} + return fileDescriptor_2f814aba9ca97169, []int{3} } func (m *RecvPacketResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,55 +330,50 @@ func init() { proto.RegisterType((*Packet)(nil), "ibc.core.channel.v2.Packet") proto.RegisterType((*Payload)(nil), "ibc.core.channel.v2.Payload") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v2.Acknowledgement") - proto.RegisterType((*AcknowledgementResult)(nil), "ibc.core.channel.v2.AcknowledgementResult") proto.RegisterType((*RecvPacketResult)(nil), "ibc.core.channel.v2.RecvPacketResult") } func init() { proto.RegisterFile("ibc/core/channel/v2/packet.proto", fileDescriptor_2f814aba9ca97169) } var fileDescriptor_2f814aba9ca97169 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 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, 0xf8, 0x85, - 0x4f, 0x0e, 0x3f, 0x5e, 0xdf, 0x56, 0xc0, 0xcd, 0x6d, 0x05, 0xfc, 0xbe, 0xad, 0x80, 0x6f, 0x77, - 0x95, 0xcc, 0xcd, 0x5d, 0x25, 0xf3, 0xf3, 0xae, 0x92, 0xf9, 0xf4, 0x7a, 0xe8, 0x88, 0xd3, 0xa8, - 0xaf, 0x13, 0xe6, 0x19, 0x84, 0x71, 0x8f, 0x71, 0xc3, 0xe9, 0x93, 0xfd, 0x21, 0x33, 0xe2, 0x03, - 0xc3, 0x63, 0x83, 0xc8, 0xa5, 0x3c, 0x79, 0x4b, 0x5e, 0xbc, 0xda, 0x9f, 0x7a, 0x4e, 0xc4, 0x45, - 0x40, 0x79, 0x7f, 0x45, 0xbe, 0x11, 0x2f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x59, 0x03, - 0x6e, 0x72, 0x04, 0x00, 0x00, + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0xeb, 0xb5, 0xdd, 0x56, 0xaf, 0x6c, 0xc1, 0x1d, 0x52, 0xa8, 0x50, 0x17, 0x2a, 0x01, + 0x05, 0xb4, 0x04, 0x0a, 0x97, 0x49, 0x08, 0xa9, 0xcb, 0x32, 0x69, 0x02, 0x95, 0xca, 0x69, 0x91, + 0xe0, 0x52, 0xb9, 0xae, 0x95, 0x45, 0x4b, 0xe2, 0x10, 0x3b, 0x99, 0xf6, 0x0a, 0x3b, 0xf1, 0x02, + 0x3b, 0x70, 0xe6, 0x45, 0x76, 0xdc, 0x91, 0x13, 0x42, 0xdb, 0x89, 0xb7, 0x40, 0x75, 0xb2, 0xaa, + 0x1b, 0x70, 0x4a, 0xbe, 0xff, 0xf7, 0xfb, 0xdb, 0xfa, 0x7f, 0xd6, 0x07, 0x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x3d, 0x85, 0xda, 0x62, 0x14, 0x45, 0xe5, 0x99, 0x37, 0x16, 0x74, 0x85, 0xea, 0x70, + 0x25, 0x63, 0x89, 0xf0, 0x79, 0x54, 0x24, 0xbd, 0x2e, 0x67, 0x23, 0x65, 0x11, 0xe5, 0x53, 0x3f, + 0xf2, 0x54, 0xaa, 0x1a, 0x9e, 0xd7, 0x68, 0x13, 0x56, 0x33, 0x12, 0xa4, 0x4c, 0xaf, 0x1a, 0xa0, + 0x53, 0xc7, 0x79, 0xd1, 0xde, 0x83, 0x1b, 0x3d, 0x7a, 0x14, 0xf1, 0xe3, 0x80, 0x4d, 0x3d, 0x16, + 0xb2, 0x48, 0xa2, 0x97, 0x70, 0x93, 0xc4, 0xf1, 0x98, 0xdc, 0x94, 0x85, 0x0e, 0x8c, 0x72, 0xa7, + 0x8e, 0x1b, 0x24, 0x8e, 0x6f, 0x39, 0x44, 0xfb, 0x18, 0x6a, 0x98, 0xd1, 0x2c, 0x7f, 0x58, 0xcc, + 0x44, 0x1a, 0x48, 0xb4, 0x03, 0x97, 0x85, 0x24, 0x32, 0x15, 0x2a, 0xec, 0x7a, 0xf7, 0xe1, 0x7f, + 0x66, 0x37, 0xb3, 0xb8, 0x0a, 0xc4, 0x85, 0x01, 0x75, 0xe0, 0xc6, 0xad, 0xdb, 0xd5, 0x28, 0xea, + 0xf8, 0xb6, 0xfc, 0xec, 0x3b, 0x80, 0xf5, 0xc5, 0x23, 0xd0, 0x13, 0x78, 0x7f, 0xd0, 0xb3, 0xdf, + 0x39, 0xc3, 0xb1, 0x3b, 0xec, 0x0d, 0x47, 0xee, 0x78, 0xd4, 0x77, 0x07, 0x8e, 0x7d, 0xb0, 0x7f, + 0xe0, 0xec, 0x69, 0xa5, 0xe6, 0xea, 0xe9, 0x99, 0x51, 0xe9, 0x7f, 0xe8, 0x3b, 0xe8, 0x31, 0xbc, + 0x77, 0x13, 0x74, 0x47, 0xb6, 0xed, 0xb8, 0xae, 0x06, 0x9a, 0x6b, 0xa7, 0x67, 0xc6, 0x8a, 0x9b, + 0x52, 0xca, 0x84, 0xf8, 0x9b, 0xdb, 0xef, 0x1d, 0xbc, 0x1f, 0x61, 0x47, 0x5b, 0xca, 0xb9, 0x7d, + 0xe2, 0x07, 0x69, 0xc2, 0x50, 0x1b, 0x36, 0x6e, 0x72, 0x3d, 0xf7, 0x53, 0xdf, 0xd6, 0xca, 0xcd, + 0xda, 0xe9, 0x99, 0x51, 0xed, 0x89, 0x93, 0x88, 0xee, 0x7e, 0x3c, 0xbf, 0x6c, 0x81, 0x8b, 0xcb, + 0x16, 0xf8, 0x75, 0xd9, 0x02, 0x5f, 0xaf, 0x5a, 0xa5, 0x8b, 0xab, 0x56, 0xe9, 0xc7, 0x55, 0xab, + 0xf4, 0xf9, 0x8d, 0xe7, 0xcb, 0xc3, 0x74, 0x62, 0x52, 0x1e, 0x5a, 0x94, 0x8b, 0x90, 0x0b, 0xcb, + 0x9f, 0xd0, 0x6d, 0x8f, 0x5b, 0xd9, 0x8e, 0x15, 0xf2, 0x69, 0x1a, 0x30, 0x91, 0xef, 0xe0, 0x8b, + 0xd7, 0xdb, 0x0b, 0x6b, 0x28, 0x4f, 0x62, 0x26, 0x26, 0xcb, 0x6a, 0xb7, 0x5e, 0xfd, 0x09, 0x00, + 0x00, 0xff, 0xff, 0x23, 0xd8, 0x40, 0xe5, 0xaa, 0x03, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -573,16 +515,11 @@ func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.AcknowledgementResults) > 0 { - for iNdEx := len(m.AcknowledgementResults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AcknowledgementResults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPacket(dAtA, i, uint64(size)) - } + if len(m.AppAcknowledgements) > 0 { + for iNdEx := len(m.AppAcknowledgements) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AppAcknowledgements[iNdEx]) + copy(dAtA[i:], m.AppAcknowledgements[iNdEx]) + i = encodeVarintPacket(dAtA, i, uint64(len(m.AppAcknowledgements[iNdEx]))) i-- dAtA[i] = 0xa } @@ -590,46 +527,6 @@ func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AcknowledgementResult) 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 *AcknowledgementResult) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AcknowledgementResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.RecvPacketResult.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPacket(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.AppName) > 0 { - i -= len(m.AppName) - copy(dAtA[i:], m.AppName) - i = encodeVarintPacket(dAtA, i, uint64(len(m.AppName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *RecvPacketResult) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -740,30 +637,15 @@ func (m *Acknowledgement) Size() (n int) { } var l int _ = l - if len(m.AcknowledgementResults) > 0 { - for _, e := range m.AcknowledgementResults { - l = e.Size() + if len(m.AppAcknowledgements) > 0 { + for _, b := range m.AppAcknowledgements { + l = len(b) n += 1 + l + sovPacket(uint64(l)) } } return n } -func (m *AcknowledgementResult) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AppName) - if l > 0 { - n += 1 + l + sovPacket(uint64(l)) - } - l = m.RecvPacketResult.Size() - n += 1 + l + sovPacket(uint64(l)) - return n -} - func (m *RecvPacketResult) Size() (n int) { if m == nil { return 0 @@ -1215,125 +1097,9 @@ func (m *Acknowledgement) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcknowledgementResults", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPacket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } + return fmt.Errorf("proto: wrong wireType = %d for field AppAcknowledgements", wireType) } - if msglen < 0 { - return ErrInvalidLengthPacket - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPacket - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcknowledgementResults = append(m.AcknowledgementResults, AcknowledgementResult{}) - if err := m.AcknowledgementResults[len(m.AcknowledgementResults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPacket(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPacket - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AcknowledgementResult) 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 ErrIntOverflowPacket - } - 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: AcknowledgementResult: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AcknowledgementResult: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPacket - } - 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 ErrInvalidLengthPacket - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPacket - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AppName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecvPacketResult", wireType) - } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPacket @@ -1343,24 +1109,23 @@ func (m *AcknowledgementResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthPacket } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthPacket } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.RecvPacketResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.AppAcknowledgements = append(m.AppAcknowledgements, make([]byte, postIndex-iNdEx)) + copy(m.AppAcknowledgements[len(m.AppAcknowledgements)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 75e37659640..a7fd7062f5e 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -128,14 +128,7 @@ func (suite *AnteTestSuite) createAcknowledgementMessageV2(isRedundant bool) *ch err = suite.path.EndpointA.MsgRecvPacket(packet) suite.Require().NoError(err) - ack := channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ - { - AppName: mock.ModuleNameB, - RecvPacketResult: mock.MockRecvPacketResult, - }, - }, - } + ack := channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{mock.MockRecvPacketResult.Acknowledgement}} if isRedundant { err = suite.path.EndpointB.MsgAcknowledgePacket(packet, ack) suite.Require().NoError(err) diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto index fef2c588e5a..ea14112c643 100644 --- a/proto/ibc/core/channel/v2/packet.proto +++ b/proto/ibc/core/channel/v2/packet.proto @@ -39,13 +39,7 @@ message Payload { // Acknowledgement contains a list of all ack results associated with a single packet. message Acknowledgement { - repeated AcknowledgementResult acknowledgement_results = 1 [(gogoproto.nullable) = false]; -} - -// AcknowledgementResult of identified acknowledgement. Correlating IBC application name to opaque ack bytes. -message AcknowledgementResult { - string app_name = 1; - RecvPacketResult recv_packet_result = 2 [(gogoproto.nullable) = false]; + repeated bytes app_acknowledgements = 1; } // PacketStatus specifies the status of a RecvPacketResult. From e2616835d9d6685bc1b69d0e870d51c3a6e87c4f Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 14 Nov 2024 10:06:50 +0100 Subject: [PATCH 128/172] support client identifiers as channels in ics20 denom hops (#7551) --- modules/apps/transfer/types/denom.go | 3 ++- modules/apps/transfer/types/denom_test.go | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/apps/transfer/types/denom.go b/modules/apps/transfer/types/denom.go index 03c4bb19f04..8846d876ce2 100644 --- a/modules/apps/transfer/types/denom.go +++ b/modules/apps/transfer/types/denom.go @@ -14,6 +14,7 @@ import ( cmtbytes "github.com/cometbft/cometbft/libs/bytes" cmttypes "github.com/cometbft/cometbft/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) @@ -167,7 +168,7 @@ func ExtractDenomFromPath(fullPath string) Denom { // will be incorrectly parsed, but the token will continue to be treated correctly // as an IBC denomination. The hash used to store the token internally on our chain // will be the same value as the base denomination being correctly parsed. - if i < length-1 && length > 2 && channeltypes.IsValidChannelID(denomSplit[i+1]) { + if i < length-1 && length > 2 && (channeltypes.IsValidChannelID(denomSplit[i+1]) || clienttypes.IsValidClientID(denomSplit[i+1])) { trace = append(trace, NewHop(denomSplit[i], denomSplit[i+1])) } else { baseDenomSlice = denomSplit[i:] diff --git a/modules/apps/transfer/types/denom_test.go b/modules/apps/transfer/types/denom_test.go index 6a240af3e84..d6d47c78e56 100644 --- a/modules/apps/transfer/types/denom_test.go +++ b/modules/apps/transfer/types/denom_test.go @@ -20,6 +20,11 @@ func (suite *TypesTestSuite) TestDenomsValidate() { types.Denoms{}, nil, }, + { + "valid trace with client id", + types.Denoms{types.NewDenom("uatom", types.NewHop("transfer", "07-tendermint-0"))}, + nil, + }, { "valid multiple trace info", types.Denoms{types.NewDenom("uatom", types.NewHop("transfer", "channel-1"), types.NewHop("transfer", "channel-2"))}, @@ -79,6 +84,16 @@ func (suite *TypesTestSuite) TestPath() { types.NewDenom("uatom", types.NewHop("transfer", "channel-0")), "transfer/channel-0/uatom", }, + { + "1 hop denom with client id", + types.NewDenom("uatom", types.NewHop("transfer", "07-tendermint-0")), + "transfer/07-tendermint-0/uatom", + }, + { + "1 hop denom with client id and slashes", + types.NewDenom("gamm/pool/osmo", types.NewHop("transfer", "07-tendermint-0")), + "transfer/07-tendermint-0/gamm/pool/osmo", + }, { "2 hop denom", types.NewDenom("uatom", types.NewHop("transfer", "channel-0"), types.NewHop("transfer", "channel-52")), @@ -202,6 +217,13 @@ func (suite *TypesTestSuite) TestDenomChainSource() { "channel-0", false, }, + { + "sender chain is source: single trace with client id", + types.NewDenom("ubtc", types.NewHop("transfer", "07-tendermint-0")), + "transfer", + "channel-0", + false, + }, { "sender chain is source: swapped portID and channelID", types.NewDenom("uatom", types.NewHop("transfer", "channel-0")), @@ -226,6 +248,13 @@ func (suite *TypesTestSuite) TestDenomChainSource() { "channel-0", true, }, + { + "receiver chain is source: single trace with client id", + types.NewDenom("ubtc", types.NewHop("transfer", "07-tendermint-0")), + "transfer", + "07-tendermint-0", + true, + }, { "receiver chain is source: multi-trace", types.NewDenom("uatom", types.NewHop("transfer", "channel-0"), types.NewHop("transfer", "channel-52")), @@ -284,6 +313,7 @@ func TestExtractDenomFromPath(t *testing.T) { {"base denom with trailing slash", "atom/", types.NewDenom("atom/")}, {"base denom multiple trailing slash", "foo///bar//baz/atom/", types.NewDenom("foo///bar//baz/atom/")}, {"ibc denom one hop", "transfer/channel-0/atom", types.NewDenom("atom", types.NewHop("transfer", "channel-0"))}, + {"ibc denom one hop with client id", "transfer/07-tendermint-0/atom", types.NewDenom("atom", types.NewHop("transfer", "07-tendermint-0"))}, {"ibc denom one hop trailing slash", "transfer/channel-0/atom/", types.NewDenom("atom/", types.NewHop("transfer", "channel-0"))}, {"ibc denom one hop multiple slashes", "transfer/channel-0//at/om/", types.NewDenom("/at/om/", types.NewHop("transfer", "channel-0"))}, {"ibc denom two hops", "transfer/channel-0/transfer/channel-60/atom", types.NewDenom("atom", types.NewHop("transfer", "channel-0"), types.NewHop("transfer", "channel-60"))}, From a2d377c5c346cd56fe0102f07175a35ce64aeea1 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 14 Nov 2024 16:54:19 +0200 Subject: [PATCH 129/172] chore: add unreceived acks rpc (#7562) * chore: add unreceived acks rpc * nit: init path in setup function. --- modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 53 ++ .../core/04-channel/v2/keeper/grpc_query.go | 52 ++ .../04-channel/v2/keeper/grpc_query_test.go | 123 +++ modules/core/04-channel/v2/types/query.pb.go | 725 ++++++++++++++++-- .../core/04-channel/v2/types/query.pb.gw.go | 123 +++ proto/ibc/core/channel/v2/query.proto | 24 + 7 files changed, 1044 insertions(+), 57 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index b759dd0e65f..a333b0c5055 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -25,6 +25,7 @@ func GetQueryCmd() *cobra.Command { getCmdQueryPacketCommitments(), getCmdQueryPacketAcknowledgement(), getCmdQueryPacketReceipt(), + getCmdQueryUnreceivedAcks(), ) return queryCmd diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index f07e853e78d..66d465afe3c 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -14,6 +14,10 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) +const ( + flagSequences = "sequences" +) + // getCmdQueryChannel defines the command to query the channel information (creator and channel) for the given channel ID. func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ @@ -282,3 +286,52 @@ func getCmdQueryPacketReceipt() *cobra.Command { return cmd } + +// getCmdQueryUnreceivedAcks defines the command to query all the unreceived acks on the original sending chain +func getCmdQueryUnreceivedAcks() *cobra.Command { + cmd := &cobra.Command{ + Use: "unreceived-acks [channel-id]", + Short: "Query all the unreceived acks associated with a channel", + Long: `Given a list of acknowledgement sequences from counterparty, determine if an ack on the counterparty chain has been received on the executing chain. + +The return value represents: +- Unreceived packet acknowledgement: packet commitment exists on original sending (executing) chain and ack exists on receiving chain. +`, + Example: fmt.Sprintf("%s query %s %s unreceived-acks [channel-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences) + if err != nil { + return err + } + + seqs := make([]uint64, len(seqSlice)) + for i := range seqSlice { + seqs[i] = uint64(seqSlice[i]) + } + + req := &types.QueryUnreceivedAcksRequest{ + ChannelId: args[0], + PacketAckSequences: seqs, + } + + res, err := queryClient.UnreceivedAcks(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().Int64Slice(flagSequences, []int64{}, "comma separated list of packet sequence numbers") + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index f11c1f5155b..7495f40763f 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -187,3 +187,55 @@ func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketR return types.NewQueryPacketReceiptResponse(hasReceipt, nil, clienttypes.GetSelfHeight(ctx)), nil } + +// UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given +// a list of counterparty packet acknowledgements, the querier checks if the packet +// has already been received by checking if the packet commitment still exists on this +// chain (original sender) for the packet sequence. +// All acknowledgmeents that haven't been received yet are returned in the response. +// Usage: To use this method correctly, first query all packet acknowledgements on +// the original receiving chain (ie the chain that wrote the acks) using the Query/PacketAcknowledgements gRPC method. +// Then input the returned sequences into the QueryUnreceivedAcksRequest +// and send the request to this Query/UnreceivedAcks on the **original sending** +// chain. This gRPC method will then return the list of packet sequences whose +// acknowledgements are already written on the receiving chain but haven't yet +// been received back to the sending chain. +// +// NOTE: The querier makes the assumption that the provided list of packet +// acknowledgements is correct and will not function properly if the list +// is not up to date. Ideally the query height should equal the latest height +// on the counterparty's client which represents this chain. +func (q *queryServer) UnreceivedAcks(ctx context.Context, req *types.QueryUnreceivedAcksRequest) (*types.QueryUnreceivedAcksResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + var unreceivedSequences []uint64 + + for _, seq := range req.PacketAckSequences { + if seq == 0 { + return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") + } + + // if packet commitment still exists on the original sending chain, then packet ack has not been received + // since processing the ack will delete the packet commitment + if commitment := q.GetPacketCommitment(ctx, req.ChannelId, seq); len(commitment) != 0 { + unreceivedSequences = append(unreceivedSequences, seq) + } + + } + + selfHeight := clienttypes.GetSelfHeight(ctx) + return &types.QueryUnreceivedAcksResponse{ + Sequences: unreceivedSequences, + Height: selfHeight, + }, nil +} diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 40a2ba07b4c..03d4e886dd5 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -586,3 +586,126 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { }) } } + +func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { + var ( + path *ibctesting.Path + req *types.QueryUnreceivedAcksRequest + expSeq = []uint64{} + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + expSeq = []uint64(nil) + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: path.EndpointA.ChannelID, + PacketAckSequences: []uint64{1}, + } + }, + nil, + }, + { + "success: single unreceived packet ack", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, []byte("commitment")) + + expSeq = []uint64{1} + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: path.EndpointA.ChannelID, + PacketAckSequences: []uint64{1}, + } + }, + nil, + }, + { + "success: multiple unreceived packet acknowledgements", + func() { + expSeq = []uint64{} // reset + packetAcks := []uint64{} + + // set packet commitment for every other sequence + for seq := uint64(1); seq < 10; seq++ { + packetAcks = append(packetAcks, seq) + + if seq%2 == 0 { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq, []byte("commitement")) + expSeq = append(expSeq, seq) + } + } + + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: path.EndpointA.ChannelID, + PacketAckSequences: packetAcks, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: "", + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: "test-channel-id", + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "test-channel-id")), + }, + { + "invalid seq", + func() { + req = &types.QueryUnreceivedAcksRequest{ + ChannelId: path.EndpointA.ChannelID, + PacketAckSequences: []uint64{0}, + } + }, + status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.UnreceivedAcks(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expSeq, res.Sequences) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index e6213b0c5b1..89675bdba42 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -717,6 +717,118 @@ func (m *QueryPacketReceiptResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryUnreceivedAcks is the request type for the +// Query/UnreceivedAcks RPC method +type QueryUnreceivedAcksRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // list of acknowledgement sequences + PacketAckSequences []uint64 `protobuf:"varint,2,rep,packed,name=packet_ack_sequences,json=packetAckSequences,proto3" json:"packet_ack_sequences,omitempty"` +} + +func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksRequest{} } +func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUnreceivedAcksRequest) ProtoMessage() {} +func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{12} +} +func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnreceivedAcksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnreceivedAcksRequest.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 *QueryUnreceivedAcksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnreceivedAcksRequest.Merge(m, src) +} +func (m *QueryUnreceivedAcksRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUnreceivedAcksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnreceivedAcksRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnreceivedAcksRequest proto.InternalMessageInfo + +func (m *QueryUnreceivedAcksRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryUnreceivedAcksRequest) GetPacketAckSequences() []uint64 { + if m != nil { + return m.PacketAckSequences + } + return nil +} + +// QueryUnreceivedAcksResponse is the response type for the +// Query/UnreceivedAcks RPC method +type QueryUnreceivedAcksResponse struct { + // list of unreceived acknowledgement sequences + Sequences []uint64 `protobuf:"varint,1,rep,packed,name=sequences,proto3" json:"sequences,omitempty"` + // query block height + Height types.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height"` +} + +func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcksResponse{} } +func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUnreceivedAcksResponse) ProtoMessage() {} +func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{13} +} +func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnreceivedAcksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnreceivedAcksResponse.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 *QueryUnreceivedAcksResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnreceivedAcksResponse.Merge(m, src) +} +func (m *QueryUnreceivedAcksResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUnreceivedAcksResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnreceivedAcksResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnreceivedAcksResponse proto.InternalMessageInfo + +func (m *QueryUnreceivedAcksResponse) GetSequences() []uint64 { + if m != nil { + return m.Sequences + } + return nil +} + +func (m *QueryUnreceivedAcksResponse) GetHeight() types.Height { + if m != nil { + return m.Height + } + return types.Height{} +} + func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") @@ -730,68 +842,75 @@ func init() { proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") proto.RegisterType((*QueryPacketReceiptRequest)(nil), "ibc.core.channel.v2.QueryPacketReceiptRequest") proto.RegisterType((*QueryPacketReceiptResponse)(nil), "ibc.core.channel.v2.QueryPacketReceiptResponse") + proto.RegisterType((*QueryUnreceivedAcksRequest)(nil), "ibc.core.channel.v2.QueryUnreceivedAcksRequest") + proto.RegisterType((*QueryUnreceivedAcksResponse)(nil), "ibc.core.channel.v2.QueryUnreceivedAcksResponse") } func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 883 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x3d, 0xb1, 0x9b, 0x1f, 0xcf, 0x41, 0x84, 0x69, 0x10, 0x66, 0x95, 0x6e, 0xdd, 0x3d, - 0x80, 0xa9, 0xda, 0x1d, 0xbc, 0xad, 0xf8, 0x21, 0xb5, 0x42, 0x8d, 0x55, 0xda, 0x20, 0x81, 0xc2, - 0x06, 0x21, 0xc1, 0x01, 0x6b, 0xbd, 0x1e, 0xd6, 0xab, 0xd8, 0x33, 0x5b, 0xef, 0xd8, 0xb4, 0xaa, - 0x7a, 0xe1, 0xc0, 0x85, 0x0b, 0xa2, 0x37, 0xfe, 0x02, 0xf8, 0x2b, 0x40, 0xe2, 0x12, 0x89, 0x4b, - 0xa4, 0x5c, 0x38, 0x21, 0x94, 0x20, 0xf1, 0x6f, 0x20, 0xcf, 0x8c, 0xed, 0xb5, 0xbd, 0x76, 0xbc, - 0x40, 0x6e, 0x33, 0xe3, 0xf7, 0xde, 0x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xa2, 0xd5, 0x6b, - 0xd8, 0x3e, 0xef, 0x10, 0xfd, 0x6f, 0x3b, 0x6c, 0xf8, 0x37, 0x03, 0x4e, 0xfa, 0xef, 0x92, 0x0e, - 0x6f, 0xf6, 0xda, 0x34, 0x56, 0xfb, 0xbf, 0x79, 0xfb, 0x66, 0x02, 0x41, 0x3c, 0x89, 0x68, 0xdc, - 0x58, 0x95, 0x7f, 0x70, 0x6f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x7f, 0x40, 0x76, 0xdf, - 0x0b, 0x00, 0x00, + // 974 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xce, 0xd8, 0x6e, 0x3e, 0x5e, 0x07, 0x08, 0xd3, 0x20, 0xcc, 0x92, 0xba, 0xee, 0x1e, 0xc0, + 0x54, 0xed, 0x4e, 0xec, 0x56, 0x7c, 0x48, 0xad, 0x50, 0x12, 0x95, 0x36, 0x48, 0xa0, 0xb0, 0x01, + 0x24, 0x38, 0x60, 0xad, 0xd7, 0xd3, 0xcd, 0xca, 0xf6, 0xcc, 0xd6, 0x33, 0x36, 0xad, 0xaa, 0x5c, + 0x38, 0x70, 0x46, 0xf4, 0xc6, 0x2f, 0x80, 0x5f, 0x01, 0x12, 0x97, 0x4a, 0x5c, 0x2a, 0xf5, 0xc2, + 0x09, 0x41, 0x82, 0xc4, 0x91, 0xbf, 0x80, 0x3c, 0x3b, 0x6b, 0xaf, 0x9d, 0xb5, 0xb3, 0x4b, 0x9b, + 0xdb, 0xee, 0xeb, 0xf7, 0xe3, 0x79, 0x9e, 0x7d, 0x3f, 0x64, 0xb8, 0xe8, 0x37, 0x5d, 0xe2, 0xf2, + 0x1e, 0x25, 0xee, 0x81, 0xc3, 0x18, 0xed, 0x90, 0x41, 0x9d, 0xdc, 0xeb, 0xd3, 0xde,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10, 0xbc, 0x38, 0xb9, 0x00, 0xf1, 0x1c, + 0x48, 0x89, 0x9b, 0xd9, 0xd8, 0x4c, 0x1f, 0xa0, 0x49, 0x74, 0x14, 0x89, 0xbb, 0xb8, 0xf5, 0x8c, + 0x53, 0x92, 0xb4, 0xf1, 0x0f, 0x49, 0x7f, 0x54, 0x54, 0x7d, 0xb0, 0xed, 0xcf, 0x1f, 0x1f, 0x95, + 0xd1, 0x93, 0xa3, 0x32, 0xfa, 0xf3, 0xa8, 0x8c, 0xbe, 0x3b, 0x2e, 0x2f, 0x3c, 0x39, 0x2e, 0x2f, + 0xfc, 0x7e, 0x5c, 0x5e, 0xf8, 0xf2, 0x86, 0xe7, 0xcb, 0x83, 0x7e, 0xd3, 0x72, 0x79, 0x97, 0xe8, + 0xff, 0x4d, 0x7e, 0xd3, 0xbd, 0xea, 0x71, 0x32, 0x78, 0x8f, 0x74, 0x79, 0xab, 0xdf, 0xa1, 0x22, + 0x84, 0xb7, 0x79, 0xfd, 0x6a, 0x0c, 0xa1, 0x7c, 0x10, 0x50, 0xd1, 0x5c, 0x54, 0x7f, 0x55, 0xae, + 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xcb, 0xc4, 0x1e, 0xa9, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -818,6 +937,8 @@ type QueryClient interface { PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. + UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAcksRequest, opts ...grpc.CallOption) (*QueryUnreceivedAcksResponse, error) } type queryClient struct { @@ -882,6 +1003,15 @@ func (c *queryClient) PacketReceipt(ctx context.Context, in *QueryPacketReceiptR return out, nil } +func (c *queryClient) UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAcksRequest, opts ...grpc.CallOption) (*QueryUnreceivedAcksResponse, error) { + out := new(QueryUnreceivedAcksResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/UnreceivedAcks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Channel queries the counterparty of an IBC client. @@ -896,6 +1026,8 @@ type QueryServer interface { PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(context.Context, *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. + UnreceivedAcks(context.Context, *QueryUnreceivedAcksRequest) (*QueryUnreceivedAcksResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -920,6 +1052,9 @@ func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req func (*UnimplementedQueryServer) PacketReceipt(ctx context.Context, req *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketReceipt not implemented") } +func (*UnimplementedQueryServer) UnreceivedAcks(ctx context.Context, req *QueryUnreceivedAcksRequest) (*QueryUnreceivedAcksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnreceivedAcks not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1033,6 +1168,24 @@ func _Query_PacketReceipt_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Query_UnreceivedAcks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUnreceivedAcksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UnreceivedAcks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/UnreceivedAcks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UnreceivedAcks(ctx, req.(*QueryUnreceivedAcksRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), @@ -1061,6 +1214,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketReceipt", Handler: _Query_PacketReceipt_Handler, }, + { + MethodName: "UnreceivedAcks", + Handler: _Query_UnreceivedAcks_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v2/query.proto", @@ -1561,6 +1718,105 @@ func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *QueryUnreceivedAcksRequest) 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 *QueryUnreceivedAcksRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketAckSequences) > 0 { + dAtA10 := make([]byte, len(m.PacketAckSequences)*10) + var j9 int + for _, num := range m.PacketAckSequences { + for num >= 1<<7 { + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j9++ + } + dAtA10[j9] = uint8(num) + j9++ + } + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintQuery(dAtA, i, uint64(j9)) + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUnreceivedAcksResponse) 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 *QueryUnreceivedAcksResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sequences) > 0 { + dAtA13 := make([]byte, len(m.Sequences)*10) + var j12 int + for _, num := range m.Sequences { + for num >= 1<<7 { + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j12++ + } + dAtA13[j12] = uint8(num) + j12++ + } + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintQuery(dAtA, i, uint64(j12)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1773,6 +2029,44 @@ func (m *QueryPacketReceiptResponse) Size() (n int) { return n } +func (m *QueryUnreceivedAcksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.PacketAckSequences) > 0 { + l = 0 + for _, e := range m.PacketAckSequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryUnreceivedAcksResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Sequences) > 0 { + l = 0 + for _, e := range m.Sequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + l = m.Height.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3207,6 +3501,323 @@ func (m *QueryPacketReceiptResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryUnreceivedAcksRequest) 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 ErrIntOverflowQuery + } + 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: QueryUnreceivedAcksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnreceivedAcksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PacketAckSequences = append(m.PacketAckSequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PacketAckSequences) == 0 { + m.PacketAckSequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PacketAckSequences = append(m.PacketAckSequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PacketAckSequences", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnreceivedAcksResponse) 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 ErrIntOverflowQuery + } + 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: QueryUnreceivedAcksResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnreceivedAcksResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Sequences) == 0 { + m.Sequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Sequences", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 7cbe955c0fb..995de0f48cc 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -459,6 +459,82 @@ func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime. } +func request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnreceivedAcksRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["packet_ack_sequences"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences") + } + + protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err) + } + + msg, err := client.UnreceivedAcks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnreceivedAcksRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["packet_ack_sequences"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences") + } + + protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err) + } + + msg, err := server.UnreceivedAcks(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -603,6 +679,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -764,6 +863,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -779,6 +898,8 @@ var ( pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -793,4 +914,6 @@ var ( forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage + + forward_Query_UnreceivedAcks_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index f9df59fcfaf..80b54c48e21 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -42,6 +42,12 @@ service Query { rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}"; } + + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. + rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { + option (google.api.http).get = + "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks"; + } } // QueryChannelRequest is the request type for the Query/Channel RPC method @@ -144,3 +150,21 @@ message QueryPacketReceiptResponse { // height at which the proof was retrieved ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; } + +// QueryUnreceivedAcks is the request type for the +// Query/UnreceivedAcks RPC method +message QueryUnreceivedAcksRequest { + // channel unique identifier + string channel_id = 1; + // list of acknowledgement sequences + repeated uint64 packet_ack_sequences = 2; +} + +// QueryUnreceivedAcksResponse is the response type for the +// Query/UnreceivedAcks RPC method +message QueryUnreceivedAcksResponse { + // list of unreceived acknowledgement sequences + repeated uint64 sequences = 1; + // query block height + ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; +} From 107ab752a38205ab8726b7600f778a86eaffa1d5 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 14 Nov 2024 21:59:51 +0100 Subject: [PATCH 130/172] make packet commitments fixed length (#7564) * make packet commitments fixed length * updated docs for packet commits --- .../core/04-channel/v2/types/commitment.go | 15 +++-- .../04-channel/v2/types/commitment_test.go | 58 +++++++++++++++++++ modules/core/24-host/v2/packet_key_test.go | 34 +++++++++++ 3 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 modules/core/04-channel/v2/types/commitment_test.go create mode 100644 modules/core/24-host/v2/packet_key_test.go diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 8078ab4123e..3f79cc3fad1 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -7,8 +7,8 @@ import ( ) // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// 0x02 + sha256_hash(destinationChannel) + sha256_hash(timeout) + sha256_hash(payload) from a given packet. -// This results in a fixed length preimage. +// ha256_hash(0x02 + sha256_hash(destinationChannel) + sha256_hash(timeout) + sha256_hash(payload)) from a given packet. +// This results in a fixed length preimage of 32 bytes. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. func CommitPacket(packet Packet) []byte { @@ -27,8 +27,10 @@ func CommitPacket(packet Packet) []byte { appHash := sha256.Sum256(appBytes) buf = append(buf, appHash[:]...) + buf = append([]byte{byte(2)}, buf...) + hash := sha256.Sum256(buf) - return append([]byte{byte(2)}, hash[:]...) + return hash[:] } // hashPayload returns the hash of the payload. @@ -48,7 +50,8 @@ func hashPayload(data Payload) []byte { return hash[:] } -// CommitAcknowledgement returns the hash of the acknowledgement data. +// CommitAcknowledgement returns the V2 acknowledgement commitment bytes. The commitment consists of: +// sha256_hash(0x02 + sha256_hash(ack1) + sha256_hash(ack2) + ...) from a given acknowledgement. func CommitAcknowledgement(acknowledgement Acknowledgement) []byte { var buf []byte for _, ack := range acknowledgement.GetAppAcknowledgements() { @@ -56,6 +59,8 @@ func CommitAcknowledgement(acknowledgement Acknowledgement) []byte { buf = append(buf, hash[:]...) } + buf = append([]byte{byte(2)}, buf...) + hash := sha256.Sum256(buf) - return append([]byte{byte(2)}, hash[:]...) + return hash[:] } diff --git a/modules/core/04-channel/v2/types/commitment_test.go b/modules/core/04-channel/v2/types/commitment_test.go new file mode 100644 index 00000000000..a77f93f451f --- /dev/null +++ b/modules/core/04-channel/v2/types/commitment_test.go @@ -0,0 +1,58 @@ +package types_test + +import ( + "encoding/hex" + "encoding/json" + "testing" + + "github.com/stretchr/testify/require" + + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +// TestCommitPacket is primarily used to document the expected commitment output +// so that other implementations (such as the IBC Solidity) can replicate the +// same commitment output. But it is also useful to catch any changes in the commitment. +func TestCommitPacket(t *testing.T) { + transferData, err := json.Marshal(transfertypes.FungibleTokenPacketData{ + Denom: "uatom", + Amount: "1000000", + Sender: "sender", + Receiver: "receiver", + Memo: "memo", + }) + require.NoError(t, err) + packet := types.Packet{ + Sequence: 1, + SourceChannel: "channel-0", + DestinationChannel: "channel-1", + TimeoutTimestamp: 100, + Payloads: []types.Payload{ + { + SourcePort: transfertypes.PortID, + DestinationPort: transfertypes.PortID, + Version: transfertypes.V1, + Encoding: "application/json", + Value: transferData, + }, + }, + } + commitment := types.CommitPacket(packet) + require.Equal(t, "450194f2ce25b12487f65593e106d91367a1e5c90b2efc03ed78265a54cfcebe", hex.EncodeToString(commitment)) + require.Len(t, commitment, 32) +} + +// TestCommitAcknowledgement is primarily used to document the expected commitment output +// so that other implementations (such as the IBC Solidity) can replicate the +// same commitment output. But it is also useful to catch any changes in the commitment. +func TestCommitAcknowledgement(t *testing.T) { + ack := types.Acknowledgement{ + AppAcknowledgements: [][]byte{ + []byte("some bytes"), + }, + } + + commitment := types.CommitAcknowledgement(ack) + require.Equal(t, "f03b4667413e56aaf086663267913e525c442b56fa1af4fa3f3dab9f37044c5b", hex.EncodeToString(commitment)) +} diff --git a/modules/core/24-host/v2/packet_key_test.go b/modules/core/24-host/v2/packet_key_test.go new file mode 100644 index 00000000000..36642005f75 --- /dev/null +++ b/modules/core/24-host/v2/packet_key_test.go @@ -0,0 +1,34 @@ +package v2_test + +import ( + "encoding/hex" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" +) + +// TestPacketCommitmentKey is primarily used to document the expected key output +// so that other implementations (such as the IBC Solidity) can replicate the +// same key output. But it is also useful to catch any changes in the keys. +func TestPacketCommitmentKey(t *testing.T) { + actual := hex.EncodeToString(v2.PacketCommitmentKey("channel-0", 1)) + require.Equal(t, "6368616e6e656c2d30010000000000000001", actual) +} + +// TestPacketReceiptKey is primarily used to document the expected key output +// so that other implementations (such as the IBC Solidity) can replicate the +// same key output. But it is also useful to catch any changes in the keys. +func TestPacketReceiptKey(t *testing.T) { + actual := hex.EncodeToString(v2.PacketReceiptKey("channel-0", 1)) + require.Equal(t, "6368616e6e656c2d30020000000000000001", actual) +} + +// TestPacketAcknowledgementKey is primarily used to document the expected key output +// so that other implementations (such as the IBC Solidity) can replicate the +// same key output. But it is also useful to catch any changes in the keys. +func TestPacketAcknowledgementKey(t *testing.T) { + actual := hex.EncodeToString(v2.PacketAcknowledgementKey("channel-0", 1)) + require.Equal(t, "6368616e6e656c2d30030000000000000001", actual) +} From 2acc7f64e9d81f6d714ef02be2bf90a9055ab5e0 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 15 Nov 2024 13:56:25 +0100 Subject: [PATCH 131/172] feat: add custom querier to wasm image (#7559) * add custom querier to wasmd + build for arm64 * Use build-push-action for multi-platform build * fix build-args * fix bad bash * lint * add build-essential for building arm64 arch * add g++-aarch64-linux-gnu for arm64 * add some more info to custom query error msg --- .../build-wasm-simd-image-from-tag.yml | 32 ++++++--- .github/workflows/wasm-client.yml | 2 +- modules/light-clients/08-wasm/Dockerfile | 40 ++++++----- modules/light-clients/08-wasm/go.mod | 14 +++- modules/light-clients/08-wasm/go.sum | 39 +++++++++-- .../08-wasm/testing/simapp/app.go | 9 +++ .../testing/simapp/customquery/crypto.go | 19 ++++++ .../testing/simapp/customquery/handler.go | 67 +++++++++++++++++++ 8 files changed, 187 insertions(+), 35 deletions(-) create mode 100644 modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go create mode 100644 modules/light-clients/08-wasm/testing/simapp/customquery/handler.go diff --git a/.github/workflows/build-wasm-simd-image-from-tag.yml b/.github/workflows/build-wasm-simd-image-from-tag.yml index 185e2e6ce31..7503201f341 100644 --- a/.github/workflows/build-wasm-simd-image-from-tag.yml +++ b/.github/workflows/build-wasm-simd-image-from-tag.yml @@ -21,24 +21,36 @@ jobs: with: ref: "${{ env.GIT_TAG }}" fetch-depth: 0 + - uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies run: make python-install-deps + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to the Container registry uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image - run: | - version="$(scripts/get-libwasm-version.py --get-version)" - checksum="$(scripts/get-libwasm-version.py --get-checksum)" - - # remove all `/` or `+` characters from the docker tag and replace them with a -. - # this ensures the docker tag is valid. - docker_tag="$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" - docker build . -t "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}" -f modules/light-clients/08-wasm/Dockerfile --build-arg LIBWASM_VERSION=${version} --build-arg LIBWASM_CHECKSUM=${checksum} - docker push "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}" + + - name: Get arguments and docker tag + run: | + echo "LIBWASM_VERSION=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_ENV + # remove all `/` or `+` characters from the docker tag and replace them with a -. + # this ensures the docker tag is valid. + echo "DOCKER_TAG=$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" >> $GITHUB_ENV + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64, + push: true + tags: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} + file: modules/light-clients/08-wasm/Dockerfile + build-args: LIBWASM_VERSION=${{ env.LIBWASM_VERSION }} diff --git a/.github/workflows/wasm-client.yml b/.github/workflows/wasm-client.yml index 187550bec23..db3969df877 100644 --- a/.github/workflows/wasm-client.yml +++ b/.github/workflows/wasm-client.yml @@ -41,7 +41,7 @@ jobs: - name: Install compiler for arm64. run: | sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV if: matrix.go-arch == 'arm64' - name: Build wasm-client diff --git a/modules/light-clients/08-wasm/Dockerfile b/modules/light-clients/08-wasm/Dockerfile index 8e4bc8999a0..317a9b2a3fe 100644 --- a/modules/light-clients/08-wasm/Dockerfile +++ b/modules/light-clients/08-wasm/Dockerfile @@ -1,19 +1,11 @@ -FROM golang:1.22-alpine3.20 as builder - +FROM golang:1.22-alpine3.20 AS builder-base ARG LIBWASM_VERSION -ARG LIBWASM_CHECKSUM +ARG TARGETARCH RUN test -n "${LIBWASM_VERSION}" -RUN test -n "${LIBWASM_CHECKSUM}" - -RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make; - ENV GOPATH="" -# Grab the static library and copy it to location that will be found by the linker flag `-lwasmvm_muslc`. -ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ${LIBWASM_CHECKSUM} -RUN cp /lib/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a +RUN set -eux; apk add --no-cache ca-certificates build-base git libusb-dev linux-headers curl; # Copy relevant files before go mod download. Replace directives to local paths break if local # files are not copied before go mod download. @@ -25,14 +17,32 @@ ADD LICENSE LICENSE COPY go.mod . COPY go.sum . +RUN go mod download + + +# Since it is not easy to fully cache a RUN script download of libwasmvm, we use two different stages +# and copy the correct file in the final stage. The multistage setup also helps speed up the build process +FROM alpine:3.18 AS amd64-stage +ARG LIBWASM_VERSION +ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a + + +FROM alpine:3.18 AS arm64-stage +ARG LIBWASM_VERSION +ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a + +# We have this one with nothing else in it, because COPY --from can't use variables (but FROM can) +FROM ${TARGETARCH}-stage AS libwasm-stage + +# Having this is a separate stage allows the previous stages to run in parallel +FROM builder-base AS builder WORKDIR /go/modules/light-clients/08-wasm -RUN go mod download +COPY --from=libwasm-stage /lib/libwasmvm_muslc.* /lib/ -RUN GOOS=linux GOARCH=amd64 go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./... +RUN go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./... -FROM alpine:3.18 +FROM alpine:3.18 COPY --from=builder /go/build/simd /bin/simd - ENTRYPOINT ["simd"] diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 8e6fa25bd3e..7fc7b032c1d 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -31,6 +31,7 @@ require ( github.com/cosmos/ibc-go/v9 v9.0.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/prysmaticlabs/prysm/v4 v4.2.1 // used by simapp for custom querier github.com/spf13/cast v1.7.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -74,7 +75,6 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect - github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect @@ -88,6 +88,7 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -103,7 +104,7 @@ require ( github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -130,6 +131,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect + github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -137,6 +139,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.9 // indirect @@ -146,9 +149,11 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/highwayhash v1.0.3 // indirect + github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -161,6 +166,8 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect + github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 // indirect + github.com/prysmaticlabs/gohashtree v0.0.3-alpha // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/cors v1.11.1 // indirect @@ -169,12 +176,15 @@ require ( github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/shamaton/msgpack/v2 v2.2.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.11 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect + github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/tidwall/btree v1.7.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 72a1bc3a368..0fe830a0f1f 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -265,6 +265,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/bazelbuild/rules_go v0.23.2 h1:Wxu7JjqnF78cKZbsBsARLSXx/jlGaSLCnUV3mTlyHvM= +github.com/bazelbuild/rules_go v0.23.2/go.mod h1:MC23Dc/wkXEyk3Wpq6lCqz0ZAYOZDw2DR5y3N1q2i7M= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -362,8 +364,6 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= -github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= -github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -376,6 +376,8 @@ github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6 github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= +github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -424,6 +426,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 h1:xH3SZXIWPj57ogsCYLpfQ9ka1BU1TjmYFrgRvqgMBmw= +github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76/go.mod h1:5SYZGkLhciK5Ds7nXpWz7YNP5iBZb4uqaRHkj+GdTWo= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -531,8 +535,9 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= @@ -680,6 +685,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e h1:wCMygKUQhmcQAjlk2Gquzq6dLmyMv2kF+llRspoRgrk= +github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= @@ -726,6 +733,8 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -769,6 +778,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -786,6 +797,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= @@ -816,13 +829,13 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -896,6 +909,12 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 h1:c3p3UzV4vFA7xaCDphnDWOjpxcadrQ26l5b+ypsvyxo= +github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg= +github.com/prysmaticlabs/gohashtree v0.0.3-alpha h1:1EVinCWdb3Lorq7xn8DYQHf48nCcdAM3Vb18KsFlRWY= +github.com/prysmaticlabs/gohashtree v0.0.3-alpha/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= +github.com/prysmaticlabs/prysm/v4 v4.2.1 h1:eHdK4OuJBUCJCmHgI3c07y0u/vWrKCyOsRN2l/VXQxc= +github.com/prysmaticlabs/prysm/v4 v4.2.1/go.mod h1:0Iz1Q/WiuClvdm/9vQbiKKeToeL/uD3QBjEwV9UExBQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -974,10 +993,14 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= +github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo= +github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -1283,11 +1306,13 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 6c63e87e97e..e9d74cc88e2 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -107,6 +107,7 @@ import ( wasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm" wasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" + "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp/customquery" wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" ica "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts" icacontroller "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller" @@ -434,9 +435,17 @@ func NewSimApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), mockVM, app.GRPCQueryRouter(), ) } else { + querierOption := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ + Custom: customquery.CustomQuerier(), + Stargate: wasmkeeper.AcceptListStargateQuerier( + []string{"/cosmos.base.tendermint.v1beta1.Service/ABCIQuery"}, + app.GRPCQueryRouter(), + ), + }) app.WasmClientKeeper = wasmkeeper.NewKeeperWithConfig( appCodec, runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), app.IBCKeeper.ClientKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), wasmConfig, app.GRPCQueryRouter(), + querierOption, ) } diff --git a/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go b/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go new file mode 100644 index 00000000000..473a7b98295 --- /dev/null +++ b/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go @@ -0,0 +1,19 @@ +package customquery + +import ( + "fmt" + + "github.com/prysmaticlabs/prysm/v4/crypto/bls" +) + +func AggregatePublicKeys(publicKeys [][]byte) (bls.PublicKey, error) { + return bls.AggregatePublicKeys(publicKeys) +} + +func VerifySignature(signature []byte, message [32]byte, publicKeys [][]byte) (bool, error) { + aggregatedPublicKey, err := AggregatePublicKeys(publicKeys) + if err != nil { + return false, fmt.Errorf("failed to aggregate public keys %v", err) + } + return bls.VerifySignature(signature, message, aggregatedPublicKey) +} diff --git a/modules/light-clients/08-wasm/testing/simapp/customquery/handler.go b/modules/light-clients/08-wasm/testing/simapp/customquery/handler.go new file mode 100644 index 00000000000..e6f448ff5a3 --- /dev/null +++ b/modules/light-clients/08-wasm/testing/simapp/customquery/handler.go @@ -0,0 +1,67 @@ +package customquery + +/* + * This custom query handler is used to aggregate public keys and verify a signature using BLS. + * It is used by the 08-wasm union light client, which we we use in the solidity IBC Eureka e2e tests. + * The code here is taken from here: https://github.com/unionlabs/union/tree/main/uniond/app/custom_query + */ +import ( + "encoding/json" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + MessageSize = 32 +) + +type CustomQuery struct { + AggregateVerify *QueryAggregateVerify `json:"aggregate_verify,omitempty"` + Aggregate *QueryAggregate `json:"aggregate,omitempty"` +} +type QueryAggregate struct { + PublicKeys [][]byte `json:"public_keys"` +} +type QueryAggregateVerify struct { + PublicKeys [][]byte `json:"public_keys"` + Signature []byte `json:"signature"` + Message []byte `json:"message"` +} + +func CustomQuerier() func(sdk.Context, json.RawMessage) ([]byte, error) { + return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { + var customQuery CustomQuery + err := json.Unmarshal([]byte(request), &customQuery) + if err != nil { + return nil, fmt.Errorf("failed to parse custom query %v", err) + } + + switch { + case customQuery.Aggregate != nil: + aggregatedPublicKeys, err := AggregatePublicKeys(customQuery.Aggregate.PublicKeys) + if err != nil { + return nil, fmt.Errorf("failed to aggregate public keys %v", err) + } + + return json.Marshal(aggregatedPublicKeys.Marshal()) + case customQuery.AggregateVerify != nil: + if len(customQuery.AggregateVerify.Message) != MessageSize { + return nil, fmt.Errorf("invalid message length (%d), must be a %d bytes hash: %x", len(customQuery.AggregateVerify.Message), MessageSize, customQuery.AggregateVerify.Message) + } + + msg := [MessageSize]byte{} + for i := 0; i < MessageSize; i++ { + msg[i] = customQuery.AggregateVerify.Message[i] + } + result, err := VerifySignature(customQuery.AggregateVerify.Signature, msg, customQuery.AggregateVerify.PublicKeys) + if err != nil { + return nil, fmt.Errorf("failed to verify signature %v", err) + } + + return json.Marshal(result) + default: + return nil, fmt.Errorf("unknown custom query %v", request) + } + } +} From f08fc12ab514c534afe2bacb22c898d824c90111 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:10:53 +0700 Subject: [PATCH 132/172] chore: add unreceived packets rpc (#7561) * add UnreceivedPackets query * lint * minor * use HasChannel and correct flag * add unit test * lint * fix expErr * Update modules/core/04-channel/v2/keeper/grpc_query.go Co-authored-by: Damian Nolan * using HasPacketReceipt --------- Co-authored-by: Damian Nolan --- modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 44 + .../core/04-channel/v2/keeper/grpc_query.go | 49 ++ .../04-channel/v2/keeper/grpc_query_test.go | 149 ++++ modules/core/04-channel/v2/types/query.go | 8 + modules/core/04-channel/v2/types/query.pb.go | 752 ++++++++++++++++-- .../core/04-channel/v2/types/query.pb.gw.go | 123 +++ proto/ibc/core/channel/v2/query.proto | 20 + 8 files changed, 1073 insertions(+), 73 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index a333b0c5055..c9a0d954287 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -25,6 +25,7 @@ func GetQueryCmd() *cobra.Command { getCmdQueryPacketCommitments(), getCmdQueryPacketAcknowledgement(), getCmdQueryPacketReceipt(), + getCmdQueryUnreceivedPackets(), getCmdQueryUnreceivedAcks(), ) diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 66d465afe3c..2be1a004d3e 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -287,6 +287,50 @@ func getCmdQueryPacketReceipt() *cobra.Command { return cmd } +// getCmdQueryUnreceivedPackets defines the command to query all the unreceived +// packets on the receiving chain +func getCmdQueryUnreceivedPackets() *cobra.Command { + cmd := &cobra.Command{ + Use: "unreceived-packets [channel-id]", + Short: "Query a channel/v2 unreceived-packets", + Long: "Query a channel/v2 unreceived-packets by channel-id and sequences", + Example: fmt.Sprintf( + "%s query %s %s unreceived-packet [channel-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences) + if err != nil { + return err + } + + seqs := make([]uint64, len(seqSlice)) + for i := range seqSlice { + seqs[i] = uint64(seqSlice[i]) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.UnreceivedPackets(cmd.Context(), types.NewQueryUnreceivedPacketsRequest(channelID, seqs)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().Int64Slice(flagSequences, []int64{}, "comma separated list of packet sequence numbers") + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // getCmdQueryUnreceivedAcks defines the command to query all the unreceived acks on the original sending chain func getCmdQueryUnreceivedAcks() *cobra.Command { cmd := &cobra.Command{ diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 7495f40763f..644fa315fb5 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -188,6 +188,55 @@ func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketR return types.NewQueryPacketReceiptResponse(hasReceipt, nil, clienttypes.GetSelfHeight(ctx)), nil } +// UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given +// a list of counterparty packet commitments, the querier checks if the packet +// has already been received by checking if a receipt exists on this +// chain for the packet sequence. All packets that haven't been received yet +// are returned in the response +// Usage: To use this method correctly, first query all packet commitments on +// the sending chain using the Query/PacketCommitments gRPC method. +// Then input the returned sequences into the QueryUnreceivedPacketsRequest +// and send the request to this Query/UnreceivedPackets on the **receiving** +// chain. This gRPC method will then return the list of packet sequences that +// are yet to be received on the receiving chain. +// +// NOTE: The querier makes the assumption that the provided list of packet +// commitments is correct and will not function properly if the list +// is not up to date. Ideally the query height should equal the latest height +// on the counterparty's client which represents this chain. +func (q *queryServer) UnreceivedPackets(ctx context.Context, req *types.QueryUnreceivedPacketsRequest) (*types.QueryUnreceivedPacketsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + var unreceivedSequences []uint64 + for i, seq := range req.Sequences { + // filter for invalid sequences to ensure they are not included in the response value. + if seq == 0 { + return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i) + } + + // if the packet receipt does not exist, then it is unreceived + if !q.HasPacketReceipt(ctx, req.ChannelId, seq) { + unreceivedSequences = append(unreceivedSequences, seq) + } + } + + selfHeight := clienttypes.GetSelfHeight(ctx) + return &types.QueryUnreceivedPacketsResponse{ + Sequences: unreceivedSequences, + Height: selfHeight, + }, nil +} + // UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given // a list of counterparty packet acknowledgements, the querier checks if the packet // has already been received by checking if the packet commitment still exists on this diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 03d4e886dd5..b0e107328d3 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -587,6 +587,155 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { } } +func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { + var ( + expSeq []uint64 + path *ibctesting.Path + req *types.QueryUnreceivedPacketsRequest + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: "", + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "invalid seq", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequences: []uint64{0}, + } + }, + status.Error(codes.InvalidArgument, "packet sequence 0 cannot be 0"), + }, + { + "channel not found", + func() { + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: "invalid-channel-id", + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "invalid-channel-id")), + }, + { + "basic success empty packet commitments", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expSeq = []uint64(nil) + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequences: []uint64{}, + } + }, + nil, + }, + { + "basic success unreceived packet commitments", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // no ack exists + + expSeq = []uint64{1} + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequences: []uint64{1}, + } + }, + nil, + }, + { + "basic success unreceived packet commitments, nothing to relay", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1) + + expSeq = []uint64(nil) + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequences: []uint64{1}, + } + }, + nil, + }, + { + "success multiple unreceived packet commitments", + func() { + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + expSeq = []uint64(nil) // reset + packetCommitments := []uint64{} + + // set packet receipt for every other sequence + for seq := uint64(1); seq < 10; seq++ { + packetCommitments = append(packetCommitments, seq) + + if seq%2 == 0 { + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq) + } else { + expSeq = append(expSeq, seq) + } + } + + req = &types.QueryUnreceivedPacketsRequest{ + ChannelId: path.EndpointA.ChannelID, + Sequences: packetCommitments, + } + }, + nil, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.UnreceivedPackets(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expSeq, res.Sequences) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Error(err) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { var ( path *ibctesting.Path diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index 2a70a6481b2..b02d0275537 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -84,3 +84,11 @@ func NewQueryPacketReceiptResponse(exists bool, proof []byte, height clienttypes ProofHeight: height, } } + +// NewQueryPacketReceiptRequest creates and returns a new packet receipt query request. +func NewQueryUnreceivedPacketsRequest(channelID string, sequences []uint64) *QueryUnreceivedPacketsRequest { + return &QueryUnreceivedPacketsRequest{ + ChannelId: channelID, + Sequences: sequences, + } +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 89675bdba42..32b16b47518 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -717,6 +717,116 @@ func (m *QueryPacketReceiptResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryUnreceivedPacketsRequest is the request type for the Query/UnreceivedPackets RPC method +type QueryUnreceivedPacketsRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // list of packet sequences + Sequences []uint64 `protobuf:"varint,2,rep,packed,name=sequences,proto3" json:"sequences,omitempty"` +} + +func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPacketsRequest{} } +func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} +func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{12} +} +func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnreceivedPacketsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnreceivedPacketsRequest.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 *QueryUnreceivedPacketsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnreceivedPacketsRequest.Merge(m, src) +} +func (m *QueryUnreceivedPacketsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUnreceivedPacketsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnreceivedPacketsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnreceivedPacketsRequest proto.InternalMessageInfo + +func (m *QueryUnreceivedPacketsRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryUnreceivedPacketsRequest) GetSequences() []uint64 { + if m != nil { + return m.Sequences + } + return nil +} + +// QueryUnreceivedPacketsResponse is the response type for the Query/UnreceivedPacketCommitments RPC method +type QueryUnreceivedPacketsResponse struct { + // list of unreceived packet sequences + Sequences []uint64 `protobuf:"varint,1,rep,packed,name=sequences,proto3" json:"sequences,omitempty"` + // query block height + Height types.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height"` +} + +func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedPacketsResponse{} } +func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} +func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{13} +} +func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnreceivedPacketsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnreceivedPacketsResponse.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 *QueryUnreceivedPacketsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnreceivedPacketsResponse.Merge(m, src) +} +func (m *QueryUnreceivedPacketsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUnreceivedPacketsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnreceivedPacketsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnreceivedPacketsResponse proto.InternalMessageInfo + +func (m *QueryUnreceivedPacketsResponse) GetSequences() []uint64 { + if m != nil { + return m.Sequences + } + return nil +} + +func (m *QueryUnreceivedPacketsResponse) GetHeight() types.Height { + if m != nil { + return m.Height + } + return types.Height{} +} + // QueryUnreceivedAcks is the request type for the // Query/UnreceivedAcks RPC method type QueryUnreceivedAcksRequest struct { @@ -730,7 +840,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -786,7 +896,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -842,6 +952,8 @@ func init() { proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") proto.RegisterType((*QueryPacketReceiptRequest)(nil), "ibc.core.channel.v2.QueryPacketReceiptRequest") proto.RegisterType((*QueryPacketReceiptResponse)(nil), "ibc.core.channel.v2.QueryPacketReceiptResponse") + proto.RegisterType((*QueryUnreceivedPacketsRequest)(nil), "ibc.core.channel.v2.QueryUnreceivedPacketsRequest") + proto.RegisterType((*QueryUnreceivedPacketsResponse)(nil), "ibc.core.channel.v2.QueryUnreceivedPacketsResponse") proto.RegisterType((*QueryUnreceivedAcksRequest)(nil), "ibc.core.channel.v2.QueryUnreceivedAcksRequest") proto.RegisterType((*QueryUnreceivedAcksResponse)(nil), "ibc.core.channel.v2.QueryUnreceivedAcksResponse") } @@ -849,68 +961,72 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 974 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xce, 0xd8, 0x6e, 0x3e, 0x5e, 0x07, 0x08, 0xd3, 0x20, 0xcc, 0x92, 0xba, 0xee, 0x1e, 0xc0, - 0x54, 0xed, 0x4e, 0xec, 0x56, 0x7c, 0x48, 0xad, 0x50, 0x12, 0x95, 0x36, 0x48, 0xa0, 0xb0, 0x01, - 0x24, 0x38, 0x60, 0xad, 0xd7, 0xd3, 0xcd, 0xca, 0xf6, 0xcc, 0xd6, 0x33, 0x36, 0xad, 0xaa, 0x5c, - 0x38, 0x70, 0x46, 0xf4, 0xc6, 0x2f, 0x80, 0x5f, 0x01, 0x12, 0x97, 0x4a, 0x5c, 0x2a, 0xf5, 0xc2, - 0x09, 0x41, 0x82, 0xc4, 0x91, 0xbf, 0x80, 0x3c, 0x3b, 0x6b, 0xaf, 0x9d, 0xb5, 0xb3, 0x4b, 0x9b, - 0xdb, 0xee, 0xeb, 0xf7, 0xe3, 0x79, 0x9e, 0x7d, 0x3f, 0x64, 0xb8, 0xe8, 0x37, 0x5d, 0xe2, 0xf2, - 0x1e, 0x25, 0xee, 0x81, 0xc3, 0x18, 0xed, 0x90, 0x41, 0x9d, 0xdc, 0xeb, 0xd3, 0xde, 0x03, 0x2b, - 0xe8, 0x71, 0xc9, 0xf1, 0x79, 0xbf, 0xe9, 0x5a, 0x43, 0x07, 0x4b, 0x3b, 0x58, 0x83, 0xba, 0x71, - 0xd9, 0xe5, 0xa2, 0xcb, 0x05, 0x69, 0x3a, 0x82, 0x86, 0xde, 0x64, 0x50, 0x6b, 0x52, 0xe9, 0xd4, - 0x48, 0xe0, 0x78, 0x3e, 0x73, 0xa4, 0xcf, 0x59, 0x98, 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x50, - 0xdf, 0x3b, 0x90, 0xa5, 0xbc, 0xe2, 0x69, 0xc4, 0x78, 0x86, 0x9f, 0x64, 0x50, 0xb3, 0xee, 0x28, - 0x0f, 0xcd, 0xb2, 0xa8, 0xa2, 0x42, 0x93, 0xf9, 0x85, 0x66, 0xba, 0xe7, 0xb8, 0x6d, 0x2a, 0x77, - 0x78, 0xb7, 0xeb, 0xcb, 0x2e, 0x65, 0x32, 0x1d, 0x53, 0x6c, 0xc0, 0x72, 0x44, 0x41, 0x81, 0x2b, - 0xd8, 0xa3, 0x77, 0xf3, 0x87, 0x48, 0x85, 0x93, 0xb9, 0xb5, 0x0a, 0x65, 0x00, 0x77, 0x64, 0x55, - 0xc9, 0x57, 0xed, 0x98, 0xe5, 0x2c, 0x79, 0x7f, 0x3b, 0x0b, 0x9c, 0x48, 0xc9, 0xfc, 0x03, 0x80, - 0xf1, 0x74, 0x29, 0x80, 0xc5, 0xfa, 0x1b, 0x56, 0x38, 0x8a, 0xd6, 0x70, 0x14, 0xad, 0x70, 0x70, - 0xf5, 0x28, 0x5a, 0x7b, 0x8e, 0x47, 0x75, 0x6a, 0x3b, 0x16, 0x69, 0xfe, 0x83, 0xa0, 0x3c, 0x0b, - 0x88, 0x96, 0x69, 0x1b, 0x8a, 0x63, 0x51, 0x44, 0x09, 0x55, 0xf2, 0xd5, 0x62, 0xbd, 0x92, 0xd8, - 0xcf, 0x61, 0x92, 0x7d, 0xe9, 0x48, 0x6a, 0xc7, 0x83, 0xf0, 0xed, 0x04, 0xb8, 0x6f, 0x9e, 0x0a, - 0x37, 0x04, 0x10, 0xc7, 0x8b, 0xdf, 0x85, 0xc5, 0x8c, 0xba, 0x6b, 0x7f, 0xf3, 0x2b, 0xb8, 0x14, - 0x23, 0xba, 0xe5, 0xb6, 0x19, 0xff, 0xba, 0x43, 0x5b, 0x1e, 0x7d, 0x4e, 0xfd, 0xf6, 0x13, 0x02, - 0x73, 0x5e, 0x01, 0xad, 0x66, 0x15, 0x5e, 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 0xfa, 0xf3, 0xa8, 0x8c, 0xbe, 0x3b, 0x2e, 0x2f, 0x3c, 0x39, 0x2e, 0x2f, - 0xfc, 0x7e, 0x5c, 0x5e, 0xf8, 0xf2, 0x86, 0xe7, 0xcb, 0x83, 0x7e, 0xd3, 0x72, 0x79, 0x97, 0xe8, - 0xff, 0x4d, 0x7e, 0xd3, 0xbd, 0xea, 0x71, 0x32, 0x78, 0x8f, 0x74, 0x79, 0xab, 0xdf, 0xa1, 0x22, - 0x84, 0xb7, 0x79, 0xfd, 0x6a, 0x0c, 0xa1, 0x7c, 0x10, 0x50, 0xd1, 0x5c, 0x54, 0x7f, 0x55, 0xae, - 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xcb, 0xc4, 0x1e, 0xa9, 0x0d, 0x00, 0x00, + // 1028 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xee, 0x49, 0xb2, 0xb5, 0x7d, 0x53, 0xa0, 0x3b, 0x2b, 0x22, 0x98, 0x2e, 0xcb, 0x7c, 0x01, + 0x61, 0xda, 0x7c, 0x9a, 0x6c, 0xe2, 0x43, 0xda, 0x84, 0xda, 0x6a, 0x6c, 0x45, 0x02, 0x15, 0x17, + 0x90, 0x40, 0xd3, 0x22, 0xc7, 0x39, 0x73, 0xad, 0x24, 0x3e, 0x5e, 0xec, 0x84, 0x4e, 0x53, 0x6f, + 0xb8, 0xe0, 0x1a, 0xb1, 0x3b, 0x7e, 0x01, 0xfc, 0x0a, 0x90, 0xb8, 0x99, 0xc4, 0xcd, 0xa4, 0x71, + 0xc1, 0x15, 0x82, 0x16, 0x89, 0xbf, 0x81, 0x72, 0xce, 0x71, 0x62, 0x27, 0xb6, 0x6b, 0xb3, 0xf5, + 0xce, 0x3e, 0x79, 0x3f, 0x9e, 0xe7, 0xf1, 0xfb, 0x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, 0x00, 0xff, 0xff, 0x9c, 0x92, 0x15, 0x18, + 0x66, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -937,6 +1053,7 @@ type QueryClient interface { PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) + UnreceivedPackets(ctx context.Context, in *QueryUnreceivedPacketsRequest, opts ...grpc.CallOption) (*QueryUnreceivedPacketsResponse, error) // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAcksRequest, opts ...grpc.CallOption) (*QueryUnreceivedAcksResponse, error) } @@ -1003,6 +1120,15 @@ func (c *queryClient) PacketReceipt(ctx context.Context, in *QueryPacketReceiptR return out, nil } +func (c *queryClient) UnreceivedPackets(ctx context.Context, in *QueryUnreceivedPacketsRequest, opts ...grpc.CallOption) (*QueryUnreceivedPacketsResponse, error) { + out := new(QueryUnreceivedPacketsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/UnreceivedPackets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAcksRequest, opts ...grpc.CallOption) (*QueryUnreceivedAcksResponse, error) { out := new(QueryUnreceivedAcksResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/UnreceivedAcks", in, out, opts...) @@ -1026,6 +1152,7 @@ type QueryServer interface { PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(context.Context, *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) + UnreceivedPackets(context.Context, *QueryUnreceivedPacketsRequest) (*QueryUnreceivedPacketsResponse, error) // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. UnreceivedAcks(context.Context, *QueryUnreceivedAcksRequest) (*QueryUnreceivedAcksResponse, error) } @@ -1052,6 +1179,9 @@ func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req func (*UnimplementedQueryServer) PacketReceipt(ctx context.Context, req *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketReceipt not implemented") } +func (*UnimplementedQueryServer) UnreceivedPackets(ctx context.Context, req *QueryUnreceivedPacketsRequest) (*QueryUnreceivedPacketsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnreceivedPackets not implemented") +} func (*UnimplementedQueryServer) UnreceivedAcks(ctx context.Context, req *QueryUnreceivedAcksRequest) (*QueryUnreceivedAcksResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UnreceivedAcks not implemented") } @@ -1168,6 +1298,24 @@ func _Query_PacketReceipt_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Query_UnreceivedPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUnreceivedPacketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UnreceivedPackets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/UnreceivedPackets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UnreceivedPackets(ctx, req.(*QueryUnreceivedPacketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_UnreceivedAcks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryUnreceivedAcksRequest) if err := dec(in); err != nil { @@ -1214,6 +1362,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketReceipt", Handler: _Query_PacketReceipt_Handler, }, + { + MethodName: "UnreceivedPackets", + Handler: _Query_UnreceivedPackets_Handler, + }, { MethodName: "UnreceivedAcks", Handler: _Query_UnreceivedAcks_Handler, @@ -1718,7 +1870,7 @@ func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryUnreceivedAcksRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedPacketsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1728,20 +1880,20 @@ func (m *QueryUnreceivedAcksRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryUnreceivedAcksRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PacketAckSequences) > 0 { - dAtA10 := make([]byte, len(m.PacketAckSequences)*10) + if len(m.Sequences) > 0 { + dAtA10 := make([]byte, len(m.Sequences)*10) var j9 int - for _, num := range m.PacketAckSequences { + for _, num := range m.Sequences { for num >= 1<<7 { dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -1766,7 +1918,7 @@ func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryUnreceivedAcksResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedPacketsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1776,12 +1928,12 @@ func (m *QueryUnreceivedAcksResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryUnreceivedAcksResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1817,6 +1969,105 @@ func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *QueryUnreceivedAcksRequest) 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 *QueryUnreceivedAcksRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketAckSequences) > 0 { + dAtA15 := make([]byte, len(m.PacketAckSequences)*10) + var j14 int + for _, num := range m.PacketAckSequences { + for num >= 1<<7 { + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j14++ + } + dAtA15[j14] = uint8(num) + j14++ + } + i -= j14 + copy(dAtA[i:], dAtA15[:j14]) + i = encodeVarintQuery(dAtA, i, uint64(j14)) + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUnreceivedAcksResponse) 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 *QueryUnreceivedAcksResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sequences) > 0 { + dAtA18 := make([]byte, len(m.Sequences)*10) + var j17 int + for _, num := range m.Sequences { + for num >= 1<<7 { + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j17++ + } + dAtA18[j17] = uint8(num) + j17++ + } + i -= j17 + copy(dAtA[i:], dAtA18[:j17]) + i = encodeVarintQuery(dAtA, i, uint64(j17)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2029,6 +2280,44 @@ func (m *QueryPacketReceiptResponse) Size() (n int) { return n } +func (m *QueryUnreceivedPacketsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Sequences) > 0 { + l = 0 + for _, e := range m.Sequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryUnreceivedPacketsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Sequences) > 0 { + l = 0 + for _, e := range m.Sequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + l = m.Height.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryUnreceivedAcksRequest) Size() (n int) { if m == nil { return 0 @@ -3501,6 +3790,323 @@ func (m *QueryPacketReceiptResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryUnreceivedPacketsRequest) 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 ErrIntOverflowQuery + } + 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: QueryUnreceivedPacketsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnreceivedPacketsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Sequences) == 0 { + m.Sequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Sequences", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnreceivedPacketsResponse) 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 ErrIntOverflowQuery + } + 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: QueryUnreceivedPacketsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnreceivedPacketsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Sequences) == 0 { + m.Sequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Sequences", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryUnreceivedAcksRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 995de0f48cc..9454ddcb63a 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -459,6 +459,82 @@ func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime. } +func request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnreceivedPacketsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequences"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequences") + } + + protoReq.Sequences, err = runtime.Uint64Slice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequences", err) + } + + msg, err := client.UnreceivedPackets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnreceivedPacketsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + val, ok = pathParams["sequences"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequences") + } + + protoReq.Sequences, err = runtime.Uint64Slice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequences", err) + } + + msg, err := server.UnreceivedPackets(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryUnreceivedAcksRequest var metadata runtime.ServerMetadata @@ -679,6 +755,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_UnreceivedPackets_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnreceivedPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -863,6 +962,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_UnreceivedPackets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnreceivedPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -899,6 +1018,8 @@ var ( pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -915,5 +1036,7 @@ var ( forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage + forward_Query_UnreceivedPackets_0 = runtime.ForwardResponseMessage + forward_Query_UnreceivedAcks_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 80b54c48e21..ca77940306d 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -43,6 +43,11 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}"; } + rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/" + "{sequences}/unreceived_packets"; + } + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { option (google.api.http).get = @@ -151,6 +156,21 @@ message QueryPacketReceiptResponse { ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; } +// QueryUnreceivedPacketsRequest is the request type for the Query/UnreceivedPackets RPC method +message QueryUnreceivedPacketsRequest { + // channel unique identifier + string channel_id = 1; + // list of packet sequences + repeated uint64 sequences = 2; +} + +// QueryUnreceivedPacketsResponse is the response type for the Query/UnreceivedPacketCommitments RPC method +message QueryUnreceivedPacketsResponse { + // list of unreceived packet sequences + repeated uint64 sequences = 1; + // query block height + ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; +} // QueryUnreceivedAcks is the request type for the // Query/UnreceivedAcks RPC method message QueryUnreceivedAcksRequest { From 7ccd1c0281f889aac2290895859bea1e4143c324 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Tue, 19 Nov 2024 09:16:09 +0000 Subject: [PATCH 133/172] Ibcmodulev2 transfer application spike (#7524) * chore: adding ibc module v2 and on recv implementation with hard coded sequence * chore: adding ack callback * chore: adding send packet * chore: adding transfer v2 module to app wiring * chore: adding happy path and basic failure for send and recv for transfer module * chore: adding ack test for transfer * chore: fix some linter errors * chore: adding timeout test for transfer v2 * chore: adding test case which ensures tokens can be transfered over both v1 and v2 * chore: full transfer flow from A - B - C - B - A * chore: separated test out into subtests * chore: add sequence as argument to OnRecvPacket * chore: adding TODOs for next steps * chore: adding transferv2 module to wasm simapp * chore: refactor OnTimeout to accept sequence * chore: refactor OnAck to accept sequence * chore: switch argument order * wip: mid merge with feature branch, build will be broken * Fix timeoutTimestamp for tests * linter * chore: removing duplicate imports in wasm simapp * chore: adding channelkeeperv2 query server * register grpc gateway routes * fix ack structure for v2 transfer tests * lint * make signature consistent --------- Co-authored-by: chatton Co-authored-by: bznein Co-authored-by: Gjermund Garaba --- modules/apps/transfer/keeper/export_test.go | 5 - modules/apps/transfer/keeper/forwarding.go | 10 +- modules/apps/transfer/keeper/genesis.go | 2 +- modules/apps/transfer/keeper/invariants.go | 2 +- modules/apps/transfer/keeper/keeper.go | 20 +- modules/apps/transfer/keeper/migrations.go | 6 +- modules/apps/transfer/keeper/msg_server.go | 4 +- modules/apps/transfer/keeper/relay.go | 44 +- modules/apps/transfer/types/packet.go | 2 + modules/apps/transfer/v2/ibc_module.go | 133 ++++ modules/apps/transfer/v2/keeper/keeper.go | 249 ++++++++ .../apps/transfer/v2/keeper/keeper_test.go | 58 ++ .../transfer/v2/keeper/msg_server_test.go | 597 ++++++++++++++++++ .../core/04-channel/v2/keeper/msg_server.go | 15 +- .../04-channel/v2/keeper/msg_server_test.go | 10 +- modules/core/04-channel/v2/keeper/packet.go | 7 +- modules/core/api/module.go | 11 +- .../08-wasm/testing/simapp/app.go | 12 +- testing/mock/v2/ibc_app.go | 8 +- testing/mock/v2/ibc_module.go | 12 +- testing/path.go | 7 + testing/simapp/app.go | 7 + 22 files changed, 1144 insertions(+), 77 deletions(-) create mode 100644 modules/apps/transfer/v2/ibc_module.go create mode 100644 modules/apps/transfer/v2/keeper/keeper.go create mode 100644 modules/apps/transfer/v2/keeper/keeper_test.go create mode 100644 modules/apps/transfer/v2/keeper/msg_server_test.go diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go index 5efd6a85910..dedfd560b9b 100644 --- a/modules/apps/transfer/keeper/export_test.go +++ b/modules/apps/transfer/keeper/export_test.go @@ -54,11 +54,6 @@ func (k Keeper) GetAllForwardedPackets(ctx sdk.Context) []types.ForwardedPacket return k.getAllForwardedPackets(ctx) } -// IsBlockedAddr is a wrapper around isBlockedAddr for testing purposes -func (k Keeper) IsBlockedAddr(addr sdk.AccAddress) bool { - return k.isBlockedAddr(addr) -} - // CreatePacketDataBytesFromVersion is a wrapper around createPacketDataBytesFromVersion for testing purposes func CreatePacketDataBytesFromVersion(appVersion, sender, receiver, memo string, tokens types.Tokens, hops []types.Hop) ([]byte, error) { return createPacketDataBytesFromVersion(appVersion, sender, receiver, memo, tokens, hops) diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index cb68b9d919a..967fed6beff 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -22,7 +22,7 @@ func (k Keeper) forwardPacket(ctx context.Context, data types.FungibleTokenPacke } // sending from module account (used as a temporary forward escrow) to the original receiver address. - sender := k.authKeeper.GetModuleAddress(types.ModuleName) + sender := k.AuthKeeper.GetModuleAddress(types.ModuleName) msg := types.NewMsgTransfer( data.Forwarding.Hops[0].PortId, @@ -68,7 +68,7 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann 2. Burning voucher tokens if the funds are foreign */ - forwardingAddr := k.authKeeper.GetModuleAddress(types.ModuleName) + forwardingAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) escrow := types.GetEscrowAddress(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) // we can iterate over the received tokens of forwardedPacket by iterating over the sent tokens of failedPacketData @@ -83,12 +83,12 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann // given that the packet is being reversed, we check the DestinationChannel and DestinationPort // of the forwardedPacket to see if a hop was added to the trace during the receive step if token.Denom.HasPrefix(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) { - if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil { + if err := k.BankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil { return err } } else { // send it back to the escrow address - if err := k.escrowCoin(ctx, forwardingAddr, escrow, coin); err != nil { + if err := k.EscrowCoin(ctx, forwardingAddr, escrow, coin); err != nil { return err } } @@ -101,7 +101,7 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann func (k Keeper) getReceiverFromPacketData(data types.FungibleTokenPacketDataV2) (sdk.AccAddress, error) { if data.HasForwarding() { // since data.Receiver can potentially be a non-CosmosSDK AccAddress, we return early if the packet should be forwarded - return k.authKeeper.GetModuleAddress(types.ModuleName), nil + return k.AuthKeeper.GetModuleAddress(types.ModuleName), nil } receiver, err := sdk.AccAddressFromBech32(data.Receiver) diff --git a/modules/apps/transfer/keeper/genesis.go b/modules/apps/transfer/keeper/genesis.go index d9653ce3c6c..330c6f0360d 100644 --- a/modules/apps/transfer/keeper/genesis.go +++ b/modules/apps/transfer/keeper/genesis.go @@ -12,7 +12,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { for _, denom := range state.Denoms { k.SetDenom(ctx, denom) - k.setDenomMetadata(ctx, denom) + k.SetDenomMetadata(ctx, denom) } k.SetParams(ctx, state.Params) diff --git a/modules/apps/transfer/keeper/invariants.go b/modules/apps/transfer/keeper/invariants.go index dded2822ec9..3dc8f95b458 100644 --- a/modules/apps/transfer/keeper/invariants.go +++ b/modules/apps/transfer/keeper/invariants.go @@ -33,7 +33,7 @@ func TotalEscrowPerDenomInvariants(k *Keeper) sdk.Invariant { transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, portID) for _, channel := range transferChannels { escrowAddress := types.GetEscrowAddress(portID, channel.ChannelId) - escrowBalances := k.bankKeeper.GetAllBalances(ctx, escrowAddress) + escrowBalances := k.BankKeeper.GetAllBalances(ctx, escrowAddress) actualTotalEscrowed = actualTotalEscrowed.Add(escrowBalances...) } diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 1ebb14ace71..b9cb766ab48 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -34,8 +34,8 @@ type Keeper struct { ics4Wrapper porttypes.ICS4Wrapper channelKeeper types.ChannelKeeper - authKeeper types.AccountKeeper - bankKeeper types.BankKeeper + AuthKeeper types.AccountKeeper + BankKeeper types.BankKeeper // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -68,8 +68,8 @@ func NewKeeper( legacySubspace: legacySubspace, ics4Wrapper: ics4Wrapper, channelKeeper: channelKeeper, - authKeeper: authKeeper, - bankKeeper: bankKeeper, + AuthKeeper: authKeeper, + BankKeeper: bankKeeper, authority: authority, } } @@ -195,8 +195,8 @@ func (k Keeper) IterateDenoms(ctx context.Context, cb func(denom types.Denom) bo } } -// setDenomMetadata sets an IBC token's denomination metadata -func (k Keeper) setDenomMetadata(ctx context.Context, denom types.Denom) { +// SetDenomMetadata sets an IBC token's denomination metadata +func (k Keeper) SetDenomMetadata(ctx context.Context, denom types.Denom) { metadata := banktypes.Metadata{ Description: fmt.Sprintf("IBC token from %s", denom.Path()), DenomUnits: []*banktypes.DenomUnit{ @@ -214,7 +214,7 @@ func (k Keeper) setDenomMetadata(ctx context.Context, denom types.Denom) { Symbol: strings.ToUpper(denom.Base), } - k.bankKeeper.SetDenomMetaData(ctx, metadata) + k.BankKeeper.SetDenomMetaData(ctx, metadata) } // GetTotalEscrowForDenom gets the total amount of source chain tokens that @@ -385,11 +385,11 @@ func (k Keeper) iterateForwardedPackets(ctx context.Context, cb func(packet type // IsBlockedAddr checks if the given address is allowed to send or receive tokens. // The module account is always allowed to send and receive tokens. -func (k Keeper) isBlockedAddr(addr sdk.AccAddress) bool { - moduleAddr := k.authKeeper.GetModuleAddress(types.ModuleName) +func (k Keeper) IsBlockedAddr(addr sdk.AccAddress) bool { + moduleAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) if addr.Equals(moduleAddr) { return false } - return k.bankKeeper.BlockedAddr(addr) + return k.BankKeeper.BlockedAddr(addr) } diff --git a/modules/apps/transfer/keeper/migrations.go b/modules/apps/transfer/keeper/migrations.go index ab1e526d4a2..bc82b83c21a 100644 --- a/modules/apps/transfer/keeper/migrations.go +++ b/modules/apps/transfer/keeper/migrations.go @@ -43,7 +43,7 @@ func (m Migrator) MigrateDenomMetadata(ctx sdk.Context) error { m.keeper.iterateDenomTraces(ctx, func(dt internaltypes.DenomTrace) (stop bool) { // check if the metadata for the given denom trace does not already exist - if !m.keeper.bankKeeper.HasDenomMetaData(ctx, dt.IBCDenom()) { + if !m.keeper.BankKeeper.HasDenomMetaData(ctx, dt.IBCDenom()) { m.keeper.setDenomMetadataWithDenomTrace(ctx, dt) } return false @@ -61,7 +61,7 @@ func (m Migrator) MigrateTotalEscrowForDenom(ctx sdk.Context) error { transferChannels := m.keeper.channelKeeper.GetAllChannelsWithPortPrefix(ctx, portID) for _, channel := range transferChannels { escrowAddress := types.GetEscrowAddress(portID, channel.ChannelId) - escrowBalances := m.keeper.bankKeeper.GetAllBalances(ctx, escrowAddress) + escrowBalances := m.keeper.BankKeeper.GetAllBalances(ctx, escrowAddress) totalEscrowed = totalEscrowed.Add(escrowBalances...) } @@ -164,5 +164,5 @@ func (k Keeper) setDenomMetadataWithDenomTrace(ctx sdk.Context, denomTrace inter Symbol: strings.ToUpper(denomTrace.BaseDenom), } - k.bankKeeper.SetDenomMetaData(ctx, metadata) + k.BankKeeper.SetDenomMetaData(ctx, metadata) } diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index b0cb57398b7..bf77a3241b0 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -29,11 +29,11 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. coins := msg.GetCoins() - if err := k.bankKeeper.IsSendEnabledCoins(ctx, coins...); err != nil { + if err := k.BankKeeper.IsSendEnabledCoins(ctx, coins...); err != nil { return nil, errorsmod.Wrapf(types.ErrSendDisabled, err.Error()) } - if k.isBlockedAddr(sender) { + if k.IsBlockedAddr(sender) { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 71ef740132c..a69ab8dbfff 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -96,7 +96,7 @@ func (k Keeper) sendTransfer( for _, coin := range coins { // Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom. if coin.Amount.Equal(types.UnboundedSpendLimit()) { - coin.Amount = k.bankKeeper.GetBalance(ctx, sender, coin.Denom).Amount + coin.Amount = k.BankKeeper.GetBalance(ctx, sender, coin.Denom).Amount } token, err := k.tokenFromCoin(ctx, coin) @@ -112,13 +112,13 @@ func (k Keeper) sendTransfer( // the token, then we must be returning the token back to the chain they originated from if token.Denom.HasPrefix(sourcePort, sourceChannel) { // transfer the coins to the module account and burn them - if err := k.bankKeeper.SendCoinsFromAccountToModule( + if err := k.BankKeeper.SendCoinsFromAccountToModule( ctx, sender, types.ModuleName, sdk.NewCoins(coin), ); err != nil { return 0, err } - if err := k.bankKeeper.BurnCoins( + if err := k.BankKeeper.BurnCoins( ctx, types.ModuleName, sdk.NewCoins(coin), ); err != nil { // NOTE: should not happen as the module account was @@ -129,7 +129,7 @@ func (k Keeper) sendTransfer( } else { // obtain the escrow address for the source channel end escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) - if err := k.escrowCoin(ctx, sender, escrowAddress, coin); err != nil { + if err := k.EscrowCoin(ctx, sender, escrowAddress, coin); err != nil { return 0, err } } @@ -178,7 +178,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da return err } - if k.isBlockedAddr(receiver) { + if k.IsBlockedAddr(receiver) { return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", receiver) } @@ -206,7 +206,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da coin := sdk.NewCoin(token.Denom.IBCDenom(), transferAmount) escrowAddress := types.GetEscrowAddress(packet.GetDestPort(), packet.GetDestChannel()) - if err := k.unescrowCoin(ctx, escrowAddress, receiver, coin); err != nil { + if err := k.UnescrowCoin(ctx, escrowAddress, receiver, coin); err != nil { return err } @@ -224,8 +224,8 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da } voucherDenom := token.Denom.IBCDenom() - if !k.bankKeeper.HasDenomMetaData(ctx, voucherDenom) { - k.setDenomMetadata(ctx, token.Denom) + if !k.BankKeeper.HasDenomMetaData(ctx, voucherDenom) { + k.SetDenomMetadata(ctx, token.Denom) } events.EmitDenomEvent(ctx, token) @@ -233,15 +233,15 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da voucher := sdk.NewCoin(voucherDenom, transferAmount) // mint new tokens if the source of the transfer is the same chain - if err := k.bankKeeper.MintCoins( + if err := k.BankKeeper.MintCoins( ctx, types.ModuleName, sdk.NewCoins(voucher), ); err != nil { return errorsmod.Wrap(err, "failed to mint IBC tokens") } // send to receiver - moduleAddr := k.authKeeper.GetModuleAddress(types.ModuleName) - if err := k.bankKeeper.SendCoins( + moduleAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) + if err := k.BankKeeper.SendCoins( ctx, moduleAddr, receiver, sdk.NewCoins(voucher), ); err != nil { return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String()) @@ -346,14 +346,14 @@ func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Pack if err != nil { return err } - if k.isBlockedAddr(sender) { + if k.IsBlockedAddr(sender) { return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", sender) } // escrow address for unescrowing tokens back to sender escrowAddress := types.GetEscrowAddress(packet.GetSourcePort(), packet.GetSourceChannel()) - moduleAccountAddr := k.authKeeper.GetModuleAddress(types.ModuleName) + moduleAccountAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) for _, token := range data.Tokens { coin, err := token.ToCoin() if err != nil { @@ -364,17 +364,17 @@ func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Pack // then the tokens were burnt when the packet was sent and we must mint new tokens if token.Denom.HasPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) { // mint vouchers back to sender - if err := k.bankKeeper.MintCoins( + if err := k.BankKeeper.MintCoins( ctx, types.ModuleName, sdk.NewCoins(coin), ); err != nil { return err } - if err := k.bankKeeper.SendCoins(ctx, moduleAccountAddr, sender, sdk.NewCoins(coin)); err != nil { + if err := k.BankKeeper.SendCoins(ctx, moduleAccountAddr, sender, sdk.NewCoins(coin)); err != nil { panic(fmt.Errorf("unable to send coins from module to account despite previously minting coins to module account: %v", err)) } } else { - if err := k.unescrowCoin(ctx, escrowAddress, sender, coin); err != nil { + if err := k.UnescrowCoin(ctx, escrowAddress, sender, coin); err != nil { return err } } @@ -383,10 +383,10 @@ func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Pack return nil } -// escrowCoin will send the given coin from the provided sender to the escrow address. It will also +// EscrowCoin will send the given coin from the provided sender to the escrow address. It will also // update the total escrowed amount by adding the escrowed coin's amount to the current total escrow. -func (k Keeper) escrowCoin(ctx context.Context, sender, escrowAddress sdk.AccAddress, coin sdk.Coin) error { - if err := k.bankKeeper.SendCoins(ctx, sender, escrowAddress, sdk.NewCoins(coin)); err != nil { +func (k Keeper) EscrowCoin(ctx context.Context, sender, escrowAddress sdk.AccAddress, coin sdk.Coin) error { + if err := k.BankKeeper.SendCoins(ctx, sender, escrowAddress, sdk.NewCoins(coin)); err != nil { // failure is expected for insufficient balances return err } @@ -399,10 +399,10 @@ func (k Keeper) escrowCoin(ctx context.Context, sender, escrowAddress sdk.AccAdd return nil } -// unescrowCoin will send the given coin from the escrow address to the provided receiver. It will also +// UnescrowCoin will send the given coin from the escrow address to the provided receiver. It will also // update the total escrow by deducting the unescrowed coin's amount from the current total escrow. -func (k Keeper) unescrowCoin(ctx context.Context, escrowAddress, receiver sdk.AccAddress, coin sdk.Coin) error { - if err := k.bankKeeper.SendCoins(ctx, escrowAddress, receiver, sdk.NewCoins(coin)); err != nil { +func (k Keeper) UnescrowCoin(ctx context.Context, escrowAddress, receiver sdk.AccAddress, coin sdk.Coin) error { + if err := k.BankKeeper.SendCoins(ctx, escrowAddress, receiver, sdk.NewCoins(coin)); err != nil { // NOTE: this error is only expected to occur given an unexpected bug or a malicious // counterparty module. The bug may occur in bank or any part of the code that allows // the escrow address to be drained. A malicious counterparty module could drain the diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 209c721d75b..98525dac769 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -210,6 +210,8 @@ func (ftpd FungibleTokenPacketDataV2) HasForwarding() bool { // UnmarshalPacketData attempts to unmarshal the provided packet data bytes into a FungibleTokenPacketDataV2. // The version of ics20 should be provided and should be either ics20-1 or ics20-2. func UnmarshalPacketData(bz []byte, ics20Version string) (FungibleTokenPacketDataV2, error) { + // TODO: in transfer ibc module V2, we need to respect he encoding value passed via the payload, some hard coded assumptions about + // encoding exist here based on the ics20 version passed in. switch ics20Version { case V1: var datav1 FungibleTokenPacketData diff --git a/modules/apps/transfer/v2/ibc_module.go b/modules/apps/transfer/v2/ibc_module.go new file mode 100644 index 00000000000..fcbedc6ef03 --- /dev/null +++ b/modules/apps/transfer/v2/ibc_module.go @@ -0,0 +1,133 @@ +package v2 + +import ( + "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/events" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/api" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" +) + +var _ api.IBCModule = (*IBCModule)(nil) + +// NewIBCModule creates a new IBCModule given the keeper +func NewIBCModule(k *keeper.Keeper) *IBCModule { + return &IBCModule{ + keeper: k, + } +} + +type IBCModule struct { + keeper *keeper.Keeper +} + +func (im *IBCModule) OnSendPacket(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, signer sdk.AccAddress) error { + ctx := sdk.UnwrapSDKContext(goCtx) + + if !im.keeper.GetParams(ctx).SendEnabled { + return transfertypes.ErrSendDisabled + } + + if im.keeper.IsBlockedAddr(signer) { + return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", signer) + } + + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + if err != nil { + return err + } + + return im.keeper.OnSendPacket(ctx, sourceChannel, payload, data, signer) +} + +func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { + var ( + ackErr error + data transfertypes.FungibleTokenPacketDataV2 + ) + + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + recvResult := types.RecvPacketResult{ + Status: types.PacketStatus_Success, + Acknowledgement: ack.Acknowledgement(), + } + // we are explicitly wrapping this emit event call in an anonymous function so that + // the packet data is evaluated after it has been assigned a value. + defer func() { + events.EmitOnRecvPacketEvent(ctx, data, ack, ackErr) + }() + + data, ackErr = transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + if ackErr != nil { + ack = channeltypes.NewErrorAcknowledgement(ackErr) + im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), sequence)) + return types.RecvPacketResult{ + Status: types.PacketStatus_Failure, + Acknowledgement: ack.Acknowledgement(), + } + } + + if ackErr = im.keeper.OnRecvPacket(ctx, sourceChannel, destinationChannel, payload, data); ackErr != nil { + ack = channeltypes.NewErrorAcknowledgement(ackErr) + im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), sequence)) + return types.RecvPacketResult{ + Status: types.PacketStatus_Failure, + Acknowledgement: ack.Acknowledgement(), + } + } + + im.keeper.Logger(ctx).Info("successfully handled ICS-20 packet", "sequence", sequence) + + if data.HasForwarding() { + // NOTE: acknowledgement will be written asynchronously + return types.RecvPacketResult{ + Status: types.PacketStatus_Async, + } + } + + // NOTE: acknowledgement will be written synchronously during IBC handler execution. + return recvResult +} + +func (im *IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, relayer sdk.AccAddress) error { + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + if err != nil { + return err + } + + // refund tokens + if err := im.keeper.OnTimeoutPacket(ctx, payload.SourcePort, sourceChannel, data); err != nil { + return err + } + + events.EmitOnTimeoutEvent(ctx, data) + return nil +} + +func (im *IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, acknowledgement []byte, payload types.Payload, relayer sdk.AccAddress) error { + var ack channeltypes.Acknowledgement + if err := transfertypes.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet acknowledgement: %v", err) + } + + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + if err != nil { + return err + } + + if err := im.keeper.OnAcknowledgementPacket(ctx, payload.SourcePort, sourceChannel, data, ack); err != nil { + return err + } + + events.EmitOnAcknowledgementPacketEvent(ctx, data, ack) + return nil +} diff --git a/modules/apps/transfer/v2/keeper/keeper.go b/modules/apps/transfer/v2/keeper/keeper.go new file mode 100644 index 00000000000..6cf535b0cac --- /dev/null +++ b/modules/apps/transfer/v2/keeper/keeper.go @@ -0,0 +1,249 @@ +package keeper + +import ( + "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/events" + transferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channelkeeperv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" +) + +type Keeper struct { + transferkeeper.Keeper + channelKeeperV2 *channelkeeperv2.Keeper +} + +func NewKeeper(transferKeeper transferkeeper.Keeper, channelKeeperV2 *channelkeeperv2.Keeper) *Keeper { + return &Keeper{ + Keeper: transferKeeper, + channelKeeperV2: channelKeeperV2, + } +} + +func (k *Keeper) OnSendPacket(ctx context.Context, sourceChannel string, payload channeltypesv2.Payload, data types.FungibleTokenPacketDataV2, sender sdk.AccAddress) error { + for _, token := range data.Tokens { + coin, err := token.ToCoin() + if err != nil { + return err + } + + if coin.Amount.Equal(types.UnboundedSpendLimit()) { + coin.Amount = k.BankKeeper.GetBalance(ctx, sender, coin.Denom).Amount + } + + // NOTE: SendTransfer simply sends the denomination as it exists on its own + // chain inside the packet data. The receiving chain will perform denom + // prefixing as necessary. + + // if the denom is prefixed by the port and channel on which we are sending + // the token, then we must be returning the token back to the chain they originated from + if token.Denom.HasPrefix(payload.SourcePort, sourceChannel) { + // transfer the coins to the module account and burn them + if err := k.BankKeeper.SendCoinsFromAccountToModule( + ctx, sender, types.ModuleName, sdk.NewCoins(coin), + ); err != nil { + return err + } + + if err := k.BankKeeper.BurnCoins( + ctx, types.ModuleName, sdk.NewCoins(coin), + ); err != nil { + // NOTE: should not happen as the module account was + // retrieved on the step above and it has enough balance + // to burn. + panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %v", err)) + } + } else { + // obtain the escrow address for the source channel end + escrowAddress := types.GetEscrowAddress(payload.SourcePort, sourceChannel) + if err := k.EscrowCoin(ctx, sender, escrowAddress, coin); err != nil { + return err + } + } + } + + // TODO: events + // events.EmitTransferEvent(ctx, sender.String(), receiver, tokens, memo, hops) + + // TODO: telemetry + // telemetry.ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChannel, tokens) + + return nil +} + +func (k *Keeper) OnRecvPacket(ctx context.Context, sourceChannel, destChannel string, payload channeltypesv2.Payload, data types.FungibleTokenPacketDataV2) error { + // validate packet data upon receiving + if err := data.ValidateBasic(); err != nil { + return errorsmod.Wrapf(err, "error validating ICS-20 transfer packet data") + } + + if !k.GetParams(ctx).ReceiveEnabled { + return types.ErrReceiveDisabled + } + + receiver, err := sdk.AccAddressFromBech32(data.Receiver) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "failed to decode receiver address %s: %v", data.Receiver, err) + } + + if k.IsBlockedAddr(receiver) { + return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", receiver) + } + + receivedCoins := make(sdk.Coins, 0, len(data.Tokens)) + for _, token := range data.Tokens { + // parse the transfer amount + transferAmount, ok := sdkmath.NewIntFromString(token.Amount) + if !ok { + return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount: %s", token.Amount) + } + + // This is the prefix that would have been prefixed to the denomination + // on sender chain IF and only if the token originally came from the + // receiving chain. + // + // NOTE: We use SourcePort and SourceChannel here, because the counterparty + // chain would have prefixed with DestPort and DestChannel when originally + // receiving this token. + if token.Denom.HasPrefix(payload.SourcePort, sourceChannel) { + // sender chain is not the source, unescrow tokens + + // remove prefix added by sender chain + token.Denom.Trace = token.Denom.Trace[1:] + + coin := sdk.NewCoin(token.Denom.IBCDenom(), transferAmount) + + escrowAddress := types.GetEscrowAddress(payload.DestinationPort, destChannel) + if err := k.UnescrowCoin(ctx, escrowAddress, receiver, coin); err != nil { + return err + } + + // Appending token. The new denom has been computed + receivedCoins = append(receivedCoins, coin) + } else { + // sender chain is the source, mint vouchers + + // since SendPacket did not prefix the denomination, we must add the destination port and channel to the trace + trace := []types.Hop{types.NewHop(payload.DestinationPort, destChannel)} + token.Denom.Trace = append(trace, token.Denom.Trace...) + + if !k.HasDenom(ctx, token.Denom.Hash()) { + k.SetDenom(ctx, token.Denom) + } + + voucherDenom := token.Denom.IBCDenom() + if !k.BankKeeper.HasDenomMetaData(ctx, voucherDenom) { + k.SetDenomMetadata(ctx, token.Denom) + } + + events.EmitDenomEvent(ctx, token) + + voucher := sdk.NewCoin(voucherDenom, transferAmount) + + // mint new tokens if the source of the transfer is the same chain + if err := k.BankKeeper.MintCoins( + ctx, types.ModuleName, sdk.NewCoins(voucher), + ); err != nil { + return errorsmod.Wrap(err, "failed to mint IBC tokens") + } + + // send to receiver + moduleAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) + if err := k.BankKeeper.SendCoins( + ctx, moduleAddr, receiver, sdk.NewCoins(voucher), + ); err != nil { + return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String()) + } + + receivedCoins = append(receivedCoins, voucher) + } + } + + _ = receivedCoins // TODO: remove this line when forwarding is implemented + // TODO: forwarding + // if data.HasForwarding() { + // // we are now sending from the forward escrow address to the final receiver address. + // TODO: inside this version of the function, we should fetch the packet that was stored in IBC core in order to set it for forwarding. + // if err := k.forwardPacket(ctx, data, packet, receivedCoins); err != nil { + // return err + // } + // } + + // TODO: telemetry + // telemetry.ReportOnRecvPacket(packet, data.Tokens) + + // The ibc_module.go module will return the proper ack. + return nil +} + +func (k *Keeper) OnAcknowledgementPacket(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement) error { + switch ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + // the acknowledgement succeeded on the receiving chain so nothing + // needs to be executed and no error needs to be returned + return nil + case *channeltypes.Acknowledgement_Error: + // We refund the tokens from the escrow address to the sender + return k.refundPacketTokens(ctx, sourcePort, sourceChannel, data) + default: + return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected one of [%T, %T], got %T", channeltypes.Acknowledgement_Result{}, channeltypes.Acknowledgement_Error{}, ack.Response) + } +} + +func (k *Keeper) OnTimeoutPacket(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2) error { + return k.refundPacketTokens(ctx, sourcePort, sourceChannel, data) +} + +func (k Keeper) refundPacketTokens(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2) error { + // NOTE: packet data type already checked in handler.go + + sender, err := sdk.AccAddressFromBech32(data.Sender) + if err != nil { + return err + } + if k.IsBlockedAddr(sender) { + return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", sender) + } + + // escrow address for unescrowing tokens back to sender + escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) + + moduleAccountAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) + for _, token := range data.Tokens { + coin, err := token.ToCoin() + if err != nil { + return err + } + + // if the token we must refund is prefixed by the source port and channel + // then the tokens were burnt when the packet was sent and we must mint new tokens + if token.Denom.HasPrefix(sourcePort, sourceChannel) { + // mint vouchers back to sender + if err := k.BankKeeper.MintCoins( + ctx, types.ModuleName, sdk.NewCoins(coin), + ); err != nil { + return err + } + + if err := k.BankKeeper.SendCoins(ctx, moduleAccountAddr, sender, sdk.NewCoins(coin)); err != nil { + panic(fmt.Errorf("unable to send coins from module to account despite previously minting coins to module account: %v", err)) + } + } else { + if err := k.UnescrowCoin(ctx, escrowAddress, sender, coin); err != nil { + return err + } + } + } + + return nil +} diff --git a/modules/apps/transfer/v2/keeper/keeper_test.go b/modules/apps/transfer/v2/keeper/keeper_test.go new file mode 100644 index 00000000000..69836b14120 --- /dev/null +++ b/modules/apps/transfer/v2/keeper/keeper_test.go @@ -0,0 +1,58 @@ +package keeper_test + +import ( + "fmt" + "testing" + + testifysuite "github.com/stretchr/testify/suite" + + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +type KeeperTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + chainC *ibctesting.TestChain +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) +} + +type amountType int + +const ( + escrow amountType = iota + balance +) + +func (suite *KeeperTestSuite) assertAmountOnChain(chain *ibctesting.TestChain, balanceType amountType, amount sdkmath.Int, denom string) { + var total sdk.Coin + switch balanceType { + case escrow: + total = chain.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(chain.GetContext(), denom) + totalV2 := chain.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(chain.GetContext(), denom) + suite.Require().Equal(total, totalV2, "escrow balance mismatch") + case balance: + total = chain.GetSimApp().BankKeeper.GetBalance(chain.GetContext(), chain.SenderAccounts[0].SenderAccount.GetAddress(), denom) + default: + suite.Fail("invalid amountType %s", balanceType) + } + suite.Require().Equal(amount, total.Amount, fmt.Sprintf("Chain %s: got balance of %s, wanted %s", chain.Name(), total.Amount.String(), amount.String())) +} + +func TestKeeperTestSuite(t *testing.T) { + testifysuite.Run(t, new(KeeperTestSuite)) +} diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go new file mode 100644 index 00000000000..9dcaba67e89 --- /dev/null +++ b/modules/apps/transfer/v2/keeper/msg_server_test.go @@ -0,0 +1,597 @@ +package keeper_test + +import ( + "bytes" + "time" + + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" +) + +// TestMsgSendPacketTransfer tests the MsgSendPacket rpc handler for the transfer v2 application. +func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { + var payload channeltypesv2.Payload + var path *ibctesting.Path + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: send transfers disabled", + func() { + suite.chainA.GetSimApp().TransferKeeperV2.SetParams(suite.chainA.GetContext(), + transfertypes.Params{ + SendEnabled: false, + }, + ) + }, + transfertypes.ErrSendDisabled, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + tokens := []transfertypes.Token{ + { + Denom: transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: nil, + }, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainA.Codec.MustMarshal(&ftpd) + + timestamp := suite.chainA.GetTimeoutTimestampSecs() + // TODO: note, encoding field currently not respected in the implementation. encoding is determined by the version. + // ics20-v1 == json + // ics20-v2 == proto + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + + tc.malleate() + + packet, err := path.EndpointA.MsgSendPacket(timestamp, payload) + + expPass := tc.expError == nil + if expPass { + + // ensure every token sent is escrowed. + for _, t := range tokens { + escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) + expected, err := t.ToCoin() + suite.Require().NoError(err) + suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") + } + suite.Require().NoError(err) + suite.Require().NotEmpty(packet) + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) + suite.Require().Empty(packet) + } + }) + } +} + +// TestMsgRecvPacketTransfer tests the MsgRecvPacket rpc handler for the transfer v2 application. +func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { + var ( + path *ibctesting.Path + packet channeltypesv2.Packet + expectedAck channeltypesv2.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: invalid destination channel on received packet", + func() { + packet.DestinationChannel = ibctesting.InvalidID + }, + channeltypesv2.ErrChannelNotFound, + }, + { + "failure: counter party channel does not match source channel", + func() { + packet.SourceChannel = ibctesting.InvalidID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: receive is disabled", + func() { + expectedAck.AppAcknowledgements[0] = channeltypes.NewErrorAcknowledgement(transfertypes.ErrReceiveDisabled).Acknowledgement() + suite.chainB.GetSimApp().TransferKeeperV2.SetParams(suite.chainB.GetContext(), + transfertypes.Params{ + ReceiveEnabled: false, + }) + }, + nil, + }, + // TODO: async tests + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + tokens := []transfertypes.Token{ + { + Denom: transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: nil, + }, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainA.Codec.MustMarshal(&ftpd) + + timestamp := suite.chainA.GetTimeoutTimestampSecs() + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + var err error + packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) + suite.Require().NoError(err) + + // by default, we assume a successful acknowledgement will be written. + ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() + expectedAck = channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} + tc.malleate() + + err = path.EndpointB.MsgRecvPacket(packet) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + actualAckHash := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + expectedHash := channeltypesv2.CommitAcknowledgement(expectedAck) + + suite.Require().Equal(expectedHash, actualAckHash) + + denom := transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: []transfertypes.Hop{ + transfertypes.NewHop(payload.DestinationPort, packet.DestinationChannel), + }, + } + + actualBalance := path.EndpointB.Chain.GetSimApp().TransferKeeperV2.BankKeeper.GetBalance(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), denom.IBCDenom()) + + var expectedBalance sdk.Coin + // on a successful ack we expect the full amount to be transferred + if bytes.Equal(expectedAck.AppAcknowledgements[0], ackBytes) { + expectedBalance = sdk.NewCoin(denom.IBCDenom(), ibctesting.DefaultCoinAmount) + } else { + // otherwise the tokens do not make it to the address. + expectedBalance = sdk.NewCoin(denom.IBCDenom(), sdkmath.NewInt(0)) + } + + suite.Require().Equal(expectedBalance.Amount, actualBalance.Amount) + + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) + } + }) + } +} + +// TestMsgAckPacketTransfer tests the MsgAcknowledgePacket rpc handler for the transfer v2 application. +func (suite *KeeperTestSuite) TestMsgAckPacketTransfer() { + var ( + path *ibctesting.Path + packet channeltypesv2.Packet + expectedAck channeltypesv2.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + causeFailureOnRecv bool + }{ + { + "success", + func() {}, + nil, + false, + }, + { + "failure: proof verification failure", + func() { + expectedAck.AppAcknowledgements[0] = mockv2.MockFailRecvPacketResult.Acknowledgement + }, + commitmenttypes.ErrInvalidProof, + false, + }, + { + "failure: escrowed tokens are refunded", + func() { + expectedAck.AppAcknowledgements[0] = channeltypes.NewErrorAcknowledgement(transfertypes.ErrReceiveDisabled).Acknowledgement() + }, + nil, + true, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + tokens := []transfertypes.Token{ + { + Denom: transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: nil, + }, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainA.Codec.MustMarshal(&ftpd) + + timestamp := suite.chainA.GetTimeoutTimestampSecs() + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + + var err error + packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) + suite.Require().NoError(err) + + if tc.causeFailureOnRecv { + // ensure that the recv packet fails at the application level, but succeeds at the IBC handler level + // this will ensure that a failed ack will be written to state. + suite.chainB.GetSimApp().TransferKeeperV2.SetParams(suite.chainB.GetContext(), + transfertypes.Params{ + ReceiveEnabled: false, + }) + } + + err = path.EndpointB.MsgRecvPacket(packet) + suite.Require().NoError(err) + + ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() + expectedAck = channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} + tc.malleate() + + err = path.EndpointA.MsgAcknowledgePacket(packet, expectedAck) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + if bytes.Equal(expectedAck.AppAcknowledgements[0], ackBytes) { + // tokens remain escrowed + for _, t := range tokens { + escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) + expected, err := t.ToCoin() + suite.Require().NoError(err) + suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") + } + } else { + // tokens have been unescrowed + for _, t := range tokens { + escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) + suite.Require().Equal(sdk.NewCoin(t.Denom.IBCDenom(), sdkmath.NewInt(0)), escrowedAmount, "escrowed amount is not equal to expected amount") + } + } + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) + } + }) + } +} + +// TestMsgTimeoutPacketTransfer tests the MsgTimeoutPacket rpc handler for the transfer v2 application. +func (suite *KeeperTestSuite) TestMsgTimeoutPacketTransfer() { + var ( + path *ibctesting.Path + packet channeltypesv2.Packet + timeoutTimestamp uint64 + ) + + testCases := []struct { + name string + malleate func() + timeoutPacket bool + expError error + }{ + { + "success", + func() {}, + true, + nil, + }, + { + "failure: packet has not timed out", + func() {}, + false, + channeltypes.ErrTimeoutNotReached, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + tokens := []transfertypes.Token{ + { + Denom: transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: nil, + }, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainA.Codec.MustMarshal(&ftpd) + + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + + var err error + packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) + suite.Require().NoError(err) + + if tc.timeoutPacket { + suite.coordinator.IncrementTimeBy(time.Hour * 2) + } + + // ensure that chainA has an update to date client of chain B. + suite.Require().NoError(path.EndpointA.UpdateClient()) + + tc.malleate() + + err = path.EndpointA.MsgTimeoutPacket(packet) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + // ensure funds are un-escrowed + for _, t := range tokens { + escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) + suite.Require().Equal(sdk.NewCoin(t.Denom.IBCDenom(), sdkmath.NewInt(0)), escrowedAmount, "escrowed amount is not equal to expected amount") + } + + } else { + ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) + // tokens remain escrowed if there is a timeout failure + for _, t := range tokens { + escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) + expected, err := t.ToCoin() + suite.Require().NoError(err) + suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") + } + } + }) + } +} + +func (suite *KeeperTestSuite) TestV2RetainsFungibility() { + suite.SetupTest() + + path := ibctesting.NewTransferPath(suite.chainA, suite.chainB) + path.Setup() + + pathv2 := ibctesting.NewPath(suite.chainB, suite.chainC) + pathv2.SetupV2() + + denomA := transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + } + + denomAtoB := transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: []transfertypes.Hop{ + transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), + }, + } + + denomBtoC := transfertypes.Denom{ + Base: sdk.DefaultBondDenom, + Trace: []transfertypes.Hop{ + transfertypes.NewHop(transfertypes.ModuleName, pathv2.EndpointB.ChannelID), + transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), + }, + } + + ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() + successfulAck := channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} + + originalAmount, ok := sdkmath.NewIntFromString(ibctesting.DefaultGenesisAccBalance) + suite.Require().True(ok) + + suite.Run("between A and B", func() { + var packet channeltypes.Packet + suite.Run("transfer packet", func() { + transferMsg := transfertypes.NewMsgTransfer( + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + sdk.NewCoins(sdk.NewCoin(denomA.IBCDenom(), ibctesting.TestCoin.Amount)), + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + clienttypes.ZeroHeight(), + suite.chainA.GetTimeoutTimestamp(), + "memo", + nil, + ) + + result, err := suite.chainA.SendMsgs(transferMsg) + suite.Require().NoError(err) // message committed + + remainingAmount := originalAmount.Sub(ibctesting.DefaultCoinAmount) + suite.assertAmountOnChain(suite.chainA, balance, remainingAmount, denomA.IBCDenom()) + + packet, err = ibctesting.ParsePacketFromEvents(result.Events) + suite.Require().NoError(err) + }) + + suite.Run("recv and ack packet", func() { + err := path.RelayPacket(packet) + suite.Require().NoError(err) + }) + }) + + suite.Run("between B and C", func() { + var packetV2 channeltypesv2.Packet + + suite.Run("send packet", func() { + tokens := []transfertypes.Token{ + { + Denom: denomAtoB, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainB.Codec.MustMarshal(&ftpd) + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + + var err error + packetV2, err = pathv2.EndpointA.MsgSendPacket(timeoutTimestamp, payload) + suite.Require().NoError(err) + // the escrow account on chain B should have escrowed the tokens after sending from B to C + suite.assertAmountOnChain(suite.chainB, escrow, ibctesting.DefaultCoinAmount, denomAtoB.IBCDenom()) + }) + + suite.Run("recv packet", func() { + err := pathv2.EndpointB.MsgRecvPacket(packetV2) + suite.Require().NoError(err) + + // the receiving chain should have received the tokens + suite.assertAmountOnChain(suite.chainC, balance, ibctesting.DefaultCoinAmount, denomBtoC.IBCDenom()) + }) + + suite.Run("ack packet", func() { + err := pathv2.EndpointA.MsgAcknowledgePacket(packetV2, successfulAck) + suite.Require().NoError(err) + }) + }) + + suite.Run("between C and B", func() { + var packetV2 channeltypesv2.Packet + + suite.Run("send packet", func() { + // send from C to B + tokens := []transfertypes.Token{ + { + Denom: denomBtoC, + Amount: ibctesting.DefaultCoinAmount.String(), + }, + } + + ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) + bz := suite.chainC.Codec.MustMarshal(&ftpd) + + timeoutTimestamp := uint64(suite.chainC.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + + var err error + packetV2, err = pathv2.EndpointB.MsgSendPacket(timeoutTimestamp, payload) + suite.Require().NoError(err) + + // tokens have been sent from chain C, and the balance is now empty. + suite.assertAmountOnChain(suite.chainC, balance, sdkmath.NewInt(0), denomBtoC.IBCDenom()) + }) + + suite.Run("recv packet", func() { + err := pathv2.EndpointA.MsgRecvPacket(packetV2) + suite.Require().NoError(err) + + // chain B should have received the tokens from chain C. + suite.assertAmountOnChain(suite.chainB, balance, ibctesting.DefaultCoinAmount, denomAtoB.IBCDenom()) + }) + + suite.Run("ack packet", func() { + err := pathv2.EndpointB.MsgAcknowledgePacket(packetV2, successfulAck) + suite.Require().NoError(err) + }) + }) + + suite.Run("between B and A", func() { + var packet channeltypes.Packet + + suite.Run("transfer packet", func() { + // send from B to A using MsgTransfer + transferMsg := transfertypes.NewMsgTransfer( + path.EndpointB.ChannelConfig.PortID, + path.EndpointB.ChannelID, + sdk.NewCoins(sdk.NewCoin(denomAtoB.IBCDenom(), ibctesting.TestCoin.Amount)), + suite.chainB.SenderAccount.GetAddress().String(), + suite.chainA.SenderAccount.GetAddress().String(), + clienttypes.ZeroHeight(), + suite.chainB.GetTimeoutTimestamp(), + "memo", + nil, + ) + + result, err := suite.chainB.SendMsgs(transferMsg) + suite.Require().NoError(err) // message committed + + suite.assertAmountOnChain(suite.chainB, balance, sdkmath.NewInt(0), denomAtoB.IBCDenom()) + + packet, err = ibctesting.ParsePacketFromEvents(result.Events) + suite.Require().NoError(err) + }) + suite.Run("recv and ack packet", func() { + // in order to recv in the other direction, we create a new path and recv + // on that with the endpoints reversed. + err := path.Reversed().RelayPacket(packet) + suite.Require().NoError(err) + + suite.assertAmountOnChain(suite.chainA, balance, originalAmount, denomA.IBCDenom()) + }) + }) +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index ba0fd05e17c..f4c2dc446a1 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -61,10 +61,9 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegis return &types.MsgRegisterCounterpartyResponse{}, nil } -// SendPacket defines a rpc handler method for MsgSendPacket. +// SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*types.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) if err != nil { sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) @@ -100,7 +99,8 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*typ return &types.MsgSendPacketResponse{Sequence: sequence}, nil } -// RecvPacket defines a rpc handler method for MsgRecvPacket. +// RecvPacket implements the PacketMsgServer RecvPacket method. + func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*types.MsgRecvPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -139,7 +139,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful. cacheCtx, writeFn = sdkCtx.CacheContext() cb := k.Router.Route(pd.DestinationPort) - res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, signer) + res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, msg.Packet.Sequence, pd, signer) if res.Status != types.PacketStatus_Failure { // write application state changes for asynchronous and successful acknowledgements @@ -178,6 +178,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ } } + // TODO: store the packet for async applications to access if required. defer telemetry.ReportRecvPacket(msg.Packet) sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", types.SUCCESS.String()) @@ -211,7 +212,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem for i, pd := range msg.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) ack := msg.Acknowledgement.AppAcknowledgements[i] - err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, ack, relayer) + err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, msg.Packet.Sequence, ack, pd, relayer) if err != nil { return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) } @@ -220,7 +221,7 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem return &types.MsgAcknowledgementResponse{Result: types.SUCCESS}, nil } -// Timeout defines a rpc handler method for MsgTimeout. +// Timeout implements the PacketMsgServer Timeout method. func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types.MsgTimeoutResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -250,7 +251,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types for _, pd := range timeout.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) - err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel, pd, signer) + err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel, timeout.Packet.Sequence, pd, signer) if err != nil { return nil, errorsmod.Wrapf(err, "failed OnTimeoutPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 339c0f3d92f..072de3e77fb 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -316,7 +316,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { expectedAck := types.Acknowledgement{AppAcknowledgements: [][]byte{expRecvRes.Acknowledgement}} // modify the callback to return the expected recv result. - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { return expRecvRes } @@ -377,7 +377,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, uint64, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -385,7 +385,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, uint64, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -471,7 +471,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // Modify the callback to return a different error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, uint64, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -480,7 +480,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, uint64, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index d7e40d07fc2..967b87445f2 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -161,6 +161,7 @@ func (k *Keeper) recvPacket( } // WriteAcknowledgement writes the acknowledgement to the store. +// TODO: change this function to accept destPort, destChannel, sequence, ack func (k Keeper) WriteAcknowledgement( ctx context.Context, packet types.Packet, @@ -191,6 +192,7 @@ func (k Keeper) WriteAcknowledgement( // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 + // TODO: remove this check, maybe pull it up to the handler. if len(ack.AppAcknowledgements) != len(packet.Payloads) { return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of app acknowledgement %d does not match length of app payload %d", len(ack.AppAcknowledgements), len(packet.Payloads)) } @@ -203,7 +205,10 @@ func (k Keeper) WriteAcknowledgement( k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest-channel", packet.DestinationChannel) - EmitWriteAcknowledgementEvents(ctx, packet, ack) + // TODO: decide how relayers will reconstruct the packet as it is not being passed. + // EmitWriteAcknowledgementEvents(ctx, packet, ack) + + // TODO: delete the packet that has been stored in ibc-core. return nil } diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 1f86bfc5386..4d26947f42a 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -19,7 +19,7 @@ type IBCModule interface { sourceChannel string, destinationChannel string, sequence uint64, - data channeltypesv2.Payload, + payload channeltypesv2.Payload, signer sdk.AccAddress, ) error @@ -27,7 +27,8 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.Payload, + sequence uint64, + payload channeltypesv2.Payload, relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult @@ -36,7 +37,8 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.Payload, + sequence uint64, + payload channeltypesv2.Payload, relayer sdk.AccAddress, ) error @@ -45,8 +47,9 @@ type IBCModule interface { ctx context.Context, sourceChannel string, destinationChannel string, - data channeltypesv2.Payload, + sequence uint64, acknowledgement []byte, + payload channeltypesv2.Payload, relayer sdk.AccAddress, ) error } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index e9d74cc88e2..8c5280db225 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -123,10 +123,13 @@ import ( "github.com/cosmos/ibc-go/v9/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + transferv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2" + ibctransferkeeperv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" ibc "github.com/cosmos/ibc-go/v9/modules/core" ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + ibcapi "github.com/cosmos/ibc-go/v9/modules/core/api" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" @@ -198,6 +201,7 @@ type SimApp struct { ICAHostKeeper icahostkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper + TransferKeeperV2 *ibctransferkeeperv2.Keeper WasmClientKeeper wasmkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper @@ -477,6 +481,7 @@ func NewSimApp( // Create IBC Router ibcRouter := porttypes.NewRouter() + ibcRouterV2 := ibcapi.NewRouter() // Middleware Stacks @@ -563,8 +568,13 @@ func NewSimApp( feeWithMockModule := ibcfee.NewIBCMiddleware(feeMockModule, app.IBCFeeKeeper) ibcRouter.AddRoute(MockFeePort, feeWithMockModule) - // Seal the IBC Router + // register the transfer v2 module. + app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) + ibcRouterV2.AddRoute(ibctransfertypes.ModuleName, transferv2.NewIBCModule(app.TransferKeeperV2)) + + // Seal the IBC Routers. app.IBCKeeper.SetRouter(ibcRouter) + app.IBCKeeper.SetRouterV2(ibcRouterV2) clientKeeper := app.IBCKeeper.ClientKeeper storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider() diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index a210285d40b..7b72f4bac30 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,8 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) error - OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error + OnSendPacket func(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload channeltypesv2.Payload, signer sdk.AccAddress) error + OnRecvPacket func(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload channeltypesv2.Payload, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 2f44dad7350..8ea9fad704a 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -38,23 +38,23 @@ func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, dest return nil } -func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { +func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { if im.IBCApp.OnRecvPacket != nil { - return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer) + return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, sequence, data, relayer) } return MockRecvPacketResult } -func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error { +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, acknowledgement []byte, payload channeltypesv2.Payload, relayer sdk.AccAddress) error { if im.IBCApp.OnAcknowledgementPacket != nil { - return im.IBCApp.OnAcknowledgementPacket(ctx, sourceChannel, destinationChannel, data, acknowledgement, relayer) + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceChannel, destinationChannel, sequence, payload, acknowledgement, relayer) } return nil } -func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) error { +func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload channeltypesv2.Payload, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { - return im.IBCApp.OnTimeoutPacket(ctx, sourceChannel, destinationChannel, data, relayer) + return im.IBCApp.OnTimeoutPacket(ctx, sourceChannel, destinationChannel, sequence, payload, relayer) } return nil } diff --git a/testing/path.go b/testing/path.go index b31dec57ed9..cc2949158e7 100644 --- a/testing/path.go +++ b/testing/path.go @@ -139,6 +139,13 @@ func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.Exec return nil, nil, errors.New("packet commitment does not exist on either endpoint for provided packet") } +// Reversed returns a new path with endpoints reversed. +func (path *Path) Reversed() *Path { + reversedPath := *path + reversedPath.EndpointA, reversedPath.EndpointB = path.EndpointB, path.EndpointA + return &reversedPath +} + // Setup constructs a TM client, connection, and channel on both chains provided. It will // fail if any error occurs. func (path *Path) Setup() { diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 320d5957b83..869b31ba649 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -96,6 +96,8 @@ import ( "github.com/cosmos/ibc-go/v9/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + transferv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2" + ibctransferkeeperv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" ibc "github.com/cosmos/ibc-go/v9/modules/core" ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" @@ -168,6 +170,7 @@ type SimApp struct { ICAControllerKeeper icacontrollerkeeper.Keeper ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper + TransferKeeperV2 *ibctransferkeeperv2.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper // make IBC modules public for test purposes @@ -484,6 +487,10 @@ func NewSimApp( ibcRouterV2.AddRoute(mockv2.ModuleNameB, mockV2B) app.MockModuleV2B = mockV2B + // register the transfer v2 module. + app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) + ibcRouterV2.AddRoute(ibctransfertypes.ModuleName, transferv2.NewIBCModule(app.TransferKeeperV2)) + // Seal the IBC Router app.IBCKeeper.SetRouter(ibcRouter) app.IBCKeeper.SetRouterV2(ibcRouterV2) From 5afcf1df0bc1d9815edbf5a5077f411f5b5d6782 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 20 Nov 2024 17:01:30 +0000 Subject: [PATCH 134/172] chore: use encoding fields for packet data unmarshaling (#7574) * chore: use encoding fields for packet data unmarshaling * linter * clean up function * more comments * use MIME type and constants * use application/x-protobuf as MIME type for proto encoding * renaming and linter --- modules/apps/transfer/ibc_module.go | 8 +- modules/apps/transfer/types/packet.go | 83 +++++++++++++++---- modules/apps/transfer/types/packet_test.go | 4 +- modules/apps/transfer/v2/ibc_module.go | 8 +- .../transfer/v2/keeper/msg_server_test.go | 15 ++-- modules/core/04-channel/v2/types/msgs_test.go | 3 +- .../core/04-channel/v2/types/packet_test.go | 3 +- testing/mock/v2/mock.go | 3 +- 8 files changed, 87 insertions(+), 40 deletions(-) diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index c6445645c23..95d4681b9b9 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -184,7 +184,7 @@ func (im IBCModule) OnRecvPacket( events.EmitOnRecvPacketEvent(ctx, data, ack, ackErr) }() - data, ackErr = types.UnmarshalPacketData(packet.GetData(), channelVersion) + data, ackErr = types.UnmarshalPacketData(packet.GetData(), channelVersion, "") if ackErr != nil { ack = channeltypes.NewErrorAcknowledgement(ackErr) im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) @@ -221,7 +221,7 @@ func (im IBCModule) OnAcknowledgementPacket( return errorsmod.Wrapf(ibcerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet acknowledgement: %v", err) } - data, err := types.UnmarshalPacketData(packet.GetData(), channelVersion) + data, err := types.UnmarshalPacketData(packet.GetData(), channelVersion, "") if err != nil { return err } @@ -242,7 +242,7 @@ func (im IBCModule) OnTimeoutPacket( packet channeltypes.Packet, relayer sdk.AccAddress, ) error { - data, err := types.UnmarshalPacketData(packet.GetData(), channelVersion) + data, err := types.UnmarshalPacketData(packet.GetData(), channelVersion, "") if err != nil { return err } @@ -305,6 +305,6 @@ func (im IBCModule) UnmarshalPacketData(ctx context.Context, portID string, chan return types.FungibleTokenPacketDataV2{}, "", errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) } - ftpd, err := types.UnmarshalPacketData(bz, ics20Version) + ftpd, err := types.UnmarshalPacketData(bz, ics20Version, "") return ftpd, ics20Version, err } diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 98525dac769..968e996c08f 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -23,6 +23,11 @@ var ( _ ibcexported.PacketDataProvider = (*FungibleTokenPacketDataV2)(nil) ) +const ( + EncodingJSON = "application/json" + EncodingProtobuf = "application/x-protobuf" +) + // NewFungibleTokenPacketData constructs a new FungibleTokenPacketData instance func NewFungibleTokenPacketData( denom string, amount string, @@ -208,36 +213,78 @@ func (ftpd FungibleTokenPacketDataV2) HasForwarding() bool { } // UnmarshalPacketData attempts to unmarshal the provided packet data bytes into a FungibleTokenPacketDataV2. -// The version of ics20 should be provided and should be either ics20-1 or ics20-2. -func UnmarshalPacketData(bz []byte, ics20Version string) (FungibleTokenPacketDataV2, error) { - // TODO: in transfer ibc module V2, we need to respect he encoding value passed via the payload, some hard coded assumptions about - // encoding exist here based on the ics20 version passed in. +func UnmarshalPacketData(bz []byte, ics20Version string, encoding string) (FungibleTokenPacketDataV2, error) { + const failedUnmarshalingErrorMsg = "cannot unmarshal %s transfer packet data: %s" + + // Depending on the ics20 version, we use a different default encoding (json for V1, proto for V2) + // and we have a different type to unmarshal the data into. + var data proto.Message switch ics20Version { case V1: - var datav1 FungibleTokenPacketData - if err := json.Unmarshal(bz, &datav1); err != nil { - return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot unmarshal ICS20-V1 transfer packet data: %s", err.Error()) + if encoding == "" { + encoding = EncodingJSON } - - return PacketDataV1ToV2(datav1) + data = &FungibleTokenPacketData{} case V2: - var datav2 FungibleTokenPacketDataV2 - if err := unknownproto.RejectUnknownFieldsStrict(bz, &datav2, unknownproto.DefaultAnyResolver{}); err != nil { - return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot unmarshal ICS20-V2 transfer packet data: %s", err.Error()) + if encoding == "" { + encoding = EncodingProtobuf } + data = &FungibleTokenPacketDataV2{} + default: + return FungibleTokenPacketDataV2{}, errorsmod.Wrap(ErrInvalidVersion, ics20Version) + } - if err := proto.Unmarshal(bz, &datav2); err != nil { - return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot unmarshal ICS20-V2 transfer packet data: %s", err.Error()) + errorMsgVersion := "ICS20-V2" + if ics20Version == V1 { + errorMsgVersion = "ICS20-V1" + } + + // Here we perform the unmarshaling based on the specified encoding. + // The functions act on the generic "data" variable which is of type proto.Message (an interface). + // The underlying type is either FungibleTokenPacketData or FungibleTokenPacketDataV2, based on the value + // of "ics20Version". + switch encoding { + case EncodingJSON: + if err := json.Unmarshal(bz, &data); err != nil { + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, failedUnmarshalingErrorMsg, errorMsgVersion, err.Error()) + } + case EncodingProtobuf: + if err := unknownproto.RejectUnknownFieldsStrict(bz, data, unknownproto.DefaultAnyResolver{}); err != nil { + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, failedUnmarshalingErrorMsg, errorMsgVersion, err.Error()) } - if err := datav2.ValidateBasic(); err != nil { - return FungibleTokenPacketDataV2{}, err + if err := proto.Unmarshal(bz, data); err != nil { + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, failedUnmarshalingErrorMsg, errorMsgVersion, err.Error()) } - return datav2, nil default: - return FungibleTokenPacketDataV2{}, errorsmod.Wrap(ErrInvalidVersion, ics20Version) + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "invalid encoding provided, must be either empty or one of [%q, %q], got %s", EncodingJSON, EncodingProtobuf, encoding) + } + + // When the unmarshaling is done, we want to retrieve the underlying data type based on the value of ics20Version + // If it's v1, we convert the data to FungibleTokenPacketData and then call the conversion function to construct + // the v2 type. + if ics20Version == V1 { + datav1, ok := data.(*FungibleTokenPacketData) + if !ok { + // We should never get here, as we manually constructed the type at the beginning of the file + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot convert proto message into FungibleTokenPacketData") + } + // The call to ValidateBasic for V1 is done inside PacketDataV1toV2. + return PacketDataV1ToV2(*datav1) + } + + // If it's v2, we convert the data to FungibleTokenPacketDataV2, validate it and return it. + datav2, ok := data.(*FungibleTokenPacketDataV2) + if !ok { + // We should never get here, as we manually constructed the type at the beginning of the file + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot convert proto message into FungibleTokenPacketDataV2") + } + + if err := datav2.ValidateBasic(); err != nil { + return FungibleTokenPacketDataV2{}, err } + return *datav2, nil } // PacketDataV1ToV2 converts a v1 packet data to a v2 packet data. The packet data is validated diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 254cec03522..db166b2b8d8 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -765,7 +765,7 @@ func TestUnmarshalPacketData(t *testing.T) { tc.malleate() - packetData, err := types.UnmarshalPacketData(packetDataBz, version) + packetData, err := types.UnmarshalPacketData(packetDataBz, version, "") expPass := tc.expError == nil if expPass { @@ -819,7 +819,7 @@ func TestV2ForwardsCompatibilityFails(t *testing.T) { tc.malleate() - packetData, err := types.UnmarshalPacketData(packetDataBz, types.V2) + packetData, err := types.UnmarshalPacketData(packetDataBz, types.V2, types.EncodingProtobuf) expPass := tc.expError == nil if expPass { diff --git a/modules/apps/transfer/v2/ibc_module.go b/modules/apps/transfer/v2/ibc_module.go index fcbedc6ef03..19aa3db5292 100644 --- a/modules/apps/transfer/v2/ibc_module.go +++ b/modules/apps/transfer/v2/ibc_module.go @@ -41,7 +41,7 @@ func (im *IBCModule) OnSendPacket(goCtx context.Context, sourceChannel string, d return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", signer) } - data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) if err != nil { return err } @@ -66,7 +66,7 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des events.EmitOnRecvPacketEvent(ctx, data, ack, ackErr) }() - data, ackErr = transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + data, ackErr = transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) if ackErr != nil { ack = channeltypes.NewErrorAcknowledgement(ackErr) im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), sequence)) @@ -99,7 +99,7 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des } func (im *IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, relayer sdk.AccAddress) error { - data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) if err != nil { return err } @@ -119,7 +119,7 @@ func (im *IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel return errorsmod.Wrapf(ibcerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet acknowledgement: %v", err) } - data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version) + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) if err != nil { return err } diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go index 9dcaba67e89..1e4c270c4ec 100644 --- a/modules/apps/transfer/v2/keeper/msg_server_test.go +++ b/modules/apps/transfer/v2/keeper/msg_server_test.go @@ -68,10 +68,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { bz := suite.chainA.Codec.MustMarshal(&ftpd) timestamp := suite.chainA.GetTimeoutTimestampSecs() - // TODO: note, encoding field currently not respected in the implementation. encoding is determined by the version. - // ics20-v1 == json - // ics20-v2 == proto - payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) tc.malleate() @@ -166,7 +163,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { bz := suite.chainA.Codec.MustMarshal(&ftpd) timestamp := suite.chainA.GetTimeoutTimestampSecs() - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) var err error packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) suite.Require().NoError(err) @@ -275,7 +272,7 @@ func (suite *KeeperTestSuite) TestMsgAckPacketTransfer() { bz := suite.chainA.Codec.MustMarshal(&ftpd) timestamp := suite.chainA.GetTimeoutTimestampSecs() - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) var err error packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) @@ -376,7 +373,7 @@ func (suite *KeeperTestSuite) TestMsgTimeoutPacketTransfer() { bz := suite.chainA.Codec.MustMarshal(&ftpd) timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) var err error packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) @@ -497,7 +494,7 @@ func (suite *KeeperTestSuite) TestV2RetainsFungibility() { bz := suite.chainB.Codec.MustMarshal(&ftpd) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) var err error packetV2, err = pathv2.EndpointA.MsgSendPacket(timeoutTimestamp, payload) @@ -536,7 +533,7 @@ func (suite *KeeperTestSuite) TestV2RetainsFungibility() { bz := suite.chainC.Codec.MustMarshal(&ftpd) timeoutTimestamp := uint64(suite.chainC.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, "json", bz) + payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) var err error packetV2, err = pathv2.EndpointB.MsgSendPacket(timeoutTimestamp, payload) diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index fd6f5ceaa0a..35165f0d72e 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -205,7 +206,7 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { msg = types.NewMsgSendPacket( ibctesting.FirstChannelID, s.chainA.GetTimeoutTimestamp(), s.chainA.SenderAccount.GetAddress().String(), - types.Payload{SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Version: "ics20-1", Encoding: "json", Value: ibctesting.MockPacketData}, + types.Payload{SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Version: "ics20-1", Encoding: transfertypes.EncodingJSON, Value: ibctesting.MockPacketData}, ) tc.malleate() diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index 0a8b079b0a5..4952e03671d 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -109,7 +110,7 @@ func TestValidateBasic(t *testing.T) { SourcePort: ibctesting.MockPort, DestinationPort: ibctesting.MockPort, Version: "ics20-v2", - Encoding: "json", + Encoding: transfertypes.EncodingProtobuf, Value: mock.MockPacketData, }) diff --git a/testing/mock/v2/mock.go b/testing/mock/v2/mock.go index 41582217070..3d2a0bd8201 100644 --- a/testing/mock/v2/mock.go +++ b/testing/mock/v2/mock.go @@ -1,6 +1,7 @@ package mock import ( + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" mockv1 "github.com/cosmos/ibc-go/v9/testing/mock" ) @@ -24,7 +25,7 @@ func NewMockPayload(sourcePort, destPort string) channeltypesv2.Payload { return channeltypesv2.Payload{ SourcePort: sourcePort, DestinationPort: destPort, - Encoding: "json", + Encoding: transfertypes.EncodingProtobuf, Value: mockv1.MockPacketData, Version: mockv1.Version, } From 5332645a5ea6e87c2de5acd71ccdbb76589fda23 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 21 Nov 2024 11:01:30 +0200 Subject: [PATCH 135/172] feat: add type constructors/validation for genesis types. (#7554) --- modules/core/04-channel/v2/types/channel.go | 17 +++ modules/core/04-channel/v2/types/genesis.go | 134 ++++++++++++++++++ .../core/04-channel/v2/types/genesis.pb.go | 94 ++++++++---- .../core/04-channel/v2/types/genesis_test.go | 102 +++++++++++++ modules/core/04-channel/v2/types/packet.go | 9 -- proto/ibc/core/channel/v2/genesis.proto | 4 +- 6 files changed, 322 insertions(+), 38 deletions(-) create mode 100644 modules/core/04-channel/v2/types/genesis.go create mode 100644 modules/core/04-channel/v2/types/genesis_test.go diff --git a/modules/core/04-channel/v2/types/channel.go b/modules/core/04-channel/v2/types/channel.go index 3a45be384fb..f4ab5b2afe4 100644 --- a/modules/core/04-channel/v2/types/channel.go +++ b/modules/core/04-channel/v2/types/channel.go @@ -32,3 +32,20 @@ func (c Channel) Validate() error { return nil } + +// NewIdentifiedChannel creates a new IdentifiedChannel instance +func NewIdentifiedChannel(channelID string, channel Channel) IdentifiedChannel { + return IdentifiedChannel{ + Channel: channel, + ChannelId: channelID, + } +} + +// ValidateBasic performs a basic validation of the identifiers and channel fields. +func (ic IdentifiedChannel) ValidateBasic() error { + if err := host.ChannelIdentifierValidator(ic.ChannelId); err != nil { + return errorsmod.Wrap(err, "invalid channel ID") + } + + return ic.Channel.Validate() +} diff --git a/modules/core/04-channel/v2/types/genesis.go b/modules/core/04-channel/v2/types/genesis.go new file mode 100644 index 00000000000..3b567f97c87 --- /dev/null +++ b/modules/core/04-channel/v2/types/genesis.go @@ -0,0 +1,134 @@ +package types + +import ( + "errors" + "fmt" + + channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" +) + +// NewPacketState creates a new PacketState instance. +func NewPacketState(channelID string, sequence uint64, data []byte) PacketState { + return PacketState{ + ChannelId: channelID, + Sequence: sequence, + Data: data, + } +} + +// Validate performs basic validation of fields returning an error upon any failure. +func (ps PacketState) Validate() error { + if ps.Data == nil { + return errors.New("data bytes cannot be nil") + } + return validateGenFields(ps.ChannelId, ps.Sequence) +} + +// NewPacketSequence creates a new PacketSequences instance. +func NewPacketSequence(channelID string, sequence uint64) PacketSequence { + return PacketSequence{ + ChannelId: channelID, + Sequence: sequence, + } +} + +// Validate performs basic validation of fields returning an error upon any failure. +func (ps PacketSequence) Validate() error { + return validateGenFields(ps.ChannelId, ps.Sequence) +} + +// NewGenesisState creates a GenesisState instance. +func NewGenesisState( + channels []IdentifiedChannel, acks, receipts, commitments []PacketState, + sendSeqs []PacketSequence, nextChannelSequence uint64, +) GenesisState { + return GenesisState{ + Channels: channels, + Acknowledgements: acks, + Receipts: receipts, + Commitments: commitments, + SendSequences: sendSeqs, + NextChannelSequence: nextChannelSequence, + } +} + +// DefaultGenesisState returns the ibc channel v2 submodule's default genesis state. +func DefaultGenesisState() GenesisState { + return GenesisState{ + Channels: []IdentifiedChannel{}, + Acknowledgements: []PacketState{}, + Receipts: []PacketState{}, + Commitments: []PacketState{}, + SendSequences: []PacketSequence{}, + NextChannelSequence: 0, + } +} + +// Validate performs basic genesis state validation returning an error upon any failure. +func (gs GenesisState) Validate() error { + // keep track of the max sequence to ensure it is less than + // the next sequence used in creating channel identifiers. + var maxSequence uint64 + + for i, channel := range gs.Channels { + sequence, err := channeltypesv1.ParseChannelSequence(channel.ChannelId) + if err != nil { + return err + } + + if sequence > maxSequence { + maxSequence = sequence + } + + if err := channel.ValidateBasic(); err != nil { + return fmt.Errorf("invalid channel %v channel index %d: %w", channel, i, err) + } + } + + if maxSequence != 0 && maxSequence >= gs.NextChannelSequence { + return fmt.Errorf("next channel sequence %d must be greater than maximum sequence used in channel identifier %d", gs.NextChannelSequence, maxSequence) + } + + for i, ack := range gs.Acknowledgements { + if err := ack.Validate(); err != nil { + return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", ack, i, err) + } + if len(ack.Data) == 0 { + return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", ack, i) + } + } + + for i, receipt := range gs.Receipts { + if err := receipt.Validate(); err != nil { + return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", receipt, i, err) + } + } + + for i, commitment := range gs.Commitments { + if err := commitment.Validate(); err != nil { + return fmt.Errorf("invalid commitment %v index %d: %w", commitment, i, err) + } + if len(commitment.Data) == 0 { + return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", commitment, i) + } + } + + for i, ss := range gs.SendSequences { + if err := ss.Validate(); err != nil { + return fmt.Errorf("invalid send sequence %v index %d: %w", ss, i, err) + } + } + + return nil +} + +func validateGenFields(channelID string, sequence uint64) error { + if err := host.ChannelIdentifierValidator(channelID); err != nil { + return fmt.Errorf("invalid channel Id: %w", err) + } + if sequence == 0 { + return errors.New("sequence cannot be 0") + } + return nil +} diff --git a/modules/core/04-channel/v2/types/genesis.pb.go b/modules/core/04-channel/v2/types/genesis.pb.go index 2528c89d61f..ea9c321819f 100644 --- a/modules/core/04-channel/v2/types/genesis.pb.go +++ b/modules/core/04-channel/v2/types/genesis.pb.go @@ -23,13 +23,15 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the ibc channel submodule's genesis state. +// GenesisState defines the ibc channel/v2 submodule's genesis state. type GenesisState struct { Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"` Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"` Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"` Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"` SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences"` + // the sequence for the next generated channel identifier + NextChannelSequence uint64 `protobuf:"varint,6,opt,name=next_channel_sequence,json=nextChannelSequence,proto3" json:"next_channel_sequence,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -100,6 +102,13 @@ func (m *GenesisState) GetSendSequences() []PacketSequence { return nil } +func (m *GenesisState) GetNextChannelSequence() uint64 { + if m != nil { + return m.NextChannelSequence + } + return 0 +} + // PacketState defines the generic type necessary to retrieve and store // packet commitments, acknowledgements, and receipts. // Caller is responsible for knowing the context necessary to interpret this @@ -210,33 +219,35 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/genesis.proto", fileDescriptor_b5d374f126f051c3) } var fileDescriptor_b5d374f126f051c3 = []byte{ - // 414 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xbf, 0xae, 0xd3, 0x30, - 0x14, 0xc6, 0xe3, 0x9b, 0x80, 0x7a, 0xdd, 0xcb, 0x15, 0x18, 0x86, 0x50, 0x89, 0x34, 0x14, 0x09, - 0x65, 0xb9, 0x31, 0x2a, 0x2c, 0x20, 0xa6, 0x30, 0x40, 0xc5, 0x52, 0x05, 0x89, 0x01, 0x09, 0x55, - 0x89, 0x7d, 0x48, 0xad, 0x36, 0x76, 0xa9, 0xdd, 0x22, 0xde, 0x80, 0x91, 0x47, 0x80, 0xb7, 0xe9, - 0xd8, 0x91, 0xa9, 0x42, 0xed, 0x5b, 0x30, 0xa1, 0xfc, 0x69, 0x55, 0xd4, 0x0a, 0xa9, 0xba, 0x9b, - 0x7d, 0xfc, 0x7d, 0xbf, 0x9f, 0x87, 0x83, 0x1f, 0x8a, 0x94, 0x51,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0x9d, 0xe9, 0x4e, 0x8a, 0x9b, 0x7b, 0x42, 0xf2, 0x00, 0xe3, 0x1a, 0x30, 0x10, 0xdc, 0x45, - 0x3e, 0x0a, 0xce, 0xe3, 0xf3, 0x7a, 0xd2, 0xe3, 0xa4, 0x85, 0x1b, 0x5b, 0xb5, 0x7b, 0xe6, 0xa3, - 0xc0, 0x89, 0x77, 0x77, 0x42, 0xb0, 0xc3, 0x13, 0x93, 0xb8, 0xb6, 0x8f, 0x82, 0x8b, 0xb8, 0x3c, - 0xbf, 0x70, 0xbe, 0xfd, 0x68, 0x5b, 0x9d, 0xb7, 0xf8, 0xf2, 0xdf, 0xaf, 0x5c, 0x43, 0x13, 0xbd, - 0x5f, 0xac, 0x3d, 0xb4, 0x5c, 0x7b, 0xe8, 0xf7, 0xda, 0x43, 0xdf, 0x37, 0x9e, 0xb5, 0xdc, 0x78, - 0xd6, 0xaf, 0x8d, 0x67, 0x7d, 0x78, 0x99, 0x09, 0x33, 0x9c, 0xa5, 0x21, 0x53, 0x39, 0x65, 0x4a, - 0xe7, 0x4a, 0x53, 0x91, 0xb2, 0xab, 0x4c, 0xd1, 0xf9, 0x73, 0x9a, 0x2b, 0x3e, 0x1b, 0x83, 0xae, - 0x36, 0xf6, 0xc9, 0xb3, 0xab, 0xbd, 0xa5, 0x35, 0x5f, 0x27, 0xa0, 0xd3, 0x9b, 0xe5, 0xce, 0x3e, - 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x16, 0xa3, 0xcb, 0xa2, 0x26, 0x03, 0x00, 0x00, + // 436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x33, 0xdd, 0x58, 0xb6, 0xb3, 0xb5, 0xe8, 0x54, 0x21, 0x2e, 0x98, 0x8d, 0x2b, 0x48, + 0x2e, 0xcd, 0x48, 0xf4, 0xa2, 0x78, 0x8a, 0x07, 0x2d, 0x5e, 0x4a, 0x04, 0x0f, 0x82, 0x94, 0x64, + 0xe6, 0x35, 0x1d, 0xba, 0x99, 0x59, 0x77, 0x66, 0x57, 0xfd, 0x06, 0x1e, 0xfd, 0x08, 0x7e, 0x9c, + 0x1e, 0x7b, 0x11, 0x3c, 0x15, 0xd9, 0xfd, 0x16, 0x9e, 0x24, 0x93, 0x3f, 0xac, 0x74, 0x11, 0x4a, + 0x6f, 0xef, 0xbc, 0xef, 0xf3, 0xfc, 0x9e, 0x97, 0xe1, 0xc5, 0x0f, 0x44, 0xce, 0x28, 0x53, 0x33, + 0xa0, 0xec, 0x24, 0x93, 0x12, 0x26, 0x74, 0x11, 0xd3, 0x02, 0x24, 0x68, 0xa1, 0xa3, 0xe9, 0x4c, + 0x19, 0x45, 0xf6, 0x45, 0xce, 0xa2, 0x4a, 0x12, 0x35, 0x92, 0x68, 0x11, 0x0f, 0xef, 0x14, 0xaa, + 0x50, 0x76, 0x4e, 0xab, 0xaa, 0x96, 0x0e, 0x37, 0xd2, 0x5a, 0x97, 0x95, 0x8c, 0x7f, 0xf6, 0xf0, + 0xee, 0xab, 0x9a, 0xff, 0xd6, 0x64, 0x06, 0xc8, 0x07, 0xdc, 0x6f, 0x14, 0xda, 0x43, 0x41, 0x2f, + 0x1c, 0xc4, 0x8f, 0xa2, 0x0d, 0x89, 0xd1, 0x21, 0x07, 0x69, 0xc4, 0x47, 0x01, 0xfc, 0x65, 0xdd, + 0x4c, 0xee, 0x9d, 0x5d, 0x8c, 0x9c, 0x3f, 0x17, 0xa3, 0xdb, 0x97, 0x46, 0x69, 0x87, 0x24, 0x29, + 0xbe, 0x95, 0xb1, 0x53, 0xa9, 0x3e, 0x4f, 0x80, 0x17, 0x50, 0x82, 0x34, 0xda, 0xdb, 0xb2, 0x31, + 0xc1, 0xc6, 0x98, 0xa3, 0x8c, 0x9d, 0x82, 0xb1, 0xab, 0x25, 0x6e, 0x15, 0x90, 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x52, 0xf1, 0xf9, 0x04, 0x74, 0x7d, 0xe5, 0x8f, 0x9f, 0x1e, 0xac, 0x1d, 0xba, 0xf9, 0x3a, + 0x05, 0x9d, 0x6f, 0xdb, 0x3b, 0x7f, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0x28, 0x88, 0xce, 0xb6, + 0x5a, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -259,6 +270,11 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NextChannelSequence != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextChannelSequence)) + i-- + dAtA[i] = 0x30 + } if len(m.SendSequences) > 0 { for iNdEx := len(m.SendSequences) - 1; iNdEx >= 0; iNdEx-- { { @@ -456,6 +472,9 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.NextChannelSequence != 0 { + n += 1 + sovGenesis(uint64(m.NextChannelSequence)) + } return n } @@ -700,6 +719,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextChannelSequence", wireType) + } + m.NextChannelSequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextChannelSequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/core/04-channel/v2/types/genesis_test.go b/modules/core/04-channel/v2/types/genesis_test.go new file mode 100644 index 00000000000..e70290d54b1 --- /dev/null +++ b/modules/core/04-channel/v2/types/genesis_test.go @@ -0,0 +1,102 @@ +package types_test + +import ( + "errors" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func TestValidateGenesis(t *testing.T) { + testCases := []struct { + name string + genState types.GenesisState + expError error + }{ + { + "default", + types.DefaultGenesisState(), + nil, + }, + { + "valid genesis", + types.NewGenesisState( + []types.IdentifiedChannel{ + types.NewIdentifiedChannel( + ibctesting.FirstChannelID, types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath), + ), + types.NewIdentifiedChannel( + ibctesting.SecondChannelID, types.NewChannel(ibctesting.SecondClientID, ibctesting.FirstChannelID, ibctesting.MerklePath), + ), + }, + []types.PacketState{types.NewPacketState(ibctesting.FirstChannelID, 1, []byte("ack"))}, + []types.PacketState{types.NewPacketState(ibctesting.SecondChannelID, 1, []byte(""))}, + []types.PacketState{types.NewPacketState(ibctesting.FirstChannelID, 1, []byte("commit_hash"))}, + []types.PacketSequence{types.NewPacketSequence(ibctesting.SecondChannelID, 1)}, + 2, + ), + nil, + }, + { + "invalid channel identifier", + types.GenesisState{ + Channels: []types.IdentifiedChannel{types.NewIdentifiedChannel(ibctesting.InvalidID, types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath))}, + }, + host.ErrInvalidID, + }, + { + "invalid ack", + types.GenesisState{ + Acknowledgements: []types.PacketState{ + types.NewPacketState(ibctesting.SecondChannelID, 1, nil), + }, + }, + errors.New("data bytes cannot be nil"), + }, + { + "invalid commitment", + types.GenesisState{ + Commitments: []types.PacketState{ + types.NewPacketState(ibctesting.FirstChannelID, 1, nil), + }, + }, + errors.New("data bytes cannot be nil"), + }, + { + "invalid send seq", + types.GenesisState{ + SendSequences: []types.PacketSequence{ + types.NewPacketSequence(ibctesting.FirstChannelID, 0), + }, + }, + errors.New("sequence cannot be 0"), + }, + { + "next channel sequence is less than maximum channel identifier sequence used", + types.GenesisState{ + Channels: []types.IdentifiedChannel{ + types.NewIdentifiedChannel("channel-10", types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath)), + }, + NextChannelSequence: 0, + }, + fmt.Errorf("next channel sequence 0 must be greater than maximum sequence used in channel identifier 10"), + }, + } + + for _, tc := range testCases { + + err := tc.genState.Validate() + + expPass := tc.expError == nil + if expPass { + require.NoError(t, err) + } else { + ibctesting.RequireErrorIsOrContains(t, err, tc.expError) + } + } +} diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 42da61b2a15..1ba7722b925 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -84,12 +84,3 @@ func (p Payload) ValidateBasic() error { func TimeoutTimestampToNanos(seconds uint64) uint64 { return uint64(time.Unix(int64(seconds), 0).UnixNano()) } - -// NewPacketState creates and returns a new PacketState envelope type to encapsulate packet commitments, acks or receipts. -func NewPacketState(channelID string, sequence uint64, data []byte) PacketState { - return PacketState{ - ChannelId: channelID, - Sequence: sequence, - Data: data, - } -} diff --git a/proto/ibc/core/channel/v2/genesis.proto b/proto/ibc/core/channel/v2/genesis.proto index ab2c2b73944..a4c54a91977 100644 --- a/proto/ibc/core/channel/v2/genesis.proto +++ b/proto/ibc/core/channel/v2/genesis.proto @@ -7,13 +7,15 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/type import "gogoproto/gogo.proto"; import "ibc/core/channel/v2/channel.proto"; -// GenesisState defines the ibc channel submodule's genesis state. +// GenesisState defines the ibc channel/v2 submodule's genesis state. message GenesisState { repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; repeated PacketSequence send_sequences = 5 [(gogoproto.nullable) = false]; + // the sequence for the next generated channel identifier + uint64 next_channel_sequence = 6; } // PacketState defines the generic type necessary to retrieve and store From f3afb2c5e2a68bfc1b99d157280e6cca4e00a221 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 21 Nov 2024 16:16:48 +0200 Subject: [PATCH 136/172] chore: add events for send packet (#7577) --- modules/core/04-channel/v2/keeper/events.go | 45 +++++++++++++++++++-- modules/core/04-channel/v2/keeper/packet.go | 2 +- modules/core/04-channel/v2/types/events.go | 17 ++++++-- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 7940cc15ff7..035ff0def79 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -2,15 +2,54 @@ package keeper import ( "context" + "encoding/hex" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) -// EmitSendPacketEvents emits events for the SendPacket handler. -func EmitSendPacketEvents(ctx context.Context, packet types.Packet) { - // TODO: https://github.com/cosmos/ibc-go/issues/7386 +// emitSendPacketEvents emits events for the SendPacket handler. +func emitSendPacketEvents(ctx context.Context, packet types.Packet) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSendPacket, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), + sdk.NewAttribute(types.AttributeKeyPayloadLength, fmt.Sprintf("%d", len(packet.Payloads))), + sdk.NewAttribute(types.AttributeKeyVersion, packet.Payloads[0].Version), + sdk.NewAttribute(types.AttributeKeyEncoding, packet.Payloads[0].Encoding), + sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(packet.Payloads[0].Value)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) + + for i, payload := range packet.Payloads { + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSendPayload, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyPayloadSequence, fmt.Sprintf("%d", i)), + sdk.NewAttribute(types.AttributeKeyVersion, payload.Version), + sdk.NewAttribute(types.AttributeKeyEncoding, payload.Encoding), + sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(payload.Value)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) + } } // EmitRecvPacketEvents emits events for the RecvPacket handler. diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 967b87445f2..9e86f020ef4 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -82,7 +82,7 @@ func (k *Keeper) sendPacket( k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_channel_id", packet.DestinationChannel, "src_channel_id", packet.SourceChannel) - EmitSendPacketEvents(ctx, packet) + emitSendPacketEvents(ctx, packet) return sequence, destChannel, nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 35496926d0e..05e5008155b 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -8,15 +8,26 @@ import ( // IBC channel events const ( + EventTypeCreateChannel = "create_channel" + EventTypeRegisterCounterparty = "register_counterparty" + EventTypeSendPacket = "send_packet" + EventTypeSendPayload = "send_payload" + AttributeKeyChannelID = "channel_id" AttributeKeyClientID = "client_id" AttributeKeyCounterpartyChannelID = "counterparty_channel_id" + AttributeKeySrcChannel = "packet_source_channel" + AttributeKeyDstChannel = "packet_dest_channel" + AttributeKeySequence = "packet_sequence" + AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" + AttributeKeyPayloadLength = "packet_payload_length" + AttributeKeyPayloadSequence = "payload_sequence" + AttributeKeyVersion = "payload_version" + AttributeKeyEncoding = "payload_encoding" + AttributeKeyData = "payload_data" ) // IBC channel events vars var ( - EventTypeCreateChannel = "create_channel" - EventTypeRegisterCounterparty = "register_counterparty" - AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) ) From 8bae734a8e699632f27fab103c25dd892ca66068 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 21 Nov 2024 20:35:08 +0200 Subject: [PATCH 137/172] chore: add events for recv packet. (#7582) * chore: add events for send packet * chore: add events for recv packet. * chore: lint-fixes --- modules/core/04-channel/v2/keeper/events.go | 51 ++++++++++++++++++--- modules/core/04-channel/v2/keeper/packet.go | 4 +- modules/core/04-channel/v2/types/events.go | 5 +- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 035ff0def79..75a9ff0efb8 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -52,8 +52,50 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) { } } -// EmitRecvPacketEvents emits events for the RecvPacket handler. -func EmitRecvPacketEvents(ctx context.Context, packet types.Packet) { +// emitRecvPacketEvents emits events for the RecvPacket handler. +func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRecvPacket, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), + sdk.NewAttribute(types.AttributeKeyPayloadLength, fmt.Sprintf("%d", len(packet.Payloads))), + sdk.NewAttribute(types.AttributeKeyVersion, packet.Payloads[0].Version), + sdk.NewAttribute(types.AttributeKeyEncoding, packet.Payloads[0].Encoding), + sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(packet.Payloads[0].Value)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) + + for i, payload := range packet.Payloads { + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRecvPayload, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyPayloadSequence, fmt.Sprintf("%d", i)), + sdk.NewAttribute(types.AttributeKeyVersion, payload.Version), + sdk.NewAttribute(types.AttributeKeyEncoding, payload.Encoding), + sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(payload.Value)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) + } +} + +// EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. +func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } @@ -67,11 +109,6 @@ func EmitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } -// EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. -func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { - // TODO: https://github.com/cosmos/ibc-go/issues/7386 -} - // emitCreateChannelEvent emits a channel create event. func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 9e86f020ef4..55553e18a53 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -126,7 +126,7 @@ func (k *Keeper) recvPacket( // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. if k.HasPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) { - EmitRecvPacketEvents(ctx, packet) + emitRecvPacketEvents(ctx, packet) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -155,7 +155,7 @@ func (k *Keeper) recvPacket( k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceChannel, "dst_id", packet.DestinationChannel) - EmitRecvPacketEvents(ctx, packet) + emitRecvPacketEvents(ctx, packet) return nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 05e5008155b..da7f25dd586 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -11,7 +11,10 @@ const ( EventTypeCreateChannel = "create_channel" EventTypeRegisterCounterparty = "register_counterparty" EventTypeSendPacket = "send_packet" - EventTypeSendPayload = "send_payload" + EventTypeRecvPacket = "recv_packet" + + EventTypeSendPayload = "send_payload" + EventTypeRecvPayload = "recv_payload" AttributeKeyChannelID = "channel_id" AttributeKeyClientID = "client_id" From f99629d20c8d7e34903dd8158b71aec85735a0d0 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 2 Dec 2024 06:59:21 +0200 Subject: [PATCH 138/172] testing: add merkle path to endpoint struct. (#7576) --- testing/endpoint.go | 4 ++++ testing/endpoint_v2.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/testing/endpoint.go b/testing/endpoint.go index 1fc0be299ed..df72c0e7ac7 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -17,6 +17,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" @@ -37,6 +38,7 @@ type Endpoint struct { ConnectionConfig *ConnectionConfig ChannelConfig *ChannelConfig + MerklePathPrefix commitmenttypesv2.MerklePath // disableUniqueChannelIDs is used to enforce, in a test, // the old way to generate channel IDs (all channels are called channel-0) // It is used only by one test suite and should not be used for new tests. @@ -54,6 +56,7 @@ func NewEndpoint( ClientConfig: clientConfig, ConnectionConfig: connectionConfig, ChannelConfig: channelConfig, + MerklePathPrefix: MerklePath, } } @@ -65,6 +68,7 @@ func NewDefaultEndpoint(chain *TestChain) *Endpoint { ClientConfig: NewTendermintConfig(), ConnectionConfig: NewConnectionConfig(), ChannelConfig: NewChannelConfig(), + MerklePathPrefix: MerklePath, } } diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index b4efd98247b..e28ff51fb6b 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -12,7 +12,7 @@ import ( // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { endpoint.IncrementNextChannelSequence() - msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, endpoint.MerklePathPrefix, endpoint.Chain.SenderAccount.GetAddress().String()) // create channel res, err := endpoint.Chain.SendMsgs(msg) From d894684b17690f701a87ea13b44ae89ca18b2ea1 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 2 Dec 2024 07:23:14 +0200 Subject: [PATCH 139/172] chore: add packet acknowledgements rpc (#7558) * chore: add packet acknowledgements rpc * Update modules/core/04-channel/v2/keeper/grpc_query_test.go Co-authored-by: Gjermund Garaba --------- Co-authored-by: Gjermund Garaba --- .../core/04-channel/v2/keeper/grpc_query.go | 65 +- .../04-channel/v2/keeper/grpc_query_test.go | 113 +++ modules/core/04-channel/v2/types/keys.go | 10 + modules/core/04-channel/v2/types/query.pb.go | 913 +++++++++++++++--- .../core/04-channel/v2/types/query.pb.gw.go | 119 +++ modules/core/24-host/v2/packet_keys.go | 5 - proto/ibc/core/channel/v2/query.proto | 29 +- 7 files changed, 1133 insertions(+), 121 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 644fa315fb5..3f5c7b1e59d 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -17,7 +17,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) var _ types.QueryServer = (*queryServer)(nil) @@ -113,7 +112,7 @@ func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPac } var commitments []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), hostv2.PacketCommitmentPrefixKey(req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.PacketCommitmentPrefixKey(req.ChannelId)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { keySplit := strings.Split(string(key), "/") @@ -165,6 +164,68 @@ func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.Quer return types.NewQueryPacketAcknowledgementResponse(acknowledgement, nil, clienttypes.GetSelfHeight(ctx)), nil } +// PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method. +func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.QueryPacketAcknowledgementsRequest) (*types.QueryPacketAcknowledgementsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if !q.HasChannel(ctx, req.ChannelId) { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, req.ChannelId).Error()) + } + + var acks []*types.PacketState + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.PacketAcknowledgementPrefixKey(req.ChannelId)) + + // if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences) + // otherwise, maintain previous behaviour and perform paginated query + for _, seq := range req.PacketCommitmentSequences { + acknowledgement := q.GetPacketAcknowledgement(ctx, req.ChannelId, seq) + if len(acknowledgement) == 0 { + continue + } + + ack := types.NewPacketState(req.ChannelId, seq, acknowledgement) + acks = append(acks, &ack) + } + + if len(req.PacketCommitmentSequences) > 0 { + selfHeight := clienttypes.GetSelfHeight(ctx) + return &types.QueryPacketAcknowledgementsResponse{ + Acknowledgements: acks, + Pagination: nil, + Height: selfHeight, + }, nil + } + + pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + keySplit := strings.Split(string(key), "/") + + sequence := sdk.BigEndianToUint64([]byte(keySplit[len(keySplit)-1])) + if sequence == 0 { + return types.ErrInvalidPacket + } + + ack := types.NewPacketState(req.ChannelId, sequence, value) + acks = append(acks, &ack) + + return nil + }) + if err != nil { + return nil, err + } + + return &types.QueryPacketAcknowledgementsResponse{ + Acknowledgements: acks, + Pagination: pageRes, + Height: clienttypes.GetSelfHeight(ctx), + }, nil +} + // PacketReceipt implements the Query/PacketReceipt gRPC method. func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index b0e107328d3..4bdcff66ff5 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -410,6 +410,119 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { } } +func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { + var ( + req *types.QueryPacketAcknowledgementsRequest + expAcknowledgements = []*types.PacketState{} + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success: with PacketCommitmentSequences", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + var commitments []uint64 + + for i := uint64(0); i < 100; i++ { + ack := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ChannelId, ack.Sequence, ack.Data) + + if i < 10 { // populate the store with 100 and query for 10 specific acks + expAcknowledgements = append(expAcknowledgements, &ack) + commitments = append(commitments, ack.Sequence) + } + } + + req = &types.QueryPacketAcknowledgementsRequest{ + ChannelId: path.EndpointA.ChannelID, + PacketCommitmentSequences: commitments, + Pagination: nil, + } + }, + nil, + }, + { + "success: with pagination", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expAcknowledgements = make([]*types.PacketState, 0, 10) + + for i := uint64(1); i <= 10; i++ { + ack := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ChannelId, ack.Sequence, ack.Data) + expAcknowledgements = append(expAcknowledgements, &ack) + } + + req = &types.QueryPacketAcknowledgementsRequest{ + ChannelId: path.EndpointA.ChannelID, + Pagination: &query.PageRequest{ + Key: nil, + Limit: 11, + CountTotal: true, + }, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid ID", + func() { + req = &types.QueryPacketAcknowledgementsRequest{ + ChannelId: "", + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryPacketAcknowledgementsRequest{ + ChannelId: "test-channel-id", + } + }, + status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "test-channel-id")), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.PacketAcknowledgements(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expAcknowledgements, res.Acknowledgements) + } else { + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPacketReceipt() { var ( expReceipt bool diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index f751a92b3f1..8e5cae328bf 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -14,3 +14,13 @@ const ( // the creator key is not a part of the ics-24 host specification CreatorKey = "creator" ) + +// PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. +func PacketCommitmentPrefixKey(channelID string) []byte { + return append([]byte(channelID), byte(1)) +} + +// PacketAcknowledgementPrefixKey returns the store key prefix under which packet acknowledgements for a particular channel are stored. +func PacketAcknowledgementPrefixKey(channelID string) []byte { + return append([]byte(channelID), byte(3)) +} diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 32b16b47518..5ae8436bd9b 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -589,6 +589,135 @@ func (m *QueryPacketAcknowledgementResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryPacketAcknowledgementsRequest is the request type for the +// Query/QueryPacketCommitments RPC method +type QueryPacketAcknowledgementsRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // pagination request + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // list of packet sequences + PacketCommitmentSequences []uint64 `protobuf:"varint,3,rep,packed,name=packet_commitment_sequences,json=packetCommitmentSequences,proto3" json:"packet_commitment_sequences,omitempty"` +} + +func (m *QueryPacketAcknowledgementsRequest) Reset() { *m = QueryPacketAcknowledgementsRequest{} } +func (m *QueryPacketAcknowledgementsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketAcknowledgementsRequest) ProtoMessage() {} +func (*QueryPacketAcknowledgementsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{10} +} +func (m *QueryPacketAcknowledgementsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketAcknowledgementsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketAcknowledgementsRequest.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 *QueryPacketAcknowledgementsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketAcknowledgementsRequest.Merge(m, src) +} +func (m *QueryPacketAcknowledgementsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketAcknowledgementsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketAcknowledgementsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketAcknowledgementsRequest proto.InternalMessageInfo + +func (m *QueryPacketAcknowledgementsRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryPacketAcknowledgementsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryPacketAcknowledgementsRequest) GetPacketCommitmentSequences() []uint64 { + if m != nil { + return m.PacketCommitmentSequences + } + return nil +} + +// QueryPacketAcknowledgemetsResponse is the request type for the +// Query/QueryPacketAcknowledgements RPC method +type QueryPacketAcknowledgementsResponse struct { + Acknowledgements []*PacketState `protobuf:"bytes,1,rep,name=acknowledgements,proto3" json:"acknowledgements,omitempty"` + // pagination response + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // query block height + Height types.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"` +} + +func (m *QueryPacketAcknowledgementsResponse) Reset() { *m = QueryPacketAcknowledgementsResponse{} } +func (m *QueryPacketAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketAcknowledgementsResponse) ProtoMessage() {} +func (*QueryPacketAcknowledgementsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{11} +} +func (m *QueryPacketAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketAcknowledgementsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketAcknowledgementsResponse.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 *QueryPacketAcknowledgementsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketAcknowledgementsResponse.Merge(m, src) +} +func (m *QueryPacketAcknowledgementsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketAcknowledgementsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketAcknowledgementsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketAcknowledgementsResponse proto.InternalMessageInfo + +func (m *QueryPacketAcknowledgementsResponse) GetAcknowledgements() []*PacketState { + if m != nil { + return m.Acknowledgements + } + return nil +} + +func (m *QueryPacketAcknowledgementsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryPacketAcknowledgementsResponse) GetHeight() types.Height { + if m != nil { + return m.Height + } + return types.Height{} +} + // QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. type QueryPacketReceiptRequest struct { // port unique identifier @@ -603,7 +732,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{10} + return fileDescriptor_a328cba4986edcab, []int{12} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -667,7 +796,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{11} + return fileDescriptor_a328cba4986edcab, []int{13} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -729,7 +858,7 @@ func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPa func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -784,7 +913,7 @@ func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedP func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -840,7 +969,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{14} + return fileDescriptor_a328cba4986edcab, []int{16} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -896,7 +1025,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{15} + return fileDescriptor_a328cba4986edcab, []int{17} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -950,6 +1079,8 @@ func init() { proto.RegisterType((*QueryPacketCommitmentsResponse)(nil), "ibc.core.channel.v2.QueryPacketCommitmentsResponse") proto.RegisterType((*QueryPacketAcknowledgementRequest)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementRequest") proto.RegisterType((*QueryPacketAcknowledgementResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementResponse") + proto.RegisterType((*QueryPacketAcknowledgementsRequest)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementsRequest") + proto.RegisterType((*QueryPacketAcknowledgementsResponse)(nil), "ibc.core.channel.v2.QueryPacketAcknowledgementsResponse") proto.RegisterType((*QueryPacketReceiptRequest)(nil), "ibc.core.channel.v2.QueryPacketReceiptRequest") proto.RegisterType((*QueryPacketReceiptResponse)(nil), "ibc.core.channel.v2.QueryPacketReceiptResponse") proto.RegisterType((*QueryUnreceivedPacketsRequest)(nil), "ibc.core.channel.v2.QueryUnreceivedPacketsRequest") @@ -961,72 +1092,77 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 1028 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5d, 0x6f, 0xdb, 0x54, - 0x18, 0xee, 0x49, 0xb2, 0xb5, 0x7d, 0x53, 0xa0, 0x3b, 0x2b, 0x22, 0x98, 0x2e, 0xcb, 0x7c, 0x01, - 0x61, 0xda, 0x7c, 0x9a, 0x6c, 0xe2, 0x43, 0xda, 0x84, 0xda, 0x6a, 0x6c, 0x45, 0x02, 0x15, 0x17, - 0x90, 0x40, 0xd3, 0x22, 0xc7, 0x39, 0x73, 0xad, 0x24, 0x3e, 0x5e, 0xec,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0x58, 0xb6, 0xbf, 0x3f, - 0x6c, 0x6b, 0x26, 0xeb, 0x13, 0xf9, 0xd1, 0x6b, 0xb7, 0xcd, 0xab, 0x16, 0x23, 0xa3, 0xf7, 0x49, - 0x9f, 0x75, 0x86, 0x3d, 0xea, 0x09, 0x78, 0x1b, 0xd7, 0xaf, 0x86, 0x10, 0xfa, 0x0f, 0x5d, 0xea, - 0xb5, 0xcf, 0xf2, 0xef, 0xcc, 0x6b, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x92, 0x15, 0x18, - 0x66, 0x0f, 0x00, 0x00, + // 1113 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x5f, 0x6f, 0xdb, 0x54, + 0x14, 0xef, 0x6d, 0xba, 0xb5, 0x3d, 0x29, 0xa3, 0xbb, 0x2b, 0x90, 0x79, 0x5d, 0x96, 0x19, 0x09, + 0xc2, 0xb4, 0xf9, 0x36, 0xd9, 0x04, 0x43, 0xda, 0x40, 0x6d, 0x19, 0x5b, 0x27, 0x40, 0xc5, 0x05, + 0x24, 0xd0, 0xb4, 0xc8, 0x71, 0xee, 0x5c, 0x2b, 0x89, 0xaf, 0x17, 0x3b, 0xa1, 0xd3, 0xd4, 0x17, + 0x1e, 0x78, 0x46, 0xec, 0x8d, 0x4f, 0x00, 0x2f, 0x7c, 0x05, 0x90, 0x78, 0x99, 0xb4, 0x97, 0x49, + 0x7b, 0x80, 0x27, 0x04, 0x2d, 0x12, 0xdf, 0x80, 0x67, 0x94, 0xeb, 0xeb, 0xf8, 0x4f, 0x1c, 0xd7, + 0xde, 0x56, 0xc4, 0x9b, 0x7d, 0x73, 0xfe, 0xfc, 0x7e, 0xe7, 0xfe, 0x8e, 0xcf, 0x51, 0xe0, 0x8c, + 0xd9, 0xd4, 0x89, 0xce, 0x7a, 0x94, 0xe8, 0xdb, 0x9a, 0x65, 0xd1, 0x0e, 0x19, 0xd4, 0xc9, 0xdd, + 0x3e, 0xed, 0xdd, 0x53, 0xec, 0x1e, 0x73, 0x19, 0x3e, 0x61, 0x36, 0x75, 0x65, 0x68, 0xa0, 0x08, + 0x03, 0x65, 0x50, 0x97, 0xce, 0xe9, 0xcc, 0xe9, 0x32, 0x87, 0x34, 0x35, 0x87, 0x7a, 0xd6, 0x64, + 0x50, 0x6b, 0x52, 0x57, 0xab, 0x11, 0x5b, 0x33, 0x4c, 0x4b, 0x73, 0x4d, 0x66, 0x79, 0x01, 0xa4, + 0xb3, 0x49, 0x19, 0xfc, 0x58, 0x29, 0x26, 0x06, 0xb5, 0xa8, 0x63, 0x3a, 0xc2, 0x24, 0x84, 0xb3, + 0x63, 0x52, 0xcb, 0x25, 0x83, 0x9a, 0x78, 0x12, 0x06, 0xcb, 0x06, 0x63, 0x46, 0x87, 0x12, 0xcd, + 0x36, 0x89, 0x66, 0x59, 0xcc, 0xe5, 0x18, 0x7c, 0xf7, 0x25, 0x83, 0x19, 0x8c, 0x3f, 0x92, 0xe1, + 0x93, 0x77, 0x2a, 0x5f, 0x82, 0x13, 0x1f, 0x0f, 0xc1, 0xaf, 0x7b, 0x59, 0x55, 0x7a, 0xb7, 0x4f, + 0x1d, 0x17, 0x9f, 0x06, 0x10, 0x38, 0x1a, 0x66, 0xab, 0x84, 0x2a, 0xa8, 0x3a, 0xaf, 0xce, 0x8b, + 0x93, 0x8d, 0x96, 0xfc, 0x09, 0x2c, 0x45, 0xbd, 0x1c, 0x9b, 0x59, 0x0e, 0xc5, 0x57, 0x60, 0x56, + 0x18, 0x71, 0x9f, 0x62, 0x7d, 0x59, 0x49, 0xa8, 0x9d, 0x22, 0xdc, 0xd6, 0x66, 0x1e, 0xfe, 0x7e, + 0x66, 0x4a, 0xf5, 0x5d, 0xe4, 0xab, 0xb0, 0xcc, 0xa3, 0x7e, 0x44, 0x77, 0xdc, 0xad, 0x21, 0x10, + 0x4b, 0xa7, 0x5b, 0xd4, 0x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, 0x8c, 0x1e, 0xef, 0x95, 0xd1, 0x1f, 0x7b, + 0x65, 0xf4, 0xcd, 0x7e, 0x79, 0xea, 0xf1, 0x7e, 0x79, 0xea, 0xb7, 0xfd, 0xf2, 0xd4, 0x17, 0x57, + 0x0c, 0xd3, 0xdd, 0xee, 0x37, 0x15, 0x9d, 0x75, 0x89, 0xf8, 0x57, 0xc6, 0x6c, 0xea, 0x17, 0x0c, + 0x46, 0x06, 0x6f, 0x93, 0x2e, 0x6b, 0xf5, 0x3b, 0xd4, 0xf1, 0xe0, 0xad, 0x5c, 0xba, 0x10, 0x42, + 0xe8, 0xde, 0xb3, 0xa9, 0xd3, 0x3c, 0xca, 0xff, 0x08, 0xb9, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xd2, 0x18, 0x54, 0x2c, 0x07, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1051,8 +1187,11 @@ type QueryClient interface { PacketCommitments(ctx context.Context, in *QueryPacketCommitmentsRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentsResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(ctx context.Context, in *QueryPacketAcknowledgementRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementResponse, error) + // PacketAcknowledgements returns all packet acknowledgements associated with a channel. + PacketAcknowledgements(ctx context.Context, in *QueryPacketAcknowledgementsRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementsResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) + // UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. UnreceivedPackets(ctx context.Context, in *QueryUnreceivedPacketsRequest, opts ...grpc.CallOption) (*QueryUnreceivedPacketsResponse, error) // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAcksRequest, opts ...grpc.CallOption) (*QueryUnreceivedAcksResponse, error) @@ -1111,6 +1250,15 @@ func (c *queryClient) PacketAcknowledgement(ctx context.Context, in *QueryPacket return out, nil } +func (c *queryClient) PacketAcknowledgements(ctx context.Context, in *QueryPacketAcknowledgementsRequest, opts ...grpc.CallOption) (*QueryPacketAcknowledgementsResponse, error) { + out := new(QueryPacketAcknowledgementsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketAcknowledgements", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) PacketReceipt(ctx context.Context, in *QueryPacketReceiptRequest, opts ...grpc.CallOption) (*QueryPacketReceiptResponse, error) { out := new(QueryPacketReceiptResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketReceipt", in, out, opts...) @@ -1150,8 +1298,11 @@ type QueryServer interface { PacketCommitments(context.Context, *QueryPacketCommitmentsRequest) (*QueryPacketCommitmentsResponse, error) // PacketAcknowledgement queries a stored acknowledgement commitment hash. PacketAcknowledgement(context.Context, *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) + // PacketAcknowledgements returns all packet acknowledgements associated with a channel. + PacketAcknowledgements(context.Context, *QueryPacketAcknowledgementsRequest) (*QueryPacketAcknowledgementsResponse, error) // PacketReceipt queries a stored packet receipt. PacketReceipt(context.Context, *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) + // UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. UnreceivedPackets(context.Context, *QueryUnreceivedPacketsRequest) (*QueryUnreceivedPacketsResponse, error) // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. UnreceivedAcks(context.Context, *QueryUnreceivedAcksRequest) (*QueryUnreceivedAcksResponse, error) @@ -1176,6 +1327,9 @@ func (*UnimplementedQueryServer) PacketCommitments(ctx context.Context, req *Que func (*UnimplementedQueryServer) PacketAcknowledgement(ctx context.Context, req *QueryPacketAcknowledgementRequest) (*QueryPacketAcknowledgementResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketAcknowledgement not implemented") } +func (*UnimplementedQueryServer) PacketAcknowledgements(ctx context.Context, req *QueryPacketAcknowledgementsRequest) (*QueryPacketAcknowledgementsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketAcknowledgements not implemented") +} func (*UnimplementedQueryServer) PacketReceipt(ctx context.Context, req *QueryPacketReceiptRequest) (*QueryPacketReceiptResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PacketReceipt not implemented") } @@ -1280,6 +1434,24 @@ func _Query_PacketAcknowledgement_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Query_PacketAcknowledgements_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketAcknowledgementsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketAcknowledgements(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/PacketAcknowledgements", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketAcknowledgements(ctx, req.(*QueryPacketAcknowledgementsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_PacketReceipt_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryPacketReceiptRequest) if err := dec(in); err != nil { @@ -1358,6 +1530,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PacketAcknowledgement", Handler: _Query_PacketAcknowledgement_Handler, }, + { + MethodName: "PacketAcknowledgements", + Handler: _Query_PacketAcknowledgements_Handler, + }, { MethodName: "PacketReceipt", Handler: _Query_PacketReceipt_Handler, @@ -1778,6 +1954,125 @@ func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } +func (m *QueryPacketAcknowledgementsRequest) 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 *QueryPacketAcknowledgementsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketCommitmentSequences) > 0 { + dAtA9 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j8 int + for _, num := range m.PacketCommitmentSequences { + for num >= 1<<7 { + dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j8++ + } + dAtA9[j8] = uint8(num) + j8++ + } + i -= j8 + copy(dAtA[i:], dAtA9[:j8]) + i = encodeVarintQuery(dAtA, i, uint64(j8)) + i-- + dAtA[i] = 0x1a + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketAcknowledgementsResponse) 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 *QueryPacketAcknowledgementsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketAcknowledgementsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Acknowledgements) > 0 { + for iNdEx := len(m.Acknowledgements) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Acknowledgements[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryPacketReceiptRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1891,20 +2186,20 @@ func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l if len(m.Sequences) > 0 { - dAtA10 := make([]byte, len(m.Sequences)*10) - var j9 int + dAtA15 := make([]byte, len(m.Sequences)*10) + var j14 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j9++ + j14++ } - dAtA10[j9] = uint8(num) - j9++ + dAtA15[j14] = uint8(num) + j14++ } - i -= j9 - copy(dAtA[i:], dAtA10[:j9]) - i = encodeVarintQuery(dAtA, i, uint64(j9)) + i -= j14 + copy(dAtA[i:], dAtA15[:j14]) + i = encodeVarintQuery(dAtA, i, uint64(j14)) i-- dAtA[i] = 0x12 } @@ -1949,20 +2244,20 @@ func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA13 := make([]byte, len(m.Sequences)*10) - var j12 int + dAtA18 := make([]byte, len(m.Sequences)*10) + var j17 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j12++ + j17++ } - dAtA13[j12] = uint8(num) - j12++ + dAtA18[j17] = uint8(num) + j17++ } - i -= j12 - copy(dAtA[i:], dAtA13[:j12]) - i = encodeVarintQuery(dAtA, i, uint64(j12)) + i -= j17 + copy(dAtA[i:], dAtA18[:j17]) + i = encodeVarintQuery(dAtA, i, uint64(j17)) i-- dAtA[i] = 0xa } @@ -1990,20 +2285,20 @@ func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, err var l int _ = l if len(m.PacketAckSequences) > 0 { - dAtA15 := make([]byte, len(m.PacketAckSequences)*10) - var j14 int + dAtA20 := make([]byte, len(m.PacketAckSequences)*10) + var j19 int for _, num := range m.PacketAckSequences { for num >= 1<<7 { - dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) + dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j14++ + j19++ } - dAtA15[j14] = uint8(num) - j14++ + dAtA20[j19] = uint8(num) + j19++ } - i -= j14 - copy(dAtA[i:], dAtA15[:j14]) - i = encodeVarintQuery(dAtA, i, uint64(j14)) + i -= j19 + copy(dAtA[i:], dAtA20[:j19]) + i = encodeVarintQuery(dAtA, i, uint64(j19)) i-- dAtA[i] = 0x12 } @@ -2048,20 +2343,20 @@ func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA18 := make([]byte, len(m.Sequences)*10) - var j17 int + dAtA23 := make([]byte, len(m.Sequences)*10) + var j22 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + dAtA23[j22] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j17++ + j22++ } - dAtA18[j17] = uint8(num) - j17++ + dAtA23[j22] = uint8(num) + j22++ } - i -= j17 - copy(dAtA[i:], dAtA18[:j17]) - i = encodeVarintQuery(dAtA, i, uint64(j17)) + i -= j22 + copy(dAtA[i:], dAtA23[:j22]) + i = encodeVarintQuery(dAtA, i, uint64(j22)) i-- dAtA[i] = 0xa } @@ -2242,16 +2537,61 @@ func (m *QueryPacketAcknowledgementResponse) Size() (n int) { return n } -func (m *QueryPacketReceiptRequest) Size() (n int) { +func (m *QueryPacketAcknowledgementsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.PacketCommitmentSequences) > 0 { + l = 0 + for _, e := range m.PacketCommitmentSequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryPacketAcknowledgementsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Acknowledgements) > 0 { + for _, e := range m.Acknowledgements { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Height.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPacketReceiptRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } l = len(m.ChannelId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -3520,6 +3860,353 @@ func (m *QueryPacketAcknowledgementResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPacketAcknowledgementsRequest) 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 ErrIntOverflowQuery + } + 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: QueryPacketAcknowledgementsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketAcknowledgementsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PacketCommitmentSequences = append(m.PacketCommitmentSequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PacketCommitmentSequences) == 0 { + m.PacketCommitmentSequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PacketCommitmentSequences = append(m.PacketCommitmentSequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PacketCommitmentSequences", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketAcknowledgementsResponse) 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 ErrIntOverflowQuery + } + 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: QueryPacketAcknowledgementsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketAcknowledgementsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgements", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Acknowledgements = append(m.Acknowledgements, &PacketState{}) + if err := m.Acknowledgements[len(m.Acknowledgements)-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 Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryPacketReceiptRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 9454ddcb63a..2f03fdadfd5 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -365,6 +365,78 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler } +var ( + filter_Query_PacketAcknowledgements_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketAcknowledgementsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PacketAcknowledgements(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPacketAcknowledgementsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PacketAcknowledgements(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_PacketReceipt_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0, "sequence": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} ) @@ -732,6 +804,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PacketAcknowledgements_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -942,6 +1037,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PacketAcknowledgements_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1016,6 +1131,8 @@ var ( pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1034,6 +1151,8 @@ var ( forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage + forward_Query_PacketAcknowledgements_0 = runtime.ForwardResponseMessage + forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage forward_Query_UnreceivedPackets_0 = runtime.ForwardResponseMessage diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index a95814198f8..5522375fb5f 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -11,11 +11,6 @@ func PacketCommitmentKey(channelID string, sequence uint64) []byte { return append(append([]byte(channelID), byte(1)), sdk.Uint64ToBigEndian(sequence)...) } -// PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. -func PacketCommitmentPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(1)) -} - // PacketReceiptKey returns the store key of under which a packet receipt is stored. func PacketReceiptKey(channelID string, sequence uint64) []byte { return append(append([]byte(channelID), byte(2)), sdk.Uint64ToBigEndian(sequence)...) diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index ca77940306d..40d1cdc31eb 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -38,16 +38,22 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acks/{sequence}"; } + // PacketAcknowledgements returns all packet acknowledgements associated with a channel. + rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acknowledgements"; + } + // PacketReceipt queries a stored packet receipt. rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}"; } + // UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/" "{sequences}/unreceived_packets"; } - + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { option (google.api.http).get = @@ -136,6 +142,27 @@ message QueryPacketAcknowledgementResponse { ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } +// QueryPacketAcknowledgementsRequest is the request type for the +// Query/QueryPacketCommitments RPC method +message QueryPacketAcknowledgementsRequest { + // channel unique identifier + string channel_id = 1; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 2; + // list of packet sequences + repeated uint64 packet_commitment_sequences = 3; +} + +// QueryPacketAcknowledgemetsResponse is the request type for the +// Query/QueryPacketAcknowledgements RPC method +message QueryPacketAcknowledgementsResponse { + repeated ibc.core.channel.v2.PacketState acknowledgements = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + // QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. message QueryPacketReceiptRequest { // port unique identifier From 3864793889dd4e09aee5caefcf79c1272e69864b Mon Sep 17 00:00:00 2001 From: srdtrk <59252793+srdtrk@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:24:05 +0800 Subject: [PATCH 140/172] imp: added simpler events (#7613) --- modules/core/04-channel/v2/keeper/events.go | 142 ++++++++++++-------- modules/core/04-channel/v2/keeper/packet.go | 11 +- modules/core/04-channel/v2/types/events.go | 13 +- 3 files changed, 98 insertions(+), 68 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 75a9ff0efb8..5245b54901b 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -5,6 +5,8 @@ import ( "encoding/hex" "fmt" + "github.com/cosmos/gogoproto/proto" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" @@ -14,6 +16,11 @@ import ( func emitSendPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx := sdk.UnwrapSDKContext(ctx) + encodedPacket, err := proto.Marshal(&packet) + if err != nil { + panic(err) + } + sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSendPacket, @@ -21,41 +28,24 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPayloadLength, fmt.Sprintf("%d", len(packet.Payloads))), - sdk.NewAttribute(types.AttributeKeyVersion, packet.Payloads[0].Version), - sdk.NewAttribute(types.AttributeKeyEncoding, packet.Payloads[0].Encoding), - sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(packet.Payloads[0].Value)), + sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), ), }) - - for i, payload := range packet.Payloads { - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeSendPayload, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), - sdk.NewAttribute(types.AttributeKeyPayloadSequence, fmt.Sprintf("%d", i)), - sdk.NewAttribute(types.AttributeKeyVersion, payload.Version), - sdk.NewAttribute(types.AttributeKeyEncoding, payload.Encoding), - sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(payload.Value)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) - } } // emitRecvPacketEvents emits events for the RecvPacket handler. func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx := sdk.UnwrapSDKContext(ctx) + encodedPacket, err := proto.Marshal(&packet) + if err != nil { + panic(err) + } + sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, @@ -63,50 +53,94 @@ func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPayloadLength, fmt.Sprintf("%d", len(packet.Payloads))), - sdk.NewAttribute(types.AttributeKeyVersion, packet.Payloads[0].Version), - sdk.NewAttribute(types.AttributeKeyEncoding, packet.Payloads[0].Encoding), - sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(packet.Payloads[0].Value)), + sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), ), }) +} - for i, payload := range packet.Payloads { - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRecvPayload, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), - sdk.NewAttribute(types.AttributeKeyPayloadSequence, fmt.Sprintf("%d", i)), - sdk.NewAttribute(types.AttributeKeyVersion, payload.Version), - sdk.NewAttribute(types.AttributeKeyEncoding, payload.Encoding), - sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(payload.Value)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +// emitWriteAcknowledgementEvents emits events for WriteAcknowledgement. +func emitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + encodedPacket, err := proto.Marshal(&packet) + if err != nil { + panic(err) } -} -// EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. -func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { - // TODO: https://github.com/cosmos/ibc-go/issues/7386 + encodedAck, err := proto.Marshal(&ack) + if err != nil { + panic(err) + } + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeWriteAck, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), + sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyAckDataHex, hex.EncodeToString(encodedAck)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) } -// EmitAcknowledgePacketEvents emits events for the AcknowledgePacket handler. -func EmitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { - // TODO: https://github.com/cosmos/ibc-go/issues/7386 +// emitAcknowledgePacketEvents emits events for the AcknowledgePacket handler. +func emitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + encodedPacket, err := proto.Marshal(&packet) + if err != nil { + panic(err) + } + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAcknowledgePacket, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), + sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) } -// EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. -func EmitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { - // TODO: https://github.com/cosmos/ibc-go/issues/7386 +// emitTimeoutPacketEvents emits events for the TimeoutPacket handler. +func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + encodedPacket, err := proto.Marshal(&packet) + if err != nil { + panic(err) + } + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeTimeoutPacket, + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), + sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), + sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) } // emitCreateChannelEvent emits a channel create event. diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 55553e18a53..392edb92db9 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -205,8 +205,7 @@ func (k Keeper) WriteAcknowledgement( k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest-channel", packet.DestinationChannel) - // TODO: decide how relayers will reconstruct the packet as it is not being passed. - // EmitWriteAcknowledgementEvents(ctx, packet, ack) + emitWriteAcknowledgementEvents(ctx, packet, ack) // TODO: delete the packet that has been stored in ibc-core. @@ -230,7 +229,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { // TODO: signal noop in events? - EmitAcknowledgePacketEvents(ctx, packet) + emitAcknowledgePacketEvents(ctx, packet) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement @@ -265,7 +264,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "source_channel_id", packet.GetSourceChannel(), "destination_channel_id", packet.GetDestinationChannel()) - EmitAcknowledgePacketEvents(ctx, packet) + emitAcknowledgePacketEvents(ctx, packet) return nil } @@ -308,7 +307,7 @@ func (k *Keeper) timeoutPacket( // check that the commitment has not been cleared and that it matches the packet sent by relayer commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - EmitTimeoutPacketEvents(ctx, packet) + emitTimeoutPacketEvents(ctx, packet) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -342,7 +341,7 @@ func (k *Keeper) timeoutPacket( k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_channel_id", packet.SourceChannel, "dst_channel_id", packet.DestinationChannel) - EmitTimeoutPacketEvents(ctx, packet) + emitTimeoutPacketEvents(ctx, packet) return nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index da7f25dd586..46ba862ac68 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -12,9 +12,9 @@ const ( EventTypeRegisterCounterparty = "register_counterparty" EventTypeSendPacket = "send_packet" EventTypeRecvPacket = "recv_packet" - - EventTypeSendPayload = "send_payload" - EventTypeRecvPayload = "recv_payload" + EventTypeTimeoutPacket = "timeout_packet" + EventTypeAcknowledgePacket = "acknowledge_packet" + EventTypeWriteAck = "write_acknowledgement" AttributeKeyChannelID = "channel_id" AttributeKeyClientID = "client_id" @@ -23,11 +23,8 @@ const ( AttributeKeyDstChannel = "packet_dest_channel" AttributeKeySequence = "packet_sequence" AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" - AttributeKeyPayloadLength = "packet_payload_length" - AttributeKeyPayloadSequence = "payload_sequence" - AttributeKeyVersion = "payload_version" - AttributeKeyEncoding = "payload_encoding" - AttributeKeyData = "payload_data" + AttributeKeyPacketDataHex = "packet_data_hex" + AttributeKeyAckDataHex = "acknowledgement_data_hex" ) // IBC channel events vars From b9000c37c798e7166f2b37b9fd3008e3d9d2938b Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 3 Dec 2024 11:05:30 +0100 Subject: [PATCH 141/172] feat: add solidity ABI support in ICS20Transfer ics20-1 (#7592) * add support for abi encoding in ICS20Transfer * fix abi encoding order * add tests for unmarshaling packet data with encoding * change from x-abi to x-solidity-abi * use solidity abigen for encoding of abi ics20 payloads * lint * fix arm64 test build * install compiler before first build step * bump ethereum-go * bump prysm for wasm simapp * tidy * add comment to abi encoding function * code review cleanups --------- Co-authored-by: srdtrk --- .github/workflows/test.yml | 6 +- .golangci.yml | 3 + e2e/go.mod | 36 ++-- e2e/go.sum | 136 ++++++++++++---- go.mod | 22 ++- go.sum | 86 +++++++++- modules/apps/callbacks/go.mod | 23 ++- modules/apps/callbacks/go.sum | 88 +++++++++- modules/apps/transfer/types/packet.go | 29 +++- modules/apps/transfer/types/packet_test.go | 113 ++++++++++++- .../transfer/v2/keeper/msg_server_test.go | 82 ++++++++-- .../04-channel/v2/types/commitment_test.go | 82 +++++++--- modules/light-clients/08-wasm/go.mod | 41 +++-- modules/light-clients/08-wasm/go.sum | 154 ++++++++++++++---- .../testing/simapp/customquery/crypto.go | 2 +- simapp/go.mod | 23 ++- simapp/go.sum | 88 +++++++++- 17 files changed, 869 insertions(+), 145 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0efed2df15b..b9833daa4ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,14 +34,14 @@ jobs: **/**.go go.mod go.sum - - name: Build ibc-go - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - name: Install compiler for arm64. if: matrix.go-arch == 'arm64' run: | sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + - name: Build ibc-go + run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - name: Build e2e run: | cd e2e diff --git a/.golangci.yml b/.golangci.yml index 99a7c1eadf8..8b9c5d6b8b6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,9 @@ issues: - linters: - staticcheck text: "SA1019:" # silence errors on usage of deprecated funcs + - text: "G115: integer overflow conversion" + linters: + - gosec max-issues-per-linter: 10000 max-same-issues: 10000 diff --git a/e2e/go.mod b/e2e/go.mod index 238265f08cb..3b840d6b765 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -63,7 +63,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect - github.com/bits-and-blooms/bitset v1.12.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -75,6 +75,8 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.1.0 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect @@ -84,9 +86,13 @@ require ( github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set v1.8.0 // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/base58 v1.0.5 // indirect github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1 // indirect @@ -101,7 +107,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect - github.com/ethereum/go-ethereum v1.13.14 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -109,8 +117,9 @@ require ( github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.3 // indirect @@ -149,7 +158,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect - github.com/holiman/uint256 v1.2.4 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 // indirect @@ -160,7 +169,7 @@ require ( github.com/jmhodges/levigo v1.0.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.17.9 // indirect - github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.9 // indirect @@ -178,6 +187,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/mtibben/percent v0.2.1 // indirect @@ -213,6 +223,7 @@ require ( github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/shamaton/msgpack/v2 v2.2.0 // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.11.0 // indirect @@ -221,24 +232,28 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.13 // indirect + github.com/tklauser/numcpus v0.7.0 // indirect github.com/tyler-smith/go-bip32 v1.0.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.4.0-alpha.1 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel v1.29.0 // indirect + go.opentelemetry.io/otel/metric v1.29.0 // indirect + go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.28.0 // indirect - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect @@ -246,7 +261,7 @@ require ( golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/tools v0.24.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect @@ -269,6 +284,7 @@ require ( modernc.org/token v1.1.0 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/e2e/go.sum b/e2e/go.sum index bc9ea4278b1..9e1e91626cc 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -256,10 +256,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/StirlingMarketingGroup/go-namecase v1.0.0 h1:2CzaNtCzc4iNHirR+5ru9OzGg8rQp860gqLBFqRI02Y= github.com/StirlingMarketingGroup/go-namecase v1.0.0/go.mod h1:ZsoSKcafcAzuBx+sndbxHu/RjDcDTrEdT4UvhniHfio= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= @@ -295,8 +295,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA= -github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -312,6 +312,8 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -363,6 +365,10 @@ github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cV github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -393,8 +399,15 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= @@ -405,8 +418,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= -github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/base58 v1.0.5 h1:hwcieUM3pfPnE/6p3J100zoRfGkQxBulZHo7GZfOqic= github.com/decred/base58 v1.0.5/go.mod h1:s/8lukEHFA6bUQQb/v3rjUySJ2hu+RioCzLukAVkrfw= github.com/decred/dcrd/chaincfg/chainhash v1.0.2 h1:rt5Vlq/jM3ZawwiacWjPa+smINyLRN07EO0cNBV6DGU= @@ -462,8 +475,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= -github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -504,10 +521,11 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -523,10 +541,14 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -626,6 +648,7 @@ github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b/go.mod h1:czg5+yv1E0Z github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -678,6 +701,8 @@ github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIv github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -725,14 +750,22 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= -github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= -github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e h1:wCMygKUQhmcQAjlk2Gquzq6dLmyMv2kF+llRspoRgrk= +github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -747,6 +780,8 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -777,8 +812,8 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= -github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -791,6 +826,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -822,6 +859,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -846,12 +885,19 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= @@ -897,6 +943,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -985,6 +1033,14 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516 h1:xuVAdtz5ShYblG2sPyb4gw01DF8InbOI/kBCQjk7NiM= +github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516/go.mod h1:h2OlIZD/M6wFvV3YMZbW16lFgh3Rsye00G44J2cwLyU= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e h1:ATgOe+abbzfx9kCPeXIW4fiWyDdxlwHw07j8UGhdTd4= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= +github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b h1:VK7thFOnhxAZ/5aolr5Os4beiubuD08WiuiHyRqgwks= +github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b/go.mod h1:HRuvtXLZ4WkaB1MItToVH2e8ZwKwZPY5/Rcby+CvvLY= +github.com/prysmaticlabs/prysm/v5 v5.1.2 h1:ib9D7Drh7QPoetJPnYXAHaArmjIreXPZ0FboW9EMzT8= +github.com/prysmaticlabs/prysm/v5 v5.1.2/go.mod h1:ykj3Bl9dHv35cC7fRw6Cd1aCd9l+eNvInHY6gsPbEig= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -992,6 +1048,8 @@ github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5 github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -1004,7 +1062,9 @@ github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= @@ -1017,8 +1077,8 @@ github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6v github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shamaton/msgpack/v2 v2.2.0 h1:IP1m01pHwCrMa6ZccP9B3bqxEMKMSmMVAVKk54g3L/Y= github.com/shamaton/msgpack/v2 v2.2.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1073,16 +1133,20 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo= +github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= +github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= +github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJdv5KE= @@ -1095,14 +1159,21 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= @@ -1126,14 +1197,14 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1178,8 +1249,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1331,6 +1402,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1494,8 +1566,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1753,6 +1825,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= @@ -1823,6 +1897,8 @@ pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/go.mod b/go.mod index 6249baccb4c..4294787ed0c 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/cosmos/cosmos-sdk v0.50.10 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ics23/go v0.11.0 + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 @@ -46,11 +47,12 @@ require ( github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -62,13 +64,18 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -76,6 +83,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -85,13 +95,14 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -118,6 +129,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -137,6 +149,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -157,14 +170,18 @@ require ( github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect @@ -193,6 +210,7 @@ require ( gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 3c0fe54de3e..c35daaa5d41 100644 --- a/go.sum +++ b/go.sum @@ -230,6 +230,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= @@ -263,8 +267,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= -github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -278,6 +282,8 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -327,6 +333,10 @@ github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cV github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -354,8 +364,15 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= @@ -364,6 +381,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= @@ -406,6 +425,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -450,6 +475,9 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -463,6 +491,8 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -473,6 +503,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -514,8 +546,9 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= @@ -569,6 +602,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -616,6 +650,8 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NM github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -663,12 +699,20 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -679,6 +723,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -721,6 +767,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -748,6 +796,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= @@ -765,6 +815,11 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -796,6 +851,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -883,6 +940,8 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -896,6 +955,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= @@ -906,6 +966,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -957,12 +1019,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -971,8 +1039,13 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1199,6 +1272,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1273,6 +1347,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= @@ -1619,6 +1695,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1655,6 +1733,8 @@ pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 40e812ed712..adb9716e369 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -41,11 +41,12 @@ require ( github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -57,16 +58,21 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect - github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -74,6 +80,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -83,6 +92,7 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -90,7 +100,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -118,6 +128,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -137,6 +148,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -156,15 +168,19 @@ require ( github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect @@ -197,5 +213,6 @@ require ( gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 2fe67923711..51b2012e95c 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -230,6 +230,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= @@ -263,8 +267,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= -github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -278,6 +282,8 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -327,6 +333,10 @@ github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cV github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -350,14 +360,19 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= -github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= -github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= @@ -366,6 +381,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= @@ -408,6 +425,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -452,6 +475,9 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -464,6 +490,8 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -474,6 +502,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -515,8 +545,9 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= @@ -570,6 +601,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -617,6 +649,8 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NM github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -664,12 +698,20 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -680,6 +722,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -722,6 +766,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -749,6 +795,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= @@ -766,6 +814,11 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -796,6 +849,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -883,6 +938,8 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -896,6 +953,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= @@ -906,6 +964,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -957,12 +1017,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -971,8 +1037,13 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1199,6 +1270,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1272,6 +1344,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= @@ -1617,6 +1691,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1653,6 +1729,8 @@ pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 968e996c08f..8978ad7443e 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" @@ -26,6 +27,7 @@ var ( const ( EncodingJSON = "application/json" EncodingProtobuf = "application/x-protobuf" + EncodingABI = "application/x-solidity-abi" ) // NewFungibleTokenPacketData constructs a new FungibleTokenPacketData instance @@ -256,7 +258,15 @@ func UnmarshalPacketData(bz []byte, ics20Version string, encoding string) (Fungi if err := proto.Unmarshal(bz, data); err != nil { return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, failedUnmarshalingErrorMsg, errorMsgVersion, err.Error()) } - + case EncodingABI: + if ics20Version != V1 { + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "encoding %s is only supported for ICS20-V1", EncodingABI) + } + var err error + data, err = decodeABIFungibleTokenPacketData(bz) + if err != nil { + return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, failedUnmarshalingErrorMsg, errorMsgVersion, err.Error()) + } default: return FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "invalid encoding provided, must be either empty or one of [%q, %q], got %s", EncodingJSON, EncodingProtobuf, encoding) } @@ -308,3 +318,20 @@ func PacketDataV1ToV2(packetData FungibleTokenPacketData) (FungibleTokenPacketDa Forwarding: ForwardingPacketData{}, }, nil } + +// decodeABIFungibleTokenPacketData decodes a solidity ABI encoded ics20lib.ICS20LibFungibleTokenPacketData +// and converts it into an ibc-go FungibleTokenPacketData. +func decodeABIFungibleTokenPacketData(data []byte) (*FungibleTokenPacketData, error) { + solidityFtpd, err := ics20lib.DecodeFungibleTokenPacketData(data) + if err != nil { + return nil, err + } + + return &FungibleTokenPacketData{ + Denom: solidityFtpd.Denom, + Amount: solidityFtpd.Amount.String(), + Sender: solidityFtpd.Sender, + Receiver: solidityFtpd.Receiver, + Memo: solidityFtpd.Memo, + }, nil +} diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index db166b2b8d8..2672de80430 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -2,9 +2,13 @@ package types_test import ( "encoding/json" + "errors" "fmt" + "math/big" "testing" + "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" @@ -719,6 +723,7 @@ func TestUnmarshalPacketData(t *testing.T) { var ( packetDataBz []byte version string + encoding string ) testCases := []struct { @@ -727,12 +732,48 @@ func TestUnmarshalPacketData(t *testing.T) { expError error }{ { - "success: v1 -> v2", + "success: v1 -> v2 with empty encoding (JSON)", func() {}, nil, }, { - "success: v2", + "success: v1 -> v2 with JSON encoding", + func() { + encoding = types.EncodingJSON + }, + nil, + }, + { + "success: v1 -> v2 with protobuf encoding", + func() { + packetData := types.NewFungibleTokenPacketData("transfer/channel-0/atom", "1000", sender, receiver, "") + bz, err := proto.Marshal(&packetData) + require.NoError(t, err) + + packetDataBz = bz + encoding = types.EncodingProtobuf + }, + nil, + }, + { + "success: v1 -> v2 with abi encoding", + func() { + bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: "atom", + Amount: big.NewInt(1000), + Sender: sender, + Receiver: receiver, + Memo: "", + }) + require.NoError(t, err) + + packetDataBz = bz + encoding = types.EncodingABI + }, + nil, + }, + { + "success: v2 with empty encoding (protobuf)", func() { packetData := types.NewFungibleTokenPacketDataV2( []types.Token{ @@ -747,6 +788,63 @@ func TestUnmarshalPacketData(t *testing.T) { }, nil, }, + { + "success: v2 with JSON encoding", + func() { + packetData := types.NewFungibleTokenPacketDataV2( + []types.Token{ + { + Denom: types.NewDenom("atom", types.NewHop("transfer", "channel-0")), + Amount: "1000", + }, + }, sender, receiver, "", types.ForwardingPacketData{}) + + packetDataBz, _ = json.Marshal(packetData) + version = types.V2 + encoding = types.EncodingJSON + }, + nil, + }, + { + "failure: v2 with ABI encoding (not supported)", + func() { + packetDataBz = []byte("should fail before this gets relevant") + version = types.V2 + encoding = types.EncodingABI + }, + errors.New("encoding application/x-solidity-abi is only supported for ICS20-V1"), + }, + { + "failure: invalid encoding", + func() { + encoding = "invalid" + }, + errors.New("invalid encoding provided"), + }, + { + "failure: invalid type for json", + func() { + packetDataBz = []byte("invalid") + encoding = types.EncodingJSON + }, + ibcerrors.ErrInvalidType, + }, + { + "failure: invalid type for protobuf", + func() { + packetDataBz = []byte("invalid") + encoding = types.EncodingProtobuf + }, + ibcerrors.ErrInvalidType, + }, + { + "failure: invalid type for abi", + func() { + packetDataBz = []byte("invalid") + encoding = types.EncodingABI + }, + ibcerrors.ErrInvalidType, + }, { "invalid version", func() { @@ -757,21 +855,24 @@ func TestUnmarshalPacketData(t *testing.T) { } for _, tc := range testCases { - packetDataV1 := types.NewFungibleTokenPacketData("transfer/channel-0/atom", "1000", sender, receiver, "") packetDataBz = packetDataV1.GetBytes() version = types.V1 + encoding = "" tc.malleate() - packetData, err := types.UnmarshalPacketData(packetDataBz, version, "") + packetData, err := types.UnmarshalPacketData(packetDataBz, version, encoding) expPass := tc.expError == nil if expPass { - require.IsType(t, types.FungibleTokenPacketDataV2{}, packetData) + require.NoError(t, err) + require.NotEmpty(t, packetData.Tokens) + require.NotEmpty(t, packetData.Sender) + require.NotEmpty(t, packetData.Receiver) } else { - require.ErrorIs(t, err, tc.expError) + ibctesting.RequireErrorIsOrContains(t, err, tc.expError) } } } diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go index 1e4c270c4ec..52ec849adc1 100644 --- a/modules/apps/transfer/v2/keeper/msg_server_test.go +++ b/modules/apps/transfer/v2/keeper/msg_server_test.go @@ -2,8 +2,11 @@ package keeper_test import ( "bytes" + "encoding/json" "time" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,10 +31,35 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { expError error }{ { - "success", + "success: v2 payload", func() {}, nil, }, + { + "success: v1 payload", + func() { + ftpd := transfertypes.NewFungibleTokenPacketData(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount.String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "") + bz, err := json.Marshal(ftpd) + suite.Require().NoError(err) + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingJSON, bz) + }, + nil, + }, + { + "success: v1 ABI encoded payload", + func() { + bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: sdk.DefaultBondDenom, + Amount: ibctesting.DefaultCoinAmount.BigInt(), + Sender: suite.chainA.SenderAccount.GetAddress().String(), + Receiver: suite.chainB.SenderAccount.GetAddress().String(), + Memo: "", + }) + suite.Require().NoError(err) + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) + }, + nil, + }, { "failure: send transfers disabled", func() { @@ -76,6 +104,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { expPass := tc.expError == nil if expPass { + suite.Require().NoError(err) + suite.Require().NotEmpty(packet) // ensure every token sent is escrowed. for _, t := range tokens { @@ -84,8 +114,6 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { suite.Require().NoError(err) suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") } - suite.Require().NoError(err) - suite.Require().NotEmpty(packet) } else { ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) suite.Require().Empty(packet) @@ -100,20 +128,51 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { path *ibctesting.Path packet channeltypesv2.Packet expectedAck channeltypesv2.Acknowledgement + sendPayload channeltypesv2.Payload ) testCases := []struct { - name string - malleate func() - expError error + name string + malleateSend func() + malleate func() + expError error }{ { - "success", + "success: v2 payload", + func() {}, + func() {}, + nil, + }, + { + "success: v1 payload", + func() { + ftpd := transfertypes.NewFungibleTokenPacketData(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount.String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "") + bz, err := json.Marshal(ftpd) + suite.Require().NoError(err) + sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingJSON, bz) + }, + func() {}, + nil, + }, + { + "success: v1 ABI encoded payload", + func() { + bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: sdk.DefaultBondDenom, + Amount: ibctesting.DefaultCoinAmount.BigInt(), + Sender: suite.chainA.SenderAccount.GetAddress().String(), + Receiver: suite.chainB.SenderAccount.GetAddress().String(), + Memo: "", + }) + suite.Require().NoError(err) + sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) + }, func() {}, nil, }, { "failure: invalid destination channel on received packet", + func() {}, func() { packet.DestinationChannel = ibctesting.InvalidID }, @@ -121,6 +180,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { }, { "failure: counter party channel does not match source channel", + func() {}, func() { packet.SourceChannel = ibctesting.InvalidID }, @@ -128,6 +188,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { }, { "failure: receive is disabled", + func() {}, func() { expectedAck.AppAcknowledgements[0] = channeltypes.NewErrorAcknowledgement(transfertypes.ErrReceiveDisabled).Acknowledgement() suite.chainB.GetSimApp().TransferKeeperV2.SetParams(suite.chainB.GetContext(), @@ -163,9 +224,10 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { bz := suite.chainA.Codec.MustMarshal(&ftpd) timestamp := suite.chainA.GetTimeoutTimestampSecs() - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) + sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) + tc.malleateSend() var err error - packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) + packet, err = path.EndpointA.MsgSendPacket(timestamp, sendPayload) suite.Require().NoError(err) // by default, we assume a successful acknowledgement will be written. @@ -187,7 +249,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { denom := transfertypes.Denom{ Base: sdk.DefaultBondDenom, Trace: []transfertypes.Hop{ - transfertypes.NewHop(payload.DestinationPort, packet.DestinationChannel), + transfertypes.NewHop(sendPayload.DestinationPort, packet.DestinationChannel), }, } diff --git a/modules/core/04-channel/v2/types/commitment_test.go b/modules/core/04-channel/v2/types/commitment_test.go index a77f93f451f..d469a41a298 100644 --- a/modules/core/04-channel/v2/types/commitment_test.go +++ b/modules/core/04-channel/v2/types/commitment_test.go @@ -3,8 +3,10 @@ package types_test import ( "encoding/hex" "encoding/json" + "math/big" "testing" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/stretchr/testify/require" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -15,32 +17,66 @@ import ( // so that other implementations (such as the IBC Solidity) can replicate the // same commitment output. But it is also useful to catch any changes in the commitment. func TestCommitPacket(t *testing.T) { - transferData, err := json.Marshal(transfertypes.FungibleTokenPacketData{ - Denom: "uatom", - Amount: "1000000", - Sender: "sender", - Receiver: "receiver", - Memo: "memo", - }) - require.NoError(t, err) - packet := types.Packet{ - Sequence: 1, - SourceChannel: "channel-0", - DestinationChannel: "channel-1", - TimeoutTimestamp: 100, - Payloads: []types.Payload{ - { - SourcePort: transfertypes.PortID, - DestinationPort: transfertypes.PortID, - Version: transfertypes.V1, - Encoding: "application/json", - Value: transferData, + var packet types.Packet + testCases := []struct { + name string + malleate func() + expectedHash string + }{ + { + "json packet", + func() {}, // default is json packet + "450194f2ce25b12487f65593e106d91367a1e5c90b2efc03ed78265a54cfcebe", + }, + { + "abi packet", + func() { + transferData, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: "uatom", + Amount: big.NewInt(1000000), + Sender: "sender", + Receiver: "receiver", + Memo: "memo", + }) + require.NoError(t, err) + packet.Payloads[0].Value = transferData + packet.Payloads[0].Encoding = transfertypes.EncodingABI }, + "b691a1950f6fb0bbbcf4bdb16fe2c4d0aa7ef783eb7803073f475cb8164d9b7a", }, } - commitment := types.CommitPacket(packet) - require.Equal(t, "450194f2ce25b12487f65593e106d91367a1e5c90b2efc03ed78265a54cfcebe", hex.EncodeToString(commitment)) - require.Len(t, commitment, 32) + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + transferData, err := json.Marshal(transfertypes.FungibleTokenPacketData{ + Denom: "uatom", + Amount: "1000000", + Sender: "sender", + Receiver: "receiver", + Memo: "memo", + }) + require.NoError(t, err) + packet = types.Packet{ + Sequence: 1, + SourceChannel: "channel-0", + DestinationChannel: "channel-1", + TimeoutTimestamp: 100, + Payloads: []types.Payload{ + { + SourcePort: transfertypes.PortID, + DestinationPort: transfertypes.PortID, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingJSON, + Value: transferData, + }, + }, + } + tc.malleate() + commitment := types.CommitPacket(packet) + require.Equal(t, tc.expectedHash, hex.EncodeToString(commitment)) + require.Len(t, commitment, 32) + }) + } } // TestCommitAcknowledgement is primarily used to document the expected commitment output diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 7af1c2810db..e9fbc13b10c 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -31,7 +31,7 @@ require ( github.com/cosmos/ibc-go/v9 v9.0.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/prysmaticlabs/prysm/v4 v4.2.1 // used by simapp for custom querier + github.com/prysmaticlabs/prysm/v5 v5.1.2 // used by simapp for custom querier github.com/spf13/cast v1.7.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -58,7 +58,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -70,6 +70,8 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect @@ -77,10 +79,14 @@ require ( github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -88,7 +94,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect - github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -96,8 +104,9 @@ require ( github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -132,6 +141,7 @@ require ( github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -139,7 +149,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.9 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.9 // indirect @@ -153,6 +163,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -166,8 +177,9 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect - github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 // indirect - github.com/prysmaticlabs/gohashtree v0.0.3-alpha // indirect + github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516 // indirect + github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e // indirect + github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/cors v1.11.1 // indirect @@ -176,29 +188,33 @@ require ( github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/shamaton/msgpack/v2 v2.2.0 // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/supranational/blst v0.3.11 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.13 // indirect + github.com/tklauser/numcpus v0.7.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.4.0-alpha.1 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel v1.29.0 // indirect + go.opentelemetry.io/otel/metric v1.29.0 // indirect + go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.28.0 // indirect - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect @@ -216,5 +232,6 @@ require ( gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index d9610bef3cb..849420ef79a 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -226,6 +226,8 @@ github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTB github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CosmWasm/wasmvm/v2 v2.1.2 h1:GkJ5bAsRlLHfIQVg/FY1VHwLyBwlCjAhDea0B8L+e20= github.com/CosmWasm/wasmvm/v2 v2.1.2/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= @@ -242,6 +244,8 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= @@ -277,8 +281,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= -github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -292,6 +296,8 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= +github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -341,6 +347,10 @@ github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cV github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -368,8 +378,15 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= @@ -384,6 +401,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= @@ -426,8 +445,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 h1:xH3SZXIWPj57ogsCYLpfQ9ka1BU1TjmYFrgRvqgMBmw= -github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76/go.mod h1:5SYZGkLhciK5Ds7nXpWz7YNP5iBZb4uqaRHkj+GdTWo= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -468,10 +491,13 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -484,6 +510,8 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -494,6 +522,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -591,6 +621,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -638,6 +669,8 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NM github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -687,12 +720,20 @@ github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e h1:wCMygKUQhmcQAjlk2Gquzq6dLmyMv2kF+llRspoRgrk= github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -703,6 +744,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -719,6 +762,8 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -733,8 +778,8 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -747,6 +792,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -774,6 +821,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= @@ -793,10 +842,18 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= @@ -825,6 +882,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -834,8 +893,8 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042 github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -857,6 +916,8 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= @@ -909,15 +970,19 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 h1:c3p3UzV4vFA7xaCDphnDWOjpxcadrQ26l5b+ypsvyxo= -github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg= -github.com/prysmaticlabs/gohashtree v0.0.3-alpha h1:1EVinCWdb3Lorq7xn8DYQHf48nCcdAM3Vb18KsFlRWY= -github.com/prysmaticlabs/gohashtree v0.0.3-alpha/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= -github.com/prysmaticlabs/prysm/v4 v4.2.1 h1:eHdK4OuJBUCJCmHgI3c07y0u/vWrKCyOsRN2l/VXQxc= -github.com/prysmaticlabs/prysm/v4 v4.2.1/go.mod h1:0Iz1Q/WiuClvdm/9vQbiKKeToeL/uD3QBjEwV9UExBQ= +github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516 h1:xuVAdtz5ShYblG2sPyb4gw01DF8InbOI/kBCQjk7NiM= +github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516/go.mod h1:h2OlIZD/M6wFvV3YMZbW16lFgh3Rsye00G44J2cwLyU= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e h1:ATgOe+abbzfx9kCPeXIW4fiWyDdxlwHw07j8UGhdTd4= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= +github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b h1:VK7thFOnhxAZ/5aolr5Os4beiubuD08WiuiHyRqgwks= +github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b/go.mod h1:HRuvtXLZ4WkaB1MItToVH2e8ZwKwZPY5/Rcby+CvvLY= +github.com/prysmaticlabs/prysm/v5 v5.1.2 h1:ib9D7Drh7QPoetJPnYXAHaArmjIreXPZ0FboW9EMzT8= +github.com/prysmaticlabs/prysm/v5 v5.1.2/go.mod h1:ykj3Bl9dHv35cC7fRw6Cd1aCd9l+eNvInHY6gsPbEig= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -931,6 +996,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= @@ -943,6 +1009,8 @@ github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6v github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shamaton/msgpack/v2 v2.2.0 h1:IP1m01pHwCrMa6ZccP9B3bqxEMKMSmMVAVKk54g3L/Y= github.com/shamaton/msgpack/v2 v2.2.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -994,8 +1062,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -1004,6 +1072,10 @@ github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYR github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= +github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= +github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -1012,14 +1084,21 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI= +github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= @@ -1043,14 +1122,14 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= +go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo= +go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1089,8 +1168,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1240,6 +1319,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1658,8 +1738,12 @@ gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1688,6 +1772,14 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +k8s.io/apimachinery v0.30.4 h1:5QHQI2tInzr8LsT4kU/2+fSeibH1eIHswNx480cqIoY= +k8s.io/apimachinery v0.30.4/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.4 h1:eculUe+HPQoPbixfwmaSZGsKcOf7D288tH6hDAdd+wY= +k8s.io/client-go v0.30.4/go.mod h1:IBS0R/Mt0LHkNHF4E6n+SUDPG7+m2po6RZU7YHeOpzc= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0= nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= @@ -1696,6 +1788,12 @@ pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go b/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go index 473a7b98295..1f9c38bda0e 100644 --- a/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go +++ b/modules/light-clients/08-wasm/testing/simapp/customquery/crypto.go @@ -3,7 +3,7 @@ package customquery import ( "fmt" - "github.com/prysmaticlabs/prysm/v4/crypto/bls" + "github.com/prysmaticlabs/prysm/v5/crypto/bls" ) func AggregatePublicKeys(publicKeys [][]byte) (bls.PublicKey, error) { diff --git a/simapp/go.mod b/simapp/go.mod index 9c80242bdad..6148a7b5203 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -46,11 +46,12 @@ require ( github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -62,18 +63,23 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect - github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -81,6 +87,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -90,6 +99,7 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -97,7 +107,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -125,6 +135,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -144,6 +155,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -163,13 +175,17 @@ require ( github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect @@ -202,6 +218,7 @@ require ( gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/simapp/go.sum b/simapp/go.sum index 10484029ca0..fb793a39812 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -240,6 +240,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= @@ -273,8 +277,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= -github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -288,6 +292,8 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -337,6 +343,10 @@ github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cV github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -360,14 +370,19 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= -github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= -github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= @@ -380,6 +395,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= @@ -422,6 +439,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -466,6 +489,9 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -478,6 +504,8 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -488,6 +516,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -529,8 +559,9 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= @@ -584,6 +615,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -631,6 +663,8 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NM github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -678,12 +712,20 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -694,6 +736,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -736,6 +780,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -763,6 +809,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= @@ -780,6 +828,11 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -810,6 +863,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -897,6 +952,8 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -910,6 +967,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= @@ -920,6 +978,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -971,12 +1031,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -985,8 +1051,13 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1213,6 +1284,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1286,6 +1358,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= @@ -1631,6 +1705,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1667,6 +1743,8 @@ pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= From 82348c6ad9c0ee45de9ef4f17cc87cc273aa8c6d Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 6 Dec 2024 12:25:59 +0200 Subject: [PATCH 142/172] chore: add channel client state rpc (#7616) * chore: add channel client state rpc * chore: drop func to provide proof --- modules/core/04-channel/v2/client/cli/cli.go | 1 + .../core/04-channel/v2/client/cli/query.go | 31 + .../core/04-channel/v2/keeper/grpc_query.go | 26 + .../04-channel/v2/keeper/grpc_query_test.go | 101 +++ .../04-channel/v2/types/expected_keepers.go | 2 + modules/core/04-channel/v2/types/query.go | 16 + modules/core/04-channel/v2/types/query.pb.go | 772 +++++++++++++++--- .../core/04-channel/v2/types/query.pb.gw.go | 101 +++ proto/ibc/core/channel/v2/query.proto | 24 + 9 files changed, 942 insertions(+), 132 deletions(-) diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index c9a0d954287..5fdde6a87dc 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCmdQueryChannel(), + getCmdQueryChannelClientState(), getCmdQueryNextSequenceSend(), getCmdQueryPacketCommitment(), getCmdQueryPacketCommitments(), diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 2be1a004d3e..04f9f91e5c7 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -49,6 +49,37 @@ func getCmdQueryChannel() *cobra.Command { return cmd } +// getCmdQueryChannelClientState defines the command to query the channel client state for the given channel ID. +func getCmdQueryChannelClientState() *cobra.Command { + cmd := &cobra.Command{ + Use: "client-state [channel-id]", + Short: "Query the client state associated with a channel.", + Long: "Query the client state associated with a channel for the provided channel ID.", + Example: fmt.Sprintf("%s query %s %s client-state [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.ChannelClientState(cmd.Context(), types.NewQueryChannelClientStateRequest(channelID)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // getCmdQueryNextSequenceSend defines the command to query a next send sequence for a given channel func getCmdQueryNextSequenceSend() *cobra.Command { cmd := &cobra.Command{ diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 3f5c7b1e59d..d21fa1d9b3d 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -51,6 +51,32 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques return types.NewQueryChannelResponse(channel), nil } +// ChannelClientState implements the Query/ChannelClientState gRPC method +func (q *queryServer) ChannelClientState(ctx context.Context, req *types.QueryChannelClientStateRequest) (*types.QueryChannelClientStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + channel, found := q.GetChannel(ctx, req.ChannelId) + if !found { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) + } + + clientState, found := q.ClientKeeper.GetClientState(ctx, channel.ClientId) + if !found { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client-id: %s", channel.ClientId).Error()) + } + + identifiedClientState := clienttypes.NewIdentifiedClientState(channel.ClientId, clientState) + res := types.NewQueryChannelClientStateResponse(identifiedClientState, nil, clienttypes.GetSelfHeight(ctx)) + + return res, nil +} + // NextSequenceSend implements the Query/NextSequenceSend gRPC method func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 4bdcff66ff5..58c0e3bf810 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -89,6 +90,106 @@ func (suite *KeeperTestSuite) TestQueryChannel() { } } +func (suite *KeeperTestSuite) TestQueryChannelClientState() { + var ( + req *types.QueryChannelClientStateRequest + expIdentifiedClientState clienttypes.IdentifiedClientState + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expClientState := suite.chainA.GetClientState(path.EndpointA.ClientID) + expIdentifiedClientState = clienttypes.NewIdentifiedClientState(path.EndpointA.ClientID, expClientState) + + req = &types.QueryChannelClientStateRequest{ + ChannelId: path.EndpointA.ChannelID, + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryChannelClientStateRequest{ + ChannelId: "", + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryChannelClientStateRequest{ + ChannelId: "test-channel-id", + } + }, + status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", "test-channel-id")), + }, + { + "client state not found", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + channel, found := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) + suite.Require().True(found) + channel.ClientId = ibctesting.SecondClientID + + path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID, channel) + + req = &types.QueryChannelClientStateRequest{ + ChannelId: path.EndpointA.ChannelID, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: light client not found", ibctesting.SecondClientID)), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.ChannelClientState(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(&expIdentifiedClientState, res.IdentifiedClientState) + + // ensure UnpackInterfaces is defined + cachedValue := res.IdentifiedClientState.ClientState.GetCachedValue() + suite.Require().NotNil(cachedValue) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPacketCommitment() { var ( expCommitment []byte diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 5a1a0a5d058..9f94668a8a0 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -19,4 +19,6 @@ type ClientKeeper interface { // GetClientTimestampAtHeight returns the timestamp for a given height on the client // given its client ID and height GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) + // GetClientState gets a particular client from the store + GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool) } diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index b02d0275537..af4b2d7ae45 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -16,6 +16,22 @@ func NewQueryChannelResponse(channel Channel) *QueryChannelResponse { } } +// NewQueryChannelClientStateRequest creates and returns a new ChannelClientState query request. +func NewQueryChannelClientStateRequest(channelID string) *QueryChannelClientStateRequest { + return &QueryChannelClientStateRequest{ + ChannelId: channelID, + } +} + +// NewQueryChannelClientStateResponse creates and returns a new ChannelClientState query response. +func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height clienttypes.Height) *QueryChannelClientStateResponse { + return &QueryChannelClientStateResponse{ + IdentifiedClientState: &identifiedClientState, + Proof: proof, + ProofHeight: height, + } +} + // NewQueryNextSequenceSendRequest creates a new next sequence send query. func NewQueryNextSequenceSendRequest(channelID string) *QueryNextSequenceSendRequest { return &QueryNextSequenceSendRequest{ diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 5ae8436bd9b..37132d2bebc 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -122,6 +122,118 @@ func (m *QueryChannelResponse) GetChannel() Channel { return Channel{} } +// QueryChannelClientStateRequest is the request type for the Query/ClientState +// RPC method +type QueryChannelClientStateRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *QueryChannelClientStateRequest) Reset() { *m = QueryChannelClientStateRequest{} } +func (m *QueryChannelClientStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelClientStateRequest) ProtoMessage() {} +func (*QueryChannelClientStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{2} +} +func (m *QueryChannelClientStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelClientStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelClientStateRequest.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 *QueryChannelClientStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelClientStateRequest.Merge(m, src) +} +func (m *QueryChannelClientStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelClientStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelClientStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelClientStateRequest proto.InternalMessageInfo + +func (m *QueryChannelClientStateRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +// QueryChannelClientStateResponse is the Response type for the +// Query/QueryChannelClientState RPC method +type QueryChannelClientStateResponse struct { + // client state associated with the channel + IdentifiedClientState *types.IdentifiedClientState `protobuf:"bytes,1,opt,name=identified_client_state,json=identifiedClientState,proto3" json:"identified_client_state,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryChannelClientStateResponse) Reset() { *m = QueryChannelClientStateResponse{} } +func (m *QueryChannelClientStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelClientStateResponse) ProtoMessage() {} +func (*QueryChannelClientStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{3} +} +func (m *QueryChannelClientStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelClientStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelClientStateResponse.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 *QueryChannelClientStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelClientStateResponse.Merge(m, src) +} +func (m *QueryChannelClientStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelClientStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelClientStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelClientStateResponse proto.InternalMessageInfo + +func (m *QueryChannelClientStateResponse) GetIdentifiedClientState() *types.IdentifiedClientState { + if m != nil { + return m.IdentifiedClientState + } + return nil +} + +func (m *QueryChannelClientStateResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryChannelClientStateResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method type QueryNextSequenceSendRequest struct { // channel unique identifier @@ -132,7 +244,7 @@ func (m *QueryNextSequenceSendRequest) Reset() { *m = QueryNextSequenceS func (m *QueryNextSequenceSendRequest) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendRequest) ProtoMessage() {} func (*QueryNextSequenceSendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{2} + return fileDescriptor_a328cba4986edcab, []int{4} } func (m *QueryNextSequenceSendRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -182,7 +294,7 @@ func (m *QueryNextSequenceSendResponse) Reset() { *m = QueryNextSequence func (m *QueryNextSequenceSendResponse) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendResponse) ProtoMessage() {} func (*QueryNextSequenceSendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{3} + return fileDescriptor_a328cba4986edcab, []int{5} } func (m *QueryNextSequenceSendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -244,7 +356,7 @@ func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitm func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentRequest) ProtoMessage() {} func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -301,7 +413,7 @@ func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentResponse) ProtoMessage() {} func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -363,7 +475,7 @@ func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsRequest) ProtoMessage() {} func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -420,7 +532,7 @@ func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommi func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsResponse) ProtoMessage() {} func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -482,7 +594,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{8} + return fileDescriptor_a328cba4986edcab, []int{10} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -539,7 +651,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{9} + return fileDescriptor_a328cba4986edcab, []int{11} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -604,7 +716,7 @@ func (m *QueryPacketAcknowledgementsRequest) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{10} + return fileDescriptor_a328cba4986edcab, []int{12} } func (m *QueryPacketAcknowledgementsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -668,7 +780,7 @@ func (m *QueryPacketAcknowledgementsResponse) Reset() { *m = QueryPacket func (m *QueryPacketAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{11} + return fileDescriptor_a328cba4986edcab, []int{13} } func (m *QueryPacketAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -732,7 +844,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -796,7 +908,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -858,7 +970,7 @@ func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPa func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{14} + return fileDescriptor_a328cba4986edcab, []int{16} } func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -913,7 +1025,7 @@ func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedP func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{15} + return fileDescriptor_a328cba4986edcab, []int{17} } func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -969,7 +1081,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{16} + return fileDescriptor_a328cba4986edcab, []int{18} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1025,7 +1137,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{17} + return fileDescriptor_a328cba4986edcab, []int{19} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1071,6 +1183,8 @@ func (m *QueryUnreceivedAcksResponse) GetHeight() types.Height { func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") + proto.RegisterType((*QueryChannelClientStateRequest)(nil), "ibc.core.channel.v2.QueryChannelClientStateRequest") + proto.RegisterType((*QueryChannelClientStateResponse)(nil), "ibc.core.channel.v2.QueryChannelClientStateResponse") proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v2.QueryNextSequenceSendRequest") proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v2.QueryNextSequenceSendResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") @@ -1092,77 +1206,82 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 1113 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x5f, 0x6f, 0xdb, 0x54, - 0x14, 0xef, 0x6d, 0xba, 0xb5, 0x3d, 0x29, 0xa3, 0xbb, 0x2b, 0x90, 0x79, 0x5d, 0x96, 0x19, 0x09, - 0xc2, 0xb4, 0xf9, 0x36, 0xd9, 0x04, 0x43, 0xda, 0x40, 0x6d, 0x19, 0x5b, 0x27, 0x40, 0xc5, 0x05, - 0x24, 0xd0, 0xb4, 0xc8, 0x71, 0xee, 0x5c, 0x2b, 0x89, 0xaf, 0x17, 0x3b, 0xa1, 0xd3, 0xd4, 0x17, - 0x1e, 0x78, 0x46, 0xec, 0x8d, 0x4f, 0x00, 0x2f, 0x7c, 0x05, 0x90, 0x78, 0x99, 0xb4, 0x97, 0x49, - 0x7b, 0x80, 0x27, 0x04, 0x2d, 0x12, 0xdf, 0x80, 0x67, 0x94, 0xeb, 0xeb, 0xf8, 0x4f, 0x1c, 0xd7, - 0xde, 0x56, 0xc4, 0x9b, 0x7d, 0x73, 0xfe, 0xfc, 0x7e, 0xe7, 0xfe, 0x8e, 0xcf, 0x51, 0xe0, 0x8c, - 0xd9, 0xd4, 0x89, 0xce, 0x7a, 0x94, 0xe8, 0xdb, 0x9a, 0x65, 0xd1, 0x0e, 0x19, 0xd4, 0xc9, 0xdd, - 0x3e, 0xed, 0xdd, 0x53, 0xec, 0x1e, 0x73, 0x19, 0x3e, 0x61, 0x36, 0x75, 0x65, 0x68, 0xa0, 0x08, - 0x03, 0x65, 0x50, 0x97, 0xce, 0xe9, 0xcc, 0xe9, 0x32, 0x87, 0x34, 0x35, 0x87, 0x7a, 0xd6, 0x64, - 0x50, 0x6b, 0x52, 0x57, 0xab, 0x11, 0x5b, 0x33, 0x4c, 0x4b, 0x73, 0x4d, 0x66, 0x79, 0x01, 0xa4, - 0xb3, 0x49, 0x19, 0xfc, 0x58, 0x29, 0x26, 0x06, 0xb5, 0xa8, 0x63, 0x3a, 0xc2, 0x24, 0x84, 0xb3, - 0x63, 0x52, 0xcb, 0x25, 0x83, 0x9a, 0x78, 0x12, 0x06, 0xcb, 0x06, 0x63, 0x46, 0x87, 0x12, 0xcd, - 0x36, 0x89, 0x66, 0x59, 0xcc, 0xe5, 0x18, 0x7c, 0xf7, 0x25, 0x83, 0x19, 0x8c, 0x3f, 0x92, 0xe1, - 0x93, 0x77, 0x2a, 0x5f, 0x82, 0x13, 0x1f, 0x0f, 0xc1, 0xaf, 0x7b, 0x59, 0x55, 0x7a, 0xb7, 0x4f, - 0x1d, 0x17, 0x9f, 0x06, 0x10, 0x38, 0x1a, 0x66, 0xab, 0x84, 0x2a, 0xa8, 0x3a, 0xaf, 0xce, 0x8b, - 0x93, 0x8d, 0x96, 0xfc, 0x09, 0x2c, 0x45, 0xbd, 0x1c, 0x9b, 0x59, 0x0e, 0xc5, 0x57, 0x60, 0x56, - 0x18, 0x71, 0x9f, 0x62, 0x7d, 0x59, 0x49,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, 0x26, 0x59, 0xd0, 0x86, 0x06, 0xab, - 0xb4, 0x92, 0xdd, 0x41, 0x70, 0xeb, 0x70, 0x6e, 0x77, 0x70, 0xeb, 0x19, 0xb9, 0x25, 0x0d, 0xec, - 0x08, 0xcd, 0x61, 0xbf, 0xad, 0x7d, 0xf6, 0x70, 0xaf, 0x8c, 0x1e, 0xef, 0x95, 0xd1, 0x1f, 0x7b, - 0x65, 0xf4, 0xcd, 0x7e, 0x79, 0xea, 0xf1, 0x7e, 0x79, 0xea, 0xb7, 0xfd, 0xf2, 0xd4, 0x17, 0x57, - 0x0c, 0xd3, 0xdd, 0xee, 0x37, 0x15, 0x9d, 0x75, 0x89, 0xf8, 0x57, 0xc6, 0x6c, 0xea, 0x17, 0x0c, - 0x46, 0x06, 0x6f, 0x93, 0x2e, 0x6b, 0xf5, 0x3b, 0xd4, 0xf1, 0xe0, 0xad, 0x5c, 0xba, 0x10, 0x42, - 0xe8, 0xde, 0xb3, 0xa9, 0xd3, 0x3c, 0xca, 0xff, 0x08, 0xb9, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xd2, 0x18, 0x54, 0x2c, 0x07, 0x12, 0x00, 0x00, + // 1197 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0xce, 0x64, 0xd3, 0xfc, 0x78, 0x09, 0x34, 0x9d, 0xa6, 0x34, 0x75, 0xd3, 0x4d, 0x6a, 0x24, + 0xd8, 0x56, 0xad, 0x27, 0xd9, 0x44, 0xb4, 0x95, 0x5a, 0xa2, 0x24, 0x94, 0x36, 0x15, 0xa0, 0xe0, + 0x00, 0x12, 0xa8, 0xea, 0xca, 0xeb, 0x9d, 0x38, 0x56, 0x76, 0x3d, 0xee, 0x8e, 0x77, 0x49, 0x55, + 0xe5, 0xc2, 0x81, 0x33, 0xa2, 0x37,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, 0x8d, 0x55, 0x1a, 0x55, 0xca, 0x7d, 0x7a, + 0xf3, 0x4b, 0x97, 0x43, 0x0c, 0xbd, 0x07, 0x2e, 0xe5, 0xe5, 0x61, 0xf1, 0x77, 0xd7, 0xe2, 0x7f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x15, 0x99, 0x77, 0xb3, 0xed, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1179,6 +1298,9 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Channel queries the counterparty of an IBC client. Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) + // ChannelClientState queries for the client state for the channel associated + // with the provided channel identifiers. + ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1214,6 +1336,15 @@ func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts return out, nil } +func (c *queryClient) ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) { + out := new(QueryChannelClientStateResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/ChannelClientState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { out := new(QueryNextSequenceSendResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) @@ -1290,6 +1421,9 @@ func (c *queryClient) UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAck type QueryServer interface { // Channel queries the counterparty of an IBC client. Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) + // ChannelClientState queries for the client state for the channel associated + // with the provided channel identifiers. + ChannelClientState(context.Context, *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1315,6 +1449,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") } +func (*UnimplementedQueryServer) ChannelClientState(ctx context.Context, req *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelClientState not implemented") +} func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") } @@ -1362,6 +1499,24 @@ func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Query_ChannelClientState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelClientStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ChannelClientState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/ChannelClientState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ChannelClientState(ctx, req.(*QueryChannelClientStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryNextSequenceSendRequest) if err := dec(in); err != nil { @@ -1514,6 +1669,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Channel", Handler: _Query_Channel_Handler, }, + { + MethodName: "ChannelClientState", + Handler: _Query_ChannelClientState_Handler, + }, { MethodName: "NextSequenceSend", Handler: _Query_NextSequenceSend_Handler, @@ -1614,6 +1773,88 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryChannelClientStateRequest) 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 *QueryChannelClientStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelClientStateRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryChannelClientStateResponse) 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 *QueryChannelClientStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.IdentifiedClientState != nil { + { + size, err := m.IdentifiedClientState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1975,20 +2216,20 @@ func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) ( var l int _ = l if len(m.PacketCommitmentSequences) > 0 { - dAtA9 := make([]byte, len(m.PacketCommitmentSequences)*10) - var j8 int + dAtA11 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j10 int for _, num := range m.PacketCommitmentSequences { for num >= 1<<7 { - dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j8++ + j10++ } - dAtA9[j8] = uint8(num) - j8++ + dAtA11[j10] = uint8(num) + j10++ } - i -= j8 - copy(dAtA[i:], dAtA9[:j8]) - i = encodeVarintQuery(dAtA, i, uint64(j8)) + i -= j10 + copy(dAtA[i:], dAtA11[:j10]) + i = encodeVarintQuery(dAtA, i, uint64(j10)) i-- dAtA[i] = 0x1a } @@ -2186,20 +2427,20 @@ func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l if len(m.Sequences) > 0 { - dAtA15 := make([]byte, len(m.Sequences)*10) - var j14 int + dAtA17 := make([]byte, len(m.Sequences)*10) + var j16 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) + dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j14++ + j16++ } - dAtA15[j14] = uint8(num) - j14++ + dAtA17[j16] = uint8(num) + j16++ } - i -= j14 - copy(dAtA[i:], dAtA15[:j14]) - i = encodeVarintQuery(dAtA, i, uint64(j14)) + i -= j16 + copy(dAtA[i:], dAtA17[:j16]) + i = encodeVarintQuery(dAtA, i, uint64(j16)) i-- dAtA[i] = 0x12 } @@ -2244,20 +2485,20 @@ func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA18 := make([]byte, len(m.Sequences)*10) - var j17 int + dAtA20 := make([]byte, len(m.Sequences)*10) + var j19 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j17++ + j19++ } - dAtA18[j17] = uint8(num) - j17++ + dAtA20[j19] = uint8(num) + j19++ } - i -= j17 - copy(dAtA[i:], dAtA18[:j17]) - i = encodeVarintQuery(dAtA, i, uint64(j17)) + i -= j19 + copy(dAtA[i:], dAtA20[:j19]) + i = encodeVarintQuery(dAtA, i, uint64(j19)) i-- dAtA[i] = 0xa } @@ -2285,20 +2526,20 @@ func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, err var l int _ = l if len(m.PacketAckSequences) > 0 { - dAtA20 := make([]byte, len(m.PacketAckSequences)*10) - var j19 int + dAtA22 := make([]byte, len(m.PacketAckSequences)*10) + var j21 int for _, num := range m.PacketAckSequences { for num >= 1<<7 { - dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) + dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j19++ + j21++ } - dAtA20[j19] = uint8(num) - j19++ + dAtA22[j21] = uint8(num) + j21++ } - i -= j19 - copy(dAtA[i:], dAtA20[:j19]) - i = encodeVarintQuery(dAtA, i, uint64(j19)) + i -= j21 + copy(dAtA[i:], dAtA22[:j21]) + i = encodeVarintQuery(dAtA, i, uint64(j21)) i-- dAtA[i] = 0x12 } @@ -2343,20 +2584,20 @@ func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA23 := make([]byte, len(m.Sequences)*10) - var j22 int + dAtA25 := make([]byte, len(m.Sequences)*10) + var j24 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA23[j22] = uint8(uint64(num)&0x7f | 0x80) + dAtA25[j24] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j22++ + j24++ } - dAtA23[j22] = uint8(num) - j22++ + dAtA25[j24] = uint8(num) + j24++ } - i -= j22 - copy(dAtA[i:], dAtA23[:j22]) - i = encodeVarintQuery(dAtA, i, uint64(j22)) + i -= j24 + copy(dAtA[i:], dAtA25[:j24]) + i = encodeVarintQuery(dAtA, i, uint64(j24)) i-- dAtA[i] = 0xa } @@ -2398,6 +2639,38 @@ func (m *QueryChannelResponse) Size() (n int) { return n } +func (m *QueryChannelClientStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryChannelClientStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IdentifiedClientState != nil { + l = m.IdentifiedClientState.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryNextSequenceSendRequest) Size() (n int) { if m == nil { return 0 @@ -2867,6 +3140,241 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryChannelClientStateRequest) 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 ErrIntOverflowQuery + } + 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: QueryChannelClientStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelClientStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelClientStateResponse) 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 ErrIntOverflowQuery + } + 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: QueryChannelClientStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelClientStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedClientState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IdentifiedClientState == nil { + m.IdentifiedClientState = &types.IdentifiedClientState{} + } + if err := m.IdentifiedClientState.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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 2f03fdadfd5..47aa5757262 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -87,6 +87,60 @@ func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marsha } +func request_Query_ChannelClientState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelClientStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + msg, err := client.ChannelClientState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ChannelClientState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelClientStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + msg, err := server.ChannelClientState(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNextSequenceSendRequest var metadata runtime.ServerMetadata @@ -712,6 +766,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ChannelClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ChannelClientState_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChannelClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -957,6 +1034,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ChannelClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ChannelClientState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChannelClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1123,6 +1220,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "client_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1143,6 +1242,8 @@ var ( var ( forward_Query_Channel_0 = runtime.ForwardResponseMessage + forward_Query_ChannelClientState_0 = runtime.ForwardResponseMessage + forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 40d1cdc31eb..3ca8a2e16ad 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -18,6 +18,12 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}"; } + // ChannelClientState queries for the client state for the channel associated + // with the provided channel identifiers. + rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/client_state"; + } + // NextSequenceSend returns the next send sequence for a given channel. rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; @@ -72,6 +78,24 @@ message QueryChannelResponse { Channel channel = 1 [(gogoproto.nullable) = false]; } +// QueryChannelClientStateRequest is the request type for the Query/ClientState +// RPC method +message QueryChannelClientStateRequest { + // channel unique identifier + string channel_id = 1; +} + +// QueryChannelClientStateResponse is the Response type for the +// Query/QueryChannelClientState RPC method +message QueryChannelClientStateResponse { + // client state associated with the channel + ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method message QueryNextSequenceSendRequest { // channel unique identifier From 945b018b6c57639e3bcad7fc2396df41f23dca68 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Mon, 9 Dec 2024 14:39:23 +0000 Subject: [PATCH 143/172] rename v2 event attribute key for encoded data (#7635) --- modules/core/04-channel/v2/keeper/events.go | 12 ++++++------ modules/core/04-channel/v2/types/events.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 5245b54901b..eb1a71b5481 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -28,7 +28,7 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -53,7 +53,7 @@ func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -83,8 +83,8 @@ func emitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), - sdk.NewAttribute(types.AttributeKeyAckDataHex, hex.EncodeToString(encodedAck)), + sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyEncodedAckHex, hex.EncodeToString(encodedAck)), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -109,7 +109,7 @@ func emitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -134,7 +134,7 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), - sdk.NewAttribute(types.AttributeKeyPacketDataHex, hex.EncodeToString(encodedPacket)), + sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 46ba862ac68..1ef33d80491 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -23,8 +23,8 @@ const ( AttributeKeyDstChannel = "packet_dest_channel" AttributeKeySequence = "packet_sequence" AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" - AttributeKeyPacketDataHex = "packet_data_hex" - AttributeKeyAckDataHex = "acknowledgement_data_hex" + AttributeKeyEncodedPacketHex = "encoded_packet_hex" + AttributeKeyEncodedAckHex = "encoded_acknowledgement_hex" ) // IBC channel events vars From cd2e4fab86ecc161a34506ac50814ffff0434533 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 9 Dec 2024 19:39:13 +0200 Subject: [PATCH 144/172] bug: fix packet commitment path used for timeout (#7646) --- modules/core/04-channel/v2/keeper/msg_server_test.go | 2 +- modules/core/04-channel/v2/keeper/packet.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 072de3e77fb..c237eaa916e 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -504,7 +504,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { { name: "failure: unable to timeout if packet has been received", malleate: func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.SourceChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) suite.Require().NoError(path.EndpointB.UpdateClient()) }, expError: commitmenttypes.ErrInvalidProof, diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 392edb92db9..633f0bb4249 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -322,7 +322,7 @@ func (k *Keeper) timeoutPacket( } // verify packet receipt absence - path := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) + path := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( From 2aae6bfe4d48a8407ad99a4624b4b7b97b5fa73c Mon Sep 17 00:00:00 2001 From: Sruthi2357 Date: Mon, 9 Dec 2024 23:09:48 +0530 Subject: [PATCH 145/172] fix: correct error message for payload validation in packet ValidateBasic (#7649) --- modules/core/04-channel/v2/types/packet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 1ba7722b925..9fe360c5a6c 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -34,7 +34,7 @@ func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Pa // ValidateBasic validates that a Packet satisfies the basic requirements. func (p Packet) ValidateBasic() error { if len(p.Payloads) != 1 { - return errorsmod.Wrap(ErrInvalidPacket, "payloads must not be empty") + return errorsmod.Wrap(ErrInvalidPacket, "payloads must contain exactly one payload") } for _, pd := range p.Payloads { From 8794e0d8e02731b8585174e79bf7780a3bb750a1 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 10 Dec 2024 09:48:48 +0200 Subject: [PATCH 146/172] chore: add validation for Ack and plug it in. (#7647) --- .../core/04-channel/v2/keeper/msg_server.go | 8 ++++ .../04-channel/v2/keeper/msg_server_test.go | 10 ++++ modules/core/04-channel/v2/keeper/packet.go | 7 --- .../core/04-channel/v2/keeper/packet_test.go | 9 ---- .../04-channel/v2/types/acknowledgement.go | 25 ++++++++++ .../v2/types/acknowledgement_test.go | 47 +++++++++++++++++++ modules/core/04-channel/v2/types/msgs.go | 4 +- modules/core/04-channel/v2/types/msgs_test.go | 9 +++- 8 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 modules/core/04-channel/v2/types/acknowledgement.go create mode 100644 modules/core/04-channel/v2/types/acknowledgement_test.go diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index f4c2dc446a1..499e2baa825 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -163,6 +163,10 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ ack.AppAcknowledgements = append(ack.AppAcknowledgements, res.Acknowledgement) } + if len(ack.AppAcknowledgements) != len(msg.Packet.Payloads) { + return nil, errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of app acknowledgement %d does not match length of app payload %d", len(ack.AppAcknowledgements), len(msg.Packet.Payloads)) + } + // note this should never happen as the payload would have had to be empty. if len(ack.AppAcknowledgements) == 0 { sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) @@ -170,6 +174,10 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ } if !isAsync { + // Validate ack before forwarding to WriteAcknowledgement. + if err := ack.Validate(); err != nil { + return nil, err + } // Set packet acknowledgement only if the acknowledgement is not async. // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the // acknowledgement is async. diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index c237eaa916e..34dff03cba7 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -290,6 +290,16 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { }, expError: commitmenttypes.ErrInvalidProof, }, + { + name: "failure: invalid acknowledgement", + malleate: func() { + expRecvRes = types.RecvPacketResult{ + Status: types.PacketStatus_Success, + Acknowledgement: []byte(""), + } + }, + expError: types.ErrInvalidAcknowledgement, + }, } for _, tc := range testCases { diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 633f0bb4249..868d12a047d 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -190,13 +190,6 @@ func (k Keeper) WriteAcknowledgement( return errorsmod.Wrap(types.ErrInvalidPacket, "receipt not found for packet") } - // TODO: Validate Acknowledgment more thoroughly here after Issue #7472: https://github.com/cosmos/ibc-go/issues/7472 - - // TODO: remove this check, maybe pull it up to the handler. - if len(ack.AppAcknowledgements) != len(packet.Payloads) { - return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "length of app acknowledgement %d does not match length of app payload %d", len(ack.AppAcknowledgements), len(packet.Payloads)) - } - // set the acknowledgement so that it can be verified on the other side k.SetPacketAcknowledgement( ctx, packet.DestinationChannel, packet.Sequence, diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index 9f4988c240a..eb826bd3b0d 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -271,15 +271,6 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { }, types.ErrAcknowledgementExists, }, - { - "failure: empty ack", - func() { - ack = types.Acknowledgement{ - AppAcknowledgements: [][]byte{}, - } - }, - types.ErrInvalidAcknowledgement, - }, { "failure: receipt not found for packet", func() { diff --git a/modules/core/04-channel/v2/types/acknowledgement.go b/modules/core/04-channel/v2/types/acknowledgement.go new file mode 100644 index 00000000000..f5d50e20394 --- /dev/null +++ b/modules/core/04-channel/v2/types/acknowledgement.go @@ -0,0 +1,25 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +// NewAcknowledgement creates a new Acknowledgement containing the provided app acknowledgements. +func NewAcknowledgement(appAcknowledgements ...[]byte) Acknowledgement { + return Acknowledgement{AppAcknowledgements: appAcknowledgements} +} + +// Validate performs a basic validation of the acknowledgement +func (ack Acknowledgement) Validate() error { + if len(ack.AppAcknowledgements) != 1 { + return errorsmod.Wrap(ErrInvalidAcknowledgement, "app acknowledgements must be of length one") + } + + for _, ack := range ack.AppAcknowledgements { + if len(ack) == 0 { + return errorsmod.Wrap(ErrInvalidAcknowledgement, "app acknowledgement cannot be empty") + } + } + + return nil +} diff --git a/modules/core/04-channel/v2/types/acknowledgement_test.go b/modules/core/04-channel/v2/types/acknowledgement_test.go new file mode 100644 index 00000000000..f06c6e89a50 --- /dev/null +++ b/modules/core/04-channel/v2/types/acknowledgement_test.go @@ -0,0 +1,47 @@ +package types_test + +import ( + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +// Test_ValidateAcknowledgement tests the acknowledgements Validate method +func (s *TypesTestSuite) Test_ValidateAcknowledgement() { + testCases := []struct { + name string + ack types.Acknowledgement + expError error + }{ + { + "success: valid successful ack", + types.NewAcknowledgement([]byte("appAck1")), + nil, + }, + { + "failure: more than one app acknowledgements", + types.NewAcknowledgement([]byte("appAck1"), []byte("appAck2")), + types.ErrInvalidAcknowledgement, + }, + { + "failure: app acknowledgement is empty", + types.NewAcknowledgement([]byte("")), + types.ErrInvalidAcknowledgement, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + s.SetupTest() + + err := tc.ack.Validate() + + expPass := tc.expError == nil + if expPass { + s.Require().NoError(err) + } else { + s.Require().ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index b0a8d9cd9de..8c9d3609be3 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -167,7 +167,9 @@ func (msg *MsgAcknowledgement) ValidateBasic() error { return errorsmod.Wrap(commitmenttypesv1.ErrInvalidProof, "cannot submit an empty acknowledgement proof") } - // TODO: Add validation for ack object https://github.com/cosmos/ibc-go/issues/7472 + if err := msg.Acknowledgement.Validate(); err != nil { + return err + } _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 35165f0d72e..2097c106c09 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -322,12 +322,19 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() { }, expError: types.ErrInvalidPacket, }, + { + name: "failure: invalid acknowledgement", + malleate: func() { + msg.Acknowledgement = types.NewAcknowledgement([]byte("")) + }, + expError: types.ErrInvalidAcknowledgement, + }, } for _, tc := range testCases { s.Run(tc.name, func() { msg = types.NewMsgAcknowledgement( types.NewPacket(1, ibctesting.FirstChannelID, ibctesting.SecondChannelID, s.chainA.GetTimeoutTimestamp(), mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB)), - types.Acknowledgement{}, + types.NewAcknowledgement([]byte("appAck1")), testProof, clienttypes.ZeroHeight(), s.chainA.SenderAccount.GetAddress().String(), From 77628947789c6f04644285a0ae93c402469c28c8 Mon Sep 17 00:00:00 2001 From: bmo Date: Tue, 10 Dec 2024 10:03:00 +0200 Subject: [PATCH 147/172] fix typeos (#7654) --- modules/core/04-channel/v2/keeper/keeper.go | 4 ++-- modules/core/04-channel/v2/keeper/msg_server.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 1b8d5398aba..6397568973d 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -118,7 +118,7 @@ func (k *Keeper) GetPacketReceipt(ctx context.Context, channelID string, sequenc return bz, true } -// HasPacketRceipt returns true if the packet receipt exists, otherwise false. +// HasPacketReceipt returns true if the packet receipt exists, otherwise false. func (k *Keeper) HasPacketReceipt(ctx context.Context, channelID string, sequence uint64) bool { store := k.storeService.OpenKVStore(ctx) has, err := store.Has(hostv2.PacketReceiptKey(channelID, sequence)) @@ -157,7 +157,7 @@ func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, channelID string, } } -// HasPacketAcknowledgement check if the packet ack hash is already on the store. +// HasPacketAcknowledgement checks if the packet ack hash is already on the store. func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) bool { return len(k.GetPacketAcknowledgement(ctx, channelID, sequence)) > 0 } diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 499e2baa825..08d0486233b 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -100,7 +100,6 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*typ } // RecvPacket implements the PacketMsgServer RecvPacket method. - func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*types.MsgRecvPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) From 96bdd56ab9b7011cb2eb600bd19236918427d353 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 10 Dec 2024 13:06:21 +0000 Subject: [PATCH 148/172] chore: document packet commitment keys + move prefixes to 24-host (#7633) --- .../core/04-channel/v2/keeper/grpc_query.go | 5 ++-- modules/core/04-channel/v2/types/keys.go | 10 ------- modules/core/24-host/v2/packet_keys.go | 27 ++++++++++++++++--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index d21fa1d9b3d..2b5e2bab977 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -17,6 +17,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) var _ types.QueryServer = (*queryServer)(nil) @@ -138,7 +139,7 @@ func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPac } var commitments []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.PacketCommitmentPrefixKey(req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), hostv2.PacketCommitmentPrefixKey(req.ChannelId)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { keySplit := strings.Split(string(key), "/") @@ -205,7 +206,7 @@ func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.Que } var acks []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.PacketAcknowledgementPrefixKey(req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), hostv2.PacketAcknowledgementPrefixKey(req.ChannelId)) // if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences) // otherwise, maintain previous behaviour and perform paginated query diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index 8e5cae328bf..f751a92b3f1 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -14,13 +14,3 @@ const ( // the creator key is not a part of the ics-24 host specification CreatorKey = "creator" ) - -// PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. -func PacketCommitmentPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(1)) -} - -// PacketAcknowledgementPrefixKey returns the store key prefix under which packet acknowledgements for a particular channel are stored. -func PacketAcknowledgementPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(3)) -} diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index 5522375fb5f..03f15a858d5 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -6,19 +6,40 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. +func PacketCommitmentPrefixKey(channelID string) []byte { + return append([]byte(channelID), byte(1)) +} + // PacketCommitmentKey returns the store key of under which a packet commitment is stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketCommitmentKey(channelID string, sequence uint64) []byte { - return append(append([]byte(channelID), byte(1)), sdk.Uint64ToBigEndian(sequence)...) + return append(PacketCommitmentPrefixKey((channelID)), sdk.Uint64ToBigEndian(sequence)...) +} + +// PacketReceiptPrefixKey returns the store key prefix under which packet receipts for a particular channel are stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. +func PacketReceiptPrefixKey(channelID string) []byte { + return append([]byte(channelID), byte(2)) } // PacketReceiptKey returns the store key of under which a packet receipt is stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketReceiptKey(channelID string, sequence uint64) []byte { - return append(append([]byte(channelID), byte(2)), sdk.Uint64ToBigEndian(sequence)...) + return append(PacketReceiptPrefixKey(channelID), sdk.Uint64ToBigEndian(sequence)...) +} + +// PacketAcknowledgementPrefixKey returns the store key prefix under which packet acknowledgements for a particular channel are stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. +func PacketAcknowledgementPrefixKey(channelID string) []byte { + return append([]byte(channelID), byte(3)) } // PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. +// channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { - return append(append([]byte(channelID), byte(3)), sdk.Uint64ToBigEndian(sequence)...) + return append(PacketAcknowledgementPrefixKey(channelID), sdk.Uint64ToBigEndian(sequence)...) } // NextSequenceSendKey returns the store key for the next sequence send of a given channelID. From 4c6b84aba88e184c648e04c8cd6b0f1801a0cef5 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 10 Dec 2024 13:06:58 +0000 Subject: [PATCH 149/172] move timestamp checks in SendPacket earlier (#7637) --- modules/core/04-channel/v2/keeper/msg_server.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 08d0486233b..e7fff53b9af 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -64,11 +64,6 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegis // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*types.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) - if err != nil { - sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) - return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) - } // Note, the validate basic function in sendPacket does the timeoutTimestamp != 0 check and other stateless checks on the packet. // timeoutTimestamp must be greater than current block time @@ -88,6 +83,12 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*typ return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } + sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) + if err != nil { + sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) + } + for _, pd := range msg.Payloads { cbs := k.Router.Route(pd.SourcePort) err := cbs.OnSendPacket(ctx, msg.SourceChannel, destChannel, sequence, pd, signer) From 2ca28242fb9354aa0612e763dfabdd8d803a9cb9 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 10 Dec 2024 13:07:14 +0000 Subject: [PATCH 150/172] rename v2 router api to use portID (#7639) --- modules/core/api/router.go | 46 ++++++------------- modules/core/api/router_test.go | 39 ++++++---------- .../08-wasm/testing/simapp/app.go | 2 +- testing/mock/v2/ibc_module.go | 4 ++ testing/simapp/app.go | 6 +-- 5 files changed, 36 insertions(+), 61 deletions(-) diff --git a/modules/core/api/router.go b/modules/core/api/router.go index 893dece45a9..753bfc7f9c0 100644 --- a/modules/core/api/router.go +++ b/modules/core/api/router.go @@ -3,13 +3,13 @@ package api import ( "errors" "fmt" - "strings" sdk "github.com/cosmos/cosmos-sdk/types" ) // Router contains all the module-defined callbacks required by IBC Protocol V2. type Router struct { + // routes is a map from portID to IBCModule routes map[string]IBCModule } @@ -20,50 +20,32 @@ func NewRouter() *Router { } } -// AddRoute registers a route for a given module name. -func (rtr *Router) AddRoute(module string, cbs IBCModule) *Router { - if !sdk.IsAlphaNumeric(module) { +// AddRoute registers a route for a given portID to a given IBCModule. +func (rtr *Router) AddRoute(portID string, cbs IBCModule) *Router { + if !sdk.IsAlphaNumeric(portID) { panic(errors.New("route expressions can only contain alphanumeric characters")) } - if rtr.HasRoute(module) { - panic(fmt.Errorf("route %s has already been registered", module)) + if rtr.HasRoute(portID) { + panic(fmt.Errorf("route %s has already been registered", portID)) } - rtr.routes[module] = cbs + rtr.routes[portID] = cbs return rtr } -// Route returns the IBCModule for a given module name. -func (rtr *Router) Route(module string) IBCModule { - route, ok := rtr.routeOrPrefixedRoute(module) +// Route returns the IBCModule for a given portID. +func (rtr *Router) Route(portID string) IBCModule { + route, ok := rtr.routes[portID] if !ok { - panic(fmt.Sprintf("no route for %s", module)) + panic(fmt.Sprintf("no route for %s", portID)) } return route } -// HasRoute returns true if the Router has a module registered or false otherwise. -func (rtr *Router) HasRoute(module string) bool { - _, ok := rtr.routeOrPrefixedRoute(module) +// HasRoute returns true if the Router has a module registered for the portID or false otherwise. +func (rtr *Router) HasRoute(portID string) bool { + _, ok := rtr.routes[portID] return ok } - -// routeOrPrefixedRoute returns the IBCModule for a given module name. -// if an exact match is not found, a route with the provided prefix is searched for instead. -func (rtr *Router) routeOrPrefixedRoute(module string) (IBCModule, bool) { - route, ok := rtr.routes[module] - if ok { - return route, true - } - - // it's possible that some routes have been dynamically added e.g. with interchain accounts. - // in this case, we need to check if the module has the specified prefix. - for prefix, ibcModule := range rtr.routes { - if strings.HasPrefix(module, prefix) { - return ibcModule, true - } - } - return nil, false -} diff --git a/modules/core/api/router_test.go b/modules/core/api/router_test.go index bdcaa3e9c5a..7258924b9b2 100644 --- a/modules/core/api/router_test.go +++ b/modules/core/api/router_test.go @@ -16,53 +16,42 @@ func (suite *APITestSuite) TestRouter() { { name: "success", malleate: func() { - router.AddRoute("module01", &mockv2.IBCModule{}) + router.AddRoute("port01", &mockv2.IBCModule{}) }, assertionFn: func() { - suite.Require().True(router.HasRoute("module01")) + suite.Require().True(router.HasRoute("port01")) }, }, { name: "success: multiple modules", malleate: func() { - router.AddRoute("module01", &mockv2.IBCModule{}) - router.AddRoute("module02", &mockv2.IBCModule{}) - router.AddRoute("module03", &mockv2.IBCModule{}) + router.AddRoute("port01", &mockv2.IBCModule{}) + router.AddRoute("port02", &mockv2.IBCModule{}) + router.AddRoute("port03", &mockv2.IBCModule{}) }, assertionFn: func() { - suite.Require().True(router.HasRoute("module01")) - suite.Require().True(router.HasRoute("module02")) - suite.Require().True(router.HasRoute("module03")) - }, - }, - { - name: "success: find by prefix", - malleate: func() { - router.AddRoute("module01", &mockv2.IBCModule{}) - }, - assertionFn: func() { - suite.Require().True(router.HasRoute("module01-foo")) + suite.Require().True(router.HasRoute("port01")) + suite.Require().True(router.HasRoute("port02")) + suite.Require().True(router.HasRoute("port03")) }, }, { name: "failure: panics on duplicate module", malleate: func() { - router.AddRoute("module01", &mockv2.IBCModule{}) + router.AddRoute("port01", &mockv2.IBCModule{}) }, assertionFn: func() { - suite.Require().PanicsWithError("route module01 has already been registered", func() { - router.AddRoute("module01", &mockv2.IBCModule{}) + suite.Require().PanicsWithError("route port01 has already been registered", func() { + router.AddRoute("port01", &mockv2.IBCModule{}) }) }, }, { - name: "failure: panics invalid-name", - malleate: func() { - router.AddRoute("module01", &mockv2.IBCModule{}) - }, + name: "failure: panics invalid-name", + malleate: func() {}, assertionFn: func() { suite.Require().PanicsWithError("route expressions can only contain alphanumeric characters", func() { - router.AddRoute("module-02", &mockv2.IBCModule{}) + router.AddRoute("port-02", &mockv2.IBCModule{}) }) }, }, diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 8c5280db225..bd4ce547337 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -570,7 +570,7 @@ func NewSimApp( // register the transfer v2 module. app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) - ibcRouterV2.AddRoute(ibctransfertypes.ModuleName, transferv2.NewIBCModule(app.TransferKeeperV2)) + ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeperV2)) // Seal the IBC Routers. app.IBCKeeper.SetRouter(ibcRouter) diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 8ea9fad704a..4aa53ee8d34 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -16,6 +16,10 @@ const ( ModuleNameA = ModuleName + "A" // ModuleNameB is a name that can be used for the second mock application. ModuleNameB = ModuleName + "B" + // PortIDA is a port ID that can be used for the first mock application. + PortIDA = ModuleNameA + // PortIDB is a port ID that can be used for the second mock application. + PortIDB = ModuleNameB ) // IBCModule is a mock implementation of the IBCModule interface. diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 869b31ba649..3405ab8047c 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -480,16 +480,16 @@ func NewSimApp( // create two separate mock v2 applications so that it is possible to test multi packet data. mockV2A := mockv2.NewIBCModule() - ibcRouterV2.AddRoute(mockv2.ModuleNameA, mockV2A) + ibcRouterV2.AddRoute(mockv2.PortIDA, mockV2A) app.MockModuleV2A = mockV2A mockV2B := mockv2.NewIBCModule() - ibcRouterV2.AddRoute(mockv2.ModuleNameB, mockV2B) + ibcRouterV2.AddRoute(mockv2.PortIDB, mockV2B) app.MockModuleV2B = mockV2B // register the transfer v2 module. app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) - ibcRouterV2.AddRoute(ibctransfertypes.ModuleName, transferv2.NewIBCModule(app.TransferKeeperV2)) + ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeperV2)) // Seal the IBC Router app.IBCKeeper.SetRouter(ibcRouter) From 8a45cd61518dfc1652c923a2441b4eb9e8483138 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 12 Dec 2024 09:11:19 +0200 Subject: [PATCH 151/172] chore: fix merge mess --- modules/apps/transfer/keeper/msg_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 0dc5b8db981..bd0b64703be 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -29,7 +29,7 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. coins := msg.GetCoins() - if err := k.bankKeeper.IsSendEnabledCoins(ctx, coins...); err != nil { + if err := k.BankKeeper.IsSendEnabledCoins(ctx, coins...); err != nil { return nil, errorsmod.Wrap(types.ErrSendDisabled, err.Error()) } From a108c018d6e04712aa8c8125abc656647c98a820 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 12 Dec 2024 09:47:43 +0200 Subject: [PATCH 152/172] chore: remove stale connection test cases brought in by merge --- .../core/03-connection/keeper/verify_test.go | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index b2fbd092425..7b75badf9fd 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -33,9 +33,6 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { expErr error }{ {"verification success", func() {}, nil}, - {"client state not found - changed client ID", func() { - path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (IDisInvalid) status is Unauthorized")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed connection state verification for client (07-tendermint-0): client state height < proof height ({1 9} < {1 14}), please ensure the client has been updated")}, @@ -96,9 +93,6 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { expErr error }{ {"verification success", func() {}, nil}, - {"client state not found- changed client ID", func() { - path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (IDisInvalid) status is Unauthorized")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed channel state verification for client (07-tendermint-0): client state height < proof height ({1 15} < {1 20}), please ensure the client has been updated")}, @@ -174,9 +168,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { delayTimePeriod = uint64(1 * time.Second.Nanoseconds()) timePerBlock = 1 }, errorsmod.Wrap(ibctm.ErrDelayPeriodNotPassed, "failed packet commitment verification for client (07-tendermint-0): cannot verify packet until height: 1-1000000016, current height: 1-17")}, - {"client state not found- changed client ID", func() { - path.EndpointB.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed packet commitment verification for client (07-tendermint-0): client state height < proof height ({1 17} < {1 22}), please ensure the client has been updated")}, @@ -266,9 +257,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { delayTimePeriod = uint64(1 * time.Second.Nanoseconds()) timePerBlock = 1 }, errorsmod.Wrap(ibctm.ErrDelayPeriodNotPassed, "failed packet acknowledgement verification for client (07-tendermint-0): cannot verify packet until height: 1-1000000018, current height: 1-19")}, - {"client state not found- changed client ID", func() { - path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed packet acknowledgement verification for client (07-tendermint-0): client state height < proof height ({1 19} < {1 24}), please ensure the client has been updated")}, @@ -367,9 +355,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { delayTimePeriod = uint64(1 * time.Second.Nanoseconds()) timePerBlock = 1 }, errorsmod.Wrap(ibctm.ErrDelayPeriodNotPassed, "failed packet commitment verification for client (07-tendermint-0): cannot verify packet until height: 1-1000000016, current height: 1-17")}, - {"client state not found - changed client ID", func() { - path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed packet commitment verification for client (07-tendermint-0): client state height < proof height ({1 17} < {1 22}), please ensure the client has been updated")}, @@ -474,9 +459,6 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { delayTimePeriod = uint64(1 * time.Second.Nanoseconds()) timePerBlock = 1 }, errorsmod.Wrap(ibctm.ErrDelayPeriodNotPassed, "failed packet commitment verification for client (07-tendermint-0): cannot verify packet until height: 1-1000000016, current height: 1-17")}, - {"client state not found- changed client ID", func() { - path.EndpointA.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen")}, {"consensus state not found - increased proof height", func() { heightDiff = 5 }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed packet commitment verification for client (07-tendermint-0): client state height < proof height ({1 17} < {1 22}), please ensure the client has been updated")}, @@ -569,13 +551,6 @@ func (suite *KeeperTestSuite) TestVerifyUpgradeErrorReceipt() { }, expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen"), }, - { - name: "fails with bad client id", - malleate: func() { - path.EndpointB.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, - expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (IDisInvalid) status is Unauthorized"), - }, { name: "verification fails when the key does not exist", malleate: func() { @@ -652,13 +627,6 @@ func (suite *KeeperTestSuite) TestVerifyUpgrade() { }, expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen"), }, - { - name: "fails with bad client id", - malleate: func() { - path.EndpointB.UpdateConnection(func(c *types.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, - expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (IDisInvalid) status is Unauthorized"), - }, { name: "fails when the upgrade field is different", malleate: func() { From 05efed953dcfdc1c755f003a90bf6e93880b95ae Mon Sep 17 00:00:00 2001 From: Alyak Date: Fri, 13 Dec 2024 14:10:30 +0200 Subject: [PATCH 153/172] use unordered check (#7689) --- modules/core/04-channel/v2/keeper/keeper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 6397568973d..febc06a1f24 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -221,8 +221,8 @@ func (k *Keeper) aliasV1Channel(ctx context.Context, portID, channelID string) ( return types.Channel{}, false } // Do not allow channel to be converted into a version 2 channel - // if the channel is not OPEN or if it is ORDERED - if channel.State != channeltypesv1.OPEN || channel.Ordering == channeltypesv1.ORDERED { + // if the channel is not OPEN or if it is not UNORDERED + if channel.State != channeltypesv1.OPEN || channel.Ordering != channeltypesv1.UNORDERED { return types.Channel{}, false } connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) From a8ee5482456c40d75ada0a3739204a5f7a0689ca Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 10:46:00 +0200 Subject: [PATCH 154/172] chore: add telemetry reporting for packet methods (#7673) --- .../core/04-channel/v2/keeper/msg_server.go | 4 ++ modules/core/internal/v2/telemetry/packet.go | 56 ++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index e7fff53b9af..3c80eb9671b 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -226,6 +226,8 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem } } + defer telemetry.ReportAcknowledgePacket(msg.Packet) + return &types.MsgAcknowledgementResponse{Result: types.SUCCESS}, nil } @@ -265,5 +267,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types } } + defer telemetry.ReportTimeoutPacket(timeout.Packet) + return &types.MsgTimeoutResponse{Result: types.SUCCESS}, nil } diff --git a/modules/core/internal/v2/telemetry/packet.go b/modules/core/internal/v2/telemetry/packet.go index 7c5c8588247..8d12f785960 100644 --- a/modules/core/internal/v2/telemetry/packet.go +++ b/modules/core/internal/v2/telemetry/packet.go @@ -1,14 +1,56 @@ package telemetry import ( - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + metrics "github.com/hashicorp/go-metrics" + + "github.com/cosmos/cosmos-sdk/telemetry" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibcmetrics "github.com/cosmos/ibc-go/v9/modules/core/metrics" ) -// ReportRecvPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportRecvPacket(packet channeltypesv2.Packet) {} +func ReportRecvPacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"tx", "msg", "ibc", types.EventTypeRecvPacket}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + }, + ) + } +} -// ReportTimeoutPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportTimeoutPacket(packet channeltypesv2.Packet, timeoutType string) {} +func ReportTimeoutPacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"ibc", "timeout", "packet"}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + telemetry.NewLabel(ibcmetrics.LabelTimeoutType, "height"), + }, + ) + } +} -// ReportAcknowledgePacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportAcknowledgePacket(packet channeltypesv2.Packet) {} +func ReportAcknowledgePacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"tx", "msg", "ibc", types.EventTypeAcknowledgePacket}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + }, + ) + } +} From a64877ff603783dd73610a85a6f5425d8785b722 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 12:47:06 +0200 Subject: [PATCH 155/172] chore: remove redundant calls to emit events in cached context. (#7648) --- modules/core/04-channel/v2/keeper/msg_server.go | 2 -- modules/core/04-channel/v2/keeper/packet.go | 5 ----- 2 files changed, 7 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 3c80eb9671b..179e44fd93f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -209,7 +209,6 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem case nil: writeFn() case types.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) return &types.MsgAcknowledgementResponse{Result: types.NOOP}, nil default: @@ -251,7 +250,6 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types case nil: writeFn() case types.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) return &types.MsgTimeoutResponse{Result: types.NOOP}, nil default: diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 868d12a047d..ef396bca6a5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -126,7 +126,6 @@ func (k *Keeper) recvPacket( // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. if k.HasPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) { - emitRecvPacketEvents(ctx, packet) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -221,9 +220,6 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - // TODO: signal noop in events? - emitAcknowledgePacketEvents(ctx, packet) - // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -300,7 +296,6 @@ func (k *Keeper) timeoutPacket( // check that the commitment has not been cleared and that it matches the packet sent by relayer commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - emitTimeoutPacketEvents(ctx, packet) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to From a5b69ec73687dec86e1f6ab5a2aebd9c667a5f3e Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 13:29:15 +0200 Subject: [PATCH 156/172] chore: add channel consensus state rpc (#7619) --- .../core/04-channel/v2/keeper/grpc_query.go | 32 + .../04-channel/v2/keeper/grpc_query_test.go | 108 ++ .../04-channel/v2/types/expected_keepers.go | 2 + modules/core/04-channel/v2/types/query.go | 16 +- modules/core/04-channel/v2/types/query.pb.go | 925 +++++++++++++++--- .../core/04-channel/v2/types/query.pb.gw.go | 119 +++ proto/ibc/core/channel/v2/query.proto | 31 + 7 files changed, 1088 insertions(+), 145 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 2b5e2bab977..93ccb5f41ee 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -78,6 +78,38 @@ func (q *queryServer) ChannelClientState(ctx context.Context, req *types.QueryCh return res, nil } +// ChannelConsensusState implements the Query/ChannelConsensusState gRPC method +func (q *queryServer) ChannelConsensusState(ctx context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + channel, found := q.GetChannel(ctx, req.ChannelId) + if !found { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) + } + + consHeight := clienttypes.NewHeight(req.RevisionNumber, req.RevisionHeight) + consensusState, found := q.ClientKeeper.GetClientConsensusState(ctx, channel.ClientId, consHeight) + if !found { + return nil, status.Error( + codes.NotFound, + errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "client-id: %s", channel.ClientId).Error(), + ) + } + + anyConsensusState, err := clienttypes.PackConsensusState(consensusState) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return types.NewQueryChannelConsensusStateResponse(channel.ClientId, anyConsensusState, nil, clienttypes.GetSelfHeight(ctx)), nil +} + // NextSequenceSend implements the Query/NextSequenceSend gRPC method func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 58c0e3bf810..4af5b3414b5 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -190,6 +191,113 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { } } +func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { + var ( + req *types.QueryChannelConsensusStateRequest + expConsensusState exported.ConsensusState + expClientID string + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, path.EndpointA.GetClientLatestHeight()) + suite.Require().NotNil(expConsensusState) + expClientID = path.EndpointA.ClientID + + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: path.EndpointA.ChannelID, + RevisionNumber: path.EndpointA.GetClientLatestHeight().GetRevisionNumber(), + RevisionHeight: path.EndpointA.GetClientLatestHeight().GetRevisionHeight(), + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: "", + RevisionNumber: 0, + RevisionHeight: 1, + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: "test-channel-id", + RevisionNumber: 0, + RevisionHeight: 1, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", "test-channel-id")), + }, + { + "consensus state for channel's connection not found", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: path.EndpointA.ChannelID, + RevisionNumber: 0, + RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height + } + }, + status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: consensus state not found", "07-tendermint-0")), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.ChannelConsensusState(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState) + suite.Require().NoError(err) + suite.Require().Equal(expConsensusState, consensusState) + suite.Require().Equal(expClientID, res.ClientId) + + // ensure UnpackInterfaces is defined + cachedValue := res.ConsensusState.GetCachedValue() + suite.Require().NotNil(cachedValue) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPacketCommitment() { var ( expCommitment []byte diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 9f94668a8a0..32cda94bba8 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -21,4 +21,6 @@ type ClientKeeper interface { GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) // GetClientState gets a particular client from the store GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool) + // GetClientConsensusState gets the stored consensus state from a client at a given height. + GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) } diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index af4b2d7ae45..92913c0ae19 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -1,6 +1,10 @@ package types -import clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" +) // NewQueryChannelRequest creates and returns a new channel query request. func NewQueryChannelRequest(channelID string) *QueryChannelRequest { @@ -32,6 +36,16 @@ func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.Identi } } +// NewQueryChannelConsensusStateResponse creates and returns a new ChannelConsensusState query response. +func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, proof []byte, height clienttypes.Height) *QueryChannelConsensusStateResponse { + return &QueryChannelConsensusStateResponse{ + ConsensusState: anyConsensusState, + ClientId: clientID, + Proof: proof, + ProofHeight: height, + } +} + // NewQueryNextSequenceSendRequest creates a new next sequence send query. func NewQueryNextSequenceSendRequest(channelID string) *QueryNextSequenceSendRequest { return &QueryNextSequenceSendRequest{ diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 37132d2bebc..90f01927af7 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types1 "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -234,6 +235,145 @@ func (m *QueryChannelClientStateResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState +// RPC method +type QueryChannelConsensusStateRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // revision number of the consensus state + RevisionNumber uint64 `protobuf:"varint,2,opt,name=revision_number,json=revisionNumber,proto3" json:"revision_number,omitempty"` + // revision height of the consensus state + RevisionHeight uint64 `protobuf:"varint,3,opt,name=revision_height,json=revisionHeight,proto3" json:"revision_height,omitempty"` +} + +func (m *QueryChannelConsensusStateRequest) Reset() { *m = QueryChannelConsensusStateRequest{} } +func (m *QueryChannelConsensusStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelConsensusStateRequest) ProtoMessage() {} +func (*QueryChannelConsensusStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{4} +} +func (m *QueryChannelConsensusStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelConsensusStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelConsensusStateRequest.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 *QueryChannelConsensusStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelConsensusStateRequest.Merge(m, src) +} +func (m *QueryChannelConsensusStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelConsensusStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelConsensusStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelConsensusStateRequest proto.InternalMessageInfo + +func (m *QueryChannelConsensusStateRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryChannelConsensusStateRequest) GetRevisionNumber() uint64 { + if m != nil { + return m.RevisionNumber + } + return 0 +} + +func (m *QueryChannelConsensusStateRequest) GetRevisionHeight() uint64 { + if m != nil { + return m.RevisionHeight + } + return 0 +} + +// QueryChannelConsensusStateResponse is the Response type for the +// Query/QueryChannelConsensusState RPC method +type QueryChannelConsensusStateResponse struct { + // consensus state associated with the channel + ConsensusState *types1.Any `protobuf:"bytes,1,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty"` + // client ID associated with the consensus state + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryChannelConsensusStateResponse) Reset() { *m = QueryChannelConsensusStateResponse{} } +func (m *QueryChannelConsensusStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelConsensusStateResponse) ProtoMessage() {} +func (*QueryChannelConsensusStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{5} +} +func (m *QueryChannelConsensusStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelConsensusStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelConsensusStateResponse.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 *QueryChannelConsensusStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelConsensusStateResponse.Merge(m, src) +} +func (m *QueryChannelConsensusStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelConsensusStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelConsensusStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelConsensusStateResponse proto.InternalMessageInfo + +func (m *QueryChannelConsensusStateResponse) GetConsensusState() *types1.Any { + if m != nil { + return m.ConsensusState + } + return nil +} + +func (m *QueryChannelConsensusStateResponse) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *QueryChannelConsensusStateResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryChannelConsensusStateResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method type QueryNextSequenceSendRequest struct { // channel unique identifier @@ -244,7 +384,7 @@ func (m *QueryNextSequenceSendRequest) Reset() { *m = QueryNextSequenceS func (m *QueryNextSequenceSendRequest) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendRequest) ProtoMessage() {} func (*QueryNextSequenceSendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryNextSequenceSendRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -294,7 +434,7 @@ func (m *QueryNextSequenceSendResponse) Reset() { *m = QueryNextSequence func (m *QueryNextSequenceSendResponse) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendResponse) ProtoMessage() {} func (*QueryNextSequenceSendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryNextSequenceSendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,7 +496,7 @@ func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitm func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentRequest) ProtoMessage() {} func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +553,7 @@ func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentResponse) ProtoMessage() {} func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -475,7 +615,7 @@ func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsRequest) ProtoMessage() {} func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{8} + return fileDescriptor_a328cba4986edcab, []int{10} } func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -532,7 +672,7 @@ func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommi func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsResponse) ProtoMessage() {} func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{9} + return fileDescriptor_a328cba4986edcab, []int{11} } func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -594,7 +734,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{10} + return fileDescriptor_a328cba4986edcab, []int{12} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,7 +791,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{11} + return fileDescriptor_a328cba4986edcab, []int{13} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -716,7 +856,7 @@ func (m *QueryPacketAcknowledgementsRequest) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryPacketAcknowledgementsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -780,7 +920,7 @@ func (m *QueryPacketAcknowledgementsResponse) Reset() { *m = QueryPacket func (m *QueryPacketAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryPacketAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -844,7 +984,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{14} + return fileDescriptor_a328cba4986edcab, []int{16} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -908,7 +1048,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{15} + return fileDescriptor_a328cba4986edcab, []int{17} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -970,7 +1110,7 @@ func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPa func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{16} + return fileDescriptor_a328cba4986edcab, []int{18} } func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1025,7 +1165,7 @@ func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedP func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{17} + return fileDescriptor_a328cba4986edcab, []int{19} } func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1081,7 +1221,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{18} + return fileDescriptor_a328cba4986edcab, []int{20} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1137,7 +1277,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{19} + return fileDescriptor_a328cba4986edcab, []int{21} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1185,6 +1325,8 @@ func init() { proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") proto.RegisterType((*QueryChannelClientStateRequest)(nil), "ibc.core.channel.v2.QueryChannelClientStateRequest") proto.RegisterType((*QueryChannelClientStateResponse)(nil), "ibc.core.channel.v2.QueryChannelClientStateResponse") + proto.RegisterType((*QueryChannelConsensusStateRequest)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateRequest") + proto.RegisterType((*QueryChannelConsensusStateResponse)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateResponse") proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v2.QueryNextSequenceSendRequest") proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v2.QueryNextSequenceSendResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") @@ -1206,82 +1348,91 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 1197 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xce, 0x64, 0xd3, 0xfc, 0x78, 0x09, 0x34, 0x9d, 0xa6, 0x34, 0x75, 0xd3, 0x4d, 0x6a, 0x24, - 0xd8, 0x56, 0xad, 0x27, 0xd9, 0x44, 0xb4, 0x95, 0x5a, 0xa2, 0x24, 0x94, 0x36, 0x15, 0xa0, 0xe0, - 0x00, 0x12, 0xa8, 0xea, 0xca, 0xeb, 0x9d, 0x38, 0x56, 0x76, 0x3d, 0xee, 0x8e, 0x77, 0x49, 0x55, - 0xe5, 0xc2, 0x81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, 0x9a, 0xd7, 0x48, 0x8d, 0x55, 0x1a, 0x55, 0xca, 0x7d, 0x7a, - 0xf3, 0x4b, 0x97, 0x43, 0x0c, 0xbd, 0x07, 0x2e, 0xe5, 0xe5, 0x61, 0xf1, 0x77, 0xd7, 0xe2, 0x7f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x15, 0x99, 0x77, 0xb3, 0xed, 0x13, 0x00, 0x00, + // 1334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x4f, 0xdc, 0x46, + 0x14, 0x66, 0x58, 0x92, 0xc0, 0x23, 0x0d, 0x30, 0x81, 0x06, 0x0c, 0x59, 0x88, 0x2b, 0x35, 0x9b, + 0x28, 0xb1, 0x61, 0x41, 0x4d, 0x52, 0x41, 0x11, 0xd0, 0x34, 0x21, 0x6a, 0x23, 0x6a, 0xda, 0x4a, + 0xad, 0xa2, 0xac, 0xbc, 0xf6, 0xb0, 0x58, 0xec, 0x8e, 0x9d, 0x1d, 0xef, 0x16, 0x14, 0x71, 0xe9, + 0xa1, 0xe7, 0xaa, 0xe9, 0xa9, 0x7f, 0x41, 0xfb, 0x57, 0x34, 0x52, 0x2f, 0x91, 0xd2, 0x43, 0xa4, + 0x1c, 0x5a, 0xa9, 0x52, 0x7f, 0x40, 0xa5, 0xfe, 0x07, 0x3d, 0x57, 0x3b, 0x1e, 0xef, 0xda, 0xbb, + 0x5e, 0x63, 0x27, 0xa1, 0xea, 0x6d, 0x3d, 0x7e, 0xef, 0xcd, 0xf7, 0x7d, 0xf3, 0x66, 0xe6, 0xf3, + 0xc2, 0xb4, 0x55, 0x34, 0x54, 0xc3, 0xae, 0x12, 0xd5, 0xd8, 0xd6, 0x29, 0x25, 0x65, 0xb5, 0x9e, + 0x57, 0x1f, 0xd4, 0x48, 0x75, 0x4f, 0x71, 0xaa, 0xb6, 0x6b, 0xe3, 0xb3, 0x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0x4c, 0x77, 0xad, 0x20, 0x20, 0xea, 0x70, 0xce, 0x32, 0x09, 0x75, 0xad, + 0x2d, 0x8b, 0x98, 0x05, 0x4f, 0xda, 0x02, 0x6b, 0x84, 0x08, 0xc8, 0x97, 0x02, 0x90, 0x3d, 0xe1, + 0xeb, 0x73, 0xca, 0x7a, 0x33, 0x25, 0x58, 0x73, 0xcc, 0x8a, 0x1a, 0xc6, 0xa3, 0x70, 0xc2, 0xa9, + 0xda, 0xf6, 0xd6, 0x78, 0xef, 0x0c, 0xca, 0x9d, 0xd6, 0xbc, 0x07, 0xbc, 0x06, 0xa7, 0xf9, 0x8f, + 0xc2, 0x36, 0xb1, 0x4a, 0xdb, 0xee, 0x78, 0x86, 0xcf, 0x26, 0x45, 0xcd, 0x76, 0x9b, 0x47, 0x08, + 0x79, 0x06, 0x79, 0x96, 0x37, 0x24, 0x7f, 0x83, 0xe0, 0x42, 0x88, 0x61, 0x83, 0x13, 0x65, 0x35, + 0x96, 0x42, 0x26, 0x7c, 0x11, 0x86, 0xaa, 0xa4, 0x6e, 0x31, 0xcb, 0xa6, 0x05, 0x5a, 0xab, 0x14, + 0x49, 0x95, 0x23, 0xed, 0xd3, 0xce, 0xf8, 0xc3, 0x77, 0xf9, 0x68, 0x28, 0x30, 0x80, 0x3a, 0x10, + 0x28, 0x60, 0xfd, 0x8a, 0x40, 0x8e, 0x83, 0x25, 0xb4, 0x5f, 0x82, 0x21, 0xc3, 0x7f, 0x13, 0xd2, + 0x7c, 0x54, 0xf1, 0xfa, 0x56, 0xf1, 0xfb, 0x56, 0x59, 0xa1, 0x7b, 0xda, 0x19, 0x23, 0x54, 0x06, + 0x4f, 0xc2, 0x80, 0x58, 0x2f, 0xcb, 0xe4, 0x88, 0x07, 0xb4, 0x7e, 0x6f, 0x60, 0xdd, 0x6c, 0x89, + 0x9e, 0x89, 0x13, 0xbd, 0xef, 0x45, 0x44, 0x5f, 0x82, 0x29, 0x4e, 0xee, 0x2e, 0xd9, 0x75, 0x37, + 0x1b, 0x12, 0x53, 0x83, 0x6c, 0x12, 0x6a, 0x26, 0xec, 0xca, 0xef, 0x10, 0x9c, 0xef, 0x92, 0x2f, + 0x74, 0xb9, 0x02, 0x98, 0x92, 0x5d, 0xb7, 0xc0, 0xc4, 0xcb, 0x02, 0x23, 0xd4, 0x2b, 0xd4, 0xa7, + 0x0d, 0xd3, 0xb6, 0xac, 0xe3, 0x6c, 0xaf, 0x4f, 0x05, 0xd3, 0x0d, 0xdd, 0xd8, 0x21, 0xee, 0x9a, + 0x5d, 0xa9, 0x58, 0x6e, 0x85, 0x50, 0x37, 0x61, 0x63, 0x49, 0xd0, 0xef, 0x53, 0x10, 0x1d, 0xd5, + 0x7c, 0x96, 0xbf, 0xf5, 0x55, 0xe8, 0xac, 0x2d, 0x54, 0xc8, 0x02, 0x18, 0xcd, 0x51, 0x5e, 0xfc, + 0xb4, 0x16, 0x18, 0x39, 0x4e, 0xde, 0x5f, 0x76, 0x03, 0xc7, 0x12, 0x32, 0x7f, 0x0f, 0xa0, 0x75, + 0x21, 0x70, 0x80, 0x83, 0xf9, 0x37, 0x15, 0xef, 0xf6, 0x50, 0x1a, 0xb7, 0x87, 0xe2, 0xdd, 0x35, + 0xe2, 0xf6, 0x50, 0x36, 0xf4, 0x92, 0xbf, 0x5b, 0xb5, 0x40, 0xa6, 0xfc, 0x37, 0x12, 0x67, 0x60, + 0x04, 0x10, 0x21, 0xd3, 0x2a, 0x0c, 0xb6, 0x44, 0x61, 0xe3, 0x68, 0x26, 0x93, 0x1b, 0xcc, 0xcf, + 0x44, 0x9e, 0xb3, 0x5e, 0x11, 0x6f, 0x0f, 0x06, 0x93, 0xf0, 0xad, 0x08, 0xb8, 0x17, 0x8f, 0x84, + 0xeb, 0x01, 0x08, 0xe2, 0xc5, 0xd7, 0xe1, 0x64, 0x4a, 0xdd, 0x45, 0xbc, 0x7c, 0x5f, 0x1c, 0x64, + 0x1e, 0xc6, 0x15, 0x63, 0x87, 0xda, 0x9f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f9, 0x92, 0xdc, 0xa2, 0x2c, 0x54, 0x88, 0x66, 0x63, + 0xbf, 0xad, 0x7e, 0xf2, 0xe4, 0x20, 0x8b, 0x9e, 0x1d, 0x64, 0xd1, 0x1f, 0x07, 0x59, 0xf4, 0xd5, + 0x61, 0xb6, 0xe7, 0xd9, 0x61, 0xb6, 0xe7, 0x97, 0xc3, 0x6c, 0xcf, 0x67, 0x8b, 0x25, 0xcb, 0xdd, + 0xae, 0x15, 0x15, 0xc3, 0xae, 0xa8, 0xe2, 0xaf, 0x5d, 0xab, 0x68, 0x5c, 0x2d, 0xd9, 0x6a, 0xfd, + 0x86, 0x5a, 0xb1, 0xcd, 0x5a, 0x99, 0x30, 0x0f, 0xde, 0xec, 0xc2, 0xd5, 0x00, 0x42, 0x77, 0xcf, + 0x21, 0xac, 0x78, 0x92, 0xff, 0x3b, 0x35, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x2a, + 0x4b, 0x9b, 0x4c, 0x16, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1301,6 +1452,9 @@ type QueryClient interface { // ChannelClientState queries for the client state for the channel associated // with the provided channel identifiers. ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) + // ChannelConsensusState queries for the consensus state for the channel associated + // with the provided channel identifiers. + ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1345,6 +1499,15 @@ func (c *queryClient) ChannelClientState(ctx context.Context, in *QueryChannelCl return out, nil } +func (c *queryClient) ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) { + out := new(QueryChannelConsensusStateResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/ChannelConsensusState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { out := new(QueryNextSequenceSendResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) @@ -1424,6 +1587,9 @@ type QueryServer interface { // ChannelClientState queries for the client state for the channel associated // with the provided channel identifiers. ChannelClientState(context.Context, *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) + // ChannelConsensusState queries for the consensus state for the channel associated + // with the provided channel identifiers. + ChannelConsensusState(context.Context, *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1452,6 +1618,9 @@ func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelR func (*UnimplementedQueryServer) ChannelClientState(ctx context.Context, req *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelClientState not implemented") } +func (*UnimplementedQueryServer) ChannelConsensusState(ctx context.Context, req *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelConsensusState not implemented") +} func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") } @@ -1517,6 +1686,24 @@ func _Query_ChannelClientState_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_ChannelConsensusState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelConsensusStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ChannelConsensusState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/ChannelConsensusState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ChannelConsensusState(ctx, req.(*QueryChannelConsensusStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryNextSequenceSendRequest) if err := dec(in); err != nil { @@ -1673,6 +1860,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ChannelClientState", Handler: _Query_ChannelClientState_Handler, }, + { + MethodName: "ChannelConsensusState", + Handler: _Query_ChannelConsensusState_Handler, + }, { MethodName: "NextSequenceSend", Handler: _Query_NextSequenceSend_Handler, @@ -1855,6 +2046,105 @@ func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryChannelConsensusStateRequest) 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 *QueryChannelConsensusStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelConsensusStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RevisionHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RevisionHeight)) + i-- + dAtA[i] = 0x18 + } + if m.RevisionNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RevisionNumber)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryChannelConsensusStateResponse) 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 *QueryChannelConsensusStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0x12 + } + if m.ConsensusState != nil { + { + size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2216,20 +2506,20 @@ func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) ( var l int _ = l if len(m.PacketCommitmentSequences) > 0 { - dAtA11 := make([]byte, len(m.PacketCommitmentSequences)*10) - var j10 int + dAtA13 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j12 int for _, num := range m.PacketCommitmentSequences { for num >= 1<<7 { - dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j10++ + j12++ } - dAtA11[j10] = uint8(num) - j10++ + dAtA13[j12] = uint8(num) + j12++ } - i -= j10 - copy(dAtA[i:], dAtA11[:j10]) - i = encodeVarintQuery(dAtA, i, uint64(j10)) + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintQuery(dAtA, i, uint64(j12)) i-- dAtA[i] = 0x1a } @@ -2427,20 +2717,20 @@ func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l if len(m.Sequences) > 0 { - dAtA17 := make([]byte, len(m.Sequences)*10) - var j16 int + dAtA19 := make([]byte, len(m.Sequences)*10) + var j18 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) + dAtA19[j18] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j16++ + j18++ } - dAtA17[j16] = uint8(num) - j16++ + dAtA19[j18] = uint8(num) + j18++ } - i -= j16 - copy(dAtA[i:], dAtA17[:j16]) - i = encodeVarintQuery(dAtA, i, uint64(j16)) + i -= j18 + copy(dAtA[i:], dAtA19[:j18]) + i = encodeVarintQuery(dAtA, i, uint64(j18)) i-- dAtA[i] = 0x12 } @@ -2485,20 +2775,20 @@ func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA20 := make([]byte, len(m.Sequences)*10) - var j19 int + dAtA22 := make([]byte, len(m.Sequences)*10) + var j21 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) + dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j19++ + j21++ } - dAtA20[j19] = uint8(num) - j19++ + dAtA22[j21] = uint8(num) + j21++ } - i -= j19 - copy(dAtA[i:], dAtA20[:j19]) - i = encodeVarintQuery(dAtA, i, uint64(j19)) + i -= j21 + copy(dAtA[i:], dAtA22[:j21]) + i = encodeVarintQuery(dAtA, i, uint64(j21)) i-- dAtA[i] = 0xa } @@ -2526,20 +2816,20 @@ func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, err var l int _ = l if len(m.PacketAckSequences) > 0 { - dAtA22 := make([]byte, len(m.PacketAckSequences)*10) - var j21 int + dAtA24 := make([]byte, len(m.PacketAckSequences)*10) + var j23 int for _, num := range m.PacketAckSequences { for num >= 1<<7 { - dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) + dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j21++ + j23++ } - dAtA22[j21] = uint8(num) - j21++ + dAtA24[j23] = uint8(num) + j23++ } - i -= j21 - copy(dAtA[i:], dAtA22[:j21]) - i = encodeVarintQuery(dAtA, i, uint64(j21)) + i -= j23 + copy(dAtA[i:], dAtA24[:j23]) + i = encodeVarintQuery(dAtA, i, uint64(j23)) i-- dAtA[i] = 0x12 } @@ -2584,20 +2874,20 @@ func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA25 := make([]byte, len(m.Sequences)*10) - var j24 int + dAtA27 := make([]byte, len(m.Sequences)*10) + var j26 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA25[j24] = uint8(uint64(num)&0x7f | 0x80) + dAtA27[j26] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j24++ + j26++ } - dAtA25[j24] = uint8(num) - j24++ + dAtA27[j26] = uint8(num) + j26++ } - i -= j24 - copy(dAtA[i:], dAtA25[:j24]) - i = encodeVarintQuery(dAtA, i, uint64(j24)) + i -= j26 + copy(dAtA[i:], dAtA27[:j26]) + i = encodeVarintQuery(dAtA, i, uint64(j26)) i-- dAtA[i] = 0xa } @@ -2671,7 +2961,7 @@ func (m *QueryChannelClientStateResponse) Size() (n int) { return n } -func (m *QueryNextSequenceSendRequest) Size() (n int) { +func (m *QueryChannelConsensusStateRequest) Size() (n int) { if m == nil { return 0 } @@ -2681,17 +2971,28 @@ func (m *QueryNextSequenceSendRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if m.RevisionNumber != 0 { + n += 1 + sovQuery(uint64(m.RevisionNumber)) + } + if m.RevisionHeight != 0 { + n += 1 + sovQuery(uint64(m.RevisionHeight)) + } return n } -func (m *QueryNextSequenceSendResponse) Size() (n int) { +func (m *QueryChannelConsensusStateResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.NextSequenceSend != 0 { - n += 1 + sovQuery(uint64(m.NextSequenceSend)) + if m.ConsensusState != nil { + l = m.ConsensusState.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } l = len(m.Proof) if l > 0 { @@ -2702,7 +3003,7 @@ func (m *QueryNextSequenceSendResponse) Size() (n int) { return n } -func (m *QueryPacketCommitmentRequest) Size() (n int) { +func (m *QueryNextSequenceSendRequest) Size() (n int) { if m == nil { return 0 } @@ -2712,8 +3013,39 @@ func (m *QueryPacketCommitmentRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Sequence != 0 { - n += 1 + sovQuery(uint64(m.Sequence)) + return n +} + +func (m *QueryNextSequenceSendResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextSequenceSend != 0 { + n += 1 + sovQuery(uint64(m.NextSequenceSend)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPacketCommitmentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) } return n } @@ -3375,6 +3707,311 @@ func (m *QueryChannelClientStateResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryChannelConsensusStateRequest) 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 ErrIntOverflowQuery + } + 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: QueryChannelConsensusStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelConsensusStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RevisionNumber", wireType) + } + m.RevisionNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevisionNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RevisionHeight", wireType) + } + m.RevisionHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevisionHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelConsensusStateResponse) 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 ErrIntOverflowQuery + } + 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: QueryChannelConsensusStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelConsensusStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsensusState == nil { + m.ConsensusState = &types1.Any{} + } + if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 47aa5757262..2d87052d3ba 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -141,6 +141,78 @@ func local_request_Query_ChannelClientState_0(ctx context.Context, marshaler run } +var ( + filter_Query_ChannelConsensusState_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelConsensusStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ChannelConsensusState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelConsensusStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ChannelConsensusState(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNextSequenceSendRequest var metadata runtime.ServerMetadata @@ -789,6 +861,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ChannelConsensusState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ChannelConsensusState_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1054,6 +1149,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ChannelConsensusState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ChannelConsensusState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1222,6 +1337,8 @@ var ( pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "client_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "consensus_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1244,6 +1361,8 @@ var ( forward_Query_ChannelClientState_0 = runtime.ForwardResponseMessage + forward_Query_ChannelConsensusState_0 = runtime.ForwardResponseMessage + forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 3ca8a2e16ad..9d16a457a9e 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -9,6 +9,7 @@ import "ibc/core/channel/v2/channel.proto"; import "ibc/core/channel/v2/genesis.proto"; import "ibc/core/client/v1/client.proto"; import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; // Query provides defines the gRPC querier service @@ -24,6 +25,12 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/client_state"; } + // ChannelConsensusState queries for the consensus state for the channel associated + // with the provided channel identifiers. + rpc ChannelConsensusState(QueryChannelConsensusStateRequest) returns (QueryChannelConsensusStateResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/consensus_state"; + } + // NextSequenceSend returns the next send sequence for a given channel. rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; @@ -96,6 +103,30 @@ message QueryChannelClientStateResponse { ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } +// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState +// RPC method +message QueryChannelConsensusStateRequest { + // channel unique identifier + string channel_id = 1; + // revision number of the consensus state + uint64 revision_number = 2; + // revision height of the consensus state + uint64 revision_height = 3; +} + +// QueryChannelConsensusStateResponse is the Response type for the +// Query/QueryChannelConsensusState RPC method +message QueryChannelConsensusStateResponse { + // consensus state associated with the channel + google.protobuf.Any consensus_state = 1; + // client ID associated with the consensus state + string client_id = 2; + // merkle proof of existence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method message QueryNextSequenceSendRequest { // channel unique identifier From 8d669113ce0ae13927cde78cf1d3c950edd23f04 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 17 Dec 2024 17:01:45 +0100 Subject: [PATCH 157/172] test: add tests for v2 transfer vesting account (#7688) * test vesting accounts in v2 transfer module * add changelog + fix godoc --- CHANGELOG.md | 1 + .../transfer/v2/keeper/msg_server_test.go | 108 +++++++++++++++++- testing/chain.go | 34 ++++-- testing/endpoint_v2.go | 16 ++- 4 files changed, 143 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f9200953d2..7dc23f363cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Testing * [\#7430](https://github.com/cosmos/ibc-go/pull/7430) Update the block proposer in test chains for each block. +* [\#7688](https://github.com/cosmos/ibc-go/pull/7688) Added `SendMsgsWithSender` to `TestChain`. ### Dependencies diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go index 2288ee34b2c..076aca171f8 100644 --- a/modules/apps/transfer/v2/keeper/msg_server_test.go +++ b/modules/apps/transfer/v2/keeper/msg_server_test.go @@ -9,7 +9,10 @@ import ( sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" @@ -22,8 +25,12 @@ import ( // TestMsgSendPacketTransfer tests the MsgSendPacket rpc handler for the transfer v2 application. func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { - var payload channeltypesv2.Payload - var path *ibctesting.Path + var ( + payload channeltypesv2.Payload + path *ibctesting.Path + expEscrowAmounts []transfertypes.Token // total amounts in escrow for each token + sender ibctesting.SenderAccount + ) testCases := []struct { name string @@ -60,6 +67,94 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { }, nil, }, + { + "successful transfer of entire spendable balance with vesting account", + func() { + // create vesting account + vestingAccPrivKey := secp256k1.GenPrivKey() + vestingAccAddress := sdk.AccAddress(vestingAccPrivKey.PubKey().Address()) + + vestingCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount)) + _, err := suite.chainA.SendMsgs(vestingtypes.NewMsgCreateVestingAccount( + suite.chainA.SenderAccount.GetAddress(), + vestingAccAddress, + vestingCoins, + suite.chainA.GetContext().BlockTime().Add(time.Hour).Unix(), + false, + )) + suite.Require().NoError(err) + + // transfer some spendable coins to vesting account + spendableAmount := sdkmath.NewInt(42) + transferCoins := sdk.NewCoins(sdk.NewCoin(vestingCoins[0].Denom, spendableAmount)) + _, err = suite.chainA.SendMsgs(banktypes.NewMsgSend(suite.chainA.SenderAccount.GetAddress(), vestingAccAddress, transferCoins)) + suite.Require().NoError(err) + + // just to prove that the vesting account has a balance (but only spendableAmount is spendable) + vestingAccBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), vestingAccAddress, vestingCoins[0].Denom) + suite.Require().Equal(vestingCoins[0].Amount.Uint64()+spendableAmount.Uint64(), vestingAccBalance.Amount.Uint64()) + vestinSpendableBalance := suite.chainA.GetSimApp().BankKeeper.SpendableCoins(suite.chainA.GetContext(), vestingAccAddress) + suite.Require().Equal(spendableAmount.Uint64(), vestinSpendableBalance.AmountOf(vestingCoins[0].Denom).Uint64()) + + bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: sdk.DefaultBondDenom, + Amount: transfertypes.UnboundedSpendLimit().BigInt(), + Sender: vestingAccAddress.String(), + Receiver: suite.chainB.SenderAccount.GetAddress().String(), + Memo: "", + }) + suite.Require().NoError(err) + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) + + sender = suite.chainA.GetSenderAccount(vestingAccPrivKey) + + expEscrowAmounts = []transfertypes.Token{ + { + Denom: transfertypes.NewDenom(sdk.DefaultBondDenom), + Amount: spendableAmount.String(), // The only spendable amount + }, + } + }, + nil, + }, + { + "failure: no spendable coins for vesting account", + func() { + // create vesting account + vestingAccPrivKey := secp256k1.GenPrivKey() + vestingAccAddress := sdk.AccAddress(vestingAccPrivKey.PubKey().Address()) + + vestingCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount)) + _, err := suite.chainA.SendMsgs(vestingtypes.NewMsgCreateVestingAccount( + suite.chainA.SenderAccount.GetAddress(), + vestingAccAddress, + vestingCoins, + suite.chainA.GetContext().BlockTime().Add(time.Hour).Unix(), + false, + )) + suite.Require().NoError(err) + + // just to prove that the vesting account has a balance (but not spendable) + vestingAccBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), vestingAccAddress, vestingCoins[0].Denom) + suite.Require().Equal(vestingCoins[0].Amount.Uint64(), vestingAccBalance.Amount.Uint64()) + vestinSpendableBalance := suite.chainA.GetSimApp().BankKeeper.SpendableCoins(suite.chainA.GetContext(), vestingAccAddress) + suite.Require().Zero(vestinSpendableBalance.AmountOf(vestingCoins[0].Denom).Uint64()) + + // try to transfer the entire spendable balance (which is zero) + bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: sdk.DefaultBondDenom, + Amount: transfertypes.UnboundedSpendLimit().BigInt(), + Sender: vestingAccAddress.String(), + Receiver: suite.chainB.SenderAccount.GetAddress().String(), + Memo: "", + }) + suite.Require().NoError(err) + payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) + + sender = suite.chainA.GetSenderAccount(vestingAccPrivKey) + }, + transfertypes.ErrInvalidAmount, + }, { "failure: send transfers disabled", func() { @@ -91,6 +186,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { Amount: ibctesting.DefaultCoinAmount.String(), }, } + expEscrowAmounts = tokens + sender = suite.chainA.SenderAccounts[0] ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) bz := suite.chainA.Codec.MustMarshal(&ftpd) @@ -99,8 +196,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) tc.malleate() - - packet, err := path.EndpointA.MsgSendPacket(timestamp, payload) + packet, err := path.EndpointA.MsgSendPacketWithSender(timestamp, payload, sender) expPass := tc.expError == nil if expPass { @@ -108,9 +204,9 @@ func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { suite.Require().NotEmpty(packet) // ensure every token sent is escrowed. - for _, t := range tokens { + for i, t := range tokens { escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - expected, err := t.ToCoin() + expected, err := expEscrowAmounts[i].ToCoin() suite.Require().NoError(err) suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") } diff --git a/testing/chain.go b/testing/chain.go index 67ff41baf9e..54ebc978c4c 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -346,10 +346,20 @@ func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { return err } -// SendMsgs delivers a transaction through the application. It updates the senders sequence -// number and updates the TestChain's headers. It returns the result and error if one -// occurred. +// SendMsgs delivers a transaction through the application using a predefined sender. +// It updates the senders sequence number and updates the TestChain's headers. +// It returns the result and error if one occurred. func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { + senderAccount := SenderAccount{ + SenderPrivKey: chain.SenderPrivKey, + SenderAccount: chain.SenderAccount, + } + + return chain.SendMsgsWithSender(senderAccount, msgs...) +} + +// SendMsgsWithSender delivers a transaction through the application using the provided sender. +func (chain *TestChain) SendMsgsWithSender(sender SenderAccount, msgs ...sdk.Msg) (*abci.ExecTxResult, error) { if chain.SendMsgsOverride != nil { return chain.SendMsgsOverride(msgs...) } @@ -359,7 +369,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { // increment acc sequence regardless of success or failure tx execution defer func() { - err := chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) + err := sender.SenderAccount.SetSequence(sender.SenderAccount.GetSequence() + 1) if err != nil { panic(err) } @@ -371,12 +381,12 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { chain.App.GetBaseApp(), msgs, chain.ChainID, - []uint64{chain.SenderAccount.GetAccountNumber()}, - []uint64{chain.SenderAccount.GetSequence()}, + []uint64{sender.SenderAccount.GetAccountNumber()}, + []uint64{sender.SenderAccount.GetSequence()}, true, chain.ProposedHeader.GetTime(), chain.NextVals.Hash(), - chain.SenderPrivKey, + sender.SenderPrivKey, ) if err != nil { return nil, err @@ -593,3 +603,13 @@ func (chain *TestChain) IBCClientHeader(header *ibctm.Header, trustedHeight clie return header, nil } + +// GetSenderAccount returns the sender account associated with the provided private key. +func (chain *TestChain) GetSenderAccount(privKey cryptotypes.PrivKey) SenderAccount { + account := chain.GetSimApp().AccountKeeper.GetAccount(chain.GetContext(), sdk.AccAddress(privKey.PubKey().Address())) + + return SenderAccount{ + SenderPrivKey: privKey, + SenderAccount: account, + } +} diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index e28ff51fb6b..be1fd011aa8 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -38,11 +38,21 @@ func (endpoint *Endpoint) RegisterCounterparty() (err error) { return err } -// MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned. +// MsgSendPacket sends a packet on the associated endpoint using a predefined sender. The constructed packet is returned. func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channeltypesv2.Payload) (channeltypesv2.Packet, error) { - msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), payload) + senderAccount := SenderAccount{ + SenderPrivKey: endpoint.Chain.SenderPrivKey, + SenderAccount: endpoint.Chain.SenderAccount, + } + + return endpoint.MsgSendPacketWithSender(timeoutTimestamp, payload, senderAccount) +} + +// MsgSendPacketWithSender sends a packet on the associated endpoint using the provided sender. The constructed packet is returned. +func (endpoint *Endpoint) MsgSendPacketWithSender(timeoutTimestamp uint64, payload channeltypesv2.Payload, sender SenderAccount) (channeltypesv2.Packet, error) { + msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, sender.SenderAccount.GetAddress().String(), payload) - res, err := endpoint.Chain.SendMsgs(msgSendPacket) + res, err := endpoint.Chain.SendMsgsWithSender(sender, msgSendPacket) if err != nil { return channeltypesv2.Packet{}, err } From 39e6b692eb7bbfa635d5a0106f6495c7b379d0fb Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 17 Dec 2024 19:05:40 +0200 Subject: [PATCH 158/172] chore: use separate store paths for channels/creators (#7696) --- .../core/04-channel/v2/keeper/export_test.go | 7 +++++ modules/core/04-channel/v2/keeper/keeper.go | 28 +++++++++++-------- .../04-channel/v2/keeper/msg_server_test.go | 2 +- modules/core/04-channel/v2/types/keys.go | 16 +++++------ 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index 6da7c89c873..002bc6d8d41 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -7,10 +7,17 @@ package keeper import ( "context" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) +// ChannelStore is a wrapper around channelStore to allow its usage during testing. +func (k Keeper) ChannelStore(ctx context.Context) storetypes.KVStore { + return k.channelStore(ctx) +} + func (k *Keeper) SendPacketTest( ctx context.Context, sourceChannel string, diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index febc06a1f24..ebf512063b2 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -18,7 +18,6 @@ import ( channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/api" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -55,21 +54,28 @@ func (Keeper) Logger(ctx context.Context) log.Logger { return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } -func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.KVStore { - channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelPrefix, channelID)) +// channelStore returns the KV store under which channels are stored. +func (k Keeper) channelStore(ctx context.Context) storetypes.KVStore { + channelPrefix := []byte(fmt.Sprintf("%s/", types.ChannelPrefix)) return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } +// creatorStore returns the KV store under which creators are stored. +func (k Keeper) creatorStore(ctx context.Context) storetypes.KVStore { + creatorPrefix := []byte(fmt.Sprintf("%s/", types.CreatorPrefix)) + return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), creatorPrefix) +} + // SetChannel sets the Channel for a given channel identifier. func (k *Keeper) SetChannel(ctx context.Context, channelID string, channel types.Channel) { bz := k.cdc.MustMarshal(&channel) - k.ChannelStore(ctx, channelID).Set([]byte(types.ChannelKey), bz) + k.channelStore(ctx).Set([]byte(channelID), bz) } // GetChannel gets the Channel for a given channel identifier. func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channel, bool) { - store := k.ChannelStore(ctx, channelID) - bz := store.Get([]byte(types.ChannelKey)) + store := k.channelStore(ctx) + bz := store.Get([]byte(channelID)) if len(bz) == 0 { return types.Channel{}, false } @@ -81,13 +87,13 @@ func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channe // HasChannel returns true if a Channel exists for a given channel identifier, otherwise false. func (k *Keeper) HasChannel(ctx context.Context, channelID string) bool { - store := k.ChannelStore(ctx, channelID) - return store.Has([]byte(types.ChannelKey)) + store := k.channelStore(ctx) + return store.Has([]byte(channelID)) } // GetCreator returns the creator of the channel. func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool) { - bz := k.ChannelStore(ctx, channelID).Get([]byte(types.CreatorKey)) + bz := k.creatorStore(ctx).Get([]byte(channelID)) if len(bz) == 0 { return "", false } @@ -97,12 +103,12 @@ func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool // SetCreator sets the creator of the channel. func (k *Keeper) SetCreator(ctx context.Context, channelID, creator string) { - k.ChannelStore(ctx, channelID).Set([]byte(types.CreatorKey), []byte(creator)) + k.creatorStore(ctx).Set([]byte(channelID), []byte(creator)) } // DeleteCreator deletes the creator associated with the channel. func (k *Keeper) DeleteCreator(ctx context.Context, channelID string) { - k.ChannelStore(ctx, channelID).Delete([]byte(types.CreatorKey)) + k.creatorStore(ctx).Delete([]byte(channelID)) } // GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 34dff03cba7..58dc3126dbd 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -53,7 +53,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { "failure: channel must already exist", func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(types.ChannelKey)) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext()).Delete([]byte(path.EndpointA.ChannelID)) }, types.ErrChannelNotFound, }, diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index f751a92b3f1..9b636340e38 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -4,13 +4,13 @@ const ( // SubModuleName defines the channelv2 module name. SubModuleName = "channelv2" - // ChannelKey is the key used to store channels in the channel store. - // the channel key is imported from types instead of host because - // the channel key is not a part of the ics-24 host specification - ChannelKey = "channel" + // ChannelPrefix is the prefix under which all v2 channels are stored. + // It is imported from types since it is not part of the ics-24 host + // specification. + ChannelPrefix = "channels" - // CreatorKey is the key used to store the channel creator in the channel store - // the creator key is imported from types instead of host because - // the creator key is not a part of the ics-24 host specification - CreatorKey = "creator" + // CreatorPrefix is the prefix under which all v2 channel creators are stored. + // It is imported from types since it is not part of the ics-24 host + // specification. + CreatorPrefix = "creators" ) From ea4e73629c55e35537467d9f032da5be8082b468 Mon Sep 17 00:00:00 2001 From: iIvaki Date: Wed, 18 Dec 2024 16:28:01 +0200 Subject: [PATCH 159/172] proto swager gen (#7722) Co-authored-by: DimitrisJim --- docs/client/config.json | 19 + docs/client/swagger-ui/swagger.yaml | 12211 +++++++++++++++++--------- 2 files changed, 8047 insertions(+), 4183 deletions(-) diff --git a/docs/client/config.json b/docs/client/config.json index 5c9b23da836..3036bf515a3 100644 --- a/docs/client/config.json +++ b/docs/client/config.json @@ -62,6 +62,25 @@ } } }, + { + "url": "./tmp-swagger-gen/ibc/core/channel/v2/query.swagger.json", + "operationIds": { + "rename": { + "Params": "ChannelV2Params", + "Channel": "ChannelV2", + "ChannelClientState": "ChannelClientStateV2", + "ChannelConsensusState": "ChannelConsensusStateV2", + "NextSequenceSend": "NextSequenceSendV2", + "PacketAcknowledgement": "PacketAcknowledgementV2", + "PacketAcknowledgements": "PacketAcknowledgementsV2", + "PacketCommitment": "PacketCommitmentV2", + "PacketCommitments": "PacketCommitmentsV2", + "PacketReceipt": "PacketReceiptV2", + "UnreceivedAcks": "UnreceivedAcksV2", + "UnreceivedPackets": "UnreceivedPacketsV2", + } + } + }, { "url": "./tmp-swagger-gen/ibc/lightclients/wasm/v1/query.swagger.json", "operationIds": { diff --git a/docs/client/swagger-ui/swagger.yaml b/docs/client/swagger-ui/swagger.yaml index bb8d6cb6d2a..b9e05109883 100644 --- a/docs/client/swagger-ui/swagger.yaml +++ b/docs/client/swagger-ui/swagger.yaml @@ -14880,142 +14880,78 @@ paths: } tags: - Query - /ibc/lightclients/wasm/v1/checksums: + /ibc/core/channel/v2/channels/{channel_id}: get: - summary: Get all Wasm checksums - operationId: Checksums + summary: Channel queries the counterparty of an IBC client. + operationId: ChannelV2 responses: '200': description: A successful response. schema: type: object properties: - checksums: - type: array - items: - type: string - description: >- - checksums is a list of the hex encoded checksums of all wasm - codes stored. - pagination: - description: pagination defines the pagination in the response. + channel: + title: the channel associated with the provided channel id type: object properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + client_id: type: string - format: uint64 title: >- - total is total number of results available if - PageRequest.count_total + the client identifier of the light client representing the + counterparty chain + counterparty_channel_id: + type: string + description: >- + the counterparty identifier that must be used by packets + sent by counterparty - was set, its value is undefined otherwise - description: >- - QueryChecksumsResponse is the response type for the - Query/Checksums RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - value: - type: string - format: byte - parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. + to our channel end. + merkle_path_prefix: + description: >- + the key path used to store packet flow messages that the + counterparty - It is less efficient than using key. Only one of offset or key - should + will use to send to us. In backwards compatible cases, we + will append the channelID and sequence in order to create - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. + the final path. + type: object + properties: + key_path: + type: array + items: + type: string + format: byte + title: >- + MerklePath is the path used to verify commitment proofs, + which can be an - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include + arbitrary structured object (defined by a commitment + type). - a count of the total number of items available for pagination in - UIs. + MerklePath is represented from root-to-leaf + description: >- + Channel defines the channel end on a chain that is + implementing the version 2 IBC protocol - count_total is only respected when offset is used. It is ignored - when key + Each side will maintain its own Channel to create an IBC + channel - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. + The channel will be referenced by a channelID which will be + used to send packets + to the counterparty - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query - /ibc/lightclients/wasm/v1/checksums/{checksum}/code: - get: - summary: Get Wasm code for given checksum - operationId: Code - responses: - '200': - description: A successful response. - schema: - type: object - properties: - data: - type: string - format: byte - description: >- - QueryCodeResponse is the response type for the Query/Code RPC - method. + The channel will contain the client identifier that will + provide proof verification for the channel + + and the counterparty channel identifier that the other channel + end will be using + + to send packets to our channel end. + title: >- + QueryChannelRequest is the response type for the Query/Channel RPC + method default: description: An unexpected error response. schema: @@ -15035,1380 +14971,4901 @@ paths: properties: type_url: type: string - value: - type: string - format: byte - parameters: - - name: checksum - description: checksum is a hex encoded string of the code stored. - in: path - required: true - type: string - tags: - - Query -definitions: - cosmos.base.v1beta1.Coin: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - google.protobuf.Any: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized + description: >- + A URL/resource name that uniquely identifies the type of + the serialized - protocol buffer message. This string must contain at least + protocol buffer message. This string must contain at + least - one "/" character. The last segment of the URL's path must represent + one "/" character. The last segment of the URL's path + must represent - the fully qualified name of the type (as in + the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a canonical - form + `path/google.protobuf.Duration`). The name should be in + a canonical form - (e.g., leading "." is not accepted). + (e.g., leading "." is not accepted). - In practice, teams usually precompile into the binary all types that - they + In practice, teams usually precompile into the binary + all types that they - expect it to use in the context of Any. However, for URLs which use - the + expect it to use in the context of Any. However, for + URLs which use the - scheme `http`, `https`, or no scheme, one can optionally set up a type + scheme `http`, `https`, or no scheme, one can optionally + set up a type - server that maps type URLs to message definitions as follows: + server that maps type URLs to message definitions as + follows: - * If no scheme is provided, `https` is assumed. + * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - Note: this functionality is not currently available in the official + Note: this functionality is not currently available in + the official - protobuf release, and it is not used for type URLs beginning with + protobuf release, and it is not used for type URLs + beginning with - type.googleapis.com. + type.googleapis.com. - Schemes other than `http`, `https` (or the empty scheme) might be + Schemes other than `http`, `https` (or the empty scheme) + might be - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along with - a + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a - URL that describes the type of the serialized message. + URL that describes the type of the serialized message. - Protobuf library provides support to pack/unpack Any values in the form + Protobuf library provides support to pack/unpack Any values + in the form - of utility functions or additional generated methods of the Any type. + of utility functions or additional generated methods of the + Any type. - Example 1: Pack and unpack a message in C++. + Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - Example 2: Pack and unpack a message in Java. + Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - The pack methods provided by protobuf library will by default use + The pack methods provided by protobuf library will by + default use - 'type.googleapis.com/full.type.name' as the type URL and the unpack + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - methods only use the fully qualified type name after the last '/' + methods only use the fully qualified type name after the + last '/' - in the type URL, for example "foo.bar.com/x/y.z" will yield type + in the type URL, for example "foo.bar.com/x/y.z" will yield + type - name "y.z". + name "y.z". - JSON + JSON - The JSON representation of an `Any` value uses the regular + The JSON representation of an `Any` value uses the regular - representation of the deserialized, embedded message, with an + representation of the deserialized, embedded message, with + an - additional field `@type` which contains the type URL. Example: + additional field `@type` which contains the type URL. + Example: - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - If the embedded message type is well-known and has a custom JSON + If the embedded message type is well-known and has a custom + JSON - representation, that representation will be embedded adding a field + representation, that representation will be embedded adding + a field - `value` which holds the custom JSON in addition to the `@type` + `value` which holds the custom JSON in addition to the + `@type` - field. Example (for message [google.protobuf.Duration][]): + field. Example (for message [google.protobuf.Duration][]): - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - grpc.gateway.runtime.Error: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + in: path + required: true + type: string + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/client_state: + get: + summary: >- + ChannelClientState queries for the client state for the channel + associated - protocol buffer message. This string must contain at least + with the provided channel identifiers. + operationId: ChannelClientStateV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + identified_client_state: + title: client state associated with the channel + type: object + properties: + client_id: + type: string + title: client identifier + client_state: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type + of the serialized - one "/" character. The last segment of the URL's path must - represent + protocol buffer message. This string must contain at + least - the fully qualified name of the type (as in + one "/" character. The last segment of the URL's path + must represent - `path/google.protobuf.Duration`). The name should be in a - canonical form + the fully qualified name of the type (as in - (e.g., leading "." is not accepted). + `path/google.protobuf.Duration`). The name should be + in a canonical form + (e.g., leading "." is not accepted). - In practice, teams usually precompile into the binary all types - that they - expect it to use in the context of Any. However, for URLs which - use the + In practice, teams usually precompile into the binary + all types that they - scheme `http`, `https`, or no scheme, one can optionally set up - a type + expect it to use in the context of Any. However, for + URLs which use the - server that maps type URLs to message definitions as follows: + scheme `http`, `https`, or no scheme, one can + optionally set up a type + server that maps type URLs to message definitions as + follows: - * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + * If no scheme is provided, `https` is assumed. - Note: this functionality is not currently available in the - official + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results + based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - protobuf release, and it is not used for type URLs beginning - with + Note: this functionality is not currently available in + the official - type.googleapis.com. + protobuf release, and it is not used for type URLs + beginning with + type.googleapis.com. - Schemes other than `http`, `https` (or the empty scheme) might - be - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a + Schemes other than `http`, `https` (or the empty + scheme) might be - URL that describes the type of the serialized message. + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the + above specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + URL that describes the type of the serialized message. - Protobuf library provides support to pack/unpack Any values in the - form - of utility functions or additional generated methods of the Any - type. + Protobuf library provides support to pack/unpack Any + values in the form + of utility functions or additional generated methods of + the Any type. - Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + Example 1: Pack and unpack a message in C++. - Example 2: Pack and unpack a message in Java. + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + Example 2: Pack and unpack a message in Java. - Example 3: Pack and unpack a message in Python. + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + Example 3: Pack and unpack a message in Python. - Example 4: Pack and unpack a message in Go + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + Example 4: Pack and unpack a message in Go - The pack methods provided by protobuf library will by default use + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - 'type.googleapis.com/full.type.name' as the type URL and the unpack + The pack methods provided by protobuf library will by + default use - methods only use the fully qualified type name after the last '/' + 'type.googleapis.com/full.type.name' as the type URL and + the unpack - in the type URL, for example "foo.bar.com/x/y.z" will yield type + methods only use the fully qualified type name after the + last '/' - name "y.z". + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + name "y.z". - JSON + JSON - The JSON representation of an `Any` value uses the regular - representation of the deserialized, embedded message, with an + The JSON representation of an `Any` value uses the regular - additional field `@type` which contains the type URL. Example: + representation of the deserialized, embedded message, with + an - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + additional field `@type` which contains the type URL. + Example: - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - If the embedded message type is well-known and has a custom JSON + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - representation, that representation will be embedded adding a field + If the embedded message type is well-known and has a + custom JSON - `value` which holds the custom JSON in addition to the `@type` + representation, that representation will be embedded + adding a field - field. Example (for message [google.protobuf.Duration][]): + `value` which holds the custom JSON in addition to the + `@type` - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - ibc.applications.transfer.v1.Params: - type: object - properties: - send_enabled: - type: boolean - description: >- - send_enabled enables or disables all cross-chain token transfers from - this + field. Example (for message [google.protobuf.Duration][]): - chain. - receive_enabled: - type: boolean - description: >- - receive_enabled enables or disables all cross-chain token transfers to - this + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: client state + description: >- + IdentifiedClientState defines a client state with an + additional client - chain. - description: >- - Params defines the set of IBC transfer parameters. + identifier field. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping - NOTE: To prevent a single token from being transferred, set the + RevisionNumber the same. However some consensus algorithms may + choose to - TransfersEnabled parameter to true and then set the bank module's - SendEnabled + reset the height in certain conditions e.g. hard forks, + state-machine - parameter for the denomination to false. - ibc.applications.transfer.v1.QueryDenomHashResponse: - type: object - properties: - hash: - type: string - description: hash (in hex format) of the denomination trace information. - description: |- - QueryDenomHashResponse is the response type for the Query/DenomHash RPC - method. - ibc.applications.transfer.v1.QueryEscrowAddressResponse: - type: object - properties: - escrow_address: - type: string - title: the escrow account address - description: >- - QueryEscrowAddressResponse is the response type of the EscrowAddress RPC - method. - ibc.applications.transfer.v1.QueryParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. - type: object - properties: - send_enabled: - type: boolean - description: >- - send_enabled enables or disables all cross-chain token transfers - from this + breaking changes In these cases, the RevisionNumber is + incremented so that - chain. - receive_enabled: - type: boolean - description: >- - receive_enabled enables or disables all cross-chain token - transfers to this + height continues to be monitonically increasing even as the + RevisionHeight - chain. - description: QueryParamsResponse is the response type for the Query/Params RPC method. - ibc.applications.transfer.v1.QueryTotalEscrowForDenomResponse: - type: object + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + title: |- + QueryChannelClientStateResponse is the Response type for the + Query/QueryChannelClientState RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/next_sequence_send: + get: + summary: NextSequenceSend returns the next send sequence for a given channel. + operationId: NextSequenceSendV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + next_sequence_send: + type: string + format: uint64 + title: next sequence send number + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + title: >- + QueryNextSequenceSendResponse is the response type for the + Query/QueryNextSequenceSend RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_acknowledgements: + get: + summary: >- + PacketAcknowledgements returns all packet acknowledgements associated + with a channel. + operationId: PacketAcknowledgementsV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + acknowledgements: + type: array + items: + type: object + properties: + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve + and store + + packet commitments, acknowledgements, and receipts. + + Caller is responsible for knowing the context necessary to + interpret this + + state as a commitment, acknowledgement, or a receipt. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + title: |- + QueryPacketAcknowledgemetsResponse is the request type for the + Query/QueryPacketAcknowledgements RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + - name: packet_commitment_sequences + description: list of packet sequences. + in: query + required: false + type: array + items: + type: string + format: uint64 + collectionFormat: multi + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_acks/{sequence}: + get: + summary: PacketAcknowledgement queries a stored acknowledgement commitment hash. + operationId: PacketAcknowledgementV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + acknowledgement: + type: string + format: byte + title: acknowledgement associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + description: >- + QueryPacketAcknowledgementResponse is the response type for the + Query/PacketAcknowledgement RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: sequence + description: packet sequence + in: path + required: true + type: string + format: uint64 + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_commitments: + get: + summary: PacketCommitments queries a stored packet commitment hash. + operationId: PacketCommitmentsV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + commitments: + type: array + items: + type: object + properties: + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve + and store + + packet commitments, acknowledgements, and receipts. + + Caller is responsible for knowing the context necessary to + interpret this + + state as a commitment, acknowledgement, or a receipt. + description: >- + collection of packet commitments for the requested channel + identifier. + pagination: + description: pagination response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + height: + description: query block height. + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes + of updating and + + freezing clients + description: >- + QueryPacketCommitmentResponse is the response type for the + Query/PacketCommitment RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks: + get: + summary: >- + UnreceivedAcks returns all the unreceived IBC acknowledgements + associated with a channel and sequences. + operationId: UnreceivedAcksV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived acknowledgement sequences + height: + title: query block height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + title: |- + QueryUnreceivedAcksResponse is the response type for the + Query/UnreceivedAcks RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: packet_ack_sequences + description: list of acknowledgement sequences + in: path + required: true + type: array + items: + type: string + format: uint64 + collectionFormat: csv + minItems: 1 + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequences}/unreceived_packets: + get: + summary: >- + UnreceivedPackets returns all the unreceived IBC packets associated with + a channel and sequences. + operationId: UnreceivedPacketsV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived packet sequences + height: + title: query block height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + title: >- + QueryUnreceivedPacketsResponse is the response type for the + Query/UnreceivedPacketCommitments RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: sequences + description: list of packet sequences + in: path + required: true + type: array + items: + type: string + format: uint64 + collectionFormat: csv + minItems: 1 + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}: + get: + summary: PacketCommitment queries a stored packet commitment hash. + operationId: PacketCommitmentV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + commitment: + type: string + format: byte + title: packet associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + description: >- + QueryPacketCommitmentResponse is the response type for the + Query/PacketCommitment RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: sequence + description: packet sequence + in: path + required: true + type: string + format: uint64 + tags: + - Query + /ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}: + get: + summary: PacketReceipt queries a stored packet receipt. + operationId: PacketReceiptV2 + responses: + '200': + description: A successful response. + schema: + type: object + properties: + received: + type: boolean + title: success flag for if receipt exists + proof: + type: string + format: byte + title: merkle proof of existence or absence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + description: >- + QueryPacketReceiptResponse is the response type for the + Query/PacketReceipt RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: channel_id + description: channel unique identifier + in: path + required: true + type: string + - name: sequence + description: packet sequence + in: path + required: true + type: string + format: uint64 + - name: port_id + description: port unique identifier. + in: query + required: false + type: string + tags: + - Query + /ibc/lightclients/wasm/v1/checksums: + get: + summary: Get all Wasm checksums + operationId: Checksums + responses: + '200': + description: A successful response. + schema: + type: object + properties: + checksums: + type: array + items: + type: string + description: >- + checksums is a list of the hex encoded checksums of all wasm + codes stored. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + QueryChecksumsResponse is the response type for the + Query/Checksums RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /ibc/lightclients/wasm/v1/checksums/{checksum}/code: + get: + summary: Get Wasm code for given checksum + operationId: Code + responses: + '200': + description: A successful response. + schema: + type: object + properties: + data: + type: string + format: byte + description: >- + QueryCodeResponse is the response type for the Query/Code RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: checksum + description: checksum is a hex encoded string of the code stored. + in: path + required: true + type: string + tags: + - Query +definitions: + cosmos.base.v1beta1.Coin: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + google.protobuf.Any: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + + protocol buffer message. This string must contain at least + + one "/" character. The last segment of the URL's path must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in a canonical + form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types that + they + + expect it to use in the context of Any. However, for URLs which use + the + + scheme `http`, `https`, or no scheme, one can optionally set up a type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the official + + protobuf release, and it is not used for type URLs beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above specified + type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along with + a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + grpc.gateway.runtime.Error: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + + protocol buffer message. This string must contain at least + + one "/" character. The last segment of the URL's path must + represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in a + canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the + + scheme `http`, `https`, or no scheme, one can optionally set up + a type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the + official + + protobuf release, and it is not used for type URLs beginning + with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might + be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + ibc.applications.transfer.v1.Params: + type: object + properties: + send_enabled: + type: boolean + description: >- + send_enabled enables or disables all cross-chain token transfers from + this + + chain. + receive_enabled: + type: boolean + description: >- + receive_enabled enables or disables all cross-chain token transfers to + this + + chain. + description: >- + Params defines the set of IBC transfer parameters. + + NOTE: To prevent a single token from being transferred, set the + + TransfersEnabled parameter to true and then set the bank module's + SendEnabled + + parameter for the denomination to false. + ibc.applications.transfer.v1.QueryDenomHashResponse: + type: object + properties: + hash: + type: string + description: hash (in hex format) of the denomination trace information. + description: |- + QueryDenomHashResponse is the response type for the Query/DenomHash RPC + method. + ibc.applications.transfer.v1.QueryEscrowAddressResponse: + type: object + properties: + escrow_address: + type: string + title: the escrow account address + description: >- + QueryEscrowAddressResponse is the response type of the EscrowAddress RPC + method. + ibc.applications.transfer.v1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + send_enabled: + type: boolean + description: >- + send_enabled enables or disables all cross-chain token transfers + from this + + chain. + receive_enabled: + type: boolean + description: >- + receive_enabled enables or disables all cross-chain token + transfers to this + + chain. + description: QueryParamsResponse is the response type for the Query/Params RPC method. + ibc.applications.transfer.v1.QueryTotalEscrowForDenomResponse: + type: object + properties: + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + description: >- + QueryTotalEscrowForDenomResponse is the response type for + TotalEscrowForDenom RPC method. + ibc.applications.interchain_accounts.controller.v1.Params: + type: object + properties: + controller_enabled: + type: boolean + description: controller_enabled enables or disables the controller submodule. + description: |- + Params defines the set of on-chain interchain accounts parameters. + The following parameters may be used to disable the controller submodule. + ibc.applications.interchain_accounts.controller.v1.QueryInterchainAccountResponse: + type: object + properties: + address: + type: string + description: >- + QueryInterchainAccountResponse the response type for the + Query/InterchainAccount RPC method. + ibc.applications.interchain_accounts.controller.v1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + controller_enabled: + type: boolean + description: controller_enabled enables or disables the controller submodule. + description: QueryParamsResponse is the response type for the Query/Params RPC method. + ibc.applications.interchain_accounts.host.v1.Params: + type: object + properties: + host_enabled: + type: boolean + description: host_enabled enables or disables the host submodule. + allow_messages: + type: array + items: + type: string + description: >- + allow_messages defines a list of sdk message typeURLs allowed to be + executed on a host chain. + description: |- + Params defines the set of on-chain interchain accounts parameters. + The following parameters may be used to disable the host submodule. + ibc.applications.interchain_accounts.host.v1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + host_enabled: + type: boolean + description: host_enabled enables or disables the host submodule. + allow_messages: + type: array + items: + type: string + description: >- + allow_messages defines a list of sdk message typeURLs allowed to + be executed on a host chain. + description: QueryParamsResponse is the response type for the Query/Params RPC method. + cosmos.base.query.v1beta1.PageRequest: + type: object + properties: + key: + type: string + format: byte + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + offset: + type: string + format: uint64 + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + limit: + type: string + format: uint64 + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + count_total: + type: boolean + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in UIs. + + count_total is only respected when offset is used. It is ignored when + key + + is set. + reverse: + type: boolean + description: >- + reverse is set to true if results are to be returned in the descending + order. + + + Since: cosmos-sdk 0.43 + description: |- + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } + title: |- + PageRequest is to be embedded in gRPC request messages for efficient + pagination. Ex: + cosmos.base.query.v1beta1.PageResponse: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: |- + total is total number of results available if PageRequest.count_total + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + ibc.applications.fee.v1.Fee: + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the packet timeout fee + title: Fee defines the ICS29 receive, acknowledgement and timeout fees + ibc.applications.fee.v1.FeeEnabledChannel: + type: object + properties: + port_id: + type: string + title: unique port identifier + channel_id: + type: string + title: unique channel identifier + title: >- + FeeEnabledChannel contains the PortID & ChannelID for a fee enabled + channel + ibc.applications.fee.v1.IdentifiedPacketFees: + type: object + properties: + packet_id: + title: >- + unique packet identifier comprised of the channel ID, port ID and + sequence + type: object + properties: + port_id: + type: string + title: channel port identifier + channel_id: + type: string + title: channel unique identifier + sequence: + type: string + format: uint64 + title: packet sequence + packet_fees: + type: array + items: + type: object + properties: + fee: + title: >- + fee encapsulates the recv, ack and timeout fees associated with + an IBC packet + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet timeout fee + refund_address: + type: string + title: the refund address for unspent fees + relayers: + type: array + items: + type: string + title: optional list of relayers permitted to receive fees + title: >- + PacketFee contains ICS29 relayer fees, refund address and optional + list of permitted relayers + title: list of packet fees + title: >- + IdentifiedPacketFees contains a list of type PacketFee and associated + PacketId + ibc.applications.fee.v1.PacketFee: + type: object + properties: + fee: + title: >- + fee encapsulates the recv, ack and timeout fees associated with an IBC + packet + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + title: the packet timeout fee + refund_address: + type: string + title: the refund address for unspent fees + relayers: + type: array + items: + type: string + title: optional list of relayers permitted to receive fees + title: >- + PacketFee contains ICS29 relayer fees, refund address and optional list of + permitted relayers + ibc.applications.fee.v1.QueryCounterpartyPayeeResponse: + type: object + properties: + counterparty_payee: + type: string + title: the counterparty payee address used to compensate forward relaying + title: >- + QueryCounterpartyPayeeResponse defines the response type for the + CounterpartyPayee rpc + ibc.applications.fee.v1.QueryFeeEnabledChannelResponse: + type: object + properties: + fee_enabled: + type: boolean + title: boolean flag representing the fee enabled channel status + title: >- + QueryFeeEnabledChannelResponse defines the response type for the + FeeEnabledChannel rpc + ibc.applications.fee.v1.QueryFeeEnabledChannelsResponse: + type: object + properties: + fee_enabled_channels: + type: array + items: + type: object + properties: + port_id: + type: string + title: unique port identifier + channel_id: + type: string + title: unique channel identifier + title: >- + FeeEnabledChannel contains the PortID & ChannelID for a fee enabled + channel + title: list of fee enabled channels + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + title: >- + QueryFeeEnabledChannelsResponse defines the response type for the + FeeEnabledChannels rpc + ibc.applications.fee.v1.QueryIncentivizedPacketResponse: + type: object + properties: + incentivized_packet: + type: object + properties: + packet_id: + title: >- + unique packet identifier comprised of the channel ID, port ID and + sequence + type: object + properties: + port_id: + type: string + title: channel port identifier + channel_id: + type: string + title: channel unique identifier + sequence: + type: string + format: uint64 + title: packet sequence + packet_fees: + type: array + items: + type: object + properties: + fee: + title: >- + fee encapsulates the recv, ack and timeout fees associated + with an IBC packet + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + title: the packet timeout fee + refund_address: + type: string + title: the refund address for unspent fees + relayers: + type: array + items: + type: string + title: optional list of relayers permitted to receive fees + title: >- + PacketFee contains ICS29 relayer fees, refund address and + optional list of permitted relayers + title: list of packet fees + title: >- + IdentifiedPacketFees contains a list of type PacketFee and associated + PacketId + title: >- + QueryIncentivizedPacketResponse defines the response type for the + IncentivizedPacket rpc + ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse: + type: object properties: - amount: + incentivized_packets: + type: array + items: + type: object + properties: + packet_id: + title: >- + unique packet identifier comprised of the channel ID, port ID + and sequence + type: object + properties: + port_id: + type: string + title: channel port identifier + channel_id: + type: string + title: channel unique identifier + sequence: + type: string + format: uint64 + title: packet sequence + packet_fees: + type: array + items: + type: object + properties: + fee: + title: >- + fee encapsulates the recv, ack and timeout fees associated + with an IBC packet + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet timeout fee + refund_address: + type: string + title: the refund address for unspent fees + relayers: + type: array + items: + type: string + title: optional list of relayers permitted to receive fees + title: >- + PacketFee contains ICS29 relayer fees, refund address and + optional list of permitted relayers + title: list of packet fees + title: >- + IdentifiedPacketFees contains a list of type PacketFee and + associated PacketId + title: Map of all incentivized_packets + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + title: >- + QueryIncentivizedPacketsForChannelResponse defines the response type for + querying for all incentivized packets + + for a specific channel + ibc.applications.fee.v1.QueryIncentivizedPacketsResponse: + type: object + properties: + incentivized_packets: + type: array + items: + type: object + properties: + packet_id: + title: >- + unique packet identifier comprised of the channel ID, port ID + and sequence + type: object + properties: + port_id: + type: string + title: channel port identifier + channel_id: + type: string + title: channel unique identifier + sequence: + type: string + format: uint64 + title: packet sequence + packet_fees: + type: array + items: + type: object + properties: + fee: + title: >- + fee encapsulates the recv, ack and timeout fees associated + with an IBC packet + type: object + properties: + recv_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet receive fee + ack_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet acknowledgement fee + timeout_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + title: the packet timeout fee + refund_address: + type: string + title: the refund address for unspent fees + relayers: + type: array + items: + type: string + title: optional list of relayers permitted to receive fees + title: >- + PacketFee contains ICS29 relayer fees, refund address and + optional list of permitted relayers + title: list of packet fees + title: >- + IdentifiedPacketFees contains a list of type PacketFee and + associated PacketId + title: list of identified fees for incentivized packets + pagination: + description: pagination defines the pagination in the response. type: object properties: - denom: + next_key: type: string - amount: + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string - description: |- - Coin defines a token with a denomination and an amount. + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: >- - QueryTotalEscrowForDenomResponse is the response type for - TotalEscrowForDenom RPC method. - ibc.applications.interchain_accounts.controller.v1.Params: - type: object - properties: - controller_enabled: - type: boolean - description: controller_enabled enables or disables the controller submodule. - description: |- - Params defines the set of on-chain interchain accounts parameters. - The following parameters may be used to disable the controller submodule. - ibc.applications.interchain_accounts.controller.v1.QueryInterchainAccountResponse: + was set, its value is undefined otherwise + title: >- + QueryIncentivizedPacketsResponse defines the response type for the + IncentivizedPackets rpc + ibc.applications.fee.v1.QueryPayeeResponse: type: object properties: - address: + payee_address: type: string - description: >- - QueryInterchainAccountResponse the response type for the - Query/InterchainAccount RPC method. - ibc.applications.interchain_accounts.controller.v1.QueryParamsResponse: + title: the payee address to which packet fees are paid out + title: QueryPayeeResponse defines the response type for the Payee rpc + ibc.applications.fee.v1.QueryTotalAckFeesResponse: type: object properties: - params: - description: params defines the parameters of the module. - type: object - properties: - controller_enabled: - type: boolean - description: controller_enabled enables or disables the controller submodule. - description: QueryParamsResponse is the response type for the Query/Params RPC method. - ibc.applications.interchain_accounts.host.v1.Params: + ack_fees: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the total packet acknowledgement fees + title: >- + QueryTotalAckFeesResponse defines the response type for the TotalAckFees + rpc + ibc.applications.fee.v1.QueryTotalRecvFeesResponse: type: object properties: - host_enabled: - type: boolean - description: host_enabled enables or disables the host submodule. - allow_messages: + recv_fees: type: array items: - type: string - description: >- - allow_messages defines a list of sdk message typeURLs allowed to be - executed on a host chain. - description: |- - Params defines the set of on-chain interchain accounts parameters. - The following parameters may be used to disable the host submodule. - ibc.applications.interchain_accounts.host.v1.QueryParamsResponse: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the total packet receive fees + title: >- + QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees + rpc + ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse: type: object properties: - params: - description: params defines the parameters of the module. - type: object - properties: - host_enabled: - type: boolean - description: host_enabled enables or disables the host submodule. - allow_messages: - type: array - items: + timeout_fees: + type: array + items: + type: object + properties: + denom: type: string - description: >- - allow_messages defines a list of sdk message typeURLs allowed to - be executed on a host chain. - description: QueryParamsResponse is the response type for the Query/Params RPC method. - cosmos.base.query.v1beta1.PageRequest: + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: the total packet timeout fees + title: >- + QueryTotalTimeoutFeesResponse defines the response type for the + TotalTimeoutFees rpc + ibc.core.channel.v1.PacketId: type: object properties: - key: + port_id: type: string - format: byte - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - offset: + title: channel port identifier + channel_id: type: string - format: uint64 - description: |- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key should - be set. - limit: + title: channel unique identifier + sequence: type: string format: uint64 + title: packet sequence + title: |- + PacketId is an identifier for a unique Packet + Source chains refer to packets by source port/channel + Destination chains refer to packets by destination port/channel + ibc.core.client.v1.ConsensusStateWithHeight: + type: object + properties: + height: + title: consensus state height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + consensus_state: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + + protocol buffer message. This string must contain at least + + one "/" character. The last segment of the URL's path must + represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in a + canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the + + scheme `http`, `https`, or no scheme, one can optionally set up a + type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the + official + + protobuf release, and it is not used for type URLs beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above specified + type. description: >- - limit is the total number of results to be returned in the result - page. + `Any` contains an arbitrary serialized protocol buffer message along + with a - If left empty it will default to a value to be set by each app. - count_total: - type: boolean - description: >- - count_total is set to true to indicate that the result set should - include + URL that describes the type of the serialized message. - a count of the total number of items available for pagination in UIs. - count_total is only respected when offset is used. It is ignored when - key + Protobuf library provides support to pack/unpack Any values in the + form - is set. - reverse: - type: boolean - description: >- - reverse is set to true if results are to be returned in the descending - order. + of utility functions or additional generated methods of the Any type. - Since: cosmos-sdk 0.43 - description: |- - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } - title: |- - PageRequest is to be embedded in gRPC request messages for efficient - pagination. Ex: - cosmos.base.query.v1beta1.PageResponse: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: |- - total is total number of results available if PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + Example 1: Pack and unpack a message in C++. - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - ibc.applications.fee.v1.Fee: - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + Example 2: Pack and unpack a message in Java. - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet timeout fee - title: Fee defines the ICS29 receive, acknowledgement and timeout fees - ibc.applications.fee.v1.FeeEnabledChannel: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - title: >- - FeeEnabledChannel contains the PortID & ChannelID for a fee enabled - channel - ibc.applications.fee.v1.IdentifiedPacketFees: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID and - sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fees: - type: array - items: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated with - an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + Example 3: Pack and unpack a message in Python. + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - NOTE: The amount field is an Int which implements the - custom method + Example 4: Pack and unpack a message in Go - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + The pack methods provided by protobuf library will by default use - NOTE: The amount field is an Int which implements the - custom method + 'type.googleapis.com/full.type.name' as the type URL and the unpack - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + field. Example (for message [google.protobuf.Duration][]): - NOTE: The amount field is an Int which implements the - custom method + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: consensus state + description: >- + ConsensusStateWithHeight defines a consensus state with an additional + height - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - PacketFee contains ICS29 relayer fees, refund address and optional - list of permitted relayers - title: list of packet fees - title: >- - IdentifiedPacketFees contains a list of type PacketFee and associated - PacketId - ibc.applications.fee.v1.PacketFee: + field. + ibc.core.client.v1.Height: type: object properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated with an IBC - packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while keeping - NOTE: The amount field is an Int which implements the custom - method + RevisionNumber the same. However some consensus algorithms may choose to - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + reset the height in certain conditions e.g. hard forks, state-machine + breaking changes In these cases, the RevisionNumber is incremented so that - NOTE: The amount field is an Int which implements the custom - method + height continues to be monitonically increasing even as the RevisionHeight - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + gets reset - NOTE: The amount field is an Int which implements the custom - method + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees + This enforces the Go json marshaller to always emit zero values for both + revision_number and revision_height. title: >- - PacketFee contains ICS29 relayer fees, refund address and optional list of - permitted relayers - ibc.applications.fee.v1.QueryCounterpartyPayeeResponse: + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of updating + and + + freezing clients + ibc.core.client.v1.IdentifiedClientState: type: object properties: - counterparty_payee: + client_id: type: string - title: the counterparty payee address used to compensate forward relaying - title: >- - QueryCounterpartyPayeeResponse defines the response type for the - CounterpartyPayee rpc - ibc.applications.fee.v1.QueryFeeEnabledChannelResponse: - type: object - properties: - fee_enabled: - type: boolean - title: boolean flag representing the fee enabled channel status - title: >- - QueryFeeEnabledChannelResponse defines the response type for the - FeeEnabledChannel rpc - ibc.applications.fee.v1.QueryFeeEnabledChannelsResponse: - type: object - properties: - fee_enabled_channels: - type: array - items: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - title: >- - FeeEnabledChannel contains the PortID & ChannelID for a fee enabled - channel - title: list of fee enabled channels - pagination: - description: pagination defines the pagination in the response. + title: client identifier + client_state: + title: client state type: object properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + type_url: type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - was set, its value is undefined otherwise - title: >- - QueryFeeEnabledChannelsResponse defines the response type for the - FeeEnabledChannels rpc - ibc.applications.fee.v1.QueryIncentivizedPacketResponse: - type: object - properties: - incentivized_packet: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID and - sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fees: - type: array - items: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated - with an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + protocol buffer message. This string must contain at least + one "/" character. The last segment of the URL's path must + represent - NOTE: The amount field is an Int which implements the - custom method + the fully qualified name of the type (as in - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + `path/google.protobuf.Duration`). The name should be in a + canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the + + scheme `http`, `https`, or no scheme, one can optionally set up a + type + server that maps type URLs to message definitions as follows: - NOTE: The amount field is an Int which implements the - custom method - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + * If no scheme is provided, `https` is assumed. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - NOTE: The amount field is an Int which implements the - custom method + Note: this functionality is not currently available in the + official - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - PacketFee contains ICS29 relayer fees, refund address and - optional list of permitted relayers - title: list of packet fees - title: >- - IdentifiedPacketFees contains a list of type PacketFee and associated - PacketId - title: >- - QueryIncentivizedPacketResponse defines the response type for the - IncentivizedPacket rpc - ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse: - type: object - properties: - incentivized_packets: - type: array - items: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID - and sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fees: - type: array - items: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated - with an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + protobuf release, and it is not used for type URLs beginning with + type.googleapis.com. - NOTE: The amount field is an Int which implements - the custom method - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + Schemes other than `http`, `https` (or the empty scheme) might be + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above specified + type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a - NOTE: The amount field is an Int which implements - the custom method + URL that describes the type of the serialized message. - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + Protobuf library provides support to pack/unpack Any values in the + form - NOTE: The amount field is an Int which implements - the custom method + of utility functions or additional generated methods of the Any type. - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - PacketFee contains ICS29 relayer fees, refund address and - optional list of permitted relayers - title: list of packet fees - title: >- - IdentifiedPacketFees contains a list of type PacketFee and - associated PacketId - title: Map of all incentivized_packets - pagination: - description: pagination defines the pagination in the response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - was set, its value is undefined otherwise - title: >- - QueryIncentivizedPacketsForChannelResponse defines the response type for - querying for all incentivized packets + Example 1: Pack and unpack a message in C++. - for a specific channel - ibc.applications.fee.v1.QueryIncentivizedPacketsResponse: - type: object - properties: - incentivized_packets: - type: array - items: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID - and sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fees: - type: array - items: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated - with an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + Example 3: Pack and unpack a message in Python. - NOTE: The amount field is an Int which implements - the custom method + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + Example 4: Pack and unpack a message in Go + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - NOTE: The amount field is an Int which implements - the custom method + The pack methods provided by protobuf library will by default use - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + 'type.googleapis.com/full.type.name' as the type URL and the unpack + methods only use the fully qualified type name after the last '/' - NOTE: The amount field is an Int which implements - the custom method + in the type URL, for example "foo.bar.com/x/y.z" will yield type - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - PacketFee contains ICS29 relayer fees, refund address and - optional list of permitted relayers - title: list of packet fees - title: >- - IdentifiedPacketFees contains a list of type PacketFee and - associated PacketId - title: list of identified fees for incentivized packets - pagination: - description: pagination defines the pagination in the response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + name "y.z". - was set, its value is undefined otherwise - title: >- - QueryIncentivizedPacketsResponse defines the response type for the - IncentivizedPackets rpc - ibc.applications.fee.v1.QueryPayeeResponse: - type: object - properties: - payee_address: - type: string - title: the payee address to which packet fees are paid out - title: QueryPayeeResponse defines the response type for the Payee rpc - ibc.applications.fee.v1.QueryTotalAckFeesResponse: - type: object - properties: - ack_fees: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the total packet acknowledgement fees - title: >- - QueryTotalAckFeesResponse defines the response type for the TotalAckFees - rpc - ibc.applications.fee.v1.QueryTotalRecvFeesResponse: - type: object - properties: - recv_fees: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + JSON - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the total packet receive fees - title: >- - QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees - rpc - ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse: + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + description: |- + IdentifiedClientState defines a client state with an additional client + identifier field. + ibc.core.client.v1.Params: type: object properties: - timeout_fees: + allowed_clients: type: array items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + type: string + description: >- + allowed_clients defines the list of allowed client state types which + can be created - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the total packet timeout fees - title: >- - QueryTotalTimeoutFeesResponse defines the response type for the - TotalTimeoutFees rpc - ibc.core.channel.v1.PacketId: - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - title: |- - PacketId is an identifier for a unique Packet - Source chains refer to packets by source port/channel - Destination chains refer to packets by destination port/channel - ibc.core.client.v1.ConsensusStateWithHeight: + and interacted with. If a client type is removed from the allowed + clients list, usage + + of this client will be disabled until it is added again to the list. + description: Params defines the set of IBC light client parameters. + ibc.core.client.v1.QueryClientParamsResponse: type: object properties: - height: - title: consensus state height + params: + description: params defines the parameters of the module. type: object properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset + allowed_clients: + type: array + items: + type: string + description: >- + allowed_clients defines the list of allowed client state types + which can be created + and interacted with. If a client type is removed from the allowed + clients list, usage - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + of this client will be disabled until it is added again to the + list. + description: >- + QueryClientParamsResponse is the response type for the Query/ClientParams + RPC - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - consensus_state: + method. + ibc.core.client.v1.QueryClientStateResponse: + type: object + properties: + client_state: type: object properties: type_url: @@ -16572,268 +20029,369 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state + title: client state associated with the request identifier + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. description: >- - ConsensusStateWithHeight defines a consensus state with an additional - height + QueryClientStateResponse is the response type for the Query/ClientState + RPC - field. - ibc.core.client.v1.Height: + method. Besides the client state, it includes a proof and the height from + + which the proof was retrieved. + ibc.core.client.v1.QueryClientStatesResponse: type: object properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while keeping + client_states: + type: array + items: + type: object + properties: + client_id: + type: string + title: client identifier + client_state: + title: client state + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - RevisionNumber the same. However some consensus algorithms may choose to + protocol buffer message. This string must contain at least - reset the height in certain conditions e.g. hard forks, state-machine + one "/" character. The last segment of the URL's path must + represent - breaking changes In these cases, the RevisionNumber is incremented so that + the fully qualified name of the type (as in - height continues to be monitonically increasing even as the RevisionHeight + `path/google.protobuf.Duration`). The name should be in a + canonical form - gets reset + (e.g., leading "." is not accepted). - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + In practice, teams usually precompile into the binary all + types that they - This enforces the Go json marshaller to always emit zero values for both - revision_number and revision_height. - title: >- - Height is a monotonically increasing data type + expect it to use in the context of Any. However, for URLs + which use the - that can be compared against another Height for the purposes of updating - and + scheme `http`, `https`, or no scheme, one can optionally set + up a type - freezing clients - ibc.core.client.v1.IdentifiedClientState: - type: object - properties: - client_id: - type: string - title: client identifier - client_state: - title: client state - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized + server that maps type URLs to message definitions as + follows: - protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must - represent + * If no scheme is provided, `https` is assumed. - the fully qualified name of the type (as in + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on + the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - `path/google.protobuf.Duration`). The name should be in a - canonical form + Note: this functionality is not currently available in the + official - (e.g., leading "." is not accepted). + protobuf release, and it is not used for type URLs beginning + with + type.googleapis.com. - In practice, teams usually precompile into the binary all types - that they - expect it to use in the context of Any. However, for URLs which - use the + Schemes other than `http`, `https` (or the empty scheme) + might be - scheme `http`, `https`, or no scheme, one can optionally set up a - type + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a - server that maps type URLs to message definitions as follows: + URL that describes the type of the serialized message. - * If no scheme is provided, `https` is assumed. + Protobuf library provides support to pack/unpack Any values in + the form - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + of utility functions or additional generated methods of the Any + type. - Note: this functionality is not currently available in the - official - protobuf release, and it is not used for type URLs beginning with + Example 1: Pack and unpack a message in C++. - type.googleapis.com. + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + Example 2: Pack and unpack a message in Java. - Schemes other than `http`, `https` (or the empty scheme) might be + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a + Example 3: Pack and unpack a message in Python. - URL that describes the type of the serialized message. + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - Protobuf library provides support to pack/unpack Any values in the - form + methods only use the fully qualified type name after the last + '/' - of utility functions or additional generated methods of the Any type. + in the type URL, for example "foo.bar.com/x/y.z" will yield type + name "y.z". - Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + JSON - Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + The JSON representation of an `Any` value uses the regular - Example 3: Pack and unpack a message in Python. + representation of the deserialized, embedded message, with an - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + additional field `@type` which contains the type URL. Example: - Example 4: Pack and unpack a message in Go + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - The pack methods provided by protobuf library will by default use + If the embedded message type is well-known and has a custom JSON - 'type.googleapis.com/full.type.name' as the type URL and the unpack + representation, that representation will be embedded adding a + field - methods only use the fully qualified type name after the last '/' + `value` which holds the custom JSON in addition to the `@type` - in the type URL, for example "foo.bar.com/x/y.z" will yield type + field. Example (for message [google.protobuf.Duration][]): - name "y.z". + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + description: >- + IdentifiedClientState defines a client state with an additional + client + identifier field. + description: list of stored ClientStates of the chain. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - JSON + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: >- + QueryClientStatesResponse is the response type for the Query/ClientStates + RPC - The JSON representation of an `Any` value uses the regular + method. + ibc.core.client.v1.QueryClientStatusResponse: + type: object + properties: + status: + type: string + description: >- + QueryClientStatusResponse is the response type for the Query/ClientStatus + RPC - representation of the deserialized, embedded message, with an + method. It returns the current status of the IBC client. + ibc.core.client.v1.QueryConsensusStateHeightsResponse: + type: object + properties: + consensus_state_heights: + type: array + items: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - additional field `@type` which contains the type URL. Example: + RevisionNumber the same. However some consensus algorithms may + choose to - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + reset the height in certain conditions e.g. hard forks, + state-machine - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + breaking changes In these cases, the RevisionNumber is incremented + so that - If the embedded message type is well-known and has a custom JSON + height continues to be monitonically increasing even as the + RevisionHeight - representation, that representation will be embedded adding a field + gets reset - `value` which holds the custom JSON in addition to the `@type` - field. Example (for message [google.protobuf.Duration][]): + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: |- - IdentifiedClientState defines a client state with an additional client - identifier field. - ibc.core.client.v1.Params: - type: object - properties: - allowed_clients: - type: array - items: - type: string - description: >- - allowed_clients defines the list of allowed client state types which - can be created + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: >- + Height is a monotonically increasing data type - and interacted with. If a client type is removed from the allowed - clients list, usage + that can be compared against another Height for the purposes of + updating and - of this client will be disabled until it is added again to the list. - description: Params defines the set of IBC light client parameters. - ibc.core.client.v1.QueryClientParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. + freezing clients + title: consensus state heights + pagination: + title: pagination response type: object properties: - allowed_clients: - type: array - items: - type: string - description: >- - allowed_clients defines the list of allowed client state types - which can be created - - and interacted with. If a client type is removed from the allowed - clients list, usage + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - of this client will be disabled until it is added again to the - list. - description: >- - QueryClientParamsResponse is the response type for the Query/ClientParams - RPC + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - method. - ibc.core.client.v1.QueryClientStateResponse: + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryConsensusStateHeightsResponse is the response type for the + Query/ConsensusStateHeights RPC method + ibc.core.client.v1.QueryConsensusStateResponse: type: object properties: - client_state: + consensus_state: type: object properties: type_url: @@ -16997,13 +20555,14 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier + title: >- + consensus state associated with the client identifier at the given + height proof: type: string format: byte title: merkle proof of existence proof_height: - title: height at which the proof was retrieved type: object properties: revision_number: @@ -17036,27 +20595,64 @@ definitions: explicitly exclude the omitempty jsontag. This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - description: >- - QueryClientStateResponse is the response type for the Query/ClientState - RPC + both revision_number and revision_height. + title: >- + Height is a monotonically increasing data type - method. Besides the client state, it includes a proof and the height from + that can be compared against another Height for the purposes of + updating and - which the proof was retrieved. - ibc.core.client.v1.QueryClientStatesResponse: + freezing clients + title: >- + QueryConsensusStateResponse is the response type for the + Query/ConsensusState + + RPC method + ibc.core.client.v1.QueryConsensusStatesResponse: type: object properties: - client_states: + consensus_states: type: array items: type: object properties: - client_id: - type: string - title: client identifier - client_state: - title: client state + height: + title: consensus state height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden + to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values + for both revision_number and revision_height. + consensus_state: type: object properties: type_url: @@ -17230,12 +20826,13 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state description: >- - IdentifiedClientState defines a client state with an additional - client + ConsensusStateWithHeight defines a consensus state with an + additional height - identifier field. - description: list of stored ClientStates of the chain. + field. + title: consensus states associated with the identifier pagination: title: pagination response type: object @@ -17263,103 +20860,184 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - description: >- - QueryClientStatesResponse is the response type for the Query/ClientStates - RPC - - method. - ibc.core.client.v1.QueryClientStatusResponse: + title: |- + QueryConsensusStatesResponse is the response type for the + Query/ConsensusStates RPC method + ibc.core.client.v1.QueryUpgradedClientStateResponse: type: object properties: - status: - type: string - description: >- - QueryClientStatusResponse is the response type for the Query/ClientStatus - RPC + upgraded_client_state: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - method. It returns the current status of the IBC client. - ibc.core.client.v1.QueryConsensusStateHeightsResponse: - type: object - properties: - consensus_state_heights: - type: array - items: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + protocol buffer message. This string must contain at least - RevisionNumber the same. However some consensus algorithms may - choose to + one "/" character. The last segment of the URL's path must + represent - reset the height in certain conditions e.g. hard forks, - state-machine + the fully qualified name of the type (as in - breaking changes In these cases, the RevisionNumber is incremented - so that + `path/google.protobuf.Duration`). The name should be in a + canonical form - height continues to be monitonically increasing even as the - RevisionHeight + (e.g., leading "." is not accepted). - gets reset + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + scheme `http`, `https`, or no scheme, one can optionally set up a + type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the + official + + protobuf release, and it is not used for type URLs beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above specified + type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: >- - Height is a monotonically increasing data type + If the embedded message type is well-known and has a custom JSON - that can be compared against another Height for the purposes of - updating and + representation, that representation will be embedded adding a field - freezing clients - title: consensus state heights - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + `value` which holds the custom JSON in addition to the `@type` - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + field. Example (for message [google.protobuf.Duration][]): - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: |- - QueryConsensusStateHeightsResponse is the response type for the - Query/ConsensusStateHeights RPC method - ibc.core.client.v1.QueryConsensusStateResponse: + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: client state associated with the request identifier + description: |- + QueryUpgradedClientStateResponse is the response type for the + Query/UpgradedClientState RPC method. + ibc.core.client.v1.QueryUpgradedConsensusStateResponse: type: object properties: - consensus_state: + upgraded_consensus_state: type: object properties: type_url: @@ -17479,362 +21157,661 @@ definitions: ... } - The pack methods provided by protobuf library will by default use + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: Consensus state associated with the request identifier + description: |- + QueryUpgradedConsensusStateResponse is the response type for the + Query/UpgradedConsensusState RPC method. + ibc.core.client.v1.QueryVerifyMembershipRequest: + type: object + properties: + client_id: + type: string + description: client unique identifier. + proof: + type: string + format: byte + description: the proof to be verified by the client. + proof_height: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of + updating and + + freezing clients + value: + type: string + format: byte + description: the value which is proven. + time_delay: + type: string + format: uint64 + title: optional time delay + block_delay: + type: string + format: uint64 + title: optional block delay + merkle_path: + description: the commitment key path. + type: object + properties: + key_path: + type: array + items: + type: string + format: byte + title: >- + MerklePath is the path used to verify commitment proofs, which can be + an + + arbitrary structured object (defined by a commitment type). + + MerklePath is represented from root-to-leaf + title: >- + QueryVerifyMembershipRequest is the request type for the + Query/VerifyMembership RPC method + ibc.core.client.v1.QueryVerifyMembershipResponse: + type: object + properties: + success: + type: boolean + description: boolean indicating success or failure of proof verification. + title: >- + QueryVerifyMembershipResponse is the response type for the + Query/VerifyMembership RPC method + ibc.core.commitment.v2.MerklePath: + type: object + properties: + key_path: + type: array + items: + type: string + format: byte + title: |- + MerklePath is the path used to verify commitment proofs, which can be an + arbitrary structured object (defined by a commitment type). + MerklePath is represented from root-to-leaf + ibc.core.commitment.v1.MerklePrefix: + type: object + properties: + key_prefix: + type: string + format: byte + title: |- + 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...)) + ibc.core.connection.v1.ConnectionEnd: + type: object + properties: + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the IBC + version in + + the connection handshake. + description: >- + IBC version which can be utilised to determine encodings or protocols + for + + channels or packets utilising this connection. + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated with a + given + + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain associated + with a - 'type.googleapis.com/full.type.name' as the type URL and the unpack + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - methods only use the fully qualified type name after the last '/' + The constructed key from the Path and the key will be + append(Path.KeyPath, - in the type URL, for example "foo.bar.com/x/y.z" will yield type + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: >- + delay period that must pass before a consensus state can be used for - name "y.z". + packet-verification NOTE: delay period logic is only implemented by + some + clients. + description: |- + 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. + ibc.core.connection.v1.Counterparty: + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated with a + given - JSON + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain associated + with a + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - The JSON representation of an `Any` value uses the regular + The constructed key from the Path and the key will be + append(Path.KeyPath, - representation of the deserialized, embedded message, with an + append(Path.KeyPrefix, key...)) + description: >- + Counterparty defines the counterparty chain associated with a connection + end. + ibc.core.connection.v1.IdentifiedConnection: + type: object + properties: + id: + type: string + description: connection identifier. + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the IBC + version in - additional field `@type` which contains the type URL. Example: + the connection handshake. + title: >- + IBC version which can be utilised to determine encodings or protocols + for - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + channels or packets utilising this connection + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated with a + given - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain associated + with a - If the embedded message type is well-known and has a custom JSON + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - representation, that representation will be embedded adding a field + The constructed key from the Path and the key will be + append(Path.KeyPath, - `value` which holds the custom JSON in addition to the `@type` + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: delay period associated with this connection. + description: |- + IdentifiedConnection defines a connection with additional connection + identifier field. + ibc.core.connection.v1.Params: + type: object + properties: + max_expected_time_per_block: + type: string + format: uint64 + description: >- + maximum expected time per block (in nanoseconds), used to enforce + block delay. This parameter should reflect the - field. Example (for message [google.protobuf.Duration][]): + largest amount of time that the chain might reasonably take to produce + the next block under normal operating - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: >- - consensus state associated with the client identifier at the given - height + conditions. A safe choice is 3-5x the expected time per block. + description: Params defines the set of Connection parameters. + ibc.core.connection.v1.QueryClientConnectionsResponse: + type: object + properties: + connection_paths: + type: array + items: + type: string + description: slice of all the connection paths associated with a client. proof: type: string format: byte title: merkle proof of existence proof_height: + title: height at which the proof was generated type: object properties: revision_number: type: string format: uint64 title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - title: >- - QueryConsensusStateResponse is the response type for the - Query/ConsensusState - - RPC method - ibc.core.client.v1.QueryConsensusStatesResponse: - type: object - properties: - consensus_states: - type: array - items: - type: object - properties: - height: - title: consensus state height - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - RevisionNumber the same. However some consensus algorithms may - choose to + RevisionNumber the same. However some consensus algorithms may choose + to - reset the height in certain conditions e.g. hard forks, - state-machine + reset the height in certain conditions e.g. hard forks, state-machine - breaking changes In these cases, the RevisionNumber is - incremented so that + breaking changes In these cases, the RevisionNumber is incremented so + that - height continues to be monitonically increasing even as the - RevisionHeight + height continues to be monitonically increasing even as the + RevisionHeight - gets reset + gets reset - Please note that json tags for generated Go code are overridden - to explicitly exclude the omitempty jsontag. + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - This enforces the Go json marshaller to always emit zero values - for both revision_number and revision_height. - consensus_state: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryClientConnectionsResponse is the response type for the + Query/ClientConnections RPC method + ibc.core.connection.v1.QueryConnectionClientStateResponse: + type: object + properties: + identified_client_state: + title: client state associated with the channel + type: object + properties: + client_id: + type: string + title: client identifier + client_state: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - protocol buffer message. This string must contain at least + protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must - represent + one "/" character. The last segment of the URL's path must + represent - the fully qualified name of the type (as in + the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a - canonical form + `path/google.protobuf.Duration`). The name should be in a + canonical form - (e.g., leading "." is not accepted). + (e.g., leading "." is not accepted). - In practice, teams usually precompile into the binary all - types that they + In practice, teams usually precompile into the binary all + types that they - expect it to use in the context of Any. However, for URLs - which use the + expect it to use in the context of Any. However, for URLs + which use the - scheme `http`, `https`, or no scheme, one can optionally set - up a type + scheme `http`, `https`, or no scheme, one can optionally set + up a type - server that maps type URLs to message definitions as - follows: + server that maps type URLs to message definitions as follows: - * If no scheme is provided, `https` is assumed. + * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on - the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on + the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - Note: this functionality is not currently available in the - official + Note: this functionality is not currently available in the + official - protobuf release, and it is not used for type URLs beginning - with + protobuf release, and it is not used for type URLs beginning + with - type.googleapis.com. + type.googleapis.com. - Schemes other than `http`, `https` (or the empty scheme) - might be + Schemes other than `http`, `https` (or the empty scheme) might + be - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a - URL that describes the type of the serialized message. + URL that describes the type of the serialized message. - Protobuf library provides support to pack/unpack Any values in - the form + Protobuf library provides support to pack/unpack Any values in the + form - of utility functions or additional generated methods of the Any - type. + of utility functions or additional generated methods of the Any + type. - Example 1: Pack and unpack a message in C++. + Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { ... - if (any.UnpackTo(&foo)) { - ... - } + } - Example 2: Pack and unpack a message in Java. + Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - methods only use the fully qualified type name after the last - '/' + The pack methods provided by protobuf library will by default use - in the type URL, for example "foo.bar.com/x/y.z" will yield type + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - name "y.z". + methods only use the fully qualified type name after the last '/' + in the type URL, for example "foo.bar.com/x/y.z" will yield type - JSON + name "y.z". - The JSON representation of an `Any` value uses the regular + JSON - representation of the deserialized, embedded message, with an - additional field `@type` which contains the type URL. Example: + The JSON representation of an `Any` value uses the regular - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + representation of the deserialized, embedded message, with an - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + additional field `@type` which contains the type URL. Example: - If the embedded message type is well-known and has a custom JSON + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - representation, that representation will be embedded adding a - field + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - `value` which holds the custom JSON in addition to the `@type` + If the embedded message type is well-known and has a custom JSON - field. Example (for message [google.protobuf.Duration][]): + representation, that representation will be embedded adding a + field - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: consensus state - description: >- - ConsensusStateWithHeight defines a consensus state with an - additional height + `value` which holds the custom JSON in addition to the `@type` - field. - title: consensus states associated with the identifier - pagination: - title: pagination response + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: client state + description: |- + IdentifiedClientState defines a client state with an additional client + identifier field. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: - next_key: + revision_number: type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + format: uint64 + title: the revision that the client is currently on + revision_height: type: string format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + RevisionNumber the same. However some consensus algorithms may choose + to - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. title: |- - QueryConsensusStatesResponse is the response type for the - Query/ConsensusStates RPC method - ibc.core.client.v1.QueryUpgradedClientStateResponse: + QueryConnectionClientStateResponse is the response type for the + Query/ConnectionClientState RPC method + ibc.core.connection.v1.QueryConnectionConsensusStateResponse: type: object properties: - upgraded_client_state: + consensus_state: type: object properties: type_url: @@ -17998,192 +21975,328 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier - description: |- - QueryUpgradedClientStateResponse is the response type for the - Query/UpgradedClientState RPC method. - ibc.core.client.v1.QueryUpgradedConsensusStateResponse: - type: object - properties: - upgraded_consensus_state: + title: consensus state associated with the channel + client_id: + type: string + title: client ID associated with the consensus state + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: - type_url: + revision_number: type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - * If no scheme is provided, `https` is assumed. + RevisionNumber the same. However some consensus algorithms may choose + to - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + reset the height in certain conditions e.g. hard forks, state-machine - Note: this functionality is not currently available in the - official + breaking changes In these cases, the RevisionNumber is incremented so + that - protobuf release, and it is not used for type URLs beginning with + height continues to be monitonically increasing even as the + RevisionHeight - type.googleapis.com. + gets reset - Schemes other than `http`, `https` (or the empty scheme) might be + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - used with implementation specific semantics. - value: + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryConnectionConsensusStateResponse is the response type for the + Query/ConnectionConsensusState RPC method + ibc.core.connection.v1.QueryConnectionParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + max_expected_time_per_block: type: string - format: byte + format: uint64 description: >- - Must be a valid serialized protocol buffer of the above specified - type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. + maximum expected time per block (in nanoseconds), used to enforce + block delay. This parameter should reflect the + largest amount of time that the chain might reasonably take to + produce the next block under normal operating - Protobuf library provides support to pack/unpack Any values in the - form + conditions. A safe choice is 3-5x the expected time per block. + description: >- + QueryConnectionParamsResponse is the response type for the + Query/ConnectionParams RPC method. + ibc.core.connection.v1.QueryConnectionResponse: + type: object + properties: + connection: + title: connection associated with the request identifier + type: object + properties: + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the IBC + version in - of utility functions or additional generated methods of the Any type. + the connection handshake. + description: >- + IBC version which can be utilised to determine encodings or + protocols for + channels or packets utilising this connection. + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated + with a given - Example 1: Pack and unpack a message in C++. + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain + associated with a - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - Example 2: Pack and unpack a message in Java. + The constructed key from the Path and the key will be + append(Path.KeyPath, - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: >- + delay period that must pass before a consensus state can be used + for - Example 3: Pack and unpack a message in Python. + packet-verification NOTE: delay period logic is only implemented + by some - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + clients. + description: >- + ConnectionEnd defines a stateful object on a chain connected to + another - Example 4: Pack and unpack a message in Go + separate one. - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + NOTE: there must only be 2 defined ConnectionEnds to establish - The pack methods provided by protobuf library will by default use + a connection between two chains. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - 'type.googleapis.com/full.type.name' as the type URL and the unpack + RevisionNumber the same. However some consensus algorithms may choose + to - methods only use the fully qualified type name after the last '/' + reset the height in certain conditions e.g. hard forks, state-machine - in the type URL, for example "foo.bar.com/x/y.z" will yield type + breaking changes In these cases, the RevisionNumber is incremented so + that - name "y.z". + height continues to be monitonically increasing even as the + RevisionHeight + gets reset - JSON + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - The JSON representation of an `Any` value uses the regular + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + description: >- + QueryConnectionResponse is the response type for the Query/Connection RPC - representation of the deserialized, embedded message, with an + method. Besides the connection end, it includes a proof and the height + from - additional field `@type` which contains the type URL. Example: + which the proof was retrieved. + ibc.core.connection.v1.QueryConnectionsResponse: + type: object + properties: + connections: + type: array + items: + type: object + properties: + id: + type: string + description: connection identifier. + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the + IBC version in - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + the connection handshake. + title: >- + IBC version which can be utilised to determine encodings or + protocols for - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + channels or packets utilising this connection + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated + with a given - If the embedded message type is well-known and has a custom JSON + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain + associated with a - representation, that representation will be embedded adding a field + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - `value` which holds the custom JSON in addition to the `@type` + The constructed key from the Path and the key will be + append(Path.KeyPath, - field. Example (for message [google.protobuf.Duration][]): + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: delay period associated with this connection. + description: |- + IdentifiedConnection defines a connection with additional connection + identifier field. + description: list of stored connections of the chain. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: Consensus state associated with the request identifier - description: |- - QueryUpgradedConsensusStateResponse is the response type for the - Query/UpgradedConsensusState RPC method. - ibc.core.client.v1.QueryVerifyMembershipRequest: - type: object - properties: - client_id: - type: string - description: client unique identifier. - proof: - type: string - format: byte - description: the proof to be verified by the client. - proof_height: + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height type: object properties: revision_number: @@ -18217,340 +22330,321 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - value: - type: string - format: byte - description: the value which is proven. - time_delay: - type: string - format: uint64 - title: optional time delay - block_delay: - type: string - format: uint64 - title: optional block delay - merkle_path: - description: the commitment key path. - type: object - properties: - key_path: - type: array - items: - type: string - format: byte - title: >- - MerklePath is the path used to verify commitment proofs, which can be - an + description: >- + QueryConnectionsResponse is the response type for the Query/Connections + RPC - arbitrary structured object (defined by a commitment type). + method. + ibc.core.connection.v1.State: + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + description: |- + State defines if a connection is in one of the following states: + INIT, TRYOPEN, OPEN or UNINITIALIZED. - MerklePath is represented from root-to-leaf - title: >- - QueryVerifyMembershipRequest is the request type for the - Query/VerifyMembership RPC method - ibc.core.client.v1.QueryVerifyMembershipResponse: - type: object - properties: - success: - type: boolean - description: boolean indicating success or failure of proof verification. - title: >- - QueryVerifyMembershipResponse is the response type for the - Query/VerifyMembership RPC method - ibc.core.commitment.v2.MerklePath: + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A connection end has just started the opening handshake. + - STATE_TRYOPEN: A connection end has acknowledged the handshake step on the counterparty + chain. + - STATE_OPEN: A connection end has completed the handshake. + ibc.core.connection.v1.Version: type: object properties: - key_path: + identifier: + type: string + title: unique version identifier + features: type: array items: type: string - format: byte - title: |- - MerklePath is the path used to verify commitment proofs, which can be an - arbitrary structured object (defined by a commitment type). - MerklePath is represented from root-to-leaf - ibc.core.commitment.v1.MerklePrefix: - type: object - properties: - key_prefix: - type: string - format: byte - title: |- - 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...)) - ibc.core.connection.v1.ConnectionEnd: + title: list of features compatible with the specified identifier + description: |- + Version defines the versioning scheme used to negotiate the IBC version in + the connection handshake. + ibc.core.channel.v1.Channel: type: object properties: - client_id: - type: string - description: client associated with this connection. - versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - version in - - the connection handshake. - description: >- - IBC version which can be utilised to determine encodings or protocols - for - - channels or packets utilising this connection. state: - description: current state of the connection end. + title: current state of the channel end type: string enum: - STATE_UNINITIALIZED_UNSPECIFIED - STATE_INIT - STATE_TRYOPEN - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED + description: |- + State defines if a channel is in one of the following states: + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent counterparty: - description: counterparty chain associated with this connection. + title: counterparty channel end type: object properties: - client_id: + port_id: type: string description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: + port on the counterparty chain which owns the other end of the + channel. + channel_id: type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - 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...)) - delay_period: + title: channel end on the counterparty chain + connection_hops: + type: array + items: + type: string + title: |- + list of connection identifiers, in order, along which packets sent on + this channel will travel + version: + type: string + title: opaque channel version, which is agreed upon during the handshake + upgrade_sequence: type: string format: uint64 - description: >- - delay period that must pass before a consensus state can be used for - - packet-verification NOTE: delay period logic is only implemented by - some + title: >- + upgrade sequence indicates the latest upgrade attempt performed by + this channel - clients. + the value of 0 indicates the channel has never been upgraded description: |- - 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. - ibc.core.connection.v1.Counterparty: + 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. + ibc.core.channel.v1.Counterparty: type: object properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - 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...)) - description: >- - Counterparty defines the counterparty chain associated with a connection - end. - ibc.core.connection.v1.IdentifiedConnection: + port_id: + type: string + description: >- + port on the counterparty chain which owns the other end of the + channel. + channel_id: + type: string + title: channel end on the counterparty chain + title: Counterparty defines a channel end counterparty + ibc.core.channel.v1.ErrorReceipt: type: object properties: - id: + sequence: type: string - description: connection identifier. - client_id: + format: uint64 + title: the channel upgrade sequence + message: type: string - description: client associated with this connection. - versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - version in + title: the error message detailing the cause of failure + description: >- + ErrorReceipt defines a type which encapsulates the upgrade sequence and + error associated with the - the connection handshake. - title: >- - IBC version which can be utilised to determine encodings or protocols - for + upgrade handshake failure. When a channel upgrade handshake is aborted + both chains are expected to increment to the - channels or packets utilising this connection + next sequence. + ibc.core.channel.v1.IdentifiedChannel: + type: object + properties: state: - description: current state of the connection end. + title: current state of the channel end type: string enum: - STATE_UNINITIALIZED_UNSPECIFIED - STATE_INIT - STATE_TRYOPEN - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED + description: |- + State defines if a channel is in one of the following states: + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent counterparty: - description: counterparty chain associated with this connection. + title: counterparty channel end type: object properties: - client_id: + port_id: type: string description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: + port on the counterparty chain which owns the other end of the + channel. + channel_id: type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - 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...)) - delay_period: + title: channel end on the counterparty chain + connection_hops: + type: array + items: + type: string + title: |- + list of connection identifiers, in order, along which packets sent on + this channel will travel + version: + type: string + title: opaque channel version, which is agreed upon during the handshake + port_id: + type: string + title: port identifier + channel_id: + type: string + title: channel identifier + upgrade_sequence: type: string format: uint64 - description: delay period associated with this connection. + title: >- + upgrade sequence indicates the latest upgrade attempt performed by + this channel + + the value of 0 indicates the channel has never been upgraded description: |- - IdentifiedConnection defines a connection with additional connection - identifier field. - ibc.core.connection.v1.Params: + IdentifiedChannel defines a channel with additional port and channel + identifier fields. + ibc.core.channel.v1.Order: + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + title: Order defines if a channel is ORDERED or UNORDERED + ibc.core.channel.v1.PacketState: type: object properties: - max_expected_time_per_block: + port_id: + type: string + description: channel port identifier. + channel_id: + type: string + description: channel unique identifier. + sequence: type: string format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably take to produce - the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per block. - description: Params defines the set of Connection parameters. - ibc.core.connection.v1.QueryClientConnectionsResponse: - type: object - properties: - connection_paths: - type: array - items: - type: string - description: slice of all the connection paths associated with a client. - proof: + description: packet sequence. + data: type: string format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was generated + description: embedded data that represents packet state. + description: |- + PacketState defines the generic type necessary to retrieve and store + packet commitments, acknowledgements, and receipts. + Caller is responsible for knowing the context necessary to interpret this + state as a commitment, acknowledgement, or a receipt. + ibc.core.channel.v1.Params: + type: object + properties: + upgrade_timeout: type: object properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + height: + title: block height after which the packet or upgrade times out + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - RevisionNumber the same. However some consensus algorithms may choose - to + RevisionNumber the same. However some consensus algorithms may + choose to - reset the height in certain conditions e.g. hard forks, state-machine + reset the height in certain conditions e.g. hard forks, + state-machine - breaking changes In these cases, the RevisionNumber is incremented so - that + breaking changes In these cases, the RevisionNumber is incremented + so that - height continues to be monitonically increasing even as the - RevisionHeight + height continues to be monitonically increasing even as the + RevisionHeight - gets reset + gets reset - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values + for both revision_number and revision_height. + timestamp: + type: string + format: uint64 + title: >- + block timestamp (in nanoseconds) after which the packet or upgrade + times out + description: >- + Timeout defines an execution deadline structure for 04-channel + handlers. + + This includes packet lifecycle handlers as well as the upgrade + handshake handlers. - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryClientConnectionsResponse is the response type for the - Query/ClientConnections RPC method - ibc.core.connection.v1.QueryConnectionClientStateResponse: + A valid Timeout contains either one or both of a timestamp and block + height (sequence). + description: Params defines the set of IBC channel parameters. + ibc.core.channel.v1.QueryChannelClientStateResponse: type: object properties: identified_client_state: @@ -18774,9 +22868,9 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryConnectionClientStateResponse is the response type for the - Query/ConnectionClientState RPC method - ibc.core.connection.v1.QueryConnectionConsensusStateResponse: + QueryChannelClientStateResponse is the Response type for the + Query/QueryChannelClientState RPC method + ibc.core.channel.v1.QueryChannelConsensusStateResponse: type: object properties: consensus_state: @@ -18823,448 +22917,136 @@ definitions: on changes to types. (Use versioned type names to manage breaking changes.) - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: consensus state associated with the channel - client_id: - type: string - title: client ID associated with the consensus state - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryConnectionConsensusStateResponse is the response type for the - Query/ConnectionConsensusState RPC method - ibc.core.connection.v1.QueryConnectionParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. - type: object - properties: - max_expected_time_per_block: - type: string - format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably take to - produce the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per block. - description: >- - QueryConnectionParamsResponse is the response type for the - Query/ConnectionParams RPC method. - ibc.core.connection.v1.QueryConnectionResponse: - type: object - properties: - connection: - title: connection associated with the request identifier - type: object - properties: - client_id: - type: string - description: client associated with this connection. - versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - version in - - the connection handshake. - description: >- - IBC version which can be utilised to determine encodings or - protocols for - - channels or packets utilising this connection. - state: - description: current state of the connection end. - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - counterparty: - description: counterparty chain associated with this connection. - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated - with a given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain - associated with a + Note: this functionality is not currently available in the + official - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. + protobuf release, and it is not used for type URLs beginning with - The constructed key from the Path and the key will be - append(Path.KeyPath, + type.googleapis.com. - append(Path.KeyPrefix, key...)) - delay_period: + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + value: type: string - format: uint64 + format: byte description: >- - delay period that must pass before a consensus state can be used - for + Must be a valid serialized protocol buffer of the above specified + type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a - packet-verification NOTE: delay period logic is only implemented - by some + URL that describes the type of the serialized message. - clients. - description: >- - ConnectionEnd defines a stateful object on a chain connected to - another - separate one. + Protobuf library provides support to pack/unpack Any values in the + form - NOTE: there must only be 2 defined ConnectionEnds to establish + of utility functions or additional generated methods of the Any type. - a connection between two chains. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - RevisionNumber the same. However some consensus algorithms may choose - to + Example 1: Pack and unpack a message in C++. - reset the height in certain conditions e.g. hard forks, state-machine + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - breaking changes In these cases, the RevisionNumber is incremented so - that + Example 2: Pack and unpack a message in Java. - height continues to be monitonically increasing even as the - RevisionHeight + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - gets reset + Example 3: Pack and unpack a message in Python. + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + Example 4: Pack and unpack a message in Go - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - description: >- - QueryConnectionResponse is the response type for the Query/Connection RPC + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - method. Besides the connection end, it includes a proof and the height - from + The pack methods provided by protobuf library will by default use - which the proof was retrieved. - ibc.core.connection.v1.QueryConnectionsResponse: - type: object - properties: - connections: - type: array - items: - type: object - properties: - id: - type: string - description: connection identifier. - client_id: - type: string - description: client associated with this connection. - versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the - IBC version in + 'type.googleapis.com/full.type.name' as the type URL and the unpack - the connection handshake. - title: >- - IBC version which can be utilised to determine encodings or - protocols for + methods only use the fully qualified type name after the last '/' - channels or packets utilising this connection - state: - description: current state of the connection end. - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - counterparty: - description: counterparty chain associated with this connection. - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated - with a given + in the type URL, for example "foo.bar.com/x/y.z" will yield type - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain - associated with a + name "y.z". - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - The constructed key from the Path and the key will be - append(Path.KeyPath, + JSON - append(Path.KeyPrefix, key...)) - delay_period: - type: string - format: uint64 - description: delay period associated with this connection. - description: |- - IdentifiedConnection defines a connection with additional connection - identifier field. - description: list of stored connections of the chain. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - height: - title: query block height + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: consensus state associated with the channel + client_id: + type: string + title: client ID associated with the consensus state + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -19298,510 +23080,727 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - description: >- - QueryConnectionsResponse is the response type for the Query/Connections - RPC - - method. - ibc.core.connection.v1.State: - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - description: |- - State defines if a connection is in one of the following states: - INIT, TRYOPEN, OPEN or UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A connection end has just started the opening handshake. - - STATE_TRYOPEN: A connection end has acknowledged the handshake step on the counterparty - chain. - - STATE_OPEN: A connection end has completed the handshake. - ibc.core.connection.v1.Version: + title: |- + QueryChannelClientStateResponse is the Response type for the + Query/QueryChannelClientState RPC method + ibc.core.channel.v1.QueryChannelParamsResponse: type: object properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: |- - Version defines the versioning scheme used to negotiate the IBC version in - the connection handshake. - ibc.core.channel.v1.Channel: + params: + description: params defines the parameters of the module. + type: object + properties: + upgrade_timeout: + type: object + properties: + height: + title: block height after which the packet or upgrade times out + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + timestamp: + type: string + format: uint64 + title: >- + block timestamp (in nanoseconds) after which the packet or + upgrade times out + description: >- + Timeout defines an execution deadline structure for 04-channel + handlers. + + This includes packet lifecycle handlers as well as the upgrade + handshake handlers. + + A valid Timeout contains either one or both of a timestamp and + block height (sequence). + description: >- + QueryChannelParamsResponse is the response type for the + Query/ChannelParams RPC method. + ibc.core.channel.v1.QueryChannelResponse: type: object properties: - state: - title: current state of the channel end - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: |- - State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end + channel: + title: channel associated with the request identifiers type: object properties: - port_id: + state: + title: current state of the channel end type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE + default: STATE_UNINITIALIZED_UNSPECIFIED description: >- - port on the counterparty chain which owns the other end of the - channel. - channel_id: - type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: - type: string - title: |- - list of connection identifiers, in order, along which packets sent on - this channel will travel - version: - type: string - title: opaque channel version, which is agreed upon during the handshake - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel + State defines if a channel is in one of the following states: - the value of 0 indicates the channel has never been upgraded - description: |- - 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. - ibc.core.channel.v1.Counterparty: - type: object - properties: - port_id: - type: string - description: >- - port on the counterparty chain which owns the other end of the - channel. - channel_id: - type: string - title: channel end on the counterparty chain - title: Counterparty defines a channel end counterparty - ibc.core.channel.v1.ErrorReceipt: - type: object - properties: - sequence: - type: string - format: uint64 - title: the channel upgrade sequence - message: - type: string - title: the error message detailing the cause of failure - description: >- - ErrorReceipt defines a type which encapsulates the upgrade sequence and - error associated with the + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or + UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + counterparty: + title: counterparty channel end + type: object + properties: + port_id: + type: string + description: >- + port on the counterparty chain which owns the other end of the + channel. + channel_id: + type: string + title: channel end on the counterparty chain + connection_hops: + type: array + items: + type: string + title: >- + list of connection identifiers, in order, along which packets sent + on - upgrade handshake failure. When a channel upgrade handshake is aborted - both chains are expected to increment to the + this channel will travel + version: + type: string + title: opaque channel version, which is agreed upon during the handshake + upgrade_sequence: + type: string + format: uint64 + title: >- + upgrade sequence indicates the latest upgrade attempt performed by + this channel - next sequence. - ibc.core.channel.v1.IdentifiedChannel: - type: object - properties: - state: - title: current state of the channel end - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: |- - State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + the value of 0 indicates the channel has never been upgraded + description: >- + Channel defines pipeline for exactly-once packet delivery between + specific - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered + modules on separate blockchains, which has at least one end capable of + + sending packets and one end capable of receiving packets. + proof: type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: - port_id: + revision_number: type: string - description: >- - port on the counterparty chain which owns the other end of the - channel. - channel_id: + format: uint64 + title: the revision that the client is currently on + revision_height: type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: - type: string - title: |- - list of connection identifiers, in order, along which packets sent on - this channel will travel - version: - type: string - title: opaque channel version, which is agreed upon during the handshake - port_id: - type: string - title: port identifier - channel_id: - type: string - title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - the value of 0 indicates the channel has never been upgraded - description: |- - IdentifiedChannel defines a channel with additional port and channel - identifier fields. - ibc.core.channel.v1.Order: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - ibc.core.channel.v1.PacketState: - type: object - properties: - port_id: - type: string - description: channel port identifier. - channel_id: - type: string - description: channel unique identifier. - sequence: - type: string - format: uint64 - description: packet sequence. - data: - type: string - format: byte - description: embedded data that represents packet state. - description: |- - PacketState defines the generic type necessary to retrieve and store - packet commitments, acknowledgements, and receipts. - Caller is responsible for knowing the context necessary to interpret this - state as a commitment, acknowledgement, or a receipt. - ibc.core.channel.v1.Params: + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + description: >- + QueryChannelResponse is the response type for the Query/Channel RPC + method. + + Besides the Channel end, it includes a proof and the height from which the + + proof was retrieved. + ibc.core.channel.v1.QueryChannelsResponse: type: object properties: - upgrade_timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: + channels: + type: array + items: + type: object + properties: + state: + title: current state of the channel end + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE + default: STATE_UNINITIALIZED_UNSPECIFIED + description: >- + State defines if a channel is in one of the following states: + + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or + UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + counterparty: + title: counterparty channel end + type: object + properties: + port_id: + type: string + description: >- + port on the counterparty chain which owns the other end of + the channel. + channel_id: + type: string + title: channel end on the counterparty chain + connection_hops: + type: array + items: type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is incremented - so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - + title: >- + list of connection identifiers, in order, along which packets + sent on - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + this channel will travel + version: + type: string + title: >- + opaque channel version, which is agreed upon during the + handshake + port_id: + type: string + title: port identifier + channel_id: + type: string + title: channel identifier + upgrade_sequence: + type: string + format: uint64 + title: >- + upgrade sequence indicates the latest upgrade attempt performed + by this channel - This enforces the Go json marshaller to always emit zero values - for both revision_number and revision_height. - timestamp: + the value of 0 indicates the channel has never been upgraded + description: |- + IdentifiedChannel defines a channel with additional port and channel + identifier fields. + description: list of stored channels of the chain. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. + total is total number of results available if + PageRequest.count_total - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - description: Params defines the set of IBC channel parameters. - ibc.core.channel.v1.QueryChannelClientStateResponse: - type: object - properties: - identified_client_state: - title: client state associated with the channel + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height type: object properties: - client_id: + revision_number: type: string - title: client identifier - client_state: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - one "/" character. The last segment of the URL's path must - represent + RevisionNumber the same. However some consensus algorithms may choose + to - the fully qualified name of the type (as in + reset the height in certain conditions e.g. hard forks, state-machine - `path/google.protobuf.Duration`). The name should be in a - canonical form + breaking changes In these cases, the RevisionNumber is incremented so + that - (e.g., leading "." is not accepted). + height continues to be monitonically increasing even as the + RevisionHeight + gets reset - In practice, teams usually precompile into the binary all - types that they - expect it to use in the context of Any. However, for URLs - which use the + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - scheme `http`, `https`, or no scheme, one can optionally set - up a type + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + description: >- + QueryChannelsResponse is the response type for the Query/Channels RPC + method. + ibc.core.channel.v1.QueryConnectionChannelsResponse: + type: object + properties: + channels: + type: array + items: + type: object + properties: + state: + title: current state of the channel end + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE + default: STATE_UNINITIALIZED_UNSPECIFIED + description: >- + State defines if a channel is in one of the following states: - server that maps type URLs to message definitions as follows: + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or + UNINITIALIZED. + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + counterparty: + title: counterparty channel end + type: object + properties: + port_id: + type: string + description: >- + port on the counterparty chain which owns the other end of + the channel. + channel_id: + type: string + title: channel end on the counterparty chain + connection_hops: + type: array + items: + type: string + title: >- + list of connection identifiers, in order, along which packets + sent on - * If no scheme is provided, `https` is assumed. + this channel will travel + version: + type: string + title: >- + opaque channel version, which is agreed upon during the + handshake + port_id: + type: string + title: port identifier + channel_id: + type: string + title: channel identifier + upgrade_sequence: + type: string + format: uint64 + title: >- + upgrade sequence indicates the latest upgrade attempt performed + by this channel - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on - the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + the value of 0 indicates the channel has never been upgraded + description: |- + IdentifiedChannel defines a channel with additional port and channel + identifier fields. + description: list of channels associated with a connection. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - Note: this functionality is not currently available in the - official + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - protobuf release, and it is not used for type URLs beginning - with + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - type.googleapis.com. + RevisionNumber the same. However some consensus algorithms may choose + to + reset the height in certain conditions e.g. hard forks, state-machine - Schemes other than `http`, `https` (or the empty scheme) might - be + breaking changes In these cases, the RevisionNumber is incremented so + that - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a + height continues to be monitonically increasing even as the + RevisionHeight - URL that describes the type of the serialized message. + gets reset - Protobuf library provides support to pack/unpack Any values in the - form + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - of utility functions or additional generated methods of the Any - type. + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryConnectionChannelsResponse is the Response type for the + Query/QueryConnectionChannels RPC method + ibc.core.channel.v1.QueryNextSequenceReceiveResponse: + type: object + properties: + next_sequence_receive: + type: string + format: uint64 + title: next sequence receive number + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + RevisionNumber the same. However some consensus algorithms may choose + to - Example 1: Pack and unpack a message in C++. + reset the height in certain conditions e.g. hard forks, state-machine - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + breaking changes In these cases, the RevisionNumber is incremented so + that - Example 2: Pack and unpack a message in Java. + height continues to be monitonically increasing even as the + RevisionHeight - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + gets reset - Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - Example 4: Pack and unpack a message in Go + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QuerySequenceResponse is the response type for the + Query/QueryNextSequenceReceiveResponse RPC method + ibc.core.channel.v1.QueryNextSequenceSendResponse: + type: object + properties: + next_sequence_send: + type: string + format: uint64 + title: next sequence send number + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + RevisionNumber the same. However some consensus algorithms may choose + to - The pack methods provided by protobuf library will by default use + reset the height in certain conditions e.g. hard forks, state-machine - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + breaking changes In these cases, the RevisionNumber is incremented so + that - methods only use the fully qualified type name after the last '/' + height continues to be monitonically increasing even as the + RevisionHeight - in the type URL, for example "foo.bar.com/x/y.z" will yield type + gets reset - name "y.z". + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - JSON + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryNextSequenceSendResponse is the request type for the + Query/QueryNextSequenceSend RPC method + ibc.core.channel.v1.QueryPacketAcknowledgementResponse: + type: object + properties: + acknowledgement: + type: string + format: byte + title: packet associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + RevisionNumber the same. However some consensus algorithms may choose + to - The JSON representation of an `Any` value uses the regular + reset the height in certain conditions e.g. hard forks, state-machine - representation of the deserialized, embedded message, with an + breaking changes In these cases, the RevisionNumber is incremented so + that - additional field `@type` which contains the type URL. Example: + height continues to be monitonically increasing even as the + RevisionHeight - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + gets reset - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - If the embedded message type is well-known and has a custom JSON + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryPacketAcknowledgementResponse defines the client query response for a + packet which also includes a proof and the height from which the + proof was retrieved + ibc.core.channel.v1.QueryPacketAcknowledgementsResponse: + type: object + properties: + acknowledgements: + type: array + items: + type: object + properties: + port_id: + type: string + description: channel port identifier. + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve and store - representation, that representation will be embedded adding a - field + packet commitments, acknowledgements, and receipts. - `value` which holds the custom JSON in addition to the `@type` + Caller is responsible for knowing the context necessary to interpret + this - field. Example (for message [google.protobuf.Duration][]): + state as a commitment, acknowledgement, or a receipt. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: client state + was set, its value is undefined otherwise description: |- - IdentifiedClientState defines a client state with an additional client - identifier field. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height type: object properties: revision_number: @@ -19836,179 +23835,163 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryChannelClientStateResponse is the Response type for the - Query/QueryChannelClientState RPC method - ibc.core.channel.v1.QueryChannelConsensusStateResponse: + QueryPacketAcknowledgemetsResponse is the request type for the + Query/QueryPacketAcknowledgements RPC method + ibc.core.channel.v1.QueryPacketCommitmentResponse: type: object properties: - consensus_state: + commitment: + type: string + format: byte + title: packet associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: - type_url: + revision_number: type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - value: + format: uint64 + title: the revision that the client is currently on + revision_height: type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above specified - type. + format: uint64 + title: the height within the given revision description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. + Normally the RevisionHeight is incremented at each height while + keeping - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + RevisionNumber the same. However some consensus algorithms may choose + to - Example 3: Pack and unpack a message in Python. + reset the height in certain conditions e.g. hard forks, state-machine - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + breaking changes In these cases, the RevisionNumber is incremented so + that - Example 4: Pack and unpack a message in Go + height continues to be monitonically increasing even as the + RevisionHeight - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + gets reset - The pack methods provided by protobuf library will by default use - 'type.googleapis.com/full.type.name' as the type URL and the unpack + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - methods only use the fully qualified type name after the last '/' + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: >- + QueryPacketCommitmentResponse defines the client query response for a + packet - in the type URL, for example "foo.bar.com/x/y.z" will yield type + which also includes a proof and the height from which the proof was - name "y.z". + retrieved + ibc.core.channel.v1.QueryPacketCommitmentsResponse: + type: object + properties: + commitments: + type: array + items: + type: object + properties: + port_id: + type: string + description: channel port identifier. + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve and store + packet commitments, acknowledgements, and receipts. - JSON + Caller is responsible for knowing the context necessary to interpret + this + state as a commitment, acknowledgement, or a receipt. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - The JSON representation of an `Any` value uses the regular + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - representation of the deserialized, embedded message, with an + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - additional field `@type` which contains the type URL. Example: + RevisionNumber the same. However some consensus algorithms may choose + to - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + reset the height in certain conditions e.g. hard forks, state-machine - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + breaking changes In these cases, the RevisionNumber is incremented so + that - If the embedded message type is well-known and has a custom JSON + height continues to be monitonically increasing even as the + RevisionHeight - representation, that representation will be embedded adding a field + gets reset - `value` which holds the custom JSON in addition to the `@type` - field. Example (for message [google.protobuf.Duration][]): + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - title: consensus state associated with the channel - client_id: - type: string - title: client ID associated with the consensus state + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryPacketCommitmentsResponse is the request type for the + Query/QueryPacketCommitments RPC method + ibc.core.channel.v1.QueryPacketReceiptResponse: + type: object + properties: + received: + type: boolean + title: success flag for if receipt exists proof: type: string format: byte @@ -20048,159 +24031,128 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: |- - QueryChannelClientStateResponse is the Response type for the - Query/QueryChannelClientState RPC method - ibc.core.channel.v1.QueryChannelParamsResponse: + title: >- + QueryPacketReceiptResponse defines the client query response for a packet + + receipt which also includes a proof, and the height from which the proof + was + + retrieved + ibc.core.channel.v1.QueryUnreceivedAcksResponse: type: object properties: - params: - description: params defines the parameters of the module. + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived acknowledgement sequences + height: + title: query block height type: object properties: - upgrade_timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - breaking changes In these cases, the RevisionNumber is - incremented so that + RevisionNumber the same. However some consensus algorithms may choose + to - height continues to be monitonically increasing even as the - RevisionHeight + reset the height in certain conditions e.g. hard forks, state-machine - gets reset + breaking changes In these cases, the RevisionNumber is incremented so + that + height continues to be monitonically increasing even as the + RevisionHeight - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. + gets reset - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or - upgrade times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. - A valid Timeout contains either one or both of a timestamp and - block height (sequence). - description: >- - QueryChannelParamsResponse is the response type for the - Query/ChannelParams RPC method. - ibc.core.channel.v1.QueryChannelResponse: + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryUnreceivedAcksResponse is the response type for the + Query/UnreceivedAcks RPC method + ibc.core.channel.v1.QueryUnreceivedPacketsResponse: type: object properties: - channel: - title: channel associated with the request identifiers + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived packet sequences + height: + title: query block height type: object properties: - state: - title: current state of the channel end + revision_number: type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- - State defines if a channel is in one of the following states: + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + RevisionNumber the same. However some consensus algorithms may choose + to - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end - type: object - properties: - port_id: - type: string - description: >- - port on the counterparty chain which owns the other end of the - channel. - channel_id: - type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: - type: string - title: >- - list of connection identifiers, in order, along which packets sent - on + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight - this channel will travel - version: - type: string - title: opaque channel version, which is agreed upon during the handshake - upgrade_sequence: + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: |- + QueryUnreceivedPacketsResponse is the response type for the + Query/UnreceivedPacketCommitments RPC method + ibc.core.channel.v1.QueryUpgradeErrorResponse: + type: object + properties: + error_receipt: + type: object + properties: + sequence: type: string format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel - - the value of 0 indicates the channel has never been upgraded + title: the channel upgrade sequence + message: + type: string + title: the error message detailing the cause of failure description: >- - Channel defines pipeline for exactly-once packet delivery between - specific + ErrorReceipt defines a type which encapsulates the upgrade sequence + and error associated with the - modules on separate blockchains, which has at least one end capable of + upgrade handshake failure. When a channel upgrade handshake is aborted + both chains are expected to increment to the - sending packets and one end capable of receiving packets. + next sequence. proof: type: string format: byte @@ -20240,134 +24192,116 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - description: >- - QueryChannelResponse is the response type for the Query/Channel RPC - method. - - Besides the Channel end, it includes a proof and the height from which the - - proof was retrieved. - ibc.core.channel.v1.QueryChannelsResponse: + title: >- + QueryUpgradeErrorResponse is the response type for the + Query/QueryUpgradeError RPC method + ibc.core.channel.v1.QueryUpgradeResponse: type: object properties: - channels: - type: array - items: - type: object - properties: - state: - title: current state of the channel end - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- - State defines if a channel is in one of the following states: + upgrade: + type: object + properties: + fields: + type: object + properties: + ordering: + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + title: Order defines if a channel is ORDERED or UNORDERED + connection_hops: + type: array + items: + type: string + version: + type: string + description: |- + UpgradeFields are the fields in a channel end which may be changed + during a channel upgrade. + timeout: + type: object + properties: + height: + title: block height after which the packet or upgrade times out + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + RevisionNumber the same. However some consensus algorithms may + choose to - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end - type: object - properties: - port_id: - type: string - description: >- - port on the counterparty chain which owns the other end of - the channel. - channel_id: - type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. + timestamp: type: string - title: >- - list of connection identifiers, in order, along which packets - sent on + format: uint64 + title: >- + block timestamp (in nanoseconds) after which the packet or + upgrade times out + description: >- + Timeout defines an execution deadline structure for 04-channel + handlers. - this channel will travel - version: - type: string - title: >- - opaque channel version, which is agreed upon during the - handshake - port_id: - type: string - title: port identifier - channel_id: - type: string - title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed - by this channel + This includes packet lifecycle handlers as well as the upgrade + handshake handlers. - the value of 0 indicates the channel has never been upgraded - description: |- - IdentifiedChannel defines a channel with additional port and channel - identifier fields. - description: list of stored channels of the chain. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + A valid Timeout contains either one or both of a timestamp and + block height (sequence). + next_sequence_send: type: string format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + description: >- + Upgrade is a verifiable type which contains the relevant information - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + for an attempted upgrade. It provides the proposed changes to the + channel - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - height: - title: query block height + end, the timeout for this upgrade attempt and the next packet sequence + + which allows the counterparty to efficiently know the highest sequence + it has received. + + The next sequence send is used for pruning and upgrading from + unordered to ordered channels. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -20401,130 +24335,38 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - description: >- - QueryChannelsResponse is the response type for the Query/Channels RPC - method. - ibc.core.channel.v1.QueryConnectionChannelsResponse: + title: >- + QueryUpgradeResponse is the response type for the QueryUpgradeResponse RPC + method + ibc.core.channel.v1.State: + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + - STATE_CLOSED + - STATE_FLUSHING + - STATE_FLUSHCOMPLETE + default: STATE_UNINITIALIZED_UNSPECIFIED + description: |- + State defines if a channel is in one of the following states: + CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. + ibc.core.channel.v1.Timeout: type: object properties: - channels: - type: array - items: - type: object - properties: - state: - title: current state of the channel end - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- - State defines if a channel is in one of the following states: - - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end - type: object - properties: - port_id: - type: string - description: >- - port on the counterparty chain which owns the other end of - the channel. - channel_id: - type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: - type: string - title: >- - list of connection identifiers, in order, along which packets - sent on - - this channel will travel - version: - type: string - title: >- - opaque channel version, which is agreed upon during the - handshake - port_id: - type: string - title: port identifier - channel_id: - type: string - title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed - by this channel - - the value of 0 indicates the channel has never been upgraded - description: |- - IdentifiedChannel defines a channel with additional port and channel - identifier fields. - description: list of channels associated with a connection. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } height: - title: query block height + title: block height after which the packet or upgrade times out type: object properties: revision_number: @@ -20544,380 +24386,420 @@ definitions: reset the height in certain conditions e.g. hard forks, state-machine - breaking changes In these cases, the RevisionNumber is incremented so - that + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + timestamp: + type: string + format: uint64 + title: >- + block timestamp (in nanoseconds) after which the packet or upgrade + times out + description: >- + Timeout defines an execution deadline structure for 04-channel handlers. + + This includes packet lifecycle handlers as well as the upgrade handshake + handlers. + + A valid Timeout contains either one or both of a timestamp and block + height (sequence). + ibc.core.channel.v1.Upgrade: + type: object + properties: + fields: + type: object + properties: + ordering: + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + title: Order defines if a channel is ORDERED or UNORDERED + connection_hops: + type: array + items: + type: string + version: + type: string + description: |- + UpgradeFields are the fields in a channel end which may be changed + during a channel upgrade. + timeout: + type: object + properties: + height: + title: block height after which the packet or upgrade times out + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is incremented + so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values + for both revision_number and revision_height. + timestamp: + type: string + format: uint64 + title: >- + block timestamp (in nanoseconds) after which the packet or upgrade + times out + description: >- + Timeout defines an execution deadline structure for 04-channel + handlers. + + This includes packet lifecycle handlers as well as the upgrade + handshake handlers. - height continues to be monitonically increasing even as the - RevisionHeight + A valid Timeout contains either one or both of a timestamp and block + height (sequence). + next_sequence_send: + type: string + format: uint64 + description: >- + Upgrade is a verifiable type which contains the relevant information - gets reset + for an attempted upgrade. It provides the proposed changes to the channel + end, the timeout for this upgrade attempt and the next packet sequence - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + which allows the counterparty to efficiently know the highest sequence it + has received. - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryConnectionChannelsResponse is the Response type for the - Query/QueryConnectionChannels RPC method - ibc.core.channel.v1.QueryNextSequenceReceiveResponse: + The next sequence send is used for pruning and upgrading from unordered to + ordered channels. + ibc.core.channel.v1.UpgradeFields: type: object properties: - next_sequence_receive: + ordering: type: string - format: uint64 - title: next sequence receive number - proof: + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: |- + - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + title: Order defines if a channel is ORDERED or UNORDERED + connection_hops: + type: array + items: + type: string + version: type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + description: |- + UpgradeFields are the fields in a channel end which may be changed + during a channel upgrade. + ibc.core.channel.v2.Channel: + type: object + properties: + client_id: + type: string + title: >- + the client identifier of the light client representing the + counterparty chain + counterparty_channel_id: + type: string + description: >- + the counterparty identifier that must be used by packets sent by + counterparty + + to our channel end. + merkle_path_prefix: + description: >- + the key path used to store packet flow messages that the counterparty + + will use to send to us. In backwards compatible cases, we will append + the channelID and sequence in order to create + + the final path. type: object properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + key_path: + type: array + items: + type: string + format: byte + title: >- + MerklePath is the path used to verify commitment proofs, which can be + an - RevisionNumber the same. However some consensus algorithms may choose - to + arbitrary structured object (defined by a commitment type). - reset the height in certain conditions e.g. hard forks, state-machine + MerklePath is represented from root-to-leaf + description: >- + Channel defines the channel end on a chain that is implementing the + version 2 IBC protocol - breaking changes In these cases, the RevisionNumber is incremented so - that + Each side will maintain its own Channel to create an IBC channel - height continues to be monitonically increasing even as the - RevisionHeight + The channel will be referenced by a channelID which will be used to send + packets - gets reset + to the counterparty + The channel will contain the client identifier that will provide proof + verification for the channel - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + and the counterparty channel identifier that the other channel end will be + using - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QuerySequenceResponse is the response type for the - Query/QueryNextSequenceReceiveResponse RPC method - ibc.core.channel.v1.QueryNextSequenceSendResponse: + to send packets to our channel end. + ibc.core.channel.v2.PacketState: type: object properties: - next_sequence_send: + channel_id: + type: string + description: channel unique identifier. + sequence: type: string format: uint64 - title: next sequence send number - proof: + description: packet sequence. + data: type: string format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + description: embedded data that represents packet state. + description: |- + PacketState defines the generic type necessary to retrieve and store + packet commitments, acknowledgements, and receipts. + Caller is responsible for knowing the context necessary to interpret this + state as a commitment, acknowledgement, or a receipt. + ibc.core.channel.v2.QueryChannelClientStateResponse: + type: object + properties: + identified_client_state: + title: client state associated with the channel type: object properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: + client_id: type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine + title: client identifier + client_state: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - breaking changes In these cases, the RevisionNumber is incremented so - that + protocol buffer message. This string must contain at least - height continues to be monitonically increasing even as the - RevisionHeight + one "/" character. The last segment of the URL's path must + represent - gets reset + the fully qualified name of the type (as in + `path/google.protobuf.Duration`). The name should be in a + canonical form - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + (e.g., leading "." is not accepted). - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryNextSequenceSendResponse is the request type for the - Query/QueryNextSequenceSend RPC method - ibc.core.channel.v1.QueryPacketAcknowledgementResponse: - type: object - properties: - acknowledgement: - type: string - format: byte - title: packet associated with the request fields - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - RevisionNumber the same. However some consensus algorithms may choose - to + In practice, teams usually precompile into the binary all + types that they - reset the height in certain conditions e.g. hard forks, state-machine + expect it to use in the context of Any. However, for URLs + which use the - breaking changes In these cases, the RevisionNumber is incremented so - that + scheme `http`, `https`, or no scheme, one can optionally set + up a type - height continues to be monitonically increasing even as the - RevisionHeight + server that maps type URLs to message definitions as follows: - gets reset + * If no scheme is provided, `https` is assumed. - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on + the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryPacketAcknowledgementResponse defines the client query response for a - packet which also includes a proof and the height from which the - proof was retrieved - ibc.core.channel.v1.QueryPacketAcknowledgementsResponse: - type: object - properties: - acknowledgements: - type: array - items: - type: object - properties: - port_id: - type: string - description: channel port identifier. - channel_id: - type: string - description: channel unique identifier. - sequence: - type: string - format: uint64 - description: packet sequence. - data: - type: string - format: byte - description: embedded data that represents packet state. - description: >- - PacketState defines the generic type necessary to retrieve and store + Note: this functionality is not currently available in the + official - packet commitments, acknowledgements, and receipts. + protobuf release, and it is not used for type URLs beginning + with - Caller is responsible for knowing the context necessary to interpret - this + type.googleapis.com. - state as a commitment, acknowledgement, or a receipt. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + Schemes other than `http`, `https` (or the empty scheme) might + be - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - height: - title: query block height - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a - RevisionNumber the same. However some consensus algorithms may choose - to + URL that describes the type of the serialized message. - reset the height in certain conditions e.g. hard forks, state-machine - breaking changes In these cases, the RevisionNumber is incremented so - that + Protobuf library provides support to pack/unpack Any values in the + form - height continues to be monitonically increasing even as the - RevisionHeight + of utility functions or additional generated methods of the Any + type. - gets reset + Example 1: Pack and unpack a message in C++. - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryPacketAcknowledgemetsResponse is the request type for the - Query/QueryPacketAcknowledgements RPC method - ibc.core.channel.v1.QueryPacketCommitmentResponse: - type: object - properties: - commitment: - type: string - format: byte - title: packet associated with the request fields - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping + Example 2: Pack and unpack a message in Java. - RevisionNumber the same. However some consensus algorithms may choose - to + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - reset the height in certain conditions e.g. hard forks, state-machine + Example 3: Pack and unpack a message in Python. - breaking changes In these cases, the RevisionNumber is incremented so - that + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - height continues to be monitonically increasing even as the - RevisionHeight + Example 4: Pack and unpack a message in Go - gets reset + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + The pack methods provided by protobuf library will by default use - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: >- - QueryPacketCommitmentResponse defines the client query response for a - packet + methods only use the fully qualified type name after the last '/' - which also includes a proof and the height from which the proof was + in the type URL, for example "foo.bar.com/x/y.z" will yield type - retrieved - ibc.core.channel.v1.QueryPacketCommitmentsResponse: - type: object - properties: - commitments: - type: array - items: - type: object - properties: - port_id: - type: string - description: channel port identifier. - channel_id: - type: string - description: channel unique identifier. - sequence: - type: string - format: uint64 - description: packet sequence. - data: - type: string - format: byte - description: embedded data that represents packet state. - description: >- - PacketState defines the generic type necessary to retrieve and store + name "y.z". - packet commitments, acknowledgements, and receipts. - Caller is responsible for knowing the context necessary to interpret - this + JSON - state as a commitment, acknowledgement, or a receipt. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + The JSON representation of an `Any` value uses the regular - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - height: - title: query block height + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + title: client state + description: |- + IdentifiedClientState defines a client state with an additional client + identifier field. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -20952,14 +24834,76 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryPacketCommitmentsResponse is the request type for the - Query/QueryPacketCommitments RPC method - ibc.core.channel.v1.QueryPacketReceiptResponse: + QueryChannelClientStateResponse is the Response type for the + Query/QueryChannelClientState RPC method + ibc.core.channel.v2.QueryChannelResponse: type: object properties: - received: - type: boolean - title: success flag for if receipt exists + channel: + title: the channel associated with the provided channel id + type: object + properties: + client_id: + type: string + title: >- + the client identifier of the light client representing the + counterparty chain + counterparty_channel_id: + type: string + description: >- + the counterparty identifier that must be used by packets sent by + counterparty + + to our channel end. + merkle_path_prefix: + description: >- + the key path used to store packet flow messages that the + counterparty + + will use to send to us. In backwards compatible cases, we will + append the channelID and sequence in order to create + + the final path. + type: object + properties: + key_path: + type: array + items: + type: string + format: byte + title: >- + MerklePath is the path used to verify commitment proofs, which can + be an + + arbitrary structured object (defined by a commitment type). + + MerklePath is represented from root-to-leaf + description: >- + Channel defines the channel end on a chain that is implementing the + version 2 IBC protocol + + Each side will maintain its own Channel to create an IBC channel + + The channel will be referenced by a channelID which will be used to + send packets + + to the counterparty + + The channel will contain the client identifier that will provide proof + verification for the channel + + and the counterparty channel identifier that the other channel end + will be using + + to send packets to our channel end. + title: QueryChannelRequest is the response type for the Query/Channel RPC method + ibc.core.channel.v2.QueryNextSequenceSendResponse: + type: object + properties: + next_sequence_send: + type: string + format: uint64 + title: next sequence send number proof: type: string format: byte @@ -21000,23 +24944,21 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: >- - QueryPacketReceiptResponse defines the client query response for a packet - - receipt which also includes a proof, and the height from which the proof - was - - retrieved - ibc.core.channel.v1.QueryUnreceivedAcksResponse: + QueryNextSequenceSendResponse is the response type for the + Query/QueryNextSequenceSend RPC method + ibc.core.channel.v2.QueryPacketAcknowledgementResponse: type: object properties: - sequences: - type: array - items: - type: string - format: uint64 - title: list of unreceived acknowledgement sequences - height: - title: query block height + acknowledgement: + type: string + format: byte + title: acknowledgement associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -21050,18 +24992,64 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: |- - QueryUnreceivedAcksResponse is the response type for the - Query/UnreceivedAcks RPC method - ibc.core.channel.v1.QueryUnreceivedPacketsResponse: + description: >- + QueryPacketAcknowledgementResponse is the response type for the + Query/PacketAcknowledgement RPC method. + ibc.core.channel.v2.QueryPacketAcknowledgementsResponse: type: object properties: - sequences: + acknowledgements: type: array items: - type: string - format: uint64 - title: list of unreceived packet sequences + type: object + properties: + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve and store + + packet commitments, acknowledgements, and receipts. + + Caller is responsible for knowing the context necessary to interpret + this + + state as a commitment, acknowledgement, or a receipt. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } height: title: query block height type: object @@ -21098,29 +25086,15 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryUnreceivedPacketsResponse is the response type for the - Query/UnreceivedPacketCommitments RPC method - ibc.core.channel.v1.QueryUpgradeErrorResponse: + QueryPacketAcknowledgemetsResponse is the request type for the + Query/QueryPacketAcknowledgements RPC method + ibc.core.channel.v2.QueryPacketCommitmentResponse: type: object properties: - error_receipt: - type: object - properties: - sequence: - type: string - format: uint64 - title: the channel upgrade sequence - message: - type: string - title: the error message detailing the cause of failure - description: >- - ErrorReceipt defines a type which encapsulates the upgrade sequence - and error associated with the - - upgrade handshake failure. When a channel upgrade handshake is aborted - both chains are expected to increment to the - - next sequence. + commitment: + type: string + format: byte + title: packet associated with the request fields proof: type: string format: byte @@ -21160,114 +25134,89 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - QueryUpgradeErrorResponse is the response type for the - Query/QueryUpgradeError RPC method - ibc.core.channel.v1.QueryUpgradeResponse: + description: >- + QueryPacketCommitmentResponse is the response type for the + Query/PacketCommitment RPC method. + ibc.core.channel.v2.QueryPacketCommitmentsResponse: type: object properties: - upgrade: - type: object - properties: - fields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. - timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or - upgrade times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. + commitments: + type: array + items: + type: object + properties: + channel_id: + type: string + description: channel unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve and store - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. + packet commitments, acknowledgements, and receipts. - A valid Timeout contains either one or both of a timestamp and - block height (sequence). - next_sequence_send: + Caller is responsible for knowing the context necessary to interpret + this + + state as a commitment, acknowledgement, or a receipt. + description: collection of packet commitments for the requested channel identifier. + pagination: + description: pagination response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 - description: >- - Upgrade is a verifiable type which contains the relevant information - - for an attempted upgrade. It provides the proposed changes to the - channel + title: >- + total is total number of results available if + PageRequest.count_total - end, the timeout for this upgrade attempt and the next packet sequence + was set, its value is undefined otherwise + height: + description: query block height. + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + title: >- + Height is a monotonically increasing data type - which allows the counterparty to efficiently know the highest sequence - it has received. + that can be compared against another Height for the purposes of + updating and - The next sequence send is used for pruning and upgrading from - unordered to ordered channels. + freezing clients + description: >- + QueryPacketCommitmentResponse is the response type for the + Query/PacketCommitment RPC method. + ibc.core.channel.v2.QueryPacketReceiptResponse: + type: object + properties: + received: + type: boolean + title: success flag for if receipt exists proof: type: string format: byte - title: merkle proof of existence + title: merkle proof of existence or absence proof_height: title: height at which the proof was retrieved type: object @@ -21303,38 +25252,20 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - QueryUpgradeResponse is the response type for the QueryUpgradeResponse RPC - method - ibc.core.channel.v1.State: - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: |- - State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ibc.core.channel.v1.Timeout: + description: >- + QueryPacketReceiptResponse is the response type for the + Query/PacketReceipt RPC method. + ibc.core.channel.v2.QueryUnreceivedAcksResponse: type: object properties: + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived acknowledgement sequences height: - title: block height after which the packet or upgrade times out + title: query block height type: object properties: revision_number: @@ -21368,142 +25299,56 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out - description: >- - Timeout defines an execution deadline structure for 04-channel handlers. - - This includes packet lifecycle handlers as well as the upgrade handshake - handlers. - - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - ibc.core.channel.v1.Upgrade: + title: |- + QueryUnreceivedAcksResponse is the response type for the + Query/UnreceivedAcks RPC method + ibc.core.channel.v2.QueryUnreceivedPacketsResponse: type: object properties: - fields: + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived packet sequences + height: + title: query block height type: object properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: + revision_number: type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. - timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is incremented - so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values - for both revision_number and revision_height. - timestamp: + format: uint64 + title: the revision that the client is currently on + revision_height: type: string format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out + title: the height within the given revision description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. + Normally the RevisionHeight is incremented at each height while + keeping - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. + RevisionNumber the same. However some consensus algorithms may choose + to - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - next_sequence_send: - type: string - format: uint64 - description: >- - Upgrade is a verifiable type which contains the relevant information + reset the height in certain conditions e.g. hard forks, state-machine - for an attempted upgrade. It provides the proposed changes to the channel + breaking changes In these cases, the RevisionNumber is incremented so + that - end, the timeout for this upgrade attempt and the next packet sequence + height continues to be monitonically increasing even as the + RevisionHeight - which allows the counterparty to efficiently know the highest sequence it - has received. + gets reset - The next sequence send is used for pruning and upgrading from unordered to - ordered channels. - ibc.core.channel.v1.UpgradeFields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. + + Please note that json tags for generated Go code are overridden to + explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero values for + both revision_number and revision_height. + title: >- + QueryUnreceivedPacketsResponse is the response type for the + Query/UnreceivedPacketCommitments RPC method ibc.lightclients.wasm.v1.QueryChecksumsResponse: type: object properties: From 07958688a9d33646d35bc9cfef3211fd3b429d2a Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 26 Dec 2024 22:21:18 +0100 Subject: [PATCH 160/172] lint --- modules/apps/transfer/v2/ibc_module.go | 10 +++++----- modules/apps/transfer/v2/keeper/keeper.go | 4 +++- modules/core/04-channel/v2/keeper/grpc_query.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/apps/transfer/v2/ibc_module.go b/modules/apps/transfer/v2/ibc_module.go index f4f22ba3c19..84b25e259db 100644 --- a/modules/apps/transfer/v2/ibc_module.go +++ b/modules/apps/transfer/v2/ibc_module.go @@ -62,7 +62,9 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des // we are explicitly wrapping this emit event call in an anonymous function so that // the packet data is evaluated after it has been assigned a value. defer func() { - im.keeper.EmitOnRecvPacketEvent(ctx, data, ack, ackErr) + if err := im.keeper.EmitOnRecvPacketEvent(ctx, data, ack, ackErr); err != nil { + im.keeper.Logger.Error(fmt.Sprintf("failed to emit %T event", types.EventTypeRecvPacket), "error", err) + } }() data, ackErr = transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) @@ -108,8 +110,7 @@ func (im *IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, return err } - im.keeper.EmitOnTimeoutEvent(ctx, data) - return nil + return im.keeper.EmitOnTimeoutEvent(ctx, data) } func (im *IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, acknowledgement []byte, payload types.Payload, relayer sdk.AccAddress) error { @@ -127,6 +128,5 @@ func (im *IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel return err } - im.keeper.EmitOnAcknowledgementPacketEvent(ctx, data, ack) - return nil + return im.keeper.EmitOnAcknowledgementPacketEvent(ctx, data, ack) } diff --git a/modules/apps/transfer/v2/keeper/keeper.go b/modules/apps/transfer/v2/keeper/keeper.go index 0eb9ee3c56a..cb2d271c6f2 100644 --- a/modules/apps/transfer/v2/keeper/keeper.go +++ b/modules/apps/transfer/v2/keeper/keeper.go @@ -148,7 +148,9 @@ func (k *Keeper) OnRecvPacket(ctx context.Context, sourceChannel, destChannel st k.SetDenomMetadata(ctx, token.Denom) } - k.EmitDenomEvent(ctx, token) + if err := k.EmitDenomEvent(ctx, token); err != nil { + return err + } voucher := sdk.NewCoin(voucherDenom, transferAmount) diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index e574dfa9d08..709781e4a4d 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -234,7 +234,7 @@ func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.Que } if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, req.ChannelId).Error()) + return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) } var acks []*types.PacketState From dbc8acf761dce86b76c8971e9cbefe19511d770c Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 26 Dec 2024 22:24:35 +0100 Subject: [PATCH 161/172] update abigen --- e2e/go.mod | 2 +- e2e/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- modules/apps/callbacks/go.mod | 2 +- modules/apps/callbacks/go.sum | 4 ++-- modules/light-clients/08-wasm/go.mod | 2 +- modules/light-clients/08-wasm/go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index db173292012..e4eb4bfbfa0 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -79,7 +79,7 @@ require ( github.com/cosmos/iavl v1.3.4 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 8c8aef64552..adb818ef180 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -420,8 +420,8 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 h1:9o9xcAsD+JAJQTnI9sRwdCSz28o3zHqqgKaHBYcXP+s= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= diff --git a/go.mod b/go.mod index 47e4711148e..dadec302598 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ics23/go v0.11.0 - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 diff --git a/go.sum b/go.sum index d9c1938b4ff..83a4195331f 100644 --- a/go.sum +++ b/go.sum @@ -402,8 +402,8 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 h1:9o9xcAsD+JAJQTnI9sRwdCSz28o3zHqqgKaHBYcXP+s= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 0760586cac2..3259a730363 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -94,7 +94,7 @@ require ( github.com/cosmos/iavl v1.3.4 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 24d1595b6e0..72c418448a7 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -402,8 +402,8 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 h1:9o9xcAsD+JAJQTnI9sRwdCSz28o3zHqqgKaHBYcXP+s= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 0a24af86ada..40751a39438 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -100,7 +100,7 @@ require ( github.com/cosmos/iavl v1.3.4 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 2a0141f133b..06858e0b96c 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -412,8 +412,8 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 h1:9o9xcAsD+JAJQTnI9sRwdCSz28o3zHqqgKaHBYcXP+s= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= diff --git a/simapp/go.mod b/simapp/go.mod index f354bea31cd..e33a831a836 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -97,7 +97,7 @@ require ( github.com/cosmos/iavl v1.3.4 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 // indirect + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 933976f1aa0..7c2c4d30c8b 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -408,8 +408,8 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4 h1:B23RM5CtuNCgvEffdaMXNZxOH3fVOtNEfEVviOs4364= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241124101149-3e2c74b736f4/go.mod h1:O7A2Q93QyD0m69LQmnDgOSvHGF5URFBTgY2QsxpdqSs= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9 h1:9o9xcAsD+JAJQTnI9sRwdCSz28o3zHqqgKaHBYcXP+s= +github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241224052802-b77c838815f9/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= From 6cf02a1bc9a9845f246e73aa5c1481216ef6081a Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Wed, 8 Jan 2025 00:08:07 +0100 Subject: [PATCH 162/172] chore: add permissions to wasm image job --- .github/workflows/build-wasm-simd-image-from-tag.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-wasm-simd-image-from-tag.yml b/.github/workflows/build-wasm-simd-image-from-tag.yml index 7503201f341..7cef57de825 100644 --- a/.github/workflows/build-wasm-simd-image-from-tag.yml +++ b/.github/workflows/build-wasm-simd-image-from-tag.yml @@ -16,6 +16,9 @@ env: jobs: build-image-at-tag: runs-on: ubuntu-latest + permissions: + packages: write + contents: read steps: - uses: actions/checkout@v4 with: From 7f0cf5414233196548814f8a295593689e28908e Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 10 Jan 2025 16:54:48 +0100 Subject: [PATCH 163/172] fix: wasm docker file + wasm simapp gas limit (#7830) * fix: dockerfile layer name * update wasm simapp image with higher max gas * lint * updated max gas to same as cosmos hub --- modules/light-clients/08-wasm/Dockerfile | 8 ++++---- .../light-clients/08-wasm/testing/simapp/app.go | 12 ++++++++++++ .../08-wasm/testing/simapp/simd/cmd/root.go | 14 +++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/modules/light-clients/08-wasm/Dockerfile b/modules/light-clients/08-wasm/Dockerfile index 2877f026ef3..4c6055eb20c 100644 --- a/modules/light-clients/08-wasm/Dockerfile +++ b/modules/light-clients/08-wasm/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.4-alpine as builder +FROM golang:1.23.4-alpine as builder-base ARG LIBWASM_VERSION ARG TARGETARCH @@ -23,12 +23,12 @@ RUN go mod download # Since it is not easy to fully cache a RUN script download of libwasmvm, we use two different stages # and copy the correct file in the final stage. The multistage setup also helps speed up the build process -FROM alpine:3.18 AS amd64-stage +FROM alpine:3.21 AS amd64-stage ARG LIBWASM_VERSION ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -FROM alpine:3.18 AS arm64-stage +FROM alpine:3.21 AS arm64-stage ARG LIBWASM_VERSION ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a @@ -44,6 +44,6 @@ COPY --from=libwasm-stage /lib/libwasmvm_muslc.* /lib/ RUN go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./... -FROM alpine:3.18 +FROM alpine:3.21 COPY --from=builder /go/build/simd /bin/simd ENTRYPOINT ["simd"] diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index f8d27ad0ce9..6b025bea332 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -110,6 +110,7 @@ import ( cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" cmtcrypto "github.com/cometbft/cometbft/crypto" cmted25519 "github.com/cometbft/cometbft/crypto/ed25519" + cmttypes "github.com/cometbft/cometbft/types" wasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm" wasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" @@ -977,6 +978,17 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.InitChainRequest) (*ab if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { panic(err) } + + paramsProto, err := app.ConsensusParamsKeeper.ParamsStore.Get(ctx) + if err != nil { + return nil, err + } + consensusParams := cmttypes.ConsensusParamsFromProto(paramsProto) + consensusParams.Block.MaxGas = 75_000_000 // The same as Cosmos Hub at the moment + if err := app.ConsensusParamsKeeper.ParamsStore.Set(ctx, consensusParams.ToProto()); err != nil { + return nil, err + } + return app.ModuleManager.InitGenesis(ctx, genesisState) } diff --git a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go index ba5303918c0..05f070929ed 100644 --- a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go +++ b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go @@ -16,6 +16,7 @@ import ( corestore "cosmossdk.io/core/store" "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" + txsigning "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" @@ -27,6 +28,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/snapshot" "github.com/cosmos/cosmos-sdk/codec" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -64,11 +66,17 @@ func NewRootCmd() *cobra.Command { initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). + WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). + WithAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())). + WithValidatorAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix())). + WithConsensusAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix())). WithHomeDir(simapp.DefaultNodeHome). - WithViper("") // In simapp, we don't use any prefix for env variables. + WithViper(""). // uses by default the binary name as prefix + WithAddressPrefix(sdk.GetConfig().GetBech32AccountAddrPrefix()). + WithValidatorPrefix(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) rootCmd := &cobra.Command{ Use: "simd", @@ -96,6 +104,10 @@ func NewRootCmd() *cobra.Command { txConfigOpts := tx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + SigningOptions: &txsigning.Options{ + AddressCodec: initClientCtx.InterfaceRegistry.SigningContext().AddressCodec(), + ValidatorAddressCodec: initClientCtx.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + }, } txConfigWithTextual, err := tx.NewTxConfigWithOptions( codec.NewProtoCodec(encodingConfig.InterfaceRegistry), From b3184b4a93699368c3e5ca98d507b27d4d4a4a9b Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:19:08 +0100 Subject: [PATCH 164/172] Move channel back to counterparty (#7842) * add back client registerCounterparty * change channel to id in packet * fix tests * split messaging key to prefix and clientId * change eureka packet handlers to no longer rely on channel * naming suggestions * fix test file * start to fix tests * fix v2/keeper tests * fix tests * DELETE channel from v2 * rm commented code * move nextSeqSend to a better place * remove resolveV2Identifiers for now * lint * lint * review suggestions * Update cli.go --- .../transfer/v2/keeper/msg_server_test.go | 18 +- modules/core/02-client/keeper/keeper.go | 41 + modules/core/02-client/keeper/keeper_test.go | 19 + modules/core/02-client/types/codec.go | 1 + modules/core/02-client/types/counterparty.go | 9 + .../core/02-client/types/counterparty.pb.go | 902 ++++++ modules/core/02-client/types/errors.go | 2 + modules/core/02-client/types/keys.go | 16 + modules/core/02-client/types/msgs.go | 27 + modules/core/02-client/types/msgs_test.go | 71 + modules/core/04-channel/v2/client/cli/cli.go | 8 +- .../core/04-channel/v2/client/cli/query.go | 142 +- modules/core/04-channel/v2/client/cli/tx.go | 93 - modules/core/04-channel/v2/keeper/events.go | 55 +- .../core/04-channel/v2/keeper/export_test.go | 12 - .../core/04-channel/v2/keeper/grpc_query.go | 146 +- .../04-channel/v2/keeper/grpc_query_test.go | 483 +--- modules/core/04-channel/v2/keeper/keeper.go | 147 +- .../core/04-channel/v2/keeper/keeper_test.go | 122 - .../core/04-channel/v2/keeper/msg_server.go | 86 +- .../04-channel/v2/keeper/msg_server_test.go | 133 +- modules/core/04-channel/v2/keeper/packet.go | 153 +- .../core/04-channel/v2/keeper/packet_test.go | 112 +- modules/core/04-channel/v2/types/channel.go | 51 - .../core/04-channel/v2/types/channel.pb.go | 658 ----- .../core/04-channel/v2/types/channel_test.go | 58 - modules/core/04-channel/v2/types/codec.go | 2 - .../core/04-channel/v2/types/commitment.go | 4 +- .../04-channel/v2/types/commitment_test.go | 12 +- modules/core/04-channel/v2/types/errors.go | 25 +- .../04-channel/v2/types/expected_keepers.go | 2 + modules/core/04-channel/v2/types/genesis.go | 70 +- .../core/04-channel/v2/types/genesis.pb.go | 200 +- .../core/04-channel/v2/types/genesis_test.go | 28 - modules/core/04-channel/v2/types/keys.go | 10 - modules/core/04-channel/v2/types/msgs.go | 65 +- modules/core/04-channel/v2/types/msgs_test.go | 114 +- modules/core/04-channel/v2/types/packet.go | 20 +- modules/core/04-channel/v2/types/packet.pb.go | 120 +- .../core/04-channel/v2/types/packet_test.go | 8 +- modules/core/04-channel/v2/types/query.go | 68 +- modules/core/04-channel/v2/types/query.pb.go | 2421 +++-------------- .../core/04-channel/v2/types/query.pb.gw.go | 487 +--- modules/core/04-channel/v2/types/tx.pb.go | 1181 +------- modules/core/ante/ante_test.go | 6 +- modules/core/internal/v2/telemetry/packet.go | 12 +- modules/core/keeper/msg_server.go | 31 +- modules/core/keeper/msg_server_test.go | 58 + modules/core/module.go | 1 + proto/ibc/core/channel/v2/channel.proto | 37 - proto/ibc/core/channel/v2/genesis.proto | 20 +- proto/ibc/core/channel/v2/packet.proto | 8 +- proto/ibc/core/channel/v2/query.proto | 125 +- proto/ibc/core/channel/v2/tx.proto | 49 +- proto/ibc/core/client/v2/counterparty.proto | 43 + testing/endpoint_v2.go | 32 +- testing/path.go | 15 - 57 files changed, 2434 insertions(+), 6405 deletions(-) create mode 100644 modules/core/02-client/types/counterparty.go create mode 100644 modules/core/02-client/types/counterparty.pb.go delete mode 100644 modules/core/04-channel/v2/client/cli/tx.go delete mode 100644 modules/core/04-channel/v2/types/channel.go delete mode 100644 modules/core/04-channel/v2/types/channel.pb.go delete mode 100644 modules/core/04-channel/v2/types/channel_test.go delete mode 100644 proto/ibc/core/channel/v2/channel.proto create mode 100644 proto/ibc/core/client/v2/counterparty.proto diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go index e12cdf43cb5..b4ab8e61016 100644 --- a/modules/apps/transfer/v2/keeper/msg_server_test.go +++ b/modules/apps/transfer/v2/keeper/msg_server_test.go @@ -265,20 +265,20 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { nil, }, { - "failure: invalid destination channel on received packet", + "failure: invalid destination client on received packet", func() {}, func() { - packet.DestinationChannel = ibctesting.InvalidID + packet.DestinationClient = ibctesting.InvalidID }, - channeltypesv2.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { - "failure: counter party channel does not match source channel", + "failure: counter party client does not match source client", func() {}, func() { - packet.SourceChannel = ibctesting.InvalidID + packet.SourceClient = ibctesting.InvalidID }, - channeltypes.ErrInvalidChannelIdentifier, + clienttypes.ErrInvalidCounterparty, }, { "failure: receive is disabled", @@ -335,7 +335,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { if expPass { suite.Require().NoError(err) - actualAckHash := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + actualAckHash := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) expectedHash := channeltypesv2.CommitAcknowledgement(expectedAck) suite.Require().Equal(expectedHash, actualAckHash) @@ -343,7 +343,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { denom := transfertypes.Denom{ Base: sdk.DefaultBondDenom, Trace: []transfertypes.Hop{ - transfertypes.NewHop(sendPayload.DestinationPort, packet.DestinationChannel), + transfertypes.NewHop(sendPayload.DestinationPort, packet.DestinationClient), }, } @@ -593,7 +593,7 @@ func (suite *KeeperTestSuite) TestV2RetainsFungibility() { denomBtoC := transfertypes.Denom{ Base: sdk.DefaultBondDenom, Trace: []transfertypes.Hop{ - transfertypes.NewHop(transfertypes.ModuleName, pathv2.EndpointB.ChannelID), + transfertypes.NewHop(transfertypes.ModuleName, pathv2.EndpointB.ClientID), transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), }, } diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 4275ae4048b..e618a54913f 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -115,6 +115,47 @@ func (k *Keeper) SetClientState(ctx context.Context, clientID string, clientStat store.Set(host.ClientStateKey(), types.MustMarshalClientState(k.cdc, clientState)) } +// GetClientCreator returns the creator of a client +func (k *Keeper) GetClientCreator(ctx context.Context, clientID string) sdk.AccAddress { + store := k.ClientStore(ctx, clientID) + bz := store.Get(types.CreatorKey()) + if len(bz) == 0 { + return nil + } + return sdk.AccAddress(bz) +} + +// SetClientCreator sets the creator of a client +func (k *Keeper) SetClientCreator(ctx context.Context, clientID string, creator sdk.AccAddress) { + store := k.ClientStore(ctx, clientID) + store.Set(types.CreatorKey(), creator.Bytes()) +} + +// DeleteClientCreator deletes the creator of a client +func (k *Keeper) DeleteClientCreator(ctx context.Context, clientID string) { + store := k.ClientStore(ctx, clientID) + store.Delete(types.CreatorKey()) +} + +// SetClientCounterparty sets counterpartyInfo for a given clientID +func (k *Keeper) SetClientCounterparty(ctx context.Context, clientID string, counterparty types.CounterpartyInfo) { + store := k.ClientStore(ctx, clientID) + store.Set(types.CounterpartyKey(), k.cdc.MustMarshal(&counterparty)) +} + +// GetClientCounterparty gets counterpartyInfo for a given clientID +func (k *Keeper) GetClientCounterparty(ctx context.Context, clientID string) (types.CounterpartyInfo, bool) { + store := k.ClientStore(ctx, clientID) + bz := store.Get(types.CounterpartyKey()) + if len(bz) == 0 { + return types.CounterpartyInfo{}, false + } + + var counterparty types.CounterpartyInfo + k.cdc.MustUnmarshal(bz, &counterparty) + return counterparty, true +} + // GetClientConsensusState gets the stored consensus state from a client at a given height. func (k *Keeper) GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) { store := k.ClientStore(ctx, clientID) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 2e9dbe09fbc..4d9e025e990 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -127,6 +127,25 @@ func (suite *KeeperTestSuite) TestSetClientState() { suite.Require().Equal(clientState, retrievedState, "Client states are not equal") } +func (suite *KeeperTestSuite) TestSetClientCreator() { + creator := suite.chainA.SenderAccount.GetAddress() + suite.keeper.SetClientCreator(suite.ctx, testClientID, creator) + getCreator := suite.keeper.GetClientCreator(suite.ctx, testClientID) + suite.Require().Equal(creator, getCreator) + suite.keeper.DeleteClientCreator(suite.ctx, testClientID) + getCreator = suite.keeper.GetClientCreator(suite.ctx, testClientID) + suite.Require().Equal(sdk.AccAddress(nil), getCreator) +} + +func (suite *KeeperTestSuite) TestSetClientCounterparty() { + counterparty := types.NewCounterpartyInfo([][]byte{[]byte("ibc"), []byte("channel-7")}, testClientID2) + suite.keeper.SetClientCounterparty(suite.ctx, testClientID, counterparty) + + retrievedCounterparty, found := suite.keeper.GetClientCounterparty(suite.ctx, testClientID) + suite.Require().True(found, "GetCounterparty failed") + suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparties are not equal") +} + func (suite *KeeperTestSuite) TestSetClientConsensusState() { suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index b39023a3bba..48a1b782f7c 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -47,6 +47,7 @@ func RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { &MsgRecoverClient{}, &MsgIBCSoftwareUpgrade{}, &MsgUpdateParams{}, + &MsgRegisterCounterparty{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/counterparty.go b/modules/core/02-client/types/counterparty.go new file mode 100644 index 00000000000..b057a590002 --- /dev/null +++ b/modules/core/02-client/types/counterparty.go @@ -0,0 +1,9 @@ +package types + +// NewCounterpartyInfo creates a new counterparty info instance from merlePrefix and clientID +func NewCounterpartyInfo(merklePrefix [][]byte, clientID string) CounterpartyInfo { + return CounterpartyInfo{ + MerklePrefix: merklePrefix, + ClientId: clientID, + } +} diff --git a/modules/core/02-client/types/counterparty.pb.go b/modules/core/02-client/types/counterparty.pb.go new file mode 100644 index 00000000000..f20ce5e466e --- /dev/null +++ b/modules/core/02-client/types/counterparty.pb.go @@ -0,0 +1,902 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/client/v2/counterparty.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// CounterpartyInfo defines the key that the counterparty will use to message our client +type CounterpartyInfo struct { + // merkle prefix key is the prefix that ics provable keys are stored under + MerklePrefix [][]byte `protobuf:"bytes,1,rep,name=merkle_prefix,json=merklePrefix,proto3" json:"merkle_prefix,omitempty"` + // client identifier is the identifier used to send packet messages to our client + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *CounterpartyInfo) Reset() { *m = CounterpartyInfo{} } +func (m *CounterpartyInfo) String() string { return proto.CompactTextString(m) } +func (*CounterpartyInfo) ProtoMessage() {} +func (*CounterpartyInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bc4a81c3d2196cf1, []int{0} +} +func (m *CounterpartyInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CounterpartyInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CounterpartyInfo.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 *CounterpartyInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_CounterpartyInfo.Merge(m, src) +} +func (m *CounterpartyInfo) XXX_Size() int { + return m.Size() +} +func (m *CounterpartyInfo) XXX_DiscardUnknown() { + xxx_messageInfo_CounterpartyInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_CounterpartyInfo proto.InternalMessageInfo + +func (m *CounterpartyInfo) GetMerklePrefix() [][]byte { + if m != nil { + return m.MerklePrefix + } + return nil +} + +func (m *CounterpartyInfo) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +// MsgRegisterCounterparty defines a message to register a counterparty on a client +type MsgRegisterCounterparty struct { + // client identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // counterparty merkle prefix + CounterpartyMerklePrefix [][]byte `protobuf:"bytes,2,rep,name=counterparty_merkle_prefix,json=counterpartyMerklePrefix,proto3" json:"counterparty_merkle_prefix,omitempty"` + // counterparty client identifier + CounterpartyClientId string `protobuf:"bytes,3,opt,name=counterparty_client_id,json=counterpartyClientId,proto3" json:"counterparty_client_id,omitempty"` + // signer address + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgRegisterCounterparty) Reset() { *m = MsgRegisterCounterparty{} } +func (m *MsgRegisterCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterparty) ProtoMessage() {} +func (*MsgRegisterCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_bc4a81c3d2196cf1, []int{1} +} +func (m *MsgRegisterCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCounterparty.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 *MsgRegisterCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterparty.Merge(m, src) +} +func (m *MsgRegisterCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCounterparty proto.InternalMessageInfo + +// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. +type MsgRegisterCounterpartyResponse struct { +} + +func (m *MsgRegisterCounterpartyResponse) Reset() { *m = MsgRegisterCounterpartyResponse{} } +func (m *MsgRegisterCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterpartyResponse) ProtoMessage() {} +func (*MsgRegisterCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bc4a81c3d2196cf1, []int{2} +} +func (m *MsgRegisterCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCounterpartyResponse.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 *MsgRegisterCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterpartyResponse.Merge(m, src) +} +func (m *MsgRegisterCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCounterpartyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*CounterpartyInfo)(nil), "ibc.core.client.v2.CounterpartyInfo") + proto.RegisterType((*MsgRegisterCounterparty)(nil), "ibc.core.client.v2.MsgRegisterCounterparty") + proto.RegisterType((*MsgRegisterCounterpartyResponse)(nil), "ibc.core.client.v2.MsgRegisterCounterpartyResponse") +} + +func init() { + proto.RegisterFile("ibc/core/client/v2/counterparty.proto", fileDescriptor_bc4a81c3d2196cf1) +} + +var fileDescriptor_bc4a81c3d2196cf1 = []byte{ + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd2, 0x4f, + 0xce, 0x2f, 0xcd, 0x2b, 0x49, 0x2d, 0x2a, 0x48, 0x2c, 0x2a, 0xa9, 0xd4, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0xca, 0x4c, 0x4a, 0xd6, 0x03, 0x29, 0xd3, 0x83, 0x28, 0xd3, 0x2b, 0x33, 0x92, + 0x12, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0xcf, 0x2d, 0x4e, 0xd7, 0x2f, 0x33, 0x04, 0x51, + 0x10, 0xc5, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x11, 0x55, 0x0a, + 0xe1, 0x12, 0x70, 0x46, 0x32, 0xd8, 0x33, 0x2f, 0x2d, 0x5f, 0x48, 0x99, 0x8b, 0x37, 0x37, 0xb5, + 0x28, 0x3b, 0x27, 0x35, 0xbe, 0xa0, 0x28, 0x35, 0x2d, 0xb3, 0x42, 0x82, 0x51, 0x81, 0x59, 0x83, + 0x27, 0x88, 0x07, 0x22, 0x18, 0x00, 0x16, 0x13, 0x92, 0xe6, 0xe2, 0x84, 0x58, 0x1a, 0x9f, 0x99, + 0x22, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x19, 0xc4, 0x01, 0x11, 0xf0, 0x4c, 0x51, 0xba, 0xcc, 0xc8, + 0x25, 0xee, 0x5b, 0x9c, 0x1e, 0x94, 0x9a, 0x9e, 0x59, 0x5c, 0x92, 0x5a, 0x84, 0x6c, 0x03, 0xaa, + 0x46, 0x46, 0x54, 0x8d, 0x42, 0x36, 0x5c, 0x52, 0xc8, 0xfe, 0x8c, 0x47, 0x75, 0x07, 0x13, 0xd8, + 0x1d, 0x12, 0xc8, 0x2a, 0x7c, 0x91, 0xdd, 0x64, 0xc2, 0x25, 0x86, 0xa2, 0x1b, 0x61, 0x0f, 0x33, + 0xd8, 0x1e, 0x11, 0x64, 0x59, 0x67, 0x98, 0x9d, 0x62, 0x5c, 0x6c, 0xc5, 0x99, 0xe9, 0x79, 0xa9, + 0x45, 0x12, 0x2c, 0x60, 0x55, 0x50, 0x9e, 0x15, 0x7f, 0xc7, 0x02, 0x79, 0x86, 0xa6, 0xe7, 0x1b, + 0xb4, 0xa0, 0x02, 0x4a, 0x8a, 0x5c, 0xf2, 0x38, 0x3c, 0x15, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, + 0x9c, 0x6a, 0x34, 0x89, 0x91, 0x8b, 0x1f, 0x59, 0xc2, 0xb7, 0x38, 0x5d, 0xa8, 0x82, 0x4b, 0x04, + 0x6b, 0x40, 0x68, 0xeb, 0x61, 0x46, 0x9f, 0x1e, 0x0e, 0x0b, 0xa4, 0x8c, 0x49, 0x50, 0x0c, 0x73, + 0x8d, 0x14, 0x6b, 0xc3, 0xf3, 0x0d, 0x5a, 0x8c, 0x4e, 0x41, 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, 0x65, 0x91, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, + 0x0f, 0x4d, 0x37, 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, + 0xa5, 0x39, 0xa9, 0xc5, 0x90, 0x74, 0x68, 0x60, 0xa4, 0x0b, 0x4d, 0x8a, 0x25, 0x95, 0x05, 0xa9, + 0xc5, 0x49, 0x6c, 0xe0, 0xe4, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xda, 0x00, 0x13, 0xe2, + 0xaa, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// CounterpartyMsgClient is the client API for CounterpartyMsg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type CounterpartyMsgClient interface { + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) +} + +type counterpartyMsgClient struct { + cc grpc1.ClientConn +} + +func NewCounterpartyMsgClient(cc grpc1.ClientConn) CounterpartyMsgClient { + return &counterpartyMsgClient{cc} +} + +func (c *counterpartyMsgClient) RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) { + out := new(MsgRegisterCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v2.CounterpartyMsg/RegisterCounterparty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CounterpartyMsgServer is the server API for CounterpartyMsg service. +type CounterpartyMsgServer interface { + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + RegisterCounterparty(context.Context, *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) +} + +// UnimplementedCounterpartyMsgServer can be embedded to have forward compatible implementations. +type UnimplementedCounterpartyMsgServer struct { +} + +func (*UnimplementedCounterpartyMsgServer) RegisterCounterparty(ctx context.Context, req *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterparty not implemented") +} + +func RegisterCounterpartyMsgServer(s grpc1.Server, srv CounterpartyMsgServer) { + s.RegisterService(&_CounterpartyMsg_serviceDesc, srv) +} + +func _CounterpartyMsg_RegisterCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterCounterparty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CounterpartyMsgServer).RegisterCounterparty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v2.CounterpartyMsg/RegisterCounterparty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CounterpartyMsgServer).RegisterCounterparty(ctx, req.(*MsgRegisterCounterparty)) + } + return interceptor(ctx, in, info, handler) +} + +var _CounterpartyMsg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.client.v2.CounterpartyMsg", + HandlerType: (*CounterpartyMsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterCounterparty", + Handler: _CounterpartyMsg_RegisterCounterparty_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/client/v2/counterparty.proto", +} + +func (m *CounterpartyInfo) 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 *CounterpartyInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CounterpartyInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0x12 + } + if len(m.MerklePrefix) > 0 { + for iNdEx := len(m.MerklePrefix) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MerklePrefix[iNdEx]) + copy(dAtA[i:], m.MerklePrefix[iNdEx]) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.MerklePrefix[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterCounterparty) 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 *MsgRegisterCounterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCounterparty) 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 = encodeVarintCounterparty(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.CounterpartyClientId) > 0 { + i -= len(m.CounterpartyClientId) + copy(dAtA[i:], m.CounterpartyClientId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyClientId))) + i-- + dAtA[i] = 0x1a + } + if len(m.CounterpartyMerklePrefix) > 0 { + for iNdEx := len(m.CounterpartyMerklePrefix) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.CounterpartyMerklePrefix[iNdEx]) + copy(dAtA[i:], m.CounterpartyMerklePrefix[iNdEx]) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyMerklePrefix[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterCounterpartyResponse) 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 *MsgRegisterCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { + offset -= sovCounterparty(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CounterpartyInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.MerklePrefix) > 0 { + for _, b := range m.MerklePrefix { + l = len(b) + n += 1 + l + sovCounterparty(uint64(l)) + } + } + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + return n +} + +func (m *MsgRegisterCounterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + if len(m.CounterpartyMerklePrefix) > 0 { + for _, b := range m.CounterpartyMerklePrefix { + l = len(b) + n += 1 + l + sovCounterparty(uint64(l)) + } + } + l = len(m.CounterpartyClientId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + return n +} + +func (m *MsgRegisterCounterpartyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovCounterparty(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCounterparty(x uint64) (n int) { + return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CounterpartyInfo) 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 ErrIntOverflowCounterparty + } + 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: CounterpartyInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CounterpartyInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MerklePrefix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MerklePrefix = append(m.MerklePrefix, make([]byte, postIndex-iNdEx)) + copy(m.MerklePrefix[len(m.MerklePrefix)-1], 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 ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterCounterparty) 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 ErrIntOverflowCounterparty + } + 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: MsgRegisterCounterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterCounterparty: 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 ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + 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 CounterpartyMerklePrefix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyMerklePrefix = append(m.CounterpartyMerklePrefix, make([]byte, postIndex-iNdEx)) + copy(m.CounterpartyMerklePrefix[len(m.CounterpartyMerklePrefix)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterCounterpartyResponse) 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 ErrIntOverflowCounterparty + } + 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: MsgRegisterCounterpartyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCounterparty(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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrIntOverflowCounterparty + } + 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, ErrInvalidLengthCounterparty + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCounterparty + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCounterparty + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index 62d906bc40c..f663019ab0f 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -38,4 +38,6 @@ var ( ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty") + ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 35, "counterparty not found") ) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index 76ce77f08c7..d0ea7ca9c7f 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -29,6 +29,12 @@ const ( // ParamsKey is the store key for the IBC client parameters ParamsKey = "clientParams" + // KeyCreator is the key for the creator in the client-specific store + KeyCreator = "creator" + + // KeyCounterparty is the key for the counterpartyInfo in the client-specific store + KeyCounterparty = "counterparty" + // AllowAllClients is the value that if set in AllowedClients param // would allow any wired up light client modules to be allowed AllowAllClients = "*" @@ -91,3 +97,13 @@ func MustParseClientIdentifier(clientID string) string { return clientType } + +// CreatorKey returns the key under which the client creator is stored in the client store +func CreatorKey() []byte { + return []byte(KeyCreator) +} + +// CounterpartyKey returns the key under which the counterparty is stored in the client store +func CounterpartyKey() []byte { + return []byte(KeyCounterparty) +} diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index a520a46ab7c..81fd0c21cac 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -22,6 +22,8 @@ var ( _ sdk.Msg = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.Msg = (*MsgRecoverClient)(nil) + _ sdk.Msg = (*MsgRegisterCounterparty)(nil) + _ sdk.HasValidateBasic = (*MsgCreateClient)(nil) _ sdk.HasValidateBasic = (*MsgUpdateClient)(nil) _ sdk.HasValidateBasic = (*MsgSubmitMisbehaviour)(nil) @@ -29,6 +31,7 @@ var ( _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.HasValidateBasic = (*MsgRecoverClient)(nil) + _ sdk.HasValidateBasic = (*MsgRegisterCounterparty)(nil) _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ gogoprotoany.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -320,3 +323,27 @@ func (msg *MsgUpdateParams) ValidateBasic() error { } return msg.Params.Validate() } + +// NewMsgRegisterCounterparty creates a new instance of MsgRegisterCounterparty. +func NewMsgRegisterCounterparty(clientID string, merklePrefix [][]byte, counterpartyClientID string, signer string) *MsgRegisterCounterparty { + return &MsgRegisterCounterparty{ + ClientId: clientID, + CounterpartyMerklePrefix: merklePrefix, + CounterpartyClientId: counterpartyClientID, + Signer: signer, + } +} + +// ValidateBasic performs basic checks on a MsgRegisterCounterparty. +func (msg *MsgRegisterCounterparty) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + if len(msg.CounterpartyMerklePrefix) == 0 { + return errorsmod.Wrap(ErrInvalidCounterparty, "counterparty messaging key cannot be empty") + } + if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + return err + } + return host.ClientIdentifierValidator(msg.CounterpartyClientId) +} diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 112b7beb211..ca51a240f37 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -981,3 +981,74 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } } } + +func TestMsgRegisterCounterpartyValidateBasic(t *testing.T) { + signer := ibctesting.TestAccAddress + testCases := []struct { + name string + msg *types.MsgRegisterCounterparty + expError error + }{ + { + "success", + types.NewMsgRegisterCounterparty( + "testclientid", + [][]byte{[]byte("ibc"), []byte("channel-9")}, + "testclientid3", + signer, + ), + nil, + }, + { + "failure: empty client id", + types.NewMsgRegisterCounterparty( + "", + [][]byte{[]byte("ibc"), []byte("channel-9")}, + "testclientid3", + signer, + ), + host.ErrInvalidID, + }, + { + "failure: empty counterparty client id", + types.NewMsgRegisterCounterparty( + "testclientid", + [][]byte{[]byte("ibc"), []byte("channel-9")}, + "", + signer, + ), + host.ErrInvalidID, + }, + { + "failure: empty counterparty messaging key", + types.NewMsgRegisterCounterparty( + "testclientid", + [][]byte{}, + "testclientid3", + signer, + ), + types.ErrInvalidCounterparty, + }, + { + "failure: empty signer", + types.NewMsgRegisterCounterparty( + "testclientid", + [][]byte{[]byte("ibc"), []byte("channel-9")}, + "testclientid3", + "badsigner", + ), + ibcerrors.ErrInvalidAddress, + }, + } + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.expError == nil { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, tc.expError) + } + }) + } +} diff --git a/modules/core/04-channel/v2/client/cli/cli.go b/modules/core/04-channel/v2/client/cli/cli.go index 5fdde6a87dc..cf8f883f46d 100644 --- a/modules/core/04-channel/v2/client/cli/cli.go +++ b/modules/core/04-channel/v2/client/cli/cli.go @@ -19,8 +19,6 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( - getCmdQueryChannel(), - getCmdQueryChannelClientState(), getCmdQueryNextSequenceSend(), getCmdQueryPacketCommitment(), getCmdQueryPacketCommitments(), @@ -43,10 +41,8 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand( - newCreateChannelTxCmd(), - newRegisterCounterpartyTxCmd(), - ) + // TODO: Add v2 packet commands: https://github.com/cosmos/ibc-go/issues/7853 + txCmd.AddCommand() return txCmd } diff --git a/modules/core/04-channel/v2/client/cli/query.go b/modules/core/04-channel/v2/client/cli/query.go index 04f9f91e5c7..0f7949d3504 100644 --- a/modules/core/04-channel/v2/client/cli/query.go +++ b/modules/core/04-channel/v2/client/cli/query.go @@ -18,76 +18,14 @@ const ( flagSequences = "sequences" ) -// getCmdQueryChannel defines the command to query the channel information (creator and channel) for the given channel ID. -func getCmdQueryChannel() *cobra.Command { - cmd := &cobra.Command{ - Use: "channel [channel-id]", - Short: "Query the information of a channel.", - Long: "Query the channel information for the provided channel ID.", - Example: fmt.Sprintf("%s query %s %s channel [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - channelID := args[0] - - queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.Channel(cmd.Context(), types.NewQueryChannelRequest(channelID)) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// getCmdQueryChannelClientState defines the command to query the channel client state for the given channel ID. -func getCmdQueryChannelClientState() *cobra.Command { - cmd := &cobra.Command{ - Use: "client-state [channel-id]", - Short: "Query the client state associated with a channel.", - Long: "Query the client state associated with a channel for the provided channel ID.", - Example: fmt.Sprintf("%s query %s %s client-state [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - channelID := args[0] - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.ChannelClientState(cmd.Context(), types.NewQueryChannelClientStateRequest(channelID)) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// getCmdQueryNextSequenceSend defines the command to query a next send sequence for a given channel +// getCmdQueryNextSequenceSend defines the command to query a next send sequence for a given client func getCmdQueryNextSequenceSend() *cobra.Command { cmd := &cobra.Command{ - Use: "next-sequence-send [channel-id]", + Use: "next-sequence-send [client-id]", Short: "Query a next send sequence", - Long: "Query the next sequence send for a given channel", + Long: "Query the next sequence send for a given client", Example: fmt.Sprintf( - "%s query %s %s next-sequence-send [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName, + "%s query %s %s next-sequence-send [client-id]", version.AppName, exported.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -95,14 +33,14 @@ func getCmdQueryNextSequenceSend() *cobra.Command { if err != nil { return err } - channelID := args[0] + clientID := args[0] prove, err := cmd.Flags().GetBool(flags.FlagProve) if err != nil { return err } if prove { - res, err := queryNextSequenceSendABCI(clientCtx, channelID) + res, err := queryNextSequenceSendABCI(clientCtx, clientID) if err != nil { return err } @@ -111,7 +49,7 @@ func getCmdQueryNextSequenceSend() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.NextSequenceSend(cmd.Context(), types.NewQueryNextSequenceSendRequest(channelID)) + res, err := queryClient.NextSequenceSend(cmd.Context(), types.NewQueryNextSequenceSendRequest(clientID)) if err != nil { return err } @@ -128,11 +66,11 @@ func getCmdQueryNextSequenceSend() *cobra.Command { func getCmdQueryPacketCommitment() *cobra.Command { cmd := &cobra.Command{ - Use: "packet-commitment [channel-id] [sequence]", + Use: "packet-commitment [client-id] [sequence]", Short: "Query a channel/v2 packet commitment", - Long: "Query a channel/v2 packet commitment by channel-id and sequence", + Long: "Query a channel/v2 packet commitment by client-id and sequence", Example: fmt.Sprintf( - "%s query %s %s packet-commitment [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + "%s query %s %s packet-commitment [client-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -141,7 +79,7 @@ func getCmdQueryPacketCommitment() *cobra.Command { return err } - channelID := args[0] + clientID := args[0] seq, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err @@ -153,7 +91,7 @@ func getCmdQueryPacketCommitment() *cobra.Command { } if prove { - res, err := queryPacketCommitmentABCI(clientCtx, channelID, seq) + res, err := queryPacketCommitmentABCI(clientCtx, clientID, seq) if err != nil { return err } @@ -162,7 +100,7 @@ func getCmdQueryPacketCommitment() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.PacketCommitment(cmd.Context(), types.NewQueryPacketCommitmentRequest(channelID, seq)) + res, err := queryClient.PacketCommitment(cmd.Context(), types.NewQueryPacketCommitmentRequest(clientID, seq)) if err != nil { return err } @@ -179,10 +117,10 @@ func getCmdQueryPacketCommitment() *cobra.Command { func getCmdQueryPacketCommitments() *cobra.Command { cmd := &cobra.Command{ - Use: "packet-commitments [channel-id]", - Short: "Query all packet commitments associated with a channel", - Long: "Query all packet commitments associated with a channel", - Example: fmt.Sprintf("%s query %s %s packet-commitments [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName), + Use: "packet-commitments [client-id]", + Short: "Query all packet commitments associated with a client", + Long: "Query all packet commitments associated with a client", + Example: fmt.Sprintf("%s query %s %s packet-commitments [client-id]", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -197,7 +135,7 @@ func getCmdQueryPacketCommitments() *cobra.Command { } req := &types.QueryPacketCommitmentsRequest{ - ChannelId: args[0], + ClientId: args[0], Pagination: pageReq, } @@ -211,18 +149,18 @@ func getCmdQueryPacketCommitments() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "packet commitments associated with a channel") + flags.AddPaginationFlagsToCmd(cmd, "packet commitments associated with a client") return cmd } func getCmdQueryPacketAcknowledgement() *cobra.Command { cmd := &cobra.Command{ - Use: "packet-acknowledgement [channel-id] [sequence]", + Use: "packet-acknowledgement [client-id] [sequence]", Short: "Query a channel/v2 packet acknowledgement", - Long: "Query a channel/v2 packet acknowledgement by channel-id and sequence", + Long: "Query a channel/v2 packet acknowledgement by client-id and sequence", Example: fmt.Sprintf( - "%s query %s %s packet-acknowledgement [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + "%s query %s %s packet-acknowledgement [client-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -231,7 +169,7 @@ func getCmdQueryPacketAcknowledgement() *cobra.Command { return err } - channelID := args[0] + clientID := args[0] seq, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err @@ -243,7 +181,7 @@ func getCmdQueryPacketAcknowledgement() *cobra.Command { } if prove { - res, err := queryPacketAcknowledgementABCI(clientCtx, channelID, seq) + res, err := queryPacketAcknowledgementABCI(clientCtx, clientID, seq) if err != nil { return err } @@ -252,7 +190,7 @@ func getCmdQueryPacketAcknowledgement() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.PacketAcknowledgement(cmd.Context(), types.NewQueryPacketAcknowledgementRequest(channelID, seq)) + res, err := queryClient.PacketAcknowledgement(cmd.Context(), types.NewQueryPacketAcknowledgementRequest(clientID, seq)) if err != nil { return err } @@ -269,11 +207,11 @@ func getCmdQueryPacketAcknowledgement() *cobra.Command { func getCmdQueryPacketReceipt() *cobra.Command { cmd := &cobra.Command{ - Use: "packet-receipt [channel-id] [sequence]", + Use: "packet-receipt [client-id] [sequence]", Short: "Query a channel/v2 packet receipt", - Long: "Query a channel/v2 packet receipt by channel-id and sequence", + Long: "Query a channel/v2 packet receipt by client-id and sequence", Example: fmt.Sprintf( - "%s query %s %s packet-receipt [channel-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, + "%s query %s %s packet-receipt [client-id] [sequence]", version.AppName, exported.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -282,7 +220,7 @@ func getCmdQueryPacketReceipt() *cobra.Command { return err } - channelID := args[0] + clientID := args[0] seq, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err @@ -294,7 +232,7 @@ func getCmdQueryPacketReceipt() *cobra.Command { } if prove { - res, err := queryPacketReceiptABCI(clientCtx, channelID, seq) + res, err := queryPacketReceiptABCI(clientCtx, clientID, seq) if err != nil { return err } @@ -303,7 +241,7 @@ func getCmdQueryPacketReceipt() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.PacketReceipt(cmd.Context(), types.NewQueryPacketReceiptRequest(channelID, seq)) + res, err := queryClient.PacketReceipt(cmd.Context(), types.NewQueryPacketReceiptRequest(clientID, seq)) if err != nil { return err } @@ -322,11 +260,11 @@ func getCmdQueryPacketReceipt() *cobra.Command { // packets on the receiving chain func getCmdQueryUnreceivedPackets() *cobra.Command { cmd := &cobra.Command{ - Use: "unreceived-packets [channel-id]", + Use: "unreceived-packets [client-id]", Short: "Query a channel/v2 unreceived-packets", - Long: "Query a channel/v2 unreceived-packets by channel-id and sequences", + Long: "Query a channel/v2 unreceived-packets by client-id and sequences", Example: fmt.Sprintf( - "%s query %s %s unreceived-packet [channel-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName, + "%s query %s %s unreceived-packet [client-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -335,7 +273,7 @@ func getCmdQueryUnreceivedPackets() *cobra.Command { return err } - channelID := args[0] + clientID := args[0] seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences) if err != nil { return err @@ -347,7 +285,7 @@ func getCmdQueryUnreceivedPackets() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.UnreceivedPackets(cmd.Context(), types.NewQueryUnreceivedPacketsRequest(channelID, seqs)) + res, err := queryClient.UnreceivedPackets(cmd.Context(), types.NewQueryUnreceivedPacketsRequest(clientID, seqs)) if err != nil { return err } @@ -365,14 +303,14 @@ func getCmdQueryUnreceivedPackets() *cobra.Command { // getCmdQueryUnreceivedAcks defines the command to query all the unreceived acks on the original sending chain func getCmdQueryUnreceivedAcks() *cobra.Command { cmd := &cobra.Command{ - Use: "unreceived-acks [channel-id]", - Short: "Query all the unreceived acks associated with a channel", + Use: "unreceived-acks [client-id]", + Short: "Query all the unreceived acks associated with a client", Long: `Given a list of acknowledgement sequences from counterparty, determine if an ack on the counterparty chain has been received on the executing chain. The return value represents: - Unreceived packet acknowledgement: packet commitment exists on original sending (executing) chain and ack exists on receiving chain. `, - Example: fmt.Sprintf("%s query %s %s unreceived-acks [channel-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName), + Example: fmt.Sprintf("%s query %s %s unreceived-acks [client-id] --sequences=1,2,3", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -392,7 +330,7 @@ The return value represents: } req := &types.QueryUnreceivedAcksRequest{ - ChannelId: args[0], + ClientId: args[0], PacketAckSequences: seqs, } diff --git a/modules/core/04-channel/v2/client/cli/tx.go b/modules/core/04-channel/v2/client/cli/tx.go deleted file mode 100644 index 6849a1476a9..00000000000 --- a/modules/core/04-channel/v2/client/cli/tx.go +++ /dev/null @@ -1,93 +0,0 @@ -package cli - -import ( - "encoding/hex" - "fmt" - "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/version" - - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - "github.com/cosmos/ibc-go/v9/modules/core/exported" -) - -// newCreateChannelTxCmd defines the command to create an IBC channel/v2. -func newCreateChannelTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "create-channel [client-identifier] [merkle-path-prefix]", - Args: cobra.ExactArgs(2), - Short: "create an IBC channel/v2", - Long: `Creates an IBC channel/v2 using the client identifier representing the counterparty chain and the hex-encoded merkle path prefix under which the counterparty stores packet flow information.`, - Example: fmt.Sprintf("%s tx %s %s create-channel 07-tendermint-0 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - clientID := args[0] - merklePathPrefix, err := parseMerklePathPrefix(args[2]) - if err != nil { - return err - } - - msg := types.NewMsgCreateChannel(clientID, merklePathPrefix, clientCtx.GetFromAddress().String()) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// newRegisterCounterpartyCmd defines the command to provide the counterparty channel identifier to an IBC channel. -func newRegisterCounterpartyTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-counterparty [channel-identifier] [counterparty-channel-identifier]", - Args: cobra.ExactArgs(2), - Short: "Register the counterparty channel identifier for an IBC channel", - Long: `Register the counterparty channel identifier for an IBC channel specified by its channel ID.`, - Example: fmt.Sprintf("%s tx %s %s register-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - channelID := args[0] - counterpartyChannelID := args[1] - - msg := types.MsgRegisterCounterparty{ - ChannelId: channelID, - CounterpartyChannelId: counterpartyChannelID, - Signer: clientCtx.GetFromAddress().String(), - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. -func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { - var keyPath [][]byte - hexPrefixes := strings.Split(merklePathPrefixString, ",") - for _, hexPrefix := range hexPrefixes { - prefix, err := hex.DecodeString(hexPrefix) - if err != nil { - return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) - } - keyPath = append(keyPath, prefix) - } - - return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil -} diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index eb1a71b5481..33b3f3bc275 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -24,8 +24,8 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSendPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -49,8 +49,8 @@ func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -79,8 +79,8 @@ func emitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeWriteAck, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -105,8 +105,8 @@ func emitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcknowledgePacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -130,8 +130,8 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel), + sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -142,38 +142,3 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { ), }) } - -// emitCreateChannelEvent emits a channel create event. -func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeCreateChannel, - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// emitRegisterCounterpartyEvent emits a register counterparty event. -func (*Keeper) emitRegisterCounterpartyEvent(ctx context.Context, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRegisterCounterparty, - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyClientID, channel.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyChannelID, channel.CounterpartyChannelId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index 002bc6d8d41..aae6048ed2a 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -7,17 +7,10 @@ package keeper import ( "context" - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// ChannelStore is a wrapper around channelStore to allow its usage during testing. -func (k Keeper) ChannelStore(ctx context.Context) storetypes.KVStore { - return k.channelStore(ctx) -} - func (k *Keeper) SendPacketTest( ctx context.Context, sourceChannel string, @@ -75,8 +68,3 @@ func (k *Keeper) TimeoutPacketTest( proofHeight, ) } - -// AliasV1Channel is a wrapper around aliasV1Channel to allow its usage in tests. -func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { - return k.aliasV1Channel(ctx, portID, channelID) -} diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 709781e4a4d..0eea059e9ca 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -34,97 +34,21 @@ func NewQueryServer(k *Keeper) types.QueryServer { } } -// Channel implements the Query/Channel gRPC method -func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - channel, found := q.GetChannel(ctx, req.ChannelId) - if !found { - return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) - } - - return types.NewQueryChannelResponse(channel), nil -} - -// ChannelClientState implements the Query/ChannelClientState gRPC method -func (q *queryServer) ChannelClientState(ctx context.Context, req *types.QueryChannelClientStateRequest) (*types.QueryChannelClientStateResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - channel, found := q.GetChannel(ctx, req.ChannelId) - if !found { - return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) - } - - clientState, found := q.ClientKeeper.GetClientState(ctx, channel.ClientId) - if !found { - return nil, status.Error(codes.NotFound, errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client-id: %s", channel.ClientId).Error()) - } - - identifiedClientState := clienttypes.NewIdentifiedClientState(channel.ClientId, clientState) - res := types.NewQueryChannelClientStateResponse(identifiedClientState, nil, clienttypes.GetSelfHeight(ctx)) - - return res, nil -} - -// ChannelConsensusState implements the Query/ChannelConsensusState gRPC method -func (q *queryServer) ChannelConsensusState(ctx context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - channel, found := q.GetChannel(ctx, req.ChannelId) - if !found { - return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) - } - - consHeight := clienttypes.NewHeight(req.RevisionNumber, req.RevisionHeight) - consensusState, found := q.ClientKeeper.GetClientConsensusState(ctx, channel.ClientId, consHeight) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "client-id: %s", channel.ClientId).Error(), - ) - } - - anyConsensusState, err := clienttypes.PackConsensusState(consensusState) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return types.NewQueryChannelConsensusStateResponse(channel.ClientId, anyConsensusState, nil, clienttypes.GetSelfHeight(ctx)), nil -} - // NextSequenceSend implements the Query/NextSequenceSend gRPC method func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - sequence, found := q.GetNextSequenceSend(ctx, req.ChannelId) + sequence, found := q.GetNextSequenceSend(ctx, req.ClientId) if !found { return nil, status.Error( codes.NotFound, - errorsmod.Wrapf(types.ErrSequenceSendNotFound, "channel-id %s", req.ChannelId).Error(), + errorsmod.Wrapf(types.ErrSequenceSendNotFound, "client-id %s", req.ClientId).Error(), ) } return types.NewQueryNextSequenceSendResponse(sequence, nil, clienttypes.GetSelfHeight(ctx)), nil @@ -136,7 +60,7 @@ func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPack return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -144,11 +68,7 @@ func (q *queryServer) PacketCommitment(ctx context.Context, req *types.QueryPack return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - - commitment := q.GetPacketCommitment(ctx, req.ChannelId, req.Sequence) + commitment := q.GetPacketCommitment(ctx, req.ClientId, req.Sequence) if len(commitment) == 0 { return nil, status.Error(codes.NotFound, "packet commitment hash not found") } @@ -162,16 +82,12 @@ func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPac return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - var commitments []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), hostv2.PacketCommitmentPrefixKey(req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), hostv2.PacketCommitmentPrefixKey(req.ClientId)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { keySplit := strings.Split(string(key), "/") @@ -181,7 +97,7 @@ func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPac return types.ErrInvalidPacket } - commitment := types.NewPacketState(req.ChannelId, sequence, value) + commitment := types.NewPacketState(req.ClientId, sequence, value) commitments = append(commitments, &commitment) return nil }) @@ -203,7 +119,7 @@ func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.Quer return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -211,11 +127,7 @@ func (q *queryServer) PacketAcknowledgement(ctx context.Context, req *types.Quer return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - - acknowledgement := q.GetPacketAcknowledgement(ctx, req.ChannelId, req.Sequence) + acknowledgement := q.GetPacketAcknowledgement(ctx, req.ClientId, req.Sequence) if len(acknowledgement) == 0 { return nil, status.Error(codes.NotFound, "packet acknowledgement hash not found") } @@ -229,26 +141,22 @@ func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.Que return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - var acks []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), hostv2.PacketAcknowledgementPrefixKey(req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), hostv2.PacketAcknowledgementPrefixKey(req.ClientId)) // if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences) // otherwise, maintain previous behaviour and perform paginated query for _, seq := range req.PacketCommitmentSequences { - acknowledgement := q.GetPacketAcknowledgement(ctx, req.ChannelId, seq) + acknowledgement := q.GetPacketAcknowledgement(ctx, req.ClientId, seq) if len(acknowledgement) == 0 { continue } - ack := types.NewPacketState(req.ChannelId, seq, acknowledgement) + ack := types.NewPacketState(req.ClientId, seq, acknowledgement) acks = append(acks, &ack) } @@ -269,7 +177,7 @@ func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.Que return types.ErrInvalidPacket } - ack := types.NewPacketState(req.ChannelId, sequence, value) + ack := types.NewPacketState(req.ClientId, sequence, value) acks = append(acks, &ack) return nil @@ -291,7 +199,7 @@ func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketR return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -299,11 +207,7 @@ func (q *queryServer) PacketReceipt(ctx context.Context, req *types.QueryPacketR return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - - hasReceipt := q.HasPacketReceipt(ctx, req.ChannelId, req.Sequence) + hasReceipt := q.HasPacketReceipt(ctx, req.ClientId, req.Sequence) return types.NewQueryPacketReceiptResponse(hasReceipt, nil, clienttypes.GetSelfHeight(ctx)), nil } @@ -329,14 +233,10 @@ func (q *queryServer) UnreceivedPackets(ctx context.Context, req *types.QueryUnr return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - var unreceivedSequences []uint64 for i, seq := range req.Sequences { // filter for invalid sequences to ensure they are not included in the response value. @@ -345,7 +245,7 @@ func (q *queryServer) UnreceivedPackets(ctx context.Context, req *types.QueryUnr } // if the packet receipt does not exist, then it is unreceived - if !q.HasPacketReceipt(ctx, req.ChannelId, seq) { + if !q.HasPacketReceipt(ctx, req.ClientId, seq) { unreceivedSequences = append(unreceivedSequences, seq) } } @@ -379,14 +279,10 @@ func (q *queryServer) UnreceivedAcks(ctx context.Context, req *types.QueryUnrece return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - if !q.HasChannel(ctx, req.ChannelId) { - return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrChannelNotFound, req.ChannelId).Error()) - } - var unreceivedSequences []uint64 for _, seq := range req.PacketAckSequences { @@ -396,7 +292,7 @@ func (q *queryServer) UnreceivedAcks(ctx context.Context, req *types.QueryUnrece // if packet commitment still exists on the original sending chain, then packet ack has not been received // since processing the ack will delete the packet commitment - if commitment := q.GetPacketCommitment(ctx, req.ChannelId, seq); len(commitment) != 0 { + if commitment := q.GetPacketCommitment(ctx, req.ClientId, seq); len(commitment) != 0 { unreceivedSequences = append(unreceivedSequences, seq) } diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 4af5b3414b5..8d8a07d73ac 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -8,296 +8,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -func (suite *KeeperTestSuite) TestQueryChannel() { - var ( - req *types.QueryChannelRequest - expChannel types.Channel - ) - - testCases := []struct { - msg string - malleate func() - expError error - }{ - { - "success", - func() { - ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) - - req = &types.QueryChannelRequest{ - ChannelId: ibctesting.FirstChannelID, - } - }, - nil, - }, - { - "req is nil", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid channelID", - func() { - req = &types.QueryChannelRequest{} - }, - status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), - }, - { - "channel not found", - func() { - req = &types.QueryChannelRequest{ - ChannelId: ibctesting.FirstChannelID, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", ibctesting.FirstChannelID)), - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) - expChannel = types.Channel{ClientId: ibctesting.SecondClientID, CounterpartyChannelId: ibctesting.SecondChannelID, MerklePathPrefix: merklePathPrefix} - - tc.malleate() - - queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2) - res, err := queryServer.Channel(suite.chainA.GetContext(), req) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(expChannel, res.Channel) - } else { - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Nil(res) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryChannelClientState() { - var ( - req *types.QueryChannelClientStateRequest - expIdentifiedClientState clienttypes.IdentifiedClientState - ) - - testCases := []struct { - msg string - malleate func() - expError error - }{ - { - "success", - func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - expClientState := suite.chainA.GetClientState(path.EndpointA.ClientID) - expIdentifiedClientState = clienttypes.NewIdentifiedClientState(path.EndpointA.ClientID, expClientState) - - req = &types.QueryChannelClientStateRequest{ - ChannelId: path.EndpointA.ChannelID, - } - }, - nil, - }, - { - "empty request", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid channel ID", - func() { - req = &types.QueryChannelClientStateRequest{ - ChannelId: "", - } - }, - status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), - }, - { - "channel not found", - func() { - req = &types.QueryChannelClientStateRequest{ - ChannelId: "test-channel-id", - } - }, - status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", "test-channel-id")), - }, - { - "client state not found", - func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - channel, found := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - channel.ClientId = ibctesting.SecondClientID - - path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID, channel) - - req = &types.QueryChannelClientStateRequest{ - ChannelId: path.EndpointA.ChannelID, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: light client not found", ibctesting.SecondClientID)), - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := suite.chainA.GetContext() - - queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) - res, err := queryServer.ChannelClientState(ctx, req) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(&expIdentifiedClientState, res.IdentifiedClientState) - - // ensure UnpackInterfaces is defined - cachedValue := res.IdentifiedClientState.ClientState.GetCachedValue() - suite.Require().NotNil(cachedValue) - } else { - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Nil(res) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { - var ( - req *types.QueryChannelConsensusStateRequest - expConsensusState exported.ConsensusState - expClientID string - ) - - testCases := []struct { - msg string - malleate func() - expError error - }{ - { - "success", - func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, path.EndpointA.GetClientLatestHeight()) - suite.Require().NotNil(expConsensusState) - expClientID = path.EndpointA.ClientID - - req = &types.QueryChannelConsensusStateRequest{ - ChannelId: path.EndpointA.ChannelID, - RevisionNumber: path.EndpointA.GetClientLatestHeight().GetRevisionNumber(), - RevisionHeight: path.EndpointA.GetClientLatestHeight().GetRevisionHeight(), - } - }, - nil, - }, - { - "empty request", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid channel ID", - func() { - req = &types.QueryChannelConsensusStateRequest{ - ChannelId: "", - RevisionNumber: 0, - RevisionHeight: 1, - } - }, - status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), - }, - { - "channel not found", - func() { - req = &types.QueryChannelConsensusStateRequest{ - ChannelId: "test-channel-id", - RevisionNumber: 0, - RevisionHeight: 1, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", "test-channel-id")), - }, - { - "consensus state for channel's connection not found", - func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - req = &types.QueryChannelConsensusStateRequest{ - ChannelId: path.EndpointA.ChannelID, - RevisionNumber: 0, - RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height - } - }, - status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: consensus state not found", "07-tendermint-0")), - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := suite.chainA.GetContext() - - queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) - res, err := queryServer.ChannelConsensusState(ctx, req) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState) - suite.Require().NoError(err) - suite.Require().Equal(expConsensusState, consensusState) - suite.Require().Equal(expClientID, res.ClientId) - - // ensure UnpackInterfaces is defined - cachedValue := res.ConsensusState.GetCachedValue() - suite.Require().NotNil(cachedValue) - } else { - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Nil(res) - } - }) - } -} - func (suite *KeeperTestSuite) TestQueryPacketCommitment() { var ( expCommitment []byte @@ -317,11 +32,11 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { path.SetupV2() expCommitment = []byte("commitmentHash") - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, expCommitment) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ClientID, 1, expCommitment) req = &types.QueryPacketCommitmentRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, nil, @@ -337,8 +52,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { "invalid channel ID", func() { req = &types.QueryPacketCommitmentRequest{ - ChannelId: "", - Sequence: 1, + ClientId: "", + Sequence: 1, } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), @@ -347,22 +62,12 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { "invalid sequence", func() { req = &types.QueryPacketCommitmentRequest{ - ChannelId: ibctesting.FirstChannelID, - Sequence: 0, + ClientId: ibctesting.FirstClientID, + Sequence: 0, } }, status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), }, - { - "channel not found", - func() { - req = &types.QueryPacketCommitmentRequest{ - ChannelId: "channel-141", - Sequence: 1, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), - }, { "commitment not found", func() { @@ -370,8 +75,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { path.SetupV2() req = &types.QueryPacketCommitmentRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, status.Error(codes.NotFound, "packet commitment hash not found"), @@ -421,13 +126,13 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments for i := uint64(1); i <= 10; i++ { - pktStateCommitment := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ChannelId, pktStateCommitment.Sequence, pktStateCommitment.Data) + pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ClientId, pktStateCommitment.Sequence, pktStateCommitment.Data) expCommitments = append(expCommitments, &pktStateCommitment) } req = &types.QueryPacketCommitmentsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Pagination: &query.PageRequest{ Key: nil, Limit: 11, @@ -445,8 +150,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments for i := uint64(1); i <= 10; i++ { - pktStateCommitment := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ChannelId, pktStateCommitment.Sequence, pktStateCommitment.Data) + pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ClientId, pktStateCommitment.Sequence, pktStateCommitment.Data) expCommitments = append(expCommitments, &pktStateCommitment) } @@ -454,7 +159,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = expCommitments[:limit] req = &types.QueryPacketCommitmentsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Pagination: &query.PageRequest{ Key: nil, Limit: limit, @@ -472,23 +177,14 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = &types.QueryPacketCommitmentsRequest{ - ChannelId: "", + ClientId: "", } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, - { - "channel not found", - func() { - req = &types.QueryPacketCommitmentsRequest{ - ChannelId: "channel-141", - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), - }, } for _, tc := range testCases { @@ -534,11 +230,11 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { path.SetupV2() expAcknowledgement = []byte("acknowledgementHash") - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, expAcknowledgement) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), path.EndpointA.ClientID, 1, expAcknowledgement) req = &types.QueryPacketAcknowledgementRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, nil, @@ -551,11 +247,11 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = &types.QueryPacketAcknowledgementRequest{ - ChannelId: "", - Sequence: 1, + ClientId: "", + Sequence: 1, } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), @@ -564,22 +260,12 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { "invalid sequence", func() { req = &types.QueryPacketAcknowledgementRequest{ - ChannelId: ibctesting.FirstChannelID, - Sequence: 0, + ClientId: ibctesting.FirstClientID, + Sequence: 0, } }, status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), }, - { - "channel not found", - func() { - req = &types.QueryPacketAcknowledgementRequest{ - ChannelId: "channel-141", - Sequence: 1, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), - }, { "acknowledgement not found", func() { @@ -587,8 +273,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { path.SetupV2() req = &types.QueryPacketAcknowledgementRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, status.Error(codes.NotFound, "packet acknowledgement hash not found"), @@ -639,8 +325,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { var commitments []uint64 for i := uint64(0); i < 100; i++ { - ack := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ChannelId, ack.Sequence, ack.Data) + ack := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ClientId, ack.Sequence, ack.Data) if i < 10 { // populate the store with 100 and query for 10 specific acks expAcknowledgements = append(expAcknowledgements, &ack) @@ -649,7 +335,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { } req = &types.QueryPacketAcknowledgementsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, PacketCommitmentSequences: commitments, Pagination: nil, } @@ -665,13 +351,13 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { expAcknowledgements = make([]*types.PacketState, 0, 10) for i := uint64(1); i <= 10; i++ { - ack := types.NewPacketState(path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ChannelId, ack.Sequence, ack.Data) + ack := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ClientId, ack.Sequence, ack.Data) expAcknowledgements = append(expAcknowledgements, &ack) } req = &types.QueryPacketAcknowledgementsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Pagination: &query.PageRequest{ Key: nil, Limit: 11, @@ -692,20 +378,11 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { "invalid ID", func() { req = &types.QueryPacketAcknowledgementsRequest{ - ChannelId: "", + ClientId: "", } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, - { - "channel not found", - func() { - req = &types.QueryPacketAcknowledgementsRequest{ - ChannelId: "test-channel-id", - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "test-channel-id")), - }, } for _, tc := range testCases { @@ -750,12 +427,12 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ClientID, 1) expReceipt = true req = &types.QueryPacketReceiptRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, nil, @@ -768,8 +445,8 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { expReceipt = false req = &types.QueryPacketReceiptRequest{ - ChannelId: path.EndpointA.ChannelID, - Sequence: 1, + ClientId: path.EndpointA.ClientID, + Sequence: 1, } }, nil, @@ -782,11 +459,11 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = &types.QueryPacketReceiptRequest{ - ChannelId: "", - Sequence: 1, + ClientId: "", + Sequence: 1, } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), @@ -795,22 +472,12 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { "invalid sequence", func() { req = &types.QueryPacketReceiptRequest{ - ChannelId: ibctesting.FirstChannelID, - Sequence: 0, + ClientId: ibctesting.FirstClientID, + Sequence: 0, } }, status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), }, - { - "channel not found", - func() { - req = &types.QueryPacketReceiptRequest{ - ChannelId: "channel-141", - Sequence: 1, - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "channel-141")), - }, } for _, tc := range testCases { @@ -856,8 +523,8 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { expSeq = 42 seq := uint64(42) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq) - req = types.NewQueryNextSequenceSendRequest(path.EndpointA.ChannelID) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ClientID, seq) + req = types.NewQueryNextSequenceSendRequest(path.EndpointA.ClientID) }, nil, }, @@ -869,7 +536,7 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = types.NewQueryNextSequenceSendRequest("") }, @@ -878,9 +545,9 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { { "sequence send not found", func() { - req = types.NewQueryNextSequenceSendRequest(ibctesting.FirstChannelID) + req = types.NewQueryNextSequenceSendRequest(ibctesting.FirstClientID) }, - status.Error(codes.NotFound, fmt.Sprintf("channel-id %s: sequence send not found", ibctesting.FirstChannelID)), + status.Error(codes.NotFound, fmt.Sprintf("client-id %s: sequence send not found", ibctesting.FirstClientID)), }, } @@ -929,10 +596,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: "", + ClientId: "", } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), @@ -944,21 +611,12 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { path.SetupV2() req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Sequences: []uint64{0}, } }, status.Error(codes.InvalidArgument, "packet sequence 0 cannot be 0"), }, - { - "channel not found", - func() { - req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: "invalid-channel-id", - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "invalid-channel-id")), - }, { "basic success empty packet commitments", func() { @@ -967,7 +625,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { expSeq = []uint64(nil) req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Sequences: []uint64{}, } }, @@ -983,7 +641,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { expSeq = []uint64{1} req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Sequences: []uint64{1}, } }, @@ -995,11 +653,11 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupV2() - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ClientID, 1) expSeq = []uint64(nil) req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Sequences: []uint64{1}, } }, @@ -1018,14 +676,14 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { packetCommitments = append(packetCommitments, seq) if seq%2 == 0 { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainA.GetContext(), path.EndpointA.ClientID, seq) } else { expSeq = append(expSeq, seq) } } req = &types.QueryUnreceivedPacketsRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, Sequences: packetCommitments, } }, @@ -1075,7 +733,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { func() { expSeq = []uint64(nil) req = &types.QueryUnreceivedAcksRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, PacketAckSequences: []uint64{1}, } }, @@ -1084,11 +742,11 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { { "success: single unreceived packet ack", func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, 1, []byte("commitment")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ClientID, 1, []byte("commitment")) expSeq = []uint64{1} req = &types.QueryUnreceivedAcksRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, PacketAckSequences: []uint64{1}, } }, @@ -1105,13 +763,13 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { packetAcks = append(packetAcks, seq) if seq%2 == 0 { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ChannelID, seq, []byte("commitement")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), path.EndpointA.ClientID, seq, []byte("commitement")) expSeq = append(expSeq, seq) } } req = &types.QueryUnreceivedAcksRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, PacketAckSequences: packetAcks, } }, @@ -1125,28 +783,19 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { status.Error(codes.InvalidArgument, "empty request"), }, { - "invalid channel ID", + "invalid client ID", func() { req = &types.QueryUnreceivedAcksRequest{ - ChannelId: "", + ClientId: "", } }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, - { - "channel not found", - func() { - req = &types.QueryUnreceivedAcksRequest{ - ChannelId: "test-channel-id", - } - }, - status.Error(codes.NotFound, fmt.Sprintf("%s: channel not found", "test-channel-id")), - }, { "invalid seq", func() { req = &types.QueryUnreceivedAcksRequest{ - ChannelId: path.EndpointA.ChannelID, + ClientId: path.EndpointA.ClientID, PacketAckSequences: []uint64{0}, } }, diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index e9843f71bb3..a63e644f83e 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -2,22 +2,16 @@ package keeper import ( "context" - "fmt" "cosmossdk.io/core/appmodule" "cosmossdk.io/log" - "cosmossdk.io/store/prefix" - storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" connectionkeeper "github.com/cosmos/ibc-go/v9/modules/core/03-connection/keeper" channelkeeperv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/api" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -61,67 +55,10 @@ func (Keeper) Logger(ctx context.Context) log.Logger { return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } -// channelStore returns the KV store under which channels are stored. -func (k Keeper) channelStore(ctx context.Context) storetypes.KVStore { - channelPrefix := []byte(fmt.Sprintf("%s/", types.ChannelPrefix)) - return prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), channelPrefix) -} - -// creatorStore returns the KV store under which creators are stored. -func (k Keeper) creatorStore(ctx context.Context) storetypes.KVStore { - creatorPrefix := []byte(fmt.Sprintf("%s/", types.CreatorPrefix)) - return prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), creatorPrefix) -} - -// SetChannel sets the Channel for a given channel identifier. -func (k *Keeper) SetChannel(ctx context.Context, channelID string, channel types.Channel) { - bz := k.cdc.MustMarshal(&channel) - k.channelStore(ctx).Set([]byte(channelID), bz) -} - -// GetChannel gets the Channel for a given channel identifier. -func (k *Keeper) GetChannel(ctx context.Context, channelID string) (types.Channel, bool) { - store := k.channelStore(ctx) - bz := store.Get([]byte(channelID)) - if len(bz) == 0 { - return types.Channel{}, false - } - - var channel types.Channel - k.cdc.MustUnmarshal(bz, &channel) - return channel, true -} - -// HasChannel returns true if a Channel exists for a given channel identifier, otherwise false. -func (k *Keeper) HasChannel(ctx context.Context, channelID string) bool { - store := k.channelStore(ctx) - return store.Has([]byte(channelID)) -} - -// GetCreator returns the creator of the channel. -func (k *Keeper) GetCreator(ctx context.Context, channelID string) (string, bool) { - bz := k.creatorStore(ctx).Get([]byte(channelID)) - if len(bz) == 0 { - return "", false - } - - return string(bz), true -} - -// SetCreator sets the creator of the channel. -func (k *Keeper) SetCreator(ctx context.Context, channelID, creator string) { - k.creatorStore(ctx).Set([]byte(channelID), []byte(creator)) -} - -// DeleteCreator deletes the creator associated with the channel. -func (k *Keeper) DeleteCreator(ctx context.Context, channelID string) { - k.creatorStore(ctx).Delete([]byte(channelID)) -} - -// GetPacketReceipt returns the packet receipt from the packet receipt path based on the channelID and sequence. -func (k *Keeper) GetPacketReceipt(ctx context.Context, channelID string, sequence uint64) ([]byte, bool) { +// GetPacketReceipt returns the packet receipt from the packet receipt path based on the clientID and sequence. +func (k *Keeper) GetPacketReceipt(ctx context.Context, clientID string, sequence uint64) ([]byte, bool) { store := k.KVStoreService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.PacketReceiptKey(channelID, sequence)) + bz, err := store.Get(hostv2.PacketReceiptKey(clientID, sequence)) if err != nil { panic(err) } @@ -132,9 +69,9 @@ func (k *Keeper) GetPacketReceipt(ctx context.Context, channelID string, sequenc } // HasPacketReceipt returns true if the packet receipt exists, otherwise false. -func (k *Keeper) HasPacketReceipt(ctx context.Context, channelID string, sequence uint64) bool { +func (k *Keeper) HasPacketReceipt(ctx context.Context, clientID string, sequence uint64) bool { store := k.KVStoreService.OpenKVStore(ctx) - has, err := store.Has(hostv2.PacketReceiptKey(channelID, sequence)) + has, err := store.Has(hostv2.PacketReceiptKey(clientID, sequence)) if err != nil { panic(err) } @@ -144,17 +81,17 @@ func (k *Keeper) HasPacketReceipt(ctx context.Context, channelID string, sequenc // SetPacketReceipt writes the packet receipt under the receipt path // This is a public path that is standardized by the IBC V2 specification. -func (k *Keeper) SetPacketReceipt(ctx context.Context, channelID string, sequence uint64) { +func (k *Keeper) SetPacketReceipt(ctx context.Context, clientID string, sequence uint64) { store := k.KVStoreService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketReceiptKey(channelID, sequence), []byte{byte(2)}); err != nil { + if err := store.Set(hostv2.PacketReceiptKey(clientID, sequence), []byte{byte(2)}); err != nil { panic(err) } } // GetPacketAcknowledgement fetches the packet acknowledgement from the store. -func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) []byte { +func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, clientID string, sequence uint64) []byte { store := k.KVStoreService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.PacketAcknowledgementKey(channelID, sequence)) + bz, err := store.Get(hostv2.PacketAcknowledgementKey(clientID, sequence)) if err != nil { panic(err) } @@ -163,22 +100,22 @@ func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, channelID string, // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC V2 specification. -func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64, ackHash []byte) { +func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, clientID string, sequence uint64, ackHash []byte) { store := k.KVStoreService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketAcknowledgementKey(channelID, sequence), ackHash); err != nil { + if err := store.Set(hostv2.PacketAcknowledgementKey(clientID, sequence), ackHash); err != nil { panic(err) } } // HasPacketAcknowledgement checks if the packet ack hash is already on the store. -func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, channelID string, sequence uint64) bool { - return len(k.GetPacketAcknowledgement(ctx, channelID, sequence)) > 0 +func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, clientID string, sequence uint64) bool { + return len(k.GetPacketAcknowledgement(ctx, clientID, sequence)) > 0 } // GetPacketCommitment returns the packet commitment hash under the commitment path. -func (k *Keeper) GetPacketCommitment(ctx context.Context, channelID string, sequence uint64) []byte { +func (k *Keeper) GetPacketCommitment(ctx context.Context, clientID string, sequence uint64) []byte { store := k.KVStoreService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.PacketCommitmentKey(channelID, sequence)) + bz, err := store.Get(hostv2.PacketCommitmentKey(clientID, sequence)) if err != nil { panic(err) } @@ -189,25 +126,25 @@ func (k *Keeper) GetPacketCommitment(ctx context.Context, channelID string, sequ } // SetPacketCommitment writes the commitment hash under the commitment path. -func (k *Keeper) SetPacketCommitment(ctx context.Context, channelID string, sequence uint64, commitment []byte) { +func (k *Keeper) SetPacketCommitment(ctx context.Context, clientID string, sequence uint64, commitment []byte) { store := k.KVStoreService.OpenKVStore(ctx) - if err := store.Set(hostv2.PacketCommitmentKey(channelID, sequence), commitment); err != nil { + if err := store.Set(hostv2.PacketCommitmentKey(clientID, sequence), commitment); err != nil { panic(err) } } // DeletePacketCommitment deletes the packet commitment hash under the commitment path. -func (k *Keeper) DeletePacketCommitment(ctx context.Context, channelID string, sequence uint64) { +func (k *Keeper) DeletePacketCommitment(ctx context.Context, clientID string, sequence uint64) { store := k.KVStoreService.OpenKVStore(ctx) - if err := store.Delete(hostv2.PacketCommitmentKey(channelID, sequence)); err != nil { + if err := store.Delete(hostv2.PacketCommitmentKey(clientID, sequence)); err != nil { panic(err) } } // GetNextSequenceSend returns the next send sequence from the sequence path -func (k *Keeper) GetNextSequenceSend(ctx context.Context, channelID string) (uint64, bool) { +func (k *Keeper) GetNextSequenceSend(ctx context.Context, clientID string) (uint64, bool) { store := k.KVStoreService.OpenKVStore(ctx) - bz, err := store.Get(hostv2.NextSequenceSendKey(channelID)) + bz, err := store.Get(hostv2.NextSequenceSendKey(clientID)) if err != nil { panic(err) } @@ -218,48 +155,10 @@ func (k *Keeper) GetNextSequenceSend(ctx context.Context, channelID string) (uin } // SetNextSequenceSend writes the next send sequence under the sequence path -func (k *Keeper) SetNextSequenceSend(ctx context.Context, channelID string, sequence uint64) { +func (k *Keeper) SetNextSequenceSend(ctx context.Context, clientID string, sequence uint64) { store := k.KVStoreService.OpenKVStore(ctx) bigEndianBz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(hostv2.NextSequenceSendKey(channelID), bigEndianBz); err != nil { + if err := store.Set(hostv2.NextSequenceSendKey(clientID), bigEndianBz); err != nil { panic(err) } } - -// aliasV1Channel returns a version 2 channel for the given port and channel ID -// by converting the channel into a version 2 channel. -func (k *Keeper) aliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) { - channel, ok := k.channelKeeperV1.GetChannel(ctx, portID, channelID) - if !ok { - return types.Channel{}, false - } - // Do not allow channel to be converted into a version 2 channel - // if the channel is not OPEN or if it is not UNORDERED - if channel.State != channeltypesv1.OPEN || channel.Ordering != channeltypesv1.UNORDERED { - return types.Channel{}, false - } - connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !ok { - return types.Channel{}, false - } - merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - - channelv2 := types.Channel{ - CounterpartyChannelId: channel.Counterparty.ChannelId, - ClientId: connection.ClientId, - MerklePathPrefix: merklePathPrefix, - } - return channelv2, true -} - -// convertV1Channel attempts to retrieve a v1 channel from the channel keeper if it exists, then converts it -// to a v2 counterparty and stores it in the v2 channel keeper for future use -func (k *Keeper) convertV1Channel(ctx context.Context, port, id string) (types.Channel, bool) { - if channel, ok := k.aliasV1Channel(ctx, port, id); ok { - // we can key on just the channel here since channel ids are globally unique - k.SetChannel(ctx, id, channel) - return channel, true - } - - return types.Channel{}, false -} diff --git a/modules/core/04-channel/v2/keeper/keeper_test.go b/modules/core/04-channel/v2/keeper/keeper_test.go index 3521e3c789f..5da9af68bda 100644 --- a/modules/core/04-channel/v2/keeper/keeper_test.go +++ b/modules/core/04-channel/v2/keeper/keeper_test.go @@ -5,10 +5,6 @@ import ( testifysuite "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypes2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -33,121 +29,3 @@ func (suite *KeeperTestSuite) SetupTest() { suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) } - -func (suite *KeeperTestSuite) TestAliasV1Channel() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expPass bool - }{ - { - "success", - func() {}, - true, - }, - { - "failure: channel not found", - func() { - path.EndpointA.ChannelID = "" - }, - false, - }, - { - "failure: channel not OPEN", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.TRYOPEN }) - }, - false, - }, - { - "failure: channel is ORDERED", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) - }, - false, - }, - { - "failure: connection not found", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{ibctesting.InvalidID} }) - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - // create a previously existing path on chainA to change the identifiers - // between the path between chainA and chainB - path1 := ibctesting.NewPath(suite.chainA, suite.chainC) - path1.Setup() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - tc.malleate() - - channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeperV2.AliasV1Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - - if tc.expPass { - suite.Require().True(found) - - merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expChannel := channeltypes2.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) - suite.Require().Equal(channel, expChannel) - } else { - suite.Require().False(found) - suite.Require().Equal(channel, channeltypes2.Channel{}) - } - }) - } -} - -func (suite *KeeperTestSuite) TestSetChannel() { - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - channel := channeltypes2.Channel{ - ClientId: ibctesting.FirstClientID, - MerklePathPrefix: merklePathPrefix, - } - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, channel) - - retrievedChannel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID) - suite.Require().True(found, "GetChannel does not return channel") - suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") - - // No channel stored under other channel identifier. - retrievedChannel, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), ibctesting.SecondChannelID) - suite.Require().False(found, "GetChannel unexpectedly returned a channel") - suite.Require().Equal(channeltypes2.Channel{}, retrievedChannel, "Channel retrieved not empty") -} - -func (suite *KeeperTestSuite) TestSetCreator() { - expectedCreator := "test-creator" - - // Set the creator for the client - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expectedCreator) - - // Retrieve the creator from the store - retrievedCreator, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) - - // Verify that the retrieved creator matches the expected creator - suite.Require().True(found, "GetCreator did not return stored creator") - suite.Require().Equal(expectedCreator, retrievedCreator, "Creator is not retrieved correctly") - - // Verify that the creator is deleted from the store - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") - - // Verify non stored creator is not found - retrievedCreator, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), ibctesting.SecondChannelID) - suite.Require().False(found, "GetCreator unexpectedly returned a creator") - suite.Require().Empty(retrievedCreator, "Creator is not empty") -} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 179e44fd93f..aaadfc8fc80 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -9,58 +9,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" internalerrors "github.com/cosmos/ibc-go/v9/modules/core/internal/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/v2/telemetry" ) var _ types.MsgServer = &Keeper{} -// CreateChannel defines a rpc handler method for MsgCreateChannel. -func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChannel) (*types.MsgCreateChannelResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - channelID := k.channelKeeperV1.GenerateChannelIdentifier(ctx) - - // Initialize channel with empty counterparty channel identifier. - channel := types.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) - k.SetChannel(ctx, channelID, channel) - k.SetCreator(ctx, channelID, msg.Signer) - k.SetNextSequenceSend(ctx, channelID, 1) - - k.emitCreateChannelEvent(goCtx, channelID, msg.ClientId) - - return &types.MsgCreateChannelResponse{ChannelId: channelID}, nil -} - -// RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. -func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegisterCounterparty) (*types.MsgRegisterCounterpartyResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - channel, ok := k.GetChannel(ctx, msg.ChannelId) - if !ok { - return nil, errorsmod.Wrapf(types.ErrChannelNotFound, "channel must exist for channel id %s", msg.ChannelId) - } - - creator, found := k.GetCreator(ctx, msg.ChannelId) - if !found { - return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "channel creator must be set") - } - - if creator != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) - } - - channel.CounterpartyChannelId = msg.CounterpartyChannelId - k.SetChannel(ctx, msg.ChannelId, channel) - // Delete client creator from state as it is not needed after this point. - k.DeleteCreator(ctx, msg.ChannelId) - - k.emitRegisterCounterpartyEvent(goCtx, msg.ChannelId, channel) - - return &types.MsgRegisterCounterpartyResponse{}, nil -} - // SendPacket implements the PacketMsgServer SendPacket method. func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*types.MsgSendPacketResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -83,15 +37,15 @@ func (k *Keeper) SendPacket(ctx context.Context, msg *types.MsgSendPacket) (*typ return nil, errorsmod.Wrap(err, "invalid address for msg Signer") } - sequence, destChannel, err := k.sendPacket(ctx, msg.SourceChannel, msg.TimeoutTimestamp, msg.Payloads) + sequence, destChannel, err := k.sendPacket(ctx, msg.SourceClient, msg.TimeoutTimestamp, msg.Payloads) if err != nil { - sdkCtx.Logger().Error("send packet failed", "source-channel", msg.SourceChannel, "error", errorsmod.Wrap(err, "send packet failed")) - return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceChannel) + sdkCtx.Logger().Error("send packet failed", "source-client", msg.SourceClient, "error", errorsmod.Wrap(err, "send packet failed")) + return nil, errorsmod.Wrapf(err, "send packet failed for source id: %s", msg.SourceClient) } for _, pd := range msg.Payloads { cbs := k.Router.Route(pd.SourcePort) - err := cbs.OnSendPacket(ctx, msg.SourceChannel, destChannel, sequence, pd, signer) + err := cbs.OnSendPacket(ctx, msg.SourceClient, destChannel, sequence, pd, signer) if err != nil { return nil, err } @@ -122,10 +76,10 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ writeFn() case types.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored - sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) + sdkCtx.Logger().Debug("no-op on redundant relay", "source-client", msg.Packet.SourceClient) return &types.MsgRecvPacketResponse{Result: types.NOOP}, nil default: - sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) + sdkCtx.Logger().Error("receive packet failed", "source-client", msg.Packet.SourceClient, "error", errorsmod.Wrap(err, "receive packet verification failed")) return nil, errorsmod.Wrap(err, "receive packet verification failed") } @@ -139,7 +93,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful. cacheCtx, writeFn = sdkCtx.CacheContext() cb := k.Router.Route(pd.DestinationPort) - res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, msg.Packet.Sequence, pd, signer) + res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceClient, msg.Packet.DestinationClient, msg.Packet.Sequence, pd, signer) if res.Status != types.PacketStatus_Failure { // write application state changes for asynchronous and successful acknowledgements @@ -169,8 +123,8 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // note this should never happen as the payload would have had to be empty. if len(ack.AppAcknowledgements) == 0 { - sdkCtx.Logger().Error("receive packet failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) - return &types.MsgRecvPacketResponse{Result: types.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-channel %s invalid acknowledgement results", msg.Packet.SourceChannel) + sdkCtx.Logger().Error("receive packet failed", "source-client", msg.Packet.SourceClient, "error", errorsmod.Wrap(err, "invalid acknowledgement results")) + return &types.MsgRecvPacketResponse{Result: types.FAILURE}, errorsmod.Wrapf(err, "receive packet failed source-client %s invalid acknowledgement results", msg.Packet.SourceClient) } if !isAsync { @@ -189,7 +143,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // TODO: store the packet for async applications to access if required. defer telemetry.ReportRecvPacket(msg.Packet) - sdkCtx.Logger().Info("receive packet callback succeeded", "source-channel", msg.Packet.SourceChannel, "dest-channel", msg.Packet.DestinationChannel, "result", types.SUCCESS.String()) + sdkCtx.Logger().Info("receive packet callback succeeded", "source-client", msg.Packet.SourceClient, "dest-client", msg.Packet.DestinationClient, "result", types.SUCCESS.String()) return &types.MsgRecvPacketResponse{Result: types.SUCCESS}, nil } @@ -209,19 +163,19 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem case nil: writeFn() case types.ErrNoOpMsg: - sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) + sdkCtx.Logger().Debug("no-op on redundant relay", "source-client", msg.Packet.SourceClient) return &types.MsgAcknowledgementResponse{Result: types.NOOP}, nil default: - sdkCtx.Logger().Error("acknowledgement failed", "source-channel", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) + sdkCtx.Logger().Error("acknowledgement failed", "source-client", msg.Packet.SourceClient, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } for i, pd := range msg.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) ack := msg.Acknowledgement.AppAcknowledgements[i] - err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, msg.Packet.Sequence, ack, pd, relayer) + err := cbs.OnAcknowledgementPacket(ctx, msg.Packet.SourceClient, msg.Packet.DestinationClient, msg.Packet.Sequence, ack, pd, relayer) if err != nil { - return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, msg.Packet.SourceChannel, msg.Packet.DestinationChannel) + return nil, errorsmod.Wrapf(err, "failed OnAcknowledgementPacket for source port %s, source client %s, destination client %s", pd.SourcePort, msg.Packet.SourceClient, msg.Packet.DestinationClient) } } @@ -242,26 +196,26 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types cacheCtx, writeFn := sdkCtx.CacheContext() if err := k.timeoutPacket(cacheCtx, timeout.Packet, timeout.ProofUnreceived, timeout.ProofHeight); err != nil { - sdkCtx.Logger().Error("Timeout packet failed", "source-channel", timeout.Packet.SourceChannel, "destination-channel", timeout.Packet.DestinationChannel, "error", errorsmod.Wrap(err, "timeout packet failed")) - return nil, errorsmod.Wrapf(err, "timeout packet failed for source id: %s and destination id: %s", timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) + sdkCtx.Logger().Error("Timeout packet failed", "source-client", timeout.Packet.SourceClient, "destination-client", timeout.Packet.DestinationClient, "error", errorsmod.Wrap(err, "timeout packet failed")) + return nil, errorsmod.Wrapf(err, "timeout packet failed for source id: %s and destination id: %s", timeout.Packet.SourceClient, timeout.Packet.DestinationClient) } switch err { case nil: writeFn() case types.ErrNoOpMsg: - sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) + sdkCtx.Logger().Debug("no-op on redundant relay", "source-client", timeout.Packet.SourceClient) return &types.MsgTimeoutResponse{Result: types.NOOP}, nil default: - sdkCtx.Logger().Error("timeout failed", "source-channel", timeout.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) + sdkCtx.Logger().Error("timeout failed", "source-client", timeout.Packet.SourceClient, "error", errorsmod.Wrap(err, "timeout packet verification failed")) return nil, errorsmod.Wrap(err, "timeout packet verification failed") } for _, pd := range timeout.Packet.Payloads { cbs := k.Router.Route(pd.SourcePort) - err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel, timeout.Packet.Sequence, pd, signer) + err := cbs.OnTimeoutPacket(ctx, timeout.Packet.SourceClient, timeout.Packet.DestinationClient, timeout.Packet.Sequence, pd, signer) if err != nil { - return nil, errorsmod.Wrapf(err, "failed OnTimeoutPacket for source port %s, source channel %s, destination channel %s", pd.SourcePort, timeout.Packet.SourceChannel, timeout.Packet.DestinationChannel) + return nil, errorsmod.Wrapf(err, "failed OnTimeoutPacket for source port %s, source client %s, destination client %s", pd.SourcePort, timeout.Packet.SourceClient, timeout.Packet.DestinationClient) } } diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 58dc3126dbd..6e02db44f75 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -11,94 +11,11 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" ) -func (suite *KeeperTestSuite) TestRegisterCounterparty() { - var ( - path *ibctesting.Path - msg *types.MsgRegisterCounterparty - ) - cases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() { - // set it before handler - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, types.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) - }, - nil, - }, - { - "failure: creator not set", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: signer does not match creator", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID, ibctesting.TestAccAddress) - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: channel must already exist", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext()).Delete([]byte(path.EndpointA.ChannelID)) - }, - types.ErrChannelNotFound, - }, - } - - for _, tc := range cases { - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupClients() - - suite.Require().NoError(path.EndpointA.CreateChannel()) - suite.Require().NoError(path.EndpointB.CreateChannel()) - - signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = types.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) - - tc.malleate() - - res, err := path.EndpointA.Chain.SendMsgs(msg) - - expPass := tc.expError == nil - if expPass { - suite.Require().NotNil(res) - suite.Require().Nil(err) - - // Assert counterparty channel id filled in and creator deleted - channel, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(channel.CounterpartyChannelId, path.EndpointB.ChannelID) - - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().False(found) - - seq, found := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(seq, uint64(1)) - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q, got %q instead", tc.expError, err) - } - }) - } -} - func (suite *KeeperTestSuite) TestMsgSendPacket() { var ( path *ibctesting.Path @@ -122,7 +39,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { malleate: func() { // ensure a message timeout. timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(types.MaxTimeoutDelta - 10*time.Second).Unix()) - expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + expectedPacket = types.NewPacket(1, path.EndpointA.ClientID, path.EndpointB.ClientID, timeoutTimestamp, payload) }, expError: nil, }, @@ -167,11 +84,11 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { expError: mock.MockApplicationCallbackError, }, { - name: "failure: channel not found", + name: "failure: client not found", malleate: func() { - path.EndpointA.ChannelID = ibctesting.InvalidID + path.EndpointA.ClientID = ibctesting.InvalidID }, - expError: types.ErrChannelNotFound, + expError: clienttypes.ErrCounterpartyNotFound, }, { name: "failure: route to non existing app", @@ -194,7 +111,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { timeoutTimestamp = suite.chainA.GetTimeoutTimestampSecs() payload = mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) - expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + expectedPacket = types.NewPacket(1, path.EndpointA.ClientID, path.EndpointB.ClientID, timeoutTimestamp, payload) tc.malleate() @@ -207,11 +124,11 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { ck := path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeperV2 - packetCommitment := ck.GetPacketCommitment(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID, 1) + packetCommitment := ck.GetPacketCommitment(path.EndpointA.Chain.GetContext(), path.EndpointA.ClientID, 1) suite.Require().NotNil(packetCommitment) suite.Require().Equal(types.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") - nextSequenceSend, ok := ck.GetNextSequenceSend(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID) + nextSequenceSend, ok := ck.GetNextSequenceSend(path.EndpointA.Chain.GetContext(), path.EndpointA.ClientID) suite.Require().True(ok) suite.Require().Equal(uint64(2), nextSequenceSend, "next sequence send was not incremented correctly") @@ -269,7 +186,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: NoOp", malleate: func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) }, expError: nil, expAckWritten: false, @@ -278,9 +195,9 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "failure: counterparty not found", malleate: func() { // change the destination id to a non-existent channel. - packet.DestinationChannel = ibctesting.InvalidID + packet.DestinationClient = ibctesting.InvalidID }, - expError: types.ErrChannelNotFound, + expError: clienttypes.ErrCounterpartyNotFound, }, { name: "failure: invalid proof", @@ -339,10 +256,10 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().NoError(err) // packet receipt should be written - _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().True(ok) - ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) + ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationClient, packet.Sequence) if !tc.expAckWritten { // ack should not be written for async app or if the packet receipt was already present. @@ -352,13 +269,13 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().True(ackWritten) expectedBz := types.CommitAcknowledgement(expectedAck) - actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) + actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().Equal(expectedBz, actualAckBz) } } else { ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError) - _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.SourceChannel, packet.Sequence) + _, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), packet.SourceClient, packet.Sequence) suite.Require().False(ok) } }) @@ -383,7 +300,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "success: NoOp", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence) // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. @@ -405,14 +322,14 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { name: "failure: counterparty not found", malleate: func() { // change the source id to a non-existent channel. - packet.SourceChannel = "not-existent-channel" + packet.SourceClient = "not-existent-channel" }, - expError: types.ErrChannelNotFound, + expError: clienttypes.ErrCounterpartyNotFound, }, { name: "failure: invalid commitment", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence, []byte("foo")) }, expError: types.ErrInvalidPacket, }, @@ -477,7 +394,7 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { { name: "failure: no-op", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence) // Modify the callback to return a different error. // This way, we can verify that the callback is not executed in a No-op case. @@ -497,24 +414,24 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { expError: mock.MockApplicationCallbackError, }, { - name: "failure: channel not found", + name: "failure: client not found", malleate: func() { - // change the source id to a non-existent channel. - packet.SourceChannel = "not-existent-channel" + // change the source id to a non-existent client. + packet.SourceClient = "not-existent-client" }, - expError: types.ErrChannelNotFound, + expError: clienttypes.ErrCounterpartyNotFound, }, { name: "failure: invalid commitment", malleate: func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence, []byte("foo")) }, expError: types.ErrInvalidPacket, }, { name: "failure: unable to timeout if packet has been received", malleate: func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().NoError(path.EndpointB.UpdateClient()) }, expError: commitmenttypes.ErrInvalidProof, diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index ef396bca6a5..ce00443cfe9 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -11,6 +11,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -19,50 +20,40 @@ import ( // in order for the packet to be sent to the counterparty. func (k *Keeper) sendPacket( ctx context.Context, - sourceChannel string, + sourceClient string, timeoutTimestamp uint64, payloads []types.Payload, ) (uint64, string, error) { - // Lookup channel associated with our source channel to retrieve the destination channel - channel, ok := k.GetChannel(ctx, sourceChannel) + // lookup counterparty from client identifiers + counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, sourceClient) if !ok { - // TODO: figure out how aliasing will work when more than one payload is sent. - channel, ok = k.convertV1Channel(ctx, payloads[0].SourcePort, sourceChannel) - if !ok { - return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) - } + return 0, "", errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", sourceClient) } - destChannel := channel.CounterpartyChannelId - clientID := channel.ClientId - - sequence, found := k.GetNextSequenceSend(ctx, sourceChannel) + sequence, found := k.GetNextSequenceSend(ctx, sourceClient) if !found { - return 0, "", errorsmod.Wrapf( - types.ErrSequenceSendNotFound, - "source channel: %s", sourceChannel, - ) + return 0, "", errorsmod.Wrapf(types.ErrSequenceSendNotFound, "source client: %s", sourceClient) } // construct packet from given fields and channel state - packet := types.NewPacket(sequence, sourceChannel, destChannel, timeoutTimestamp, payloads...) + packet := types.NewPacket(sequence, sourceClient, counterparty.ClientId, timeoutTimestamp, payloads...) if err := packet.ValidateBasic(); err != nil { return 0, "", errorsmod.Wrapf(types.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) } // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { - return 0, "", errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) + if status := k.ClientKeeper.GetClientStatus(ctx, sourceClient); status != exported.Active { + return 0, "", errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceClient, status) } // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceClient) if latestHeight.IsZero() { - return 0, "", errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) + return 0, "", errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceClient) } - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceClient, latestHeight) if err != nil { return 0, "", err } @@ -77,14 +68,14 @@ func (k *Keeper) sendPacket( commitment := types.CommitPacket(packet) // bump the sequence and set the packet commitment, so it is provable by the counterparty - k.SetNextSequenceSend(ctx, sourceChannel, sequence+1) - k.SetPacketCommitment(ctx, sourceChannel, packet.GetSequence(), commitment) + k.SetNextSequenceSend(ctx, sourceClient, sequence+1) + k.SetPacketCommitment(ctx, sourceClient, packet.GetSequence(), commitment) - k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest_channel_id", packet.DestinationChannel, "src_channel_id", packet.SourceChannel) + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "dst_client_id", packet.DestinationClient, "src_client_id", packet.SourceClient) emitSendPacketEvents(ctx, packet) - return sequence, destChannel, nil + return sequence, counterparty.ClientId, nil } // recvPacket implements the packet receiving logic required by a packet handler. @@ -100,21 +91,16 @@ func (k *Keeper) recvPacket( proof []byte, proofHeight exported.Height, ) error { - channel, ok := k.GetChannel(ctx, packet.DestinationChannel) + // lookup counterparty from client identifiers + counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.DestinationClient) if !ok { - // TODO: figure out how aliasing will work when more than one payload is sent. - channel, ok = k.convertV1Channel(ctx, packet.Payloads[0].DestinationPort, packet.DestinationChannel) - if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) - } + return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.DestinationClient) } - if channel.CounterpartyChannelId != packet.SourceChannel { - return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) + if counterparty.ClientId != packet.SourceClient { + return errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty id (%s) does not match packet source id (%s)", counterparty.ClientId, packet.SourceClient) } - clientID := channel.ClientId - // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) currentTimestamp := uint64(sdkCtx.BlockTime().Unix()) @@ -123,36 +109,37 @@ func (k *Keeper) recvPacket( } // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received - // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale + // Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. - if k.HasPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) { + if k.HasPacketReceipt(ctx, packet.DestinationClient, packet.Sequence) { // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. return types.ErrNoOpMsg } - path := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + path := hostv2.PacketCommitmentKey(packet.SourceClient, packet.Sequence) + merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) + merklePath := types.BuildMerklePath(merklePrefix, path) commitment := types.CommitPacket(packet) if err := k.ClientKeeper.VerifyMembership( ctx, - clientID, + packet.DestinationClient, proofHeight, 0, 0, proof, merklePath, commitment, ); err != nil { - return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", clientID) + return errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationClient) } // Set Packet Receipt to prevent timeout from occurring on counterparty - k.SetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) + k.SetPacketReceipt(ctx, packet.DestinationClient, packet.Sequence) - k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_id", packet.SourceChannel, "dst_id", packet.DestinationChannel) + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_client_id", packet.SourceClient, "dst_client_id", packet.DestinationClient) emitRecvPacketEvents(ctx, packet) @@ -166,36 +153,34 @@ func (k Keeper) WriteAcknowledgement( packet types.Packet, ack types.Acknowledgement, ) error { - // Lookup channel associated with destination channel ID and ensure - // that the packet was indeed sent by our counterparty by verifying - // packet sender is our channel's counterparty channel id. - channel, ok := k.GetChannel(ctx, packet.DestinationChannel) + // lookup counterparty from client identifiers + counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.DestinationClient) if !ok { - return errorsmod.Wrapf(types.ErrChannelNotFound, "channel (%s) not found", packet.DestinationChannel) + return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.DestinationClient) } - if channel.CounterpartyChannelId != packet.SourceChannel { - return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet source channel id (%s)", channel.CounterpartyChannelId, packet.SourceChannel) + if counterparty.ClientId != packet.SourceClient { + return errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty id (%s) does not match packet source id (%s)", counterparty.ClientId, packet.SourceClient) } // NOTE: IBC app modules might have written the acknowledgement synchronously on // the OnRecvPacket callback so we need to check if the acknowledgement is already // set on the store and return an error if so. - if k.HasPacketAcknowledgement(ctx, packet.DestinationChannel, packet.Sequence) { - return errorsmod.Wrapf(types.ErrAcknowledgementExists, "acknowledgement for channel %s, sequence %d already exists", packet.DestinationChannel, packet.Sequence) + if k.HasPacketAcknowledgement(ctx, packet.DestinationClient, packet.Sequence) { + return errorsmod.Wrapf(types.ErrAcknowledgementExists, "acknowledgement for id %s, sequence %d already exists", packet.DestinationClient, packet.Sequence) } - if _, found := k.GetPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence); !found { + if _, found := k.GetPacketReceipt(ctx, packet.DestinationClient, packet.Sequence); !found { return errorsmod.Wrap(types.ErrInvalidPacket, "receipt not found for packet") } // set the acknowledgement so that it can be verified on the other side k.SetPacketAcknowledgement( - ctx, packet.DestinationChannel, packet.Sequence, + ctx, packet.DestinationClient, packet.Sequence, types.CommitAcknowledgement(ack), ) - k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dest-channel", packet.DestinationChannel) + k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "dst_client_id", packet.DestinationClient) emitWriteAcknowledgementEvents(ctx, packet, ack) @@ -205,20 +190,17 @@ func (k Keeper) WriteAcknowledgement( } func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, acknowledgement types.Acknowledgement, proof []byte, proofHeight exported.Height) error { - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - channel, ok := k.GetChannel(ctx, packet.SourceChannel) + // lookup counterparty from client identifiers + counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.SourceClient) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) + return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.SourceClient) } - if channel.CounterpartyChannelId != packet.DestinationChannel { - return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) + if counterparty.ClientId != packet.DestinationClient { + return errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty id (%s) does not match packet destination id (%s)", counterparty.ClientId, packet.DestinationClient) } - clientID := channel.ClientId - - commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + commitment := k.GetPacketCommitment(ctx, packet.SourceClient, packet.Sequence) if len(commitment) == 0 { // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement @@ -234,24 +216,25 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack return errorsmod.Wrapf(types.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) } - path := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + path := hostv2.PacketAcknowledgementKey(packet.DestinationClient, packet.Sequence) + merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) + merklePath := types.BuildMerklePath(merklePrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, - clientID, + packet.SourceClient, proofHeight, 0, 0, proof, merklePath, types.CommitAcknowledgement(acknowledgement), ); err != nil { - return errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) + return errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceClient) } - k.DeletePacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + k.DeletePacketCommitment(ctx, packet.SourceClient, packet.Sequence) - k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "source_channel_id", packet.GetSourceChannel(), "destination_channel_id", packet.GetDestinationChannel()) + k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_client_id", packet.GetSourceClient(), "dst_client_id", packet.GetDestinationClient()) emitAcknowledgePacketEvents(ctx, packet) @@ -271,19 +254,18 @@ func (k *Keeper) timeoutPacket( proof []byte, proofHeight exported.Height, ) error { - channel, ok := k.GetChannel(ctx, packet.SourceChannel) + // lookup counterparty from client identifiers + counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.SourceClient) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) + return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.SourceClient) } - if channel.CounterpartyChannelId != packet.DestinationChannel { - return errorsmod.Wrapf(types.ErrInvalidChannelIdentifier, "counterparty channel id (%s) does not match packet destination channel id (%s)", channel.CounterpartyChannelId, packet.DestinationChannel) + if counterparty.ClientId != packet.DestinationClient { + return errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty id (%s) does not match packet destination id (%s)", counterparty.ClientId, packet.DestinationClient) } - clientID := channel.ClientId - // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceClient, proofHeight) if err != nil { return err } @@ -294,7 +276,7 @@ func (k *Keeper) timeoutPacket( } // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + commitment := k.GetPacketCommitment(ctx, packet.SourceClient, packet.Sequence) if len(commitment) == 0 { // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout @@ -310,24 +292,25 @@ func (k *Keeper) timeoutPacket( } // verify packet receipt absence - path := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) + path := hostv2.PacketReceiptKey(packet.DestinationClient, packet.Sequence) + merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) + merklePath := types.BuildMerklePath(merklePrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, - clientID, + packet.SourceClient, proofHeight, 0, 0, proof, merklePath, ); err != nil { - return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", clientID) + return errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceClient) } // delete packet commitment to prevent replay - k.DeletePacketCommitment(ctx, packet.SourceChannel, packet.Sequence) + k.DeletePacketCommitment(ctx, packet.SourceClient, packet.Sequence) - k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_channel_id", packet.SourceChannel, "dst_channel_id", packet.DestinationChannel) + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_client_id", packet.SourceClient, "dst_client_id", packet.DestinationClient) emitTimeoutPacketEvents(ctx, packet) diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index eb826bd3b0d..4c988d2ee69 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -36,24 +36,24 @@ func (suite *KeeperTestSuite) TestSendPacket() { "success with later packet", func() { // send the same packet earlier so next packet send should be sequence 2 - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Payloads) + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err) expSequence = 2 }, nil, }, { - "channel not found", + "client not found", func() { - packet.SourceChannel = ibctesting.InvalidID + packet.SourceClient = ibctesting.InvalidID }, - types.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "packet failed basic validation", func() { // invalid data - packet.Payloads = nil + packet.Payloads[0].SourcePort = "" }, types.ErrInvalidPacket, }, @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // create standard packet that can be malleated - packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + packet = types.NewPacket(1, path.EndpointA.ClientID, path.EndpointB.ClientID, timeoutTimestamp, payload) expSequence = 1 @@ -109,22 +109,22 @@ func (suite *KeeperTestSuite) TestSendPacket() { tc.malleate() // send packet - seq, destChannel, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, packet.TimeoutTimestamp, packet.Payloads) + seq, destClient, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) expPass := tc.expError == nil if expPass { suite.Require().NoError(err) // verify send packet method instantiated packet with correct sequence and destination channel suite.Require().Equal(expSequence, seq) - suite.Require().Equal(path.EndpointB.ChannelID, destChannel) + suite.Require().Equal(path.EndpointB.ClientID, destClient) // verify send packet stored the packet commitment correctly expCommitment := types.CommitPacket(packet) - suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, seq)) + suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, seq)) } else { suite.Require().Error(err) suite.Require().ErrorIs(err, tc.expError) suite.Require().Equal(uint64(0), seq) - suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, seq)) + suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, seq)) } }) @@ -149,11 +149,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { nil, }, { - "failure: channel not found", + "failure: client not found", func() { - packet.DestinationChannel = ibctesting.InvalidID + packet.DestinationClient = ibctesting.InvalidID }, - types.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { "failure: client is not active", @@ -163,11 +163,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { clienttypes.ErrClientNotActive, }, { - "failure: counterparty channel identifier different than source channel", + "failure: counterparty client identifier different than source client", func() { - packet.SourceChannel = unusedChannel + packet.SourceClient = unusedChannel }, - types.ErrInvalidChannelIdentifier, + clienttypes.ErrInvalidCounterparty, }, { "failure: packet has timed out", @@ -179,14 +179,14 @@ func (suite *KeeperTestSuite) TestRecvPacket() { { "failure: packet already received", func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) }, types.ErrNoOpMsg, }, { "failure: verify membership failed", func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("")) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence, []byte("")) suite.coordinator.CommitBlock(path.EndpointA.Chain) suite.Require().NoError(path.EndpointB.UpdateClient()) }, @@ -214,7 +214,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { tc.malleate() // get proof of v2 packet commitment from chainA - packetKey := hostv2.PacketCommitmentKey(packet.GetSourceChannel(), packet.GetSequence()) + packetKey := hostv2.PacketCommitmentKey(packet.GetSourceClient(), packet.GetSequence()) proof, proofHeight := path.EndpointA.QueryProof(packetKey) err = suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.RecvPacketTest(suite.chainB.GetContext(), packet, proof, proofHeight) @@ -223,7 +223,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { if expPass { suite.Require().NoError(err) - _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().True(found) } else { suite.Require().Error(err) @@ -250,24 +250,24 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { nil, }, { - "failure: channel not found", + "failure: client not found", func() { - packet.DestinationChannel = ibctesting.InvalidID + packet.DestinationClient = ibctesting.InvalidID }, - types.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { - "failure: counterparty channel identifier different than source channel", + "failure: counterparty client identifier different than source client", func() { - packet.SourceChannel = unusedChannel + packet.SourceClient = unusedChannel }, - types.ErrInvalidChannelIdentifier, + clienttypes.ErrInvalidCounterparty, }, { "failure: ack already exists", func() { ackBz := types.CommitAcknowledgement(ack) - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence, ackBz) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, ackBz) }, types.ErrAcknowledgementExists, }, @@ -293,7 +293,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // create standard packet that can be malleated - packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + packet = types.NewPacket(1, path.EndpointA.ClientID, path.EndpointB.ClientID, timeoutTimestamp, payload) // create standard ack that can be malleated @@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { AppAcknowledgements: [][]byte{mockv2.MockRecvPacketResult.Acknowledgement}, } - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) tc.malleate() @@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { if expPass { suite.Require().NoError(err) - ackCommitment := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + ackCommitment := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().Equal(types.CommitAcknowledgement(ack), ackCommitment) } else { suite.Require().Error(err) @@ -342,23 +342,23 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { nil, }, { - "failure: channel not found", + "failure: client not found", func() { - packet.SourceChannel = ibctesting.InvalidID + packet.SourceClient = ibctesting.InvalidID }, - types.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { - "failure: counterparty channel identifier different than source channel", + "failure: counterparty client identifier different than destination client", func() { - packet.DestinationChannel = unusedChannel + packet.DestinationClient = unusedChannel }, - types.ErrInvalidChannelIdentifier, + clienttypes.ErrInvalidCounterparty, }, { "failure: packet commitment doesn't exist.", func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence) }, types.ErrNoOpMsg, }, @@ -409,7 +409,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { tc.malleate() - packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationClient, packet.Sequence) proof, proofHeight := path.EndpointB.QueryProof(packetKey) if freezeClient { @@ -422,7 +422,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { if expPass { suite.Require().NoError(err) - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence) + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.SourceClient, packet.Sequence) suite.Require().Empty(commitment) } else { suite.Require().Error(err) @@ -448,35 +448,35 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { "success", func() { // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") }, nil, }, { - "failure: channel not found", + "failure: client not found", func() { // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") - packet.SourceChannel = ibctesting.InvalidID + packet.SourceClient = ibctesting.InvalidID }, - types.ErrChannelNotFound, + clienttypes.ErrCounterpartyNotFound, }, { - "failure: counterparty channel identifier different than source channel", + "failure: counterparty client identifier different than destination client", func() { // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") - packet.DestinationChannel = unusedChannel + packet.DestinationClient = unusedChannel }, - types.ErrInvalidChannelIdentifier, + clienttypes.ErrInvalidCounterparty, }, { "failure: packet has not timed out yet", @@ -484,7 +484,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") }, @@ -498,7 +498,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { { "failure: packet does not match commitment", func() { - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") @@ -511,7 +511,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { "failure: client status invalid", func() { // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") @@ -523,12 +523,12 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { "failure: verify non-membership failed", func() { // send packet - _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceChannel, + _, _, err := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SendPacketTest(suite.chainA.GetContext(), packet.SourceClient, packet.TimeoutTimestamp, packet.Payloads) suite.Require().NoError(err, "send packet failed") // set packet receipt to mock a valid past receive - suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) }, commitmenttypes.ErrInvalidProof, }, @@ -551,7 +551,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) // test cases may mutate timeout values - packet = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, + packet = types.NewPacket(1, path.EndpointA.ClientID, path.EndpointB.ClientID, timeoutTimestamp, payload) tc.malleate() @@ -563,7 +563,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Require().NoError(path.EndpointA.UpdateClient()) // get proof of packet receipt absence from chainB - receiptKey := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) + receiptKey := hostv2.PacketReceiptKey(packet.DestinationClient, packet.Sequence) proof, proofHeight := path.EndpointB.QueryProof(receiptKey) if freezeClient { @@ -576,7 +576,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { if expPass { suite.Require().NoError(err) - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationChannel, packet.Sequence) + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationClient, packet.Sequence) suite.Require().Nil(commitment, "packet commitment not deleted") } else { suite.Require().Error(err) diff --git a/modules/core/04-channel/v2/types/channel.go b/modules/core/04-channel/v2/types/channel.go deleted file mode 100644 index f4ab5b2afe4..00000000000 --- a/modules/core/04-channel/v2/types/channel.go +++ /dev/null @@ -1,51 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" -) - -// NewChannel creates a new Channel instance -func NewChannel(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Channel { - return Channel{ - ClientId: clientID, - CounterpartyChannelId: counterpartyChannelID, - MerklePathPrefix: merklePathPrefix, - } -} - -// Validate validates the Channel -func (c Channel) Validate() error { - if err := host.ClientIdentifierValidator(c.ClientId); err != nil { - return err - } - - if err := host.ChannelIdentifierValidator(c.CounterpartyChannelId); err != nil { - return err - } - - if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidChannel, err.Error()) - } - - return nil -} - -// NewIdentifiedChannel creates a new IdentifiedChannel instance -func NewIdentifiedChannel(channelID string, channel Channel) IdentifiedChannel { - return IdentifiedChannel{ - Channel: channel, - ChannelId: channelID, - } -} - -// ValidateBasic performs a basic validation of the identifiers and channel fields. -func (ic IdentifiedChannel) ValidateBasic() error { - if err := host.ChannelIdentifierValidator(ic.ChannelId); err != nil { - return errorsmod.Wrap(err, "invalid channel ID") - } - - return ic.Channel.Validate() -} diff --git a/modules/core/04-channel/v2/types/channel.pb.go b/modules/core/04-channel/v2/types/channel.pb.go deleted file mode 100644 index 8d3dafb35ae..00000000000 --- a/modules/core/04-channel/v2/types/channel.pb.go +++ /dev/null @@ -1,658 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/channel/v2/channel.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - 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 - -// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol -// Each side will maintain its own Channel to create an IBC channel -// The channel will be referenced by a channelID which will be used to send packets -// to the counterparty -// The channel will contain the client identifier that will provide proof verification for the channel -// and the counterparty channel identifier that the other channel end will be using -// to send packets to our channel end. -type Channel struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the counterparty identifier that must be used by packets sent by counterparty - // to our channel end. - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` -} - -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_7e9b57d8f218397d, []int{0} -} -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 - -func (m *Channel) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Channel) GetCounterpartyChannelId() string { - if m != nil { - return m.CounterpartyChannelId - } - return "" -} - -func (m *Channel) GetMerklePathPrefix() v2.MerklePath { - if m != nil { - return m.MerklePathPrefix - } - return v2.MerklePath{} -} - -// IdentifiedChannel defines a channel with an additional channel identifier field. -type IdentifiedChannel struct { - // channel identified. - Channel Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel"` - // channel identifier - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} } -func (m *IdentifiedChannel) String() string { return proto.CompactTextString(m) } -func (*IdentifiedChannel) ProtoMessage() {} -func (*IdentifiedChannel) Descriptor() ([]byte, []int) { - return fileDescriptor_7e9b57d8f218397d, []int{1} -} -func (m *IdentifiedChannel) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *IdentifiedChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_IdentifiedChannel.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 *IdentifiedChannel) XXX_Merge(src proto.Message) { - xxx_messageInfo_IdentifiedChannel.Merge(m, src) -} -func (m *IdentifiedChannel) XXX_Size() int { - return m.Size() -} -func (m *IdentifiedChannel) XXX_DiscardUnknown() { - xxx_messageInfo_IdentifiedChannel.DiscardUnknown(m) -} - -var xxx_messageInfo_IdentifiedChannel proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Channel)(nil), "ibc.core.channel.v2.Channel") - proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v2.IdentifiedChannel") -} - -func init() { proto.RegisterFile("ibc/core/channel/v2/channel.proto", fileDescriptor_7e9b57d8f218397d) } - -var fileDescriptor_7e9b57d8f218397d = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4e, 0xea, 0x40, - 0x14, 0x86, 0x3b, 0xf7, 0x92, 0xcb, 0x65, 0xd8, 0x68, 0xd5, 0x48, 0x50, 0x0b, 0xb2, 0x91, 0x0d, - 0x33, 0xa6, 0x1a, 0x13, 0x0d, 0x2b, 0x5c, 0xb1, 0x30, 0x21, 0x2c, 0x58, 0xb8, 0x69, 0xda, 0xe9, - 0xd0, 0x4e, 0xec, 0x74, 0x9a, 0x76, 0x68, 0xe4, 0x0d, 0x5c, 0xfa, 0x08, 0x3e, 0x85, 0xcf, 0xc0, - 0x92, 0xa5, 0x2b, 0x63, 0xe0, 0x45, 0x4c, 0xa7, 0x2d, 0x90, 0xe8, 0xee, 0xcc, 0x39, 0xff, 0xf9, - 0xf2, 0xff, 0x73, 0xe0, 0x39, 0x73, 0x08, 0x26, 0x22, 0xa6, 0x98, 0xf8, 0x76, 0x18, 0xd2, 0x00, - 0xa7, 0x66, 0x59, 0xa2, 0x28, 0x16, 0x52, 0xe8, 0x07, 0xcc, 0x21, 0x28, 0x93, 0xa0, 0xb2, 0x9f, - 0x9a, 0xcd, 0x43, 0x4f, 0x78, 0x42, 0xcd, 0x71, 0x56, 0xe5, 0xd2, 0xe6, 0xc5, 0x96, 0x26, 0x38, - 0x67, 0x92, 0xd3, 0x50, 0x2a, 0xe0, 0xe6, 0x95, 0x0b, 0x3b, 0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b, 0xcc, 0x85, 0x3b, 0x0b, 0x68, 0x92, 0xdf, 0xe4, 0xf2, 0xba, 0xb7, 0x73, 0x64, 0x39, 0x8f, - 0x68, 0xe2, 0xfc, 0x53, 0xf7, 0xb8, 0xfa, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xc9, 0x7e, 0x8b, - 0x08, 0x02, 0x00, 0x00, -} - -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 - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.CounterpartyChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintChannel(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *IdentifiedChannel) 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 *IdentifiedChannel) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *IdentifiedChannel) 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 = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { - offset -= sovChannel(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Channel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - -func (m *IdentifiedChannel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Channel.Size() - n += 1 + l + sovChannel(uint64(l)) - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovChannel(uint64(l)) - } - return n -} - -func sovChannel(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozChannel(x uint64) (n int) { - return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -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 ErrIntOverflowChannel - } - 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 != 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - 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 CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *IdentifiedChannel) 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 ErrIntOverflowChannel - } - 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: IdentifiedChannel: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IdentifiedChannel: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 ErrIntOverflowChannel - } - 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 ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipChannel(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, ErrIntOverflowChannel - } - 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, ErrIntOverflowChannel - } - 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, ErrIntOverflowChannel - } - 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, ErrInvalidLengthChannel - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupChannel - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthChannel - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") -) diff --git a/modules/core/04-channel/v2/types/channel_test.go b/modules/core/04-channel/v2/types/channel_test.go deleted file mode 100644 index c6c71d9a157..00000000000 --- a/modules/core/04-channel/v2/types/channel_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package types_test - -import ( - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - ibctesting "github.com/cosmos/ibc-go/v9/testing" -) - -func (s *TypesTestSuite) TestValidateChannel() { - var c types.Channel - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - name: "success", - malleate: func() {}, - }, - { - name: "failure: invalid ClientID", - malleate: func() { - c.ClientId = "" - }, - expErr: host.ErrInvalidID, - }, - { - name: "failure: invalid counterparty channel id", - malleate: func() { - c.CounterpartyChannelId = "" - }, - expErr: host.ErrInvalidID, - }, - { - name: "failure: invalid Merkle Path Prefix", - malleate: func() { - c.MerklePathPrefix.KeyPath = [][]byte{} - }, - expErr: types.ErrInvalidChannel, - }, - } - for _, tc := range testCases { - s.Run(tc.name, func() { - c = types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondClientID, ibctesting.MerklePath) - - tc.malleate() - - err := c.Validate() - - expPass := tc.expErr == nil - if expPass { - s.Require().NoError(err) - } else { - ibctesting.RequireErrorIsOrContains(s.T(), err, tc.expErr) - } - }) - } -} diff --git a/modules/core/04-channel/v2/types/codec.go b/modules/core/04-channel/v2/types/codec.go index 12124c4e841..1207e8d4899 100644 --- a/modules/core/04-channel/v2/types/codec.go +++ b/modules/core/04-channel/v2/types/codec.go @@ -11,8 +11,6 @@ import ( func RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &MsgCreateChannel{}, - &MsgRegisterCounterparty{}, &MsgSendPacket{}, &MsgRecvPacket{}, &MsgTimeout{}, diff --git a/modules/core/04-channel/v2/types/commitment.go b/modules/core/04-channel/v2/types/commitment.go index 3f79cc3fad1..787b00bd4b4 100644 --- a/modules/core/04-channel/v2/types/commitment.go +++ b/modules/core/04-channel/v2/types/commitment.go @@ -7,13 +7,13 @@ import ( ) // CommitPacket returns the V2 packet commitment bytes. The commitment consists of: -// ha256_hash(0x02 + sha256_hash(destinationChannel) + sha256_hash(timeout) + sha256_hash(payload)) from a given packet. +// ha256_hash(0x02 + sha256_hash(destinationClient) + sha256_hash(timeout) + sha256_hash(payload)) from a given packet. // This results in a fixed length preimage of 32 bytes. // NOTE: A fixed length preimage is ESSENTIAL to prevent relayers from being able // to malleate the packet fields and create a commitment hash that matches the original packet. func CommitPacket(packet Packet) []byte { var buf []byte - destIDHash := sha256.Sum256([]byte(packet.DestinationChannel)) + destIDHash := sha256.Sum256([]byte(packet.DestinationClient)) buf = append(buf, destIDHash[:]...) timeoutBytes := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp()) diff --git a/modules/core/04-channel/v2/types/commitment_test.go b/modules/core/04-channel/v2/types/commitment_test.go index d469a41a298..bad4d42e465 100644 --- a/modules/core/04-channel/v2/types/commitment_test.go +++ b/modules/core/04-channel/v2/types/commitment_test.go @@ -26,7 +26,7 @@ func TestCommitPacket(t *testing.T) { { "json packet", func() {}, // default is json packet - "450194f2ce25b12487f65593e106d91367a1e5c90b2efc03ed78265a54cfcebe", + "a096722aa6534040a0efbdae05765132a7b223ad306d6512f3734821bd046505", }, { "abi packet", @@ -42,7 +42,7 @@ func TestCommitPacket(t *testing.T) { packet.Payloads[0].Value = transferData packet.Payloads[0].Encoding = transfertypes.EncodingABI }, - "b691a1950f6fb0bbbcf4bdb16fe2c4d0aa7ef783eb7803073f475cb8164d9b7a", + "d408dca5088b9b375edb3c4df6bae0e18084fc0dbd90fcd0d028506553c81b25", }, } @@ -57,10 +57,10 @@ func TestCommitPacket(t *testing.T) { }) require.NoError(t, err) packet = types.Packet{ - Sequence: 1, - SourceChannel: "channel-0", - DestinationChannel: "channel-1", - TimeoutTimestamp: 100, + Sequence: 1, + SourceClient: "07-tendermint-0", + DestinationClient: "07-tendermint-1", + TimeoutTimestamp: 100, Payloads: []types.Payload{ { SourcePort: transfertypes.PortID, diff --git a/modules/core/04-channel/v2/types/errors.go b/modules/core/04-channel/v2/types/errors.go index eb64f47e5ce..6407370c5be 100644 --- a/modules/core/04-channel/v2/types/errors.go +++ b/modules/core/04-channel/v2/types/errors.go @@ -5,18 +5,15 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 2, "invalid channel") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 4, "invalid packet") - ErrInvalidPayload = errorsmod.Register(SubModuleName, 5, "invalid payload") - ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 6, "sequence send not found") - ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 7, "invalid acknowledgement") - ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 8, "packet commitment not found") - ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 9, "packet acknowledgement not found") - ErrInvalidTimeout = errorsmod.Register(SubModuleName, 10, "invalid packet timeout") - ErrTimeoutElapsed = errorsmod.Register(SubModuleName, 11, "timeout elapsed") - ErrTimeoutNotReached = errorsmod.Register(SubModuleName, 12, "timeout not reached") - ErrInvalidChannelIdentifier = errorsmod.Register(SubModuleName, 13, "invalid channel identifier") - ErrAcknowledgementExists = errorsmod.Register(SubModuleName, 14, "acknowledgement for packet already exists") - ErrNoOpMsg = errorsmod.Register(SubModuleName, 15, "message is redundant, no-op will be performed") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 2, "invalid packet") + ErrInvalidPayload = errorsmod.Register(SubModuleName, 3, "invalid payload") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 4, "sequence send not found") + ErrInvalidAcknowledgement = errorsmod.Register(SubModuleName, 5, "invalid acknowledgement") + ErrPacketCommitmentNotFound = errorsmod.Register(SubModuleName, 6, "packet commitment not found") + ErrAcknowledgementNotFound = errorsmod.Register(SubModuleName, 7, "packet acknowledgement not found") + ErrInvalidTimeout = errorsmod.Register(SubModuleName, 8, "invalid packet timeout") + ErrTimeoutElapsed = errorsmod.Register(SubModuleName, 9, "timeout elapsed") + ErrTimeoutNotReached = errorsmod.Register(SubModuleName, 10, "timeout not reached") + ErrAcknowledgementExists = errorsmod.Register(SubModuleName, 11, "acknowledgement for packet already exists") + ErrNoOpMsg = errorsmod.Register(SubModuleName, 12, "message is redundant, no-op will be performed") ) diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 32cda94bba8..41db0741876 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -23,4 +23,6 @@ type ClientKeeper interface { GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool) // GetClientConsensusState gets the stored consensus state from a client at a given height. GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) + // GetClientCounterparty returns the counterpartyInfo given a clientID + GetClientCounterparty(ctx context.Context, clientID string) (clienttypes.CounterpartyInfo, bool) } diff --git a/modules/core/04-channel/v2/types/genesis.go b/modules/core/04-channel/v2/types/genesis.go index 3b567f97c87..d94365b15de 100644 --- a/modules/core/04-channel/v2/types/genesis.go +++ b/modules/core/04-channel/v2/types/genesis.go @@ -4,16 +4,15 @@ import ( "errors" "fmt" - channeltypesv1 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) // NewPacketState creates a new PacketState instance. -func NewPacketState(channelID string, sequence uint64, data []byte) PacketState { +func NewPacketState(clientID string, sequence uint64, data []byte) PacketState { return PacketState{ - ChannelId: channelID, - Sequence: sequence, - Data: data, + ClientId: clientID, + Sequence: sequence, + Data: data, } } @@ -22,74 +21,47 @@ func (ps PacketState) Validate() error { if ps.Data == nil { return errors.New("data bytes cannot be nil") } - return validateGenFields(ps.ChannelId, ps.Sequence) + return validateGenFields(ps.ClientId, ps.Sequence) } // NewPacketSequence creates a new PacketSequences instance. -func NewPacketSequence(channelID string, sequence uint64) PacketSequence { +func NewPacketSequence(clientID string, sequence uint64) PacketSequence { return PacketSequence{ - ChannelId: channelID, - Sequence: sequence, + ClientId: clientID, + Sequence: sequence, } } // Validate performs basic validation of fields returning an error upon any failure. func (ps PacketSequence) Validate() error { - return validateGenFields(ps.ChannelId, ps.Sequence) + return validateGenFields(ps.ClientId, ps.Sequence) } // NewGenesisState creates a GenesisState instance. func NewGenesisState( - channels []IdentifiedChannel, acks, receipts, commitments []PacketState, - sendSeqs []PacketSequence, nextChannelSequence uint64, + acks, receipts, commitments []PacketState, + sendSeqs []PacketSequence, ) GenesisState { return GenesisState{ - Channels: channels, - Acknowledgements: acks, - Receipts: receipts, - Commitments: commitments, - SendSequences: sendSeqs, - NextChannelSequence: nextChannelSequence, + Acknowledgements: acks, + Receipts: receipts, + Commitments: commitments, + SendSequences: sendSeqs, } } // DefaultGenesisState returns the ibc channel v2 submodule's default genesis state. func DefaultGenesisState() GenesisState { return GenesisState{ - Channels: []IdentifiedChannel{}, - Acknowledgements: []PacketState{}, - Receipts: []PacketState{}, - Commitments: []PacketState{}, - SendSequences: []PacketSequence{}, - NextChannelSequence: 0, + Acknowledgements: []PacketState{}, + Receipts: []PacketState{}, + Commitments: []PacketState{}, + SendSequences: []PacketSequence{}, } } // Validate performs basic genesis state validation returning an error upon any failure. func (gs GenesisState) Validate() error { - // keep track of the max sequence to ensure it is less than - // the next sequence used in creating channel identifiers. - var maxSequence uint64 - - for i, channel := range gs.Channels { - sequence, err := channeltypesv1.ParseChannelSequence(channel.ChannelId) - if err != nil { - return err - } - - if sequence > maxSequence { - maxSequence = sequence - } - - if err := channel.ValidateBasic(); err != nil { - return fmt.Errorf("invalid channel %v channel index %d: %w", channel, i, err) - } - } - - if maxSequence != 0 && maxSequence >= gs.NextChannelSequence { - return fmt.Errorf("next channel sequence %d must be greater than maximum sequence used in channel identifier %d", gs.NextChannelSequence, maxSequence) - } - for i, ack := range gs.Acknowledgements { if err := ack.Validate(); err != nil { return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", ack, i, err) @@ -123,8 +95,8 @@ func (gs GenesisState) Validate() error { return nil } -func validateGenFields(channelID string, sequence uint64) error { - if err := host.ChannelIdentifierValidator(channelID); err != nil { +func validateGenFields(clientID string, sequence uint64) error { + if err := host.ClientIdentifierValidator(clientID); err != nil { return fmt.Errorf("invalid channel Id: %w", err) } if sequence == 0 { diff --git a/modules/core/04-channel/v2/types/genesis.pb.go b/modules/core/04-channel/v2/types/genesis.pb.go index ea9c321819f..bb06101aec1 100644 --- a/modules/core/04-channel/v2/types/genesis.pb.go +++ b/modules/core/04-channel/v2/types/genesis.pb.go @@ -25,13 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the ibc channel/v2 submodule's genesis state. type GenesisState struct { - Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"` - Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"` - Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"` - Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"` - SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences"` - // the sequence for the next generated channel identifier - NextChannelSequence uint64 `protobuf:"varint,6,opt,name=next_channel_sequence,json=nextChannelSequence,proto3" json:"next_channel_sequence,omitempty"` + Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"` + Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"` + Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"` + SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,13 +64,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetChannels() []IdentifiedChannel { - if m != nil { - return m.Channels - } - return nil -} - func (m *GenesisState) GetAcknowledgements() []PacketState { if m != nil { return m.Acknowledgements @@ -102,20 +92,13 @@ func (m *GenesisState) GetSendSequences() []PacketSequence { return nil } -func (m *GenesisState) GetNextChannelSequence() uint64 { - if m != nil { - return m.NextChannelSequence - } - return 0 -} - // PacketState defines the generic type necessary to retrieve and store // packet commitments, acknowledgements, and receipts. // Caller is responsible for knowing the context necessary to interpret this // state as a commitment, acknowledgement, or a receipt. type PacketState struct { - // channel unique identifier. - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier. + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // packet sequence. Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` // embedded data that represents packet state. @@ -157,8 +140,8 @@ var xxx_messageInfo_PacketState proto.InternalMessageInfo // PacketSequence defines the genesis type necessary to retrieve and store next send sequences. type PacketSequence struct { - // channel unique identifier. - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier. + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // packet sequence Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } @@ -196,9 +179,9 @@ func (m *PacketSequence) XXX_DiscardUnknown() { var xxx_messageInfo_PacketSequence proto.InternalMessageInfo -func (m *PacketSequence) GetChannelId() string { +func (m *PacketSequence) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -219,35 +202,31 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/genesis.proto", fileDescriptor_b5d374f126f051c3) } var fileDescriptor_b5d374f126f051c3 = []byte{ - // 436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0xdd, 0x58, 0xb6, 0xb3, 0xb5, 0xe8, 0x54, 0x21, 0x2e, 0x98, 0x8d, 0x2b, 0x48, - 0x2e, 0xcd, 0x48, 0xf4, 0xa2, 0x78, 0x8a, 0x07, 0x2d, 0x5e, 0x4a, 0x04, 0x0f, 0x82, 0x94, 0x64, - 0xe6, 0x35, 0x1d, 0xba, 0x99, 0x59, 0x77, 0x66, 0x57, 0xfd, 0x06, 0x1e, 0xfd, 0x08, 0x7e, 0x9c, - 0x1e, 0x7b, 0x11, 0x3c, 0x15, 0xd9, 0xfd, 0x16, 0x9e, 0x24, 0x93, 0x3f, 0xac, 0x74, 0x11, 0x4a, - 0x6f, 0xef, 0xbc, 0xef, 0xf3, 0xfc, 0x9e, 0x97, 0xe1, 0xc5, 0x0f, 0x44, 0xce, 0x28, 0x53, 0x33, - 0xa0, 0xec, 0x24, 0x93, 0x12, 0x26, 0x74, 0x11, 0xd3, 0x02, 0x24, 0x68, 0xa1, 0xa3, 0xe9, 0x4c, - 0x19, 0x45, 0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0x74, 0x6b, 0x1a, 0xe7, 0x78, 0xb0, - 0xb6, 0x24, 0xb9, 0x8f, 0x71, 0xeb, 0x16, 0xdc, 0x43, 0x01, 0x0a, 0x77, 0xd2, 0x9d, 0xa6, 0x73, - 0xc8, 0xc9, 0x10, 0xf7, 0x3b, 0xe8, 0x96, 0x85, 0x76, 0x6f, 0x42, 0xb0, 0xcb, 0x33, 0x93, 0x79, - 0xbd, 0x00, 0x85, 0xbb, 0xa9, 0xad, 0x9f, 0xbb, 0xdf, 0x7e, 0x8c, 0x9c, 0xf1, 0x1b, 0xbc, 0xf7, - 0xef, 0xfa, 0xd7, 0x88, 0x49, 0xde, 0x9d, 0x2d, 0x7d, 0x74, 0xbe, 0xf4, 0xd1, 0xef, 0xa5, 0x8f, - 0xbe, 0xaf, 0x7c, 0xe7, 0x7c, 0xe5, 0x3b, 0xbf, 0x56, 0xbe, 0xf3, 0xfe, 0x45, 0x21, 0xcc, 0xc9, - 0x3c, 0x8f, 0x98, 0x2a, 0x29, 0x53, 0xba, 0x54, 0x9a, 0x8a, 0x9c, 0x1d, 0x14, 0x8a, 0x2e, 0x9e, - 0xd1, 0x52, 0xf1, 0xf9, 0x04, 0x74, 0x7d, 0xe5, 0x8f, 0x9f, 0x1e, 0xac, 0x1d, 0xba, 0xf9, 0x3a, - 0x05, 0x9d, 0x6f, 0xdb, 0x3b, 0x7f, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0x28, 0x88, 0xce, 0xb6, - 0x5a, 0x03, 0x00, 0x00, + // 370 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4f, 0xfa, 0x40, + 0x18, 0xc6, 0x5b, 0xe8, 0xff, 0x1f, 0x38, 0x90, 0x98, 0xd3, 0xa1, 0xc1, 0xa4, 0x54, 0x5c, 0xba, + 0xd0, 0x33, 0xe8, 0xa2, 0x71, 0x62, 0x51, 0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, 0x5d, + 0xc2, 0x76, 0x16, 0x80, 0xd5, 0x4e, 0xd6, 0xef, 0x50, 0x69, 0x23, 0x10, 0x1f, 0xa0, 0x22, 0x8d, + 0x19, 0x70, 0xd5, 0x65, 0xa1, 0xa9, 0xdb, 0xba, 0x53, 0xf4, 0x0a, 0xd9, 0xa2, 0x1d, 0xe2, 0x2a, + 0x2a, 0xac, 0x82, 0xcd, 0x9c, 0xad, 0x3b, 0x86, 0xb7, 0x7e, 0x63, 0x8c, 0x8c, 0xd0, 0x57, 0xbe, + 0x99, 0xb7, 0x75, 0xa7, 0xec, 0xa5, 0xf3, 0xb9, 0xf1, 0xf4, 0x52, 0xd3, 0xea, 0x6d, 0x54, 0xf9, + 0x7a, 0xc8, 0x9f, 0x43, 0x5a, 0x37, 0x93, 0x99, 0xa5, 0x4f, 0x67, 0x96, 0xfe, 0x31, 0xb3, 0xf4, + 0xe7, 0xb9, 0xa5, 0x4d, 0xe7, 0x96, 0xf6, 0x36, 0xb7, 0xb4, 0xdb, 0x8b, 0x88, 0xa9, 0xde, 0x28, + 0x70, 0xa9, 0x48, 0x08, 0x15, 0x32, 0x11, 0x92, 0xb0, 0x80, 0x36, 0x22, 0x41, 0xc6, 0x67, 0x24, + 0x11, 0xe1, 0x28, 0x06, 0x99, 0x35, 0xef, 0xf8, 0xb4, 0xb1, 0x51, 0x3e, 0xf5, 0x38, 0x00, 0x19, + 0xfc, 0x4f, 0x0b, 0x75, 0xf2, 0x19, 0x00, 0x00, 0xff, 0xff, 0xee, 0xb6, 0xa0, 0xcd, 0xa0, 0x02, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -270,11 +249,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NextChannelSequence != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.NextChannelSequence)) - i-- - dAtA[i] = 0x30 - } if len(m.SendSequences) > 0 { for iNdEx := len(m.SendSequences) - 1; iNdEx >= 0; iNdEx-- { { @@ -331,20 +305,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.Channels) > 0 { - for iNdEx := len(m.Channels) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Channels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } return len(dAtA) - i, nil } @@ -380,10 +340,10 @@ func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } @@ -415,10 +375,10 @@ func (m *PacketSequence) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } @@ -442,12 +402,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.Channels) > 0 { - for _, e := range m.Channels { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } if len(m.Acknowledgements) > 0 { for _, e := range m.Acknowledgements { l = e.Size() @@ -472,9 +426,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if m.NextChannelSequence != 0 { - n += 1 + sovGenesis(uint64(m.NextChannelSequence)) - } return n } @@ -484,7 +435,7 @@ func (m *PacketState) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } @@ -504,7 +455,7 @@ func (m *PacketSequence) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } @@ -549,40 +500,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Channels", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Channels = append(m.Channels, IdentifiedChannel{}) - if err := m.Channels[len(m.Channels)-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 Acknowledgements", wireType) @@ -719,25 +636,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextChannelSequence", wireType) - } - m.NextChannelSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NextChannelSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -790,7 +688,7 @@ func (m *PacketState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -818,7 +716,7 @@ func (m *PacketState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { @@ -925,7 +823,7 @@ func (m *PacketSequence) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -953,7 +851,7 @@ func (m *PacketSequence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { diff --git a/modules/core/04-channel/v2/types/genesis_test.go b/modules/core/04-channel/v2/types/genesis_test.go index e70290d54b1..7b22f9c5719 100644 --- a/modules/core/04-channel/v2/types/genesis_test.go +++ b/modules/core/04-channel/v2/types/genesis_test.go @@ -2,13 +2,11 @@ package types_test import ( "errors" - "fmt" "testing" "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -26,29 +24,13 @@ func TestValidateGenesis(t *testing.T) { { "valid genesis", types.NewGenesisState( - []types.IdentifiedChannel{ - types.NewIdentifiedChannel( - ibctesting.FirstChannelID, types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath), - ), - types.NewIdentifiedChannel( - ibctesting.SecondChannelID, types.NewChannel(ibctesting.SecondClientID, ibctesting.FirstChannelID, ibctesting.MerklePath), - ), - }, []types.PacketState{types.NewPacketState(ibctesting.FirstChannelID, 1, []byte("ack"))}, []types.PacketState{types.NewPacketState(ibctesting.SecondChannelID, 1, []byte(""))}, []types.PacketState{types.NewPacketState(ibctesting.FirstChannelID, 1, []byte("commit_hash"))}, []types.PacketSequence{types.NewPacketSequence(ibctesting.SecondChannelID, 1)}, - 2, ), nil, }, - { - "invalid channel identifier", - types.GenesisState{ - Channels: []types.IdentifiedChannel{types.NewIdentifiedChannel(ibctesting.InvalidID, types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath))}, - }, - host.ErrInvalidID, - }, { "invalid ack", types.GenesisState{ @@ -76,16 +58,6 @@ func TestValidateGenesis(t *testing.T) { }, errors.New("sequence cannot be 0"), }, - { - "next channel sequence is less than maximum channel identifier sequence used", - types.GenesisState{ - Channels: []types.IdentifiedChannel{ - types.NewIdentifiedChannel("channel-10", types.NewChannel(ibctesting.FirstClientID, ibctesting.SecondChannelID, ibctesting.MerklePath)), - }, - NextChannelSequence: 0, - }, - fmt.Errorf("next channel sequence 0 must be greater than maximum sequence used in channel identifier 10"), - }, } for _, tc := range testCases { diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index 9b636340e38..98c8e520b46 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -3,14 +3,4 @@ package types const ( // SubModuleName defines the channelv2 module name. SubModuleName = "channelv2" - - // ChannelPrefix is the prefix under which all v2 channels are stored. - // It is imported from types since it is not part of the ics-24 host - // specification. - ChannelPrefix = "channels" - - // CreatorPrefix is the prefix under which all v2 channel creators are stored. - // It is imported from types since it is not part of the ics-24 host - // specification. - CreatorPrefix = "creators" ) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index 8c9d3609be3..7c71e8972fe 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -9,7 +9,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" commitmenttypesv1 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) @@ -17,12 +16,6 @@ import ( const MaxTimeoutDelta time.Duration = 24 * time.Hour var ( - _ sdk.Msg = (*MsgCreateChannel)(nil) - _ sdk.HasValidateBasic = (*MsgCreateChannel)(nil) - - _ sdk.Msg = (*MsgRegisterCounterparty)(nil) - _ sdk.HasValidateBasic = (*MsgRegisterCounterparty)(nil) - _ sdk.Msg = (*MsgSendPacket)(nil) _ sdk.HasValidateBasic = (*MsgSendPacket)(nil) @@ -36,62 +29,10 @@ var ( _ sdk.HasValidateBasic = (*MsgAcknowledgement)(nil) ) -// NewMsgCreateChannel creates a new MsgCreateChannel instance -func NewMsgCreateChannel(clientID string, merklePathPrefix commitmenttypesv2.MerklePath, signer string) *MsgCreateChannel { - return &MsgCreateChannel{ - Signer: signer, - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, - } -} - -// ValidateBasic performs basic checks on a MsgCreateChannel. -func (msg *MsgCreateChannel) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { - return err - } - - if err := msg.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return err - } - - return nil -} - -// NewMsgRegisterCounterparty creates a new MsgRegisterCounterparty instance -func NewMsgRegisterCounterparty(channelID, counterpartyChannelID string, signer string) *MsgRegisterCounterparty { - return &MsgRegisterCounterparty{ - Signer: signer, - ChannelId: channelID, - CounterpartyChannelId: counterpartyChannelID, - } -} - -// ValidateBasic performs basic checks on a MsgRegisterCounterparty. -func (msg *MsgRegisterCounterparty) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { - return err - } - - if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { - return err - } - - return nil -} - // NewMsgSendPacket creates a new MsgSendPacket instance. -func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer string, payloads ...Payload) *MsgSendPacket { +func NewMsgSendPacket(sourceClient string, timeoutTimestamp uint64, signer string, payloads ...Payload) *MsgSendPacket { return &MsgSendPacket{ - SourceChannel: sourceChannel, + SourceClient: sourceClient, TimeoutTimestamp: timeoutTimestamp, Payloads: payloads, Signer: signer, @@ -100,7 +41,7 @@ func NewMsgSendPacket(sourceChannel string, timeoutTimestamp uint64, signer stri // ValidateBasic performs basic checks on a MsgSendPacket. func (msg *MsgSendPacket) ValidateBasic() error { - if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { + if err := host.ClientIdentifierValidator(msg.SourceClient); err != nil { return err } diff --git a/modules/core/04-channel/v2/types/msgs_test.go b/modules/core/04-channel/v2/types/msgs_test.go index 2097c106c09..e097a7fd173 100644 --- a/modules/core/04-channel/v2/types/msgs_test.go +++ b/modules/core/04-channel/v2/types/msgs_test.go @@ -1,7 +1,6 @@ package types_test import ( - "errors" "testing" "github.com/stretchr/testify/suite" @@ -36,117 +35,6 @@ func TestTypesTestSuite(t *testing.T) { suite.Run(t, new(TypesTestSuite)) } -func (s *TypesTestSuite) TestMsgRegisterCounterpartyValidateBasic() { - var msg *types.MsgRegisterCounterparty - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: invalid signer address", - func() { - msg.Signer = "invalid" - }, - ibcerrors.ErrInvalidAddress, - }, - { - "failure: invalid channel ID", - func() { - msg.ChannelId = "" - }, - host.ErrInvalidID, - }, - { - "failure: invalid counterparty channel ID", - func() { - msg.CounterpartyChannelId = "" - }, - host.ErrInvalidID, - }, - } - - for _, tc := range testCases { - msg = types.NewMsgRegisterCounterparty( - ibctesting.FirstChannelID, - ibctesting.SecondChannelID, - ibctesting.TestAccAddress, - ) - - tc.malleate() - - err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { - s.Require().NoError(err, "valid case %s failed", tc.name) - } else { - s.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) - } - } -} - -// TestMsgCreateChannelValidateBasic tests ValidateBasic for MsgCreateChannel -func (s *TypesTestSuite) TestMsgCreateChannelValidateBasic() { - var msg *types.MsgCreateChannel - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: invalid signer address", - func() { - msg.Signer = "invalid" - }, - ibcerrors.ErrInvalidAddress, - }, - { - "failure: invalid client ID", - func() { - msg.ClientId = "" - }, - host.ErrInvalidID, - }, - { - "failure: empty key path", - func() { - msg.MerklePathPrefix.KeyPath = nil - }, - errors.New("path cannot have length 0"), - }, - } - - for _, tc := range testCases { - msg = types.NewMsgCreateChannel( - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("key")), - ibctesting.TestAccAddress, - ) - - tc.malleate() - - err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { - s.Require().NoError(err, "valid case %s failed", tc.name) - } else { - s.Require().ErrorContains(err, tc.expError.Error(), "invalid case %s passed", tc.name) - } - } -} - func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { var msg *types.MsgSendPacket testCases := []struct { @@ -161,7 +49,7 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() { { name: "failure: invalid source channel", malleate: func() { - msg.SourceChannel = "" + msg.SourceClient = "" }, expError: host.ErrInvalidID, }, diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index 9fe360c5a6c..e78a598fa6e 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -10,13 +10,13 @@ import ( ) // NewPacket constructs a new packet. -func NewPacket(sequence uint64, sourceChannel, destinationChannel string, timeoutTimestamp uint64, payloads ...Payload) Packet { +func NewPacket(sequence uint64, sourceClient, destinationClient string, timeoutTimestamp uint64, payloads ...Payload) Packet { return Packet{ - Sequence: sequence, - SourceChannel: sourceChannel, - DestinationChannel: destinationChannel, - TimeoutTimestamp: timeoutTimestamp, - Payloads: payloads, + Sequence: sequence, + SourceClient: sourceClient, + DestinationClient: destinationClient, + TimeoutTimestamp: timeoutTimestamp, + Payloads: payloads, } } @@ -43,11 +43,11 @@ func (p Packet) ValidateBasic() error { } } - if err := host.ChannelIdentifierValidator(p.SourceChannel); err != nil { - return errorsmod.Wrap(err, "invalid source channel ID") + if err := host.ChannelIdentifierValidator(p.SourceClient); err != nil { + return errorsmod.Wrap(err, "invalid source ID") } - if err := host.ChannelIdentifierValidator(p.DestinationChannel); err != nil { - return errorsmod.Wrap(err, "invalid destination channel ID") + if err := host.ChannelIdentifierValidator(p.DestinationClient); err != nil { + return errorsmod.Wrap(err, "invalid destination ID") } if p.Sequence == 0 { diff --git a/modules/core/04-channel/v2/types/packet.pb.go b/modules/core/04-channel/v2/types/packet.pb.go index cb14c1e8880..2c52ed19bf9 100644 --- a/modules/core/04-channel/v2/types/packet.pb.go +++ b/modules/core/04-channel/v2/types/packet.pb.go @@ -65,10 +65,10 @@ type Packet struct { // 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 sending chain. - SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` - // identifies the receiving chain. - DestinationChannel string `protobuf:"bytes,3,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` + // identifies the sending client on the sending chain. + SourceClient string `protobuf:"bytes,2,opt,name=source_client,json=sourceClient,proto3" json:"source_client,omitempty"` + // identifies the receiving client on the receiving chain. + DestinationClient string `protobuf:"bytes,3,opt,name=destination_client,json=destinationClient,proto3" json:"destination_client,omitempty"` // timeout timestamp in seconds after which the packet times out. TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` // a list of payloads, each one for a specific application. @@ -115,16 +115,16 @@ func (m *Packet) GetSequence() uint64 { return 0 } -func (m *Packet) GetSourceChannel() string { +func (m *Packet) GetSourceClient() string { if m != nil { - return m.SourceChannel + return m.SourceClient } return "" } -func (m *Packet) GetDestinationChannel() string { +func (m *Packet) GetDestinationClient() string { if m != nil { - return m.DestinationChannel + return m.DestinationClient } return "" } @@ -336,44 +336,44 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/packet.proto", fileDescriptor_2f814aba9ca97169) } var fileDescriptor_2f814aba9ca97169 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0xc7, 0xeb, 0xb5, 0xdd, 0x56, 0xaf, 0x6c, 0xc1, 0x1d, 0x52, 0xa8, 0x50, 0x17, 0x2a, 0x01, - 0x05, 0xb4, 0x04, 0x0a, 0x97, 0x49, 0x08, 0xa9, 0xcb, 0x32, 0x69, 0x02, 0x95, 0xca, 0x69, 0x91, - 0xe0, 0x52, 0xb9, 0xae, 0x95, 0x45, 0x4b, 0xe2, 0x10, 0x3b, 0x99, 0xf6, 0x0a, 0x3b, 0xf1, 0x02, - 0x3b, 0x70, 0xe6, 0x45, 0x76, 0xdc, 0x91, 0x13, 0x42, 0xdb, 0x89, 0xb7, 0x40, 0x75, 0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0xe0, 0x5a, 0x11, 0x28, 0xe6, 0x89, 0x54, 0x79, 0x6b, 0x18, 0xe6, 0xd2, 0x80, - 0x27, 0x12, 0x3d, 0x85, 0xda, 0x62, 0x14, 0x45, 0xe5, 0x99, 0x37, 0x16, 0x74, 0x85, 0xea, 0x70, - 0x25, 0x63, 0x89, 0xf0, 0x79, 0x54, 0x24, 0xbd, 0x2e, 0x67, 0x23, 0x65, 0x11, 0xe5, 0x53, 0x3f, - 0xf2, 0x54, 0xaa, 0x1a, 0x9e, 0xd7, 0x68, 0x13, 0x56, 0x33, 0x12, 0xa4, 0x4c, 0xaf, 0x1a, 0xa0, - 0x53, 0xc7, 0x79, 0xd1, 0xde, 0x83, 0x1b, 0x3d, 0x7a, 0x14, 0xf1, 0xe3, 0x80, 0x4d, 0x3d, 0x16, - 0xb2, 0x48, 0xa2, 0x97, 0x70, 0x93, 0xc4, 0xf1, 0x98, 0xdc, 0x94, 0x85, 0x0e, 0x8c, 0x72, 0xa7, - 0x8e, 0x1b, 0x24, 0x8e, 0x6f, 0x39, 0x44, 0xfb, 0x18, 0x6a, 0x98, 0xd1, 0x2c, 0x7f, 0x58, 0xcc, - 0x44, 0x1a, 0x48, 0xb4, 0x03, 0x97, 0x85, 0x24, 0x32, 0x15, 0x2a, 0xec, 0x7a, 0xf7, 0xe1, 0x7f, - 0x66, 0x37, 0xb3, 0xb8, 0x0a, 0xc4, 0x85, 0x01, 0x75, 0xe0, 0xc6, 0xad, 0xdb, 0xd5, 0x28, 0xea, - 0xf8, 0xb6, 0xfc, 0xec, 0x3b, 0x80, 0xf5, 0xc5, 0x23, 0xd0, 0x13, 0x78, 0x7f, 0xd0, 0xb3, 0xdf, - 0x39, 0xc3, 0xb1, 0x3b, 0xec, 0x0d, 0x47, 0xee, 0x78, 0xd4, 0x77, 0x07, 0x8e, 0x7d, 0xb0, 0x7f, - 0xe0, 0xec, 0x69, 0xa5, 0xe6, 0xea, 0xe9, 0x99, 0x51, 0xe9, 0x7f, 0xe8, 0x3b, 0xe8, 0x31, 0xbc, - 0x77, 0x13, 0x74, 0x47, 0xb6, 0xed, 0xb8, 0xae, 0x06, 0x9a, 0x6b, 0xa7, 0x67, 0xc6, 0x8a, 0x9b, - 0x52, 0xca, 0x84, 0xf8, 0x9b, 0xdb, 0xef, 0x1d, 0xbc, 0x1f, 0x61, 0x47, 0x5b, 0xca, 0xb9, 0x7d, - 0xe2, 0x07, 0x69, 0xc2, 0x50, 0x1b, 0x36, 0x6e, 0x72, 0x3d, 0xf7, 0x53, 0xdf, 0xd6, 0xca, 0xcd, - 0xda, 0xe9, 0x99, 0x51, 0xed, 0x89, 0x93, 0x88, 0xee, 0x7e, 0x3c, 0xbf, 0x6c, 0x81, 0x8b, 0xcb, - 0x16, 0xf8, 0x75, 0xd9, 0x02, 0x5f, 0xaf, 0x5a, 0xa5, 0x8b, 0xab, 0x56, 0xe9, 0xc7, 0x55, 0xab, - 0xf4, 0xf9, 0x8d, 0xe7, 0xcb, 0xc3, 0x74, 0x62, 0x52, 0x1e, 0x5a, 0x94, 0x8b, 0x90, 0x0b, 0xcb, - 0x9f, 0xd0, 0x6d, 0x8f, 0x5b, 0xd9, 0x8e, 0x15, 0xf2, 0x69, 0x1a, 0x30, 0x91, 0xef, 0xe0, 0x8b, - 0xd7, 0xdb, 0x0b, 0x6b, 0x28, 0x4f, 0x62, 0x26, 0x26, 0xcb, 0x6a, 0xb7, 0x5e, 0xfd, 0x09, 0x00, - 0x00, 0xff, 0xff, 0x23, 0xd8, 0x40, 0xe5, 0xaa, 0x03, 0x00, 0x00, + // 588 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0xb3, 0x4d, 0xd2, 0x36, 0xdb, 0x40, 0xdd, 0x6d, 0x91, 0x4c, 0x84, 0x52, 0x13, 0x24, + 0x08, 0xa0, 0xda, 0x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0x36, 0x46, 0x57, 0x3a, 0x7a, 0x0b, + 0x97, 0x63, 0x72, 0x1c, 0x70, 0x32, 0x13, 0x7a, 0xdd, 0xa8, 0x76, 0x57, 0x7a, 0x0f, 0xcc, 0x7f, + 0xa4, 0x34, 0x87, 0x05, 0xb4, 0x53, 0x3b, 0xfb, 0xb9, 0x59, 0xc1, 0xd7, 0x9e, 0xce, 0x37, 0x00, + 0x97, 0xca, 0x1e, 0xda, 0x84, 0x2b, 0x65, 0x98, 0x98, 0x27, 0x52, 0x65, 0x6d, 0x60, 0x58, 0x48, + 0x43, 0x9e, 0x48, 0xf4, 0x14, 0x6a, 0xf3, 0x41, 0x14, 0x55, 0x04, 0x5e, 0x9d, 0xd3, 0x15, 0xaa, + 0xc3, 0xa5, 0x8c, 0x25, 0xc2, 0xe7, 0x51, 0x19, 0xf4, 0xaa, 0xcc, 0xd7, 0xc9, 0x22, 0xca, 0x67, + 0x7e, 0xe4, 0xa9, 0x54, 0x0d, 0x7c, 0x5d, 0xa3, 0x0d, 0x58, 0xcf, 0x48, 0x90, 0x32, 0xbd, 0x6e, + 0x80, 0x6e, 0x13, 0x17, 0x45, 0x67, 0x17, 0xae, 0xf6, 0xe9, 0x61, 0xc4, 0x8f, 0x02, 0x36, 0xf3, + 0x58, 0x98, 0xef, 0xe8, 0x25, 0xdc, 0x20, 0x71, 0x3c, 0x21, 0x37, 0x65, 0xa1, 0x03, 0xa3, 0xda, + 0x6d, 0xe2, 0x75, 0x12, 0xc7, 0xb7, 0x1c, 0xa2, 0x73, 0x04, 0x35, 0xcc, 0x68, 0x56, 0xfc, 0x54, + 0xcc, 0x44, 0x1a, 0x48, 0xb4, 0x0d, 0x17, 0x85, 0x24, 0x32, 0x15, 0x2a, 0xec, 0xdd, 0xde, 0xc3, + 0xff, 0xec, 0x2e, 0xb7, 0xb8, 0x0a, 0xc4, 0xa5, 0x01, 0x75, 0xe1, 0xea, 0xad, 0xe9, 0x6a, 0x15, + 0x4d, 0x7c, 0x5b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, 0xa6, 0x03, 0x00, 0x00, } func (m *Packet) Marshal() (dAtA []byte, err error) { @@ -415,17 +415,17 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.DestinationChannel) > 0 { - i -= len(m.DestinationChannel) - copy(dAtA[i:], m.DestinationChannel) - i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationChannel))) + if len(m.DestinationClient) > 0 { + i -= len(m.DestinationClient) + copy(dAtA[i:], m.DestinationClient) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DestinationClient))) i-- dAtA[i] = 0x1a } - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintPacket(dAtA, i, uint64(len(m.SourceChannel))) + if len(m.SourceClient) > 0 { + i -= len(m.SourceClient) + copy(dAtA[i:], m.SourceClient) + i = encodeVarintPacket(dAtA, i, uint64(len(m.SourceClient))) i-- dAtA[i] = 0x12 } @@ -582,11 +582,11 @@ func (m *Packet) Size() (n int) { if m.Sequence != 0 { n += 1 + sovPacket(uint64(m.Sequence)) } - l = len(m.SourceChannel) + l = len(m.SourceClient) if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - l = len(m.DestinationChannel) + l = len(m.DestinationClient) if l > 0 { n += 1 + l + sovPacket(uint64(l)) } @@ -718,7 +718,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SourceClient", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -746,11 +746,11 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) + m.SourceClient = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DestinationClient", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -778,7 +778,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DestinationChannel = string(dAtA[iNdEx:postIndex]) + m.DestinationClient = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 0 { diff --git a/modules/core/04-channel/v2/types/packet_test.go b/modules/core/04-channel/v2/types/packet_test.go index 4952e03671d..ec5d5776160 100644 --- a/modules/core/04-channel/v2/types/packet_test.go +++ b/modules/core/04-channel/v2/types/packet_test.go @@ -55,16 +55,16 @@ func TestValidateBasic(t *testing.T) { host.ErrInvalidID, }, { - "failure: invalid source channel ID", + "failure: invalid source ID", func() { - packet.SourceChannel = "" + packet.SourceClient = "" }, host.ErrInvalidID, }, { - "failure: invalid dest channel ID", + "failure: invalid dest ID", func() { - packet.DestinationChannel = "" + packet.DestinationClient = "" }, host.ErrInvalidID, }, diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index 92913c0ae19..fdc87dccb39 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -1,55 +1,13 @@ package types import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ) -// NewQueryChannelRequest creates and returns a new channel query request. -func NewQueryChannelRequest(channelID string) *QueryChannelRequest { - return &QueryChannelRequest{ - ChannelId: channelID, - } -} - -// NewQueryChannelResponse creates and returns a new channel query response. -func NewQueryChannelResponse(channel Channel) *QueryChannelResponse { - return &QueryChannelResponse{ - Channel: channel, - } -} - -// NewQueryChannelClientStateRequest creates and returns a new ChannelClientState query request. -func NewQueryChannelClientStateRequest(channelID string) *QueryChannelClientStateRequest { - return &QueryChannelClientStateRequest{ - ChannelId: channelID, - } -} - -// NewQueryChannelClientStateResponse creates and returns a new ChannelClientState query response. -func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height clienttypes.Height) *QueryChannelClientStateResponse { - return &QueryChannelClientStateResponse{ - IdentifiedClientState: &identifiedClientState, - Proof: proof, - ProofHeight: height, - } -} - -// NewQueryChannelConsensusStateResponse creates and returns a new ChannelConsensusState query response. -func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, proof []byte, height clienttypes.Height) *QueryChannelConsensusStateResponse { - return &QueryChannelConsensusStateResponse{ - ConsensusState: anyConsensusState, - ClientId: clientID, - Proof: proof, - ProofHeight: height, - } -} - // NewQueryNextSequenceSendRequest creates a new next sequence send query. -func NewQueryNextSequenceSendRequest(channelID string) *QueryNextSequenceSendRequest { +func NewQueryNextSequenceSendRequest(clientID string) *QueryNextSequenceSendRequest { return &QueryNextSequenceSendRequest{ - ChannelId: channelID, + ClientId: clientID, } } @@ -65,10 +23,10 @@ func NewQueryNextSequenceSendResponse( } // NewQueryPacketCommitmentRequest creates and returns a new packet commitment query request. -func NewQueryPacketCommitmentRequest(channelID string, sequence uint64) *QueryPacketCommitmentRequest { +func NewQueryPacketCommitmentRequest(clientID string, sequence uint64) *QueryPacketCommitmentRequest { return &QueryPacketCommitmentRequest{ - ChannelId: channelID, - Sequence: sequence, + ClientId: clientID, + Sequence: sequence, } } @@ -82,10 +40,10 @@ func NewQueryPacketCommitmentResponse(commitmentHash []byte, proof []byte, proof } // NewQueryPacketAcknowledgementRequest creates and returns a new packet acknowledgement query request. -func NewQueryPacketAcknowledgementRequest(channelID string, sequence uint64) *QueryPacketAcknowledgementRequest { +func NewQueryPacketAcknowledgementRequest(clientID string, sequence uint64) *QueryPacketAcknowledgementRequest { return &QueryPacketAcknowledgementRequest{ - ChannelId: channelID, - Sequence: sequence, + ClientId: clientID, + Sequence: sequence, } } @@ -99,10 +57,10 @@ func NewQueryPacketAcknowledgementResponse(acknowledgementHash []byte, proof []b } // NewQueryPacketReceiptRequest creates and returns a new packet receipt query request. -func NewQueryPacketReceiptRequest(channelID string, sequence uint64) *QueryPacketReceiptRequest { +func NewQueryPacketReceiptRequest(clientID string, sequence uint64) *QueryPacketReceiptRequest { return &QueryPacketReceiptRequest{ - ChannelId: channelID, - Sequence: sequence, + ClientId: clientID, + Sequence: sequence, } } @@ -116,9 +74,9 @@ func NewQueryPacketReceiptResponse(exists bool, proof []byte, height clienttypes } // NewQueryPacketReceiptRequest creates and returns a new packet receipt query request. -func NewQueryUnreceivedPacketsRequest(channelID string, sequences []uint64) *QueryUnreceivedPacketsRequest { +func NewQueryUnreceivedPacketsRequest(clientID string, sequences []uint64) *QueryUnreceivedPacketsRequest { return &QueryUnreceivedPacketsRequest{ - ChannelId: channelID, + ClientId: clientID, Sequences: sequences, } } diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 90f01927af7..4f230d4757a 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - types1 "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -32,359 +31,17 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryChannelRequest is the request type for the Query/Channel RPC method -type QueryChannelRequest struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *QueryChannelRequest) Reset() { *m = QueryChannelRequest{} } -func (m *QueryChannelRequest) String() string { return proto.CompactTextString(m) } -func (*QueryChannelRequest) ProtoMessage() {} -func (*QueryChannelRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{0} -} -func (m *QueryChannelRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelRequest.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 *QueryChannelRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelRequest.Merge(m, src) -} -func (m *QueryChannelRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelRequest proto.InternalMessageInfo - -func (m *QueryChannelRequest) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -// QueryChannelRequest is the response type for the Query/Channel RPC method -type QueryChannelResponse struct { - // the channel associated with the provided channel id - Channel Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel"` -} - -func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } -func (m *QueryChannelResponse) String() string { return proto.CompactTextString(m) } -func (*QueryChannelResponse) ProtoMessage() {} -func (*QueryChannelResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{1} -} -func (m *QueryChannelResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelResponse.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 *QueryChannelResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelResponse.Merge(m, src) -} -func (m *QueryChannelResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelResponse proto.InternalMessageInfo - -func (m *QueryChannelResponse) GetChannel() Channel { - if m != nil { - return m.Channel - } - return Channel{} -} - -// QueryChannelClientStateRequest is the request type for the Query/ClientState -// RPC method -type QueryChannelClientStateRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *QueryChannelClientStateRequest) Reset() { *m = QueryChannelClientStateRequest{} } -func (m *QueryChannelClientStateRequest) String() string { return proto.CompactTextString(m) } -func (*QueryChannelClientStateRequest) ProtoMessage() {} -func (*QueryChannelClientStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{2} -} -func (m *QueryChannelClientStateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelClientStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelClientStateRequest.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 *QueryChannelClientStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelClientStateRequest.Merge(m, src) -} -func (m *QueryChannelClientStateRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelClientStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelClientStateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelClientStateRequest proto.InternalMessageInfo - -func (m *QueryChannelClientStateRequest) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -// QueryChannelClientStateResponse is the Response type for the -// Query/QueryChannelClientState RPC method -type QueryChannelClientStateResponse struct { - // client state associated with the channel - IdentifiedClientState *types.IdentifiedClientState `protobuf:"bytes,1,opt,name=identified_client_state,json=identifiedClientState,proto3" json:"identified_client_state,omitempty"` - // merkle proof of existence - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - // height at which the proof was retrieved - ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` -} - -func (m *QueryChannelClientStateResponse) Reset() { *m = QueryChannelClientStateResponse{} } -func (m *QueryChannelClientStateResponse) String() string { return proto.CompactTextString(m) } -func (*QueryChannelClientStateResponse) ProtoMessage() {} -func (*QueryChannelClientStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{3} -} -func (m *QueryChannelClientStateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelClientStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelClientStateResponse.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 *QueryChannelClientStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelClientStateResponse.Merge(m, src) -} -func (m *QueryChannelClientStateResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelClientStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelClientStateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelClientStateResponse proto.InternalMessageInfo - -func (m *QueryChannelClientStateResponse) GetIdentifiedClientState() *types.IdentifiedClientState { - if m != nil { - return m.IdentifiedClientState - } - return nil -} - -func (m *QueryChannelClientStateResponse) GetProof() []byte { - if m != nil { - return m.Proof - } - return nil -} - -func (m *QueryChannelClientStateResponse) GetProofHeight() types.Height { - if m != nil { - return m.ProofHeight - } - return types.Height{} -} - -// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState -// RPC method -type QueryChannelConsensusStateRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // revision number of the consensus state - RevisionNumber uint64 `protobuf:"varint,2,opt,name=revision_number,json=revisionNumber,proto3" json:"revision_number,omitempty"` - // revision height of the consensus state - RevisionHeight uint64 `protobuf:"varint,3,opt,name=revision_height,json=revisionHeight,proto3" json:"revision_height,omitempty"` -} - -func (m *QueryChannelConsensusStateRequest) Reset() { *m = QueryChannelConsensusStateRequest{} } -func (m *QueryChannelConsensusStateRequest) String() string { return proto.CompactTextString(m) } -func (*QueryChannelConsensusStateRequest) ProtoMessage() {} -func (*QueryChannelConsensusStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} -} -func (m *QueryChannelConsensusStateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelConsensusStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelConsensusStateRequest.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 *QueryChannelConsensusStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelConsensusStateRequest.Merge(m, src) -} -func (m *QueryChannelConsensusStateRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelConsensusStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelConsensusStateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelConsensusStateRequest proto.InternalMessageInfo - -func (m *QueryChannelConsensusStateRequest) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -func (m *QueryChannelConsensusStateRequest) GetRevisionNumber() uint64 { - if m != nil { - return m.RevisionNumber - } - return 0 -} - -func (m *QueryChannelConsensusStateRequest) GetRevisionHeight() uint64 { - if m != nil { - return m.RevisionHeight - } - return 0 -} - -// QueryChannelConsensusStateResponse is the Response type for the -// Query/QueryChannelConsensusState RPC method -type QueryChannelConsensusStateResponse struct { - // consensus state associated with the channel - ConsensusState *types1.Any `protobuf:"bytes,1,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty"` - // client ID associated with the consensus state - ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // merkle proof of existence - Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` - // height at which the proof was retrieved - ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` -} - -func (m *QueryChannelConsensusStateResponse) Reset() { *m = QueryChannelConsensusStateResponse{} } -func (m *QueryChannelConsensusStateResponse) String() string { return proto.CompactTextString(m) } -func (*QueryChannelConsensusStateResponse) ProtoMessage() {} -func (*QueryChannelConsensusStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} -} -func (m *QueryChannelConsensusStateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelConsensusStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelConsensusStateResponse.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 *QueryChannelConsensusStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelConsensusStateResponse.Merge(m, src) -} -func (m *QueryChannelConsensusStateResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelConsensusStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelConsensusStateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelConsensusStateResponse proto.InternalMessageInfo - -func (m *QueryChannelConsensusStateResponse) GetConsensusState() *types1.Any { - if m != nil { - return m.ConsensusState - } - return nil -} - -func (m *QueryChannelConsensusStateResponse) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *QueryChannelConsensusStateResponse) GetProof() []byte { - if m != nil { - return m.Proof - } - return nil -} - -func (m *QueryChannelConsensusStateResponse) GetProofHeight() types.Height { - if m != nil { - return m.ProofHeight - } - return types.Height{} -} - // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method type QueryNextSequenceSendRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` } func (m *QueryNextSequenceSendRequest) Reset() { *m = QueryNextSequenceSendRequest{} } func (m *QueryNextSequenceSendRequest) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendRequest) ProtoMessage() {} func (*QueryNextSequenceSendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{0} } func (m *QueryNextSequenceSendRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,9 +70,9 @@ func (m *QueryNextSequenceSendRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryNextSequenceSendRequest proto.InternalMessageInfo -func (m *QueryNextSequenceSendRequest) GetChannelId() string { +func (m *QueryNextSequenceSendRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -434,7 +91,7 @@ func (m *QueryNextSequenceSendResponse) Reset() { *m = QueryNextSequence func (m *QueryNextSequenceSendResponse) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendResponse) ProtoMessage() {} func (*QueryNextSequenceSendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{1} } func (m *QueryNextSequenceSendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -486,8 +143,8 @@ func (m *QueryNextSequenceSendResponse) GetProofHeight() types.Height { // QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. type QueryPacketCommitmentRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // packet sequence Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } @@ -496,7 +153,7 @@ func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitm func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentRequest) ProtoMessage() {} func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{8} + return fileDescriptor_a328cba4986edcab, []int{2} } func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -525,9 +182,9 @@ func (m *QueryPacketCommitmentRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPacketCommitmentRequest proto.InternalMessageInfo -func (m *QueryPacketCommitmentRequest) GetChannelId() string { +func (m *QueryPacketCommitmentRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -553,7 +210,7 @@ func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentResponse) ProtoMessage() {} func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{9} + return fileDescriptor_a328cba4986edcab, []int{3} } func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -605,8 +262,8 @@ func (m *QueryPacketCommitmentResponse) GetProofHeight() types.Height { // QueryPacketCommitmentsRequest is the request type for the Query/PacketCommitments RPC method. type QueryPacketCommitmentsRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // pagination request Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -615,7 +272,7 @@ func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsRequest) ProtoMessage() {} func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{10} + return fileDescriptor_a328cba4986edcab, []int{4} } func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -644,9 +301,9 @@ func (m *QueryPacketCommitmentsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPacketCommitmentsRequest proto.InternalMessageInfo -func (m *QueryPacketCommitmentsRequest) GetChannelId() string { +func (m *QueryPacketCommitmentsRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -672,7 +329,7 @@ func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommi func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsResponse) ProtoMessage() {} func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{11} + return fileDescriptor_a328cba4986edcab, []int{5} } func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -724,8 +381,8 @@ func (m *QueryPacketCommitmentsResponse) GetHeight() types.Height { // QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. type QueryPacketAcknowledgementRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // packet sequence Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } @@ -734,7 +391,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -763,9 +420,9 @@ func (m *QueryPacketAcknowledgementRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPacketAcknowledgementRequest proto.InternalMessageInfo -func (m *QueryPacketAcknowledgementRequest) GetChannelId() string { +func (m *QueryPacketAcknowledgementRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -791,7 +448,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -844,8 +501,8 @@ func (m *QueryPacketAcknowledgementResponse) GetProofHeight() types.Height { // QueryPacketAcknowledgementsRequest is the request type for the // Query/QueryPacketCommitments RPC method type QueryPacketAcknowledgementsRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // pagination request Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` // list of packet sequences @@ -856,7 +513,7 @@ func (m *QueryPacketAcknowledgementsRequest) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{14} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketAcknowledgementsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -885,9 +542,9 @@ func (m *QueryPacketAcknowledgementsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPacketAcknowledgementsRequest proto.InternalMessageInfo -func (m *QueryPacketAcknowledgementsRequest) GetChannelId() string { +func (m *QueryPacketAcknowledgementsRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -920,7 +577,7 @@ func (m *QueryPacketAcknowledgementsResponse) Reset() { *m = QueryPacket func (m *QueryPacketAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{15} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -972,19 +629,17 @@ func (m *QueryPacketAcknowledgementsResponse) GetHeight() types.Height { // QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. type QueryPacketReceiptRequest struct { - // port unique identifier - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - // channel unique identifier - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // packet sequence - Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptRequest{} } func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{16} + return fileDescriptor_a328cba4986edcab, []int{10} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1013,16 +668,9 @@ func (m *QueryPacketReceiptRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPacketReceiptRequest proto.InternalMessageInfo -func (m *QueryPacketReceiptRequest) GetPortId() string { - if m != nil { - return m.PortId - } - return "" -} - -func (m *QueryPacketReceiptRequest) GetChannelId() string { +func (m *QueryPacketReceiptRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -1048,7 +696,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{17} + return fileDescriptor_a328cba4986edcab, []int{11} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1100,8 +748,8 @@ func (m *QueryPacketReceiptResponse) GetProofHeight() types.Height { // QueryUnreceivedPacketsRequest is the request type for the Query/UnreceivedPackets RPC method type QueryUnreceivedPacketsRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // list of packet sequences Sequences []uint64 `protobuf:"varint,2,rep,packed,name=sequences,proto3" json:"sequences,omitempty"` } @@ -1110,7 +758,7 @@ func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPa func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{18} + return fileDescriptor_a328cba4986edcab, []int{12} } func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1139,9 +787,9 @@ func (m *QueryUnreceivedPacketsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryUnreceivedPacketsRequest proto.InternalMessageInfo -func (m *QueryUnreceivedPacketsRequest) GetChannelId() string { +func (m *QueryUnreceivedPacketsRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -1165,7 +813,7 @@ func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedP func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{19} + return fileDescriptor_a328cba4986edcab, []int{13} } func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1211,8 +859,8 @@ func (m *QueryUnreceivedPacketsResponse) GetHeight() types.Height { // QueryUnreceivedAcks is the request type for the // Query/UnreceivedAcks RPC method type QueryUnreceivedAcksRequest struct { - // channel unique identifier - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` // list of acknowledgement sequences PacketAckSequences []uint64 `protobuf:"varint,2,rep,packed,name=packet_ack_sequences,json=packetAckSequences,proto3" json:"packet_ack_sequences,omitempty"` } @@ -1221,7 +869,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{20} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1250,9 +898,9 @@ func (m *QueryUnreceivedAcksRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryUnreceivedAcksRequest proto.InternalMessageInfo -func (m *QueryUnreceivedAcksRequest) GetChannelId() string { +func (m *QueryUnreceivedAcksRequest) GetClientId() string { if m != nil { - return m.ChannelId + return m.ClientId } return "" } @@ -1277,7 +925,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{21} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1321,12 +969,6 @@ func (m *QueryUnreceivedAcksResponse) GetHeight() types.Height { } func init() { - proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v2.QueryChannelRequest") - proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") - proto.RegisterType((*QueryChannelClientStateRequest)(nil), "ibc.core.channel.v2.QueryChannelClientStateRequest") - proto.RegisterType((*QueryChannelClientStateResponse)(nil), "ibc.core.channel.v2.QueryChannelClientStateResponse") - proto.RegisterType((*QueryChannelConsensusStateRequest)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateRequest") - proto.RegisterType((*QueryChannelConsensusStateResponse)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateResponse") proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v2.QueryNextSequenceSendRequest") proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v2.QueryNextSequenceSendResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") @@ -1348,91 +990,72 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 1334 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x4f, 0xdc, 0x46, - 0x14, 0x66, 0x58, 0x92, 0xc0, 0x23, 0x0d, 0x30, 0x81, 0x06, 0x0c, 0x59, 0x88, 0x2b, 0x35, 0x9b, - 0x28, 0xb1, 0x61, 0x41, 0x4d, 0x52, 0x41, 0x11, 0xd0, 0x34, 0x21, 0x6a, 0x23, 0x6a, 0xda, 0x4a, - 0xad, 0xa2, 0xac, 0xbc, 0xf6, 0xb0, 0x58, 0xec, 0x8e, 0x9d, 0x1d, 0xef, 0x16, 0x14, 0x71, 0xe9, - 0xa1, 0xe7, 0xaa, 0xe9, 0xa9, 0x7f, 0x41, 0xfb, 0x57, 0x34, 0x52, 0x2f, 0x91, 0xd2, 0x43, 0xa4, - 0x1c, 0x5a, 0xa9, 0x52, 0x7f, 0x40, 0xa5, 0xfe, 0x07, 0x3d, 0x57, 0x3b, 0x1e, 0xef, 0xda, 0xbb, - 0x5e, 0x63, 0x27, 0xa1, 0xea, 0x6d, 0x3d, 0x7e, 0xef, 0xcd, 0xf7, 0x7d, 0xf3, 0x66, 0xe6, 0xf3, - 0xc2, 0xb4, 0x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69, 0xab, 0x7d, 0x4f, 0x7e, 0x9b, - 0xee, 0xd1, 0xfc, 0x14, 0x79, 0x19, 0xb2, 0xc1, 0xaa, 0x6b, 0x9c, 0xf6, 0xa6, 0xab, 0xbb, 0x24, - 0x21, 0xac, 0xdf, 0x11, 0x4c, 0x77, 0xad, 0x20, 0x20, 0xea, 0x70, 0xce, 0x32, 0x09, 0x75, 0xad, - 0x2d, 0x8b, 0x98, 0x05, 0x4f, 0xda, 0x02, 0x6b, 0x84, 0x08, 0xc8, 0x97, 0x02, 0x90, 0x3d, 0xe1, - 0xeb, 0x73, 0xca, 0x7a, 0x33, 0x25, 0x58, 0x73, 0xcc, 0x8a, 0x1a, 0xc6, 0xa3, 0x70, 0xc2, 0xa9, - 0xda, 0xf6, 0xd6, 0x78, 0xef, 0x0c, 0xca, 0x9d, 0xd6, 0xbc, 0x07, 0xbc, 0x06, 0xa7, 0xf9, 0x8f, - 0xc2, 0x36, 0xb1, 0x4a, 0xdb, 0xee, 0x78, 0x86, 0xcf, 0x26, 0x45, 0xcd, 0x76, 0x9b, 0x47, 0x08, - 0x79, 0x06, 0x79, 0x96, 0x37, 0x24, 0x7f, 0x83, 0xe0, 0x42, 0x88, 0x61, 0x83, 0x13, 0x65, 0x35, - 0x96, 0x42, 0x26, 0x7c, 0x11, 0x86, 0xaa, 0xa4, 0x6e, 0x31, 0xcb, 0xa6, 0x05, 0x5a, 0xab, 0x14, - 0x49, 0x95, 0x23, 0xed, 0xd3, 0xce, 0xf8, 0xc3, 0x77, 0xf9, 0x68, 0x28, 0x30, 0x80, 0x3a, 0x10, - 0x28, 0x60, 0xfd, 0x8a, 0x40, 0x8e, 0x83, 0x25, 0xb4, 0x5f, 0x82, 0x21, 0xc3, 0x7f, 0x13, 0xd2, - 0x7c, 0x54, 0xf1, 0xfa, 0x56, 0xf1, 0xfb, 0x56, 0x59, 0xa1, 0x7b, 0xda, 0x19, 0x23, 0x54, 0x06, - 0x4f, 0xc2, 0x80, 0x58, 0x2f, 0xcb, 0xe4, 0x88, 0x07, 0xb4, 0x7e, 0x6f, 0x60, 0xdd, 0x6c, 0x89, - 0x9e, 0x89, 0x13, 0xbd, 0xef, 0x45, 0x44, 0x5f, 0x82, 0x29, 0x4e, 0xee, 0x2e, 0xd9, 0x75, 0x37, - 0x1b, 0x12, 0x53, 0x83, 0x6c, 0x12, 0x6a, 0x26, 0xec, 0xca, 0xef, 0x10, 0x9c, 0xef, 0x92, 0x2f, - 0x74, 0xb9, 0x02, 0x98, 0x92, 0x5d, 0xb7, 0xc0, 0xc4, 0xcb, 0x02, 0x23, 0xd4, 0x2b, 0xd4, 0xa7, - 0x0d, 0xd3, 0xb6, 0xac, 0xe3, 0x6c, 0xaf, 0x4f, 0x05, 0xd3, 0x0d, 0xdd, 0xd8, 0x21, 0xee, 0x9a, - 0x5d, 0xa9, 0x58, 0x6e, 0x85, 0x50, 0x37, 0x61, 0x63, 0x49, 0xd0, 0xef, 0x53, 0x10, 0x1d, 0xd5, - 0x7c, 0x96, 0xbf, 0xf5, 0x55, 0xe8, 0xac, 0x2d, 0x54, 0xc8, 0x02, 0x18, 0xcd, 0x51, 0x5e, 0xfc, - 0xb4, 0x16, 0x18, 0x39, 0x4e, 0xde, 0x5f, 0x76, 0x03, 0xc7, 0x12, 0x32, 0x7f, 0x0f, 0xa0, 0x75, - 0x21, 0x70, 0x80, 0x83, 0xf9, 0x37, 0x15, 0xef, 0xf6, 0x50, 0x1a, 0xb7, 0x87, 0xe2, 0xdd, 0x35, - 0xe2, 0xf6, 0x50, 0x36, 0xf4, 0x92, 0xbf, 0x5b, 0xb5, 0x40, 0xa6, 0xfc, 0x37, 0x12, 0x67, 0x60, - 0x04, 0x10, 0x21, 0xd3, 0x2a, 0x0c, 0xb6, 0x44, 0x61, 0xe3, 0x68, 0x26, 0x93, 0x1b, 0xcc, 0xcf, - 0x44, 0x9e, 0xb3, 0x5e, 0x11, 0x6f, 0x0f, 0x06, 0x93, 0xf0, 0xad, 0x08, 0xb8, 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0x2b, 0x38, 0x82, - 0xce, 0x9f, 0x08, 0xce, 0x84, 0x1d, 0x05, 0x56, 0x93, 0xa0, 0x0d, 0x58, 0x1d, 0x69, 0x36, 0x79, - 0x82, 0xe0, 0x56, 0xe6, 0xdc, 0xb6, 0xb0, 0xf9, 0x92, 0xdc, 0xa2, 0x2c, 0x54, 0x88, 0x66, 0x63, - 0xbf, 0xad, 0x7e, 0xf2, 0xe4, 0x20, 0x8b, 0x9e, 0x1d, 0x64, 0xd1, 0x1f, 0x07, 0x59, 0xf4, 0xd5, - 0x61, 0xb6, 0xe7, 0xd9, 0x61, 0xb6, 0xe7, 0x97, 0xc3, 0x6c, 0xcf, 0x67, 0x8b, 0x25, 0xcb, 0xdd, - 0xae, 0x15, 0x15, 0xc3, 0xae, 0xa8, 0xe2, 0xaf, 0x5d, 0xab, 0x68, 0x5c, 0x2d, 0xd9, 0x6a, 0xfd, - 0x86, 0x5a, 0xb1, 0xcd, 0x5a, 0x99, 0x30, 0x0f, 0xde, 0xec, 0xc2, 0xd5, 0x00, 0x42, 0x77, 0xcf, - 0x21, 0xac, 0x78, 0x92, 0xff, 0x3b, 0x35, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x2a, - 0x4b, 0x9b, 0x4c, 0x16, 0x00, 0x00, + // 1031 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xce, 0xc4, 0x6e, 0x95, 0xbe, 0x4e, 0x21, 0x1d, 0x02, 0x72, 0x37, 0xc1, 0x75, 0x17, 0x09, + 0x2c, 0x44, 0x77, 0x62, 0x17, 0x41, 0x51, 0xf9, 0x4a, 0x22, 0xda, 0x20, 0x50, 0x55, 0x36, 0x7c, + 0x48, 0x51, 0x25, 0x6b, 0xbd, 0x1e, 0x36, 0x8b, 0xed, 0x9d, 0xad, 0x67, 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xf7, 0xfb, 0x61, 0x69, 0x6e, 0xe7, 0x4d, 0xc7, + 0x0d, 0x76, 0x7b, 0x0d, 0xc3, 0x66, 0x1d, 0xa2, 0xfe, 0x31, 0xe0, 0x36, 0xec, 0x4b, 0x0e, 0x23, + 0xfd, 0x37, 0x48, 0x87, 0x35, 0x7b, 0x6d, 0xca, 0x25, 0xb8, 0xb5, 0x57, 0x2f, 0x85, 0xf0, 0x05, + 0x77, 0x7c, 0xca, 0x1b, 0xa7, 0xc5, 0x9f, 0xeb, 0x97, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xdc, + 0x82, 0xc5, 0xf4, 0x8a, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1447,14 +1070,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Channel queries the counterparty of an IBC client. - Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) - // ChannelClientState queries for the client state for the channel associated - // with the provided channel identifiers. - ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) - // ChannelConsensusState queries for the consensus state for the channel associated - // with the provided channel identifiers. - ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1481,45 +1096,18 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) { - out := new(QueryChannelResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/Channel", in, out, opts...) +func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { + out := new(QueryNextSequenceSendResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) { - out := new(QueryChannelClientStateResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/ChannelClientState", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) { - out := new(QueryChannelConsensusStateResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/ChannelConsensusState", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { - out := new(QueryNextSequenceSendResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) { - out := new(QueryPacketCommitmentResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketCommitment", in, out, opts...) +func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) { + out := new(QueryPacketCommitmentResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/PacketCommitment", in, out, opts...) if err != nil { return nil, err } @@ -1582,14 +1170,6 @@ func (c *queryClient) UnreceivedAcks(ctx context.Context, in *QueryUnreceivedAck // QueryServer is the server API for Query service. type QueryServer interface { - // Channel queries the counterparty of an IBC client. - Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) - // ChannelClientState queries for the client state for the channel associated - // with the provided channel identifiers. - ChannelClientState(context.Context, *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) - // ChannelConsensusState queries for the consensus state for the channel associated - // with the provided channel identifiers. - ChannelConsensusState(context.Context, *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1612,15 +1192,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") -} -func (*UnimplementedQueryServer) ChannelClientState(ctx context.Context, req *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelClientState not implemented") -} -func (*UnimplementedQueryServer) ChannelConsensusState(ctx context.Context, req *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelConsensusState not implemented") -} func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") } @@ -1650,60 +1221,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryChannelRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Channel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v2.Query/Channel", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Channel(ctx, req.(*QueryChannelRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ChannelClientState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryChannelClientStateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ChannelClientState(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v2.Query/ChannelClientState", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ChannelClientState(ctx, req.(*QueryChannelClientStateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ChannelConsensusState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryChannelConsensusStateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ChannelConsensusState(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v2.Query/ChannelConsensusState", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ChannelConsensusState(ctx, req.(*QueryChannelConsensusStateRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryNextSequenceSendRequest) if err := dec(in); err != nil { @@ -1852,18 +1369,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Channel", - Handler: _Query_Channel_Handler, - }, - { - MethodName: "ChannelClientState", - Handler: _Query_ChannelClientState_Handler, - }, - { - MethodName: "ChannelConsensusState", - Handler: _Query_ChannelConsensusState_Handler, - }, { MethodName: "NextSequenceSend", Handler: _Query_NextSequenceSend_Handler, @@ -1901,7 +1406,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/core/channel/v2/query.proto", } -func (m *QueryChannelRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1911,27 +1416,27 @@ func (m *QueryChannelRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryChannelRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryNextSequenceSendRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryNextSequenceSendRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryChannelResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryNextSequenceSendResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1941,18 +1446,18 @@ func (m *QueryChannelResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryChannelResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryNextSequenceSendResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryNextSequenceSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1960,11 +1465,23 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x1a + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.NextSequenceSend != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NextSequenceSend)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *QueryChannelClientStateRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketCommitmentRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1974,27 +1491,32 @@ func (m *QueryChannelClientStateRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryChannelClientStateRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelClientStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryChannelClientStateResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketCommitmentResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2004,12 +1526,12 @@ func (m *QueryChannelClientStateResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryChannelClientStateResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2031,22 +1553,17 @@ func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x12 } - if m.IdentifiedClientState != nil { - { - size, err := m.IdentifiedClientState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryChannelConsensusStateRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketCommitmentsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2056,37 +1573,39 @@ func (m *QueryChannelConsensusStateRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryChannelConsensusStateRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelConsensusStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.RevisionHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.RevisionHeight)) - i-- - dAtA[i] = 0x18 - } - if m.RevisionNumber != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.RevisionNumber)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryChannelConsensusStateResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketCommitmentsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2096,18 +1615,18 @@ func (m *QueryChannelConsensusStateResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryChannelConsensusStateResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2115,24 +1634,10 @@ func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) ( i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) - i-- - dAtA[i] = 0x1a - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0x12 - } - if m.ConsensusState != nil { + dAtA[i] = 0x1a + if m.Pagination != nil { { - size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2140,12 +1645,26 @@ func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) ( i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if len(m.Commitments) > 0 { + for iNdEx := len(m.Commitments) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commitments[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } -func (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketAcknowledgementRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2155,27 +1674,32 @@ func (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryNextSequenceSendRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryNextSequenceSendRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryNextSequenceSendResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketAcknowledgementResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2185,12 +1709,12 @@ func (m *QueryNextSequenceSendResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryNextSequenceSendResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryNextSequenceSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2212,15 +1736,17 @@ func (m *QueryNextSequenceSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 } - if m.NextSequenceSend != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.NextSequenceSend)) + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Acknowledgement))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketCommitmentRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketAcknowledgementsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2230,32 +1756,57 @@ func (m *QueryPacketCommitmentRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPacketCommitmentRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketCommitmentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Sequence != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + if len(m.PacketCommitmentSequences) > 0 { + dAtA8 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j7 int + for _, num := range m.PacketCommitmentSequences { + for num >= 1<<7 { + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j7++ + } + dAtA8[j7] = uint8(num) + j7++ + } + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintQuery(dAtA, i, uint64(j7)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x1a + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketCommitmentResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketAcknowledgementsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2265,107 +1816,18 @@ func (m *QueryPacketCommitmentResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPacketCommitmentResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketAcknowledgementsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) - i-- - dAtA[i] = 0x12 - } - if len(m.Commitment) > 0 { - i -= len(m.Commitment) - copy(dAtA[i:], m.Commitment) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryPacketCommitmentsRequest) 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 *QueryPacketCommitmentsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPacketCommitmentsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryPacketCommitmentsResponse) 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 *QueryPacketCommitmentsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2386,10 +1848,10 @@ func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 } - if len(m.Commitments) > 0 { - for iNdEx := len(m.Commitments) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Acknowledgements) > 0 { + for iNdEx := len(m.Acknowledgements) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Commitments[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Acknowledgements[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2403,7 +1865,7 @@ func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryPacketAcknowledgementRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketReceiptRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2413,12 +1875,12 @@ func (m *QueryPacketAcknowledgementRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPacketAcknowledgementRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketReceiptRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketAcknowledgementRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2428,17 +1890,17 @@ func (m *QueryPacketAcknowledgementRequest) MarshalToSizedBuffer(dAtA []byte) (i i-- dAtA[i] = 0x10 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketAcknowledgementResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPacketReceiptResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2448,12 +1910,12 @@ func (m *QueryPacketAcknowledgementResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryPacketAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPacketReceiptResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2467,25 +1929,28 @@ func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) ( i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if len(m.Proof) > 0 { i -= len(m.Proof) copy(dAtA[i:], m.Proof) i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } - if len(m.Acknowledgement) > 0 { - i -= len(m.Acknowledgement) - copy(dAtA[i:], m.Acknowledgement) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Acknowledgement))) + if m.Received { i-- - dAtA[i] = 0xa + if m.Received { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 } return len(dAtA) - i, nil } -func (m *QueryPacketAcknowledgementsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedPacketsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2495,57 +1960,45 @@ func (m *QueryPacketAcknowledgementsRequest) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryPacketAcknowledgementsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PacketCommitmentSequences) > 0 { - dAtA13 := make([]byte, len(m.PacketCommitmentSequences)*10) - var j12 int - for _, num := range m.PacketCommitmentSequences { + if len(m.Sequences) > 0 { + dAtA14 := make([]byte, len(m.Sequences)*10) + var j13 int + for _, num := range m.Sequences { for num >= 1<<7 { - dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j12++ - } - dAtA13[j12] = uint8(num) - j12++ - } - i -= j12 - copy(dAtA[i:], dAtA13[:j12]) - i = encodeVarintQuery(dAtA, i, uint64(j12)) - i-- - dAtA[i] = 0x1a - } - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + j13++ } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + dAtA14[j13] = uint8(num) + j13++ } + i -= j13 + copy(dAtA[i:], dAtA14[:j13]) + i = encodeVarintQuery(dAtA, i, uint64(j13)) i-- dAtA[i] = 0x12 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketAcknowledgementsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedPacketsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2555,12 +2008,12 @@ func (m *QueryPacketAcknowledgementsResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryPacketAcknowledgementsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketAcknowledgementsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2574,37 +2027,29 @@ func (m *QueryPacketAcknowledgementsResponse) MarshalToSizedBuffer(dAtA []byte) i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + dAtA[i] = 0x12 + if len(m.Sequences) > 0 { + dAtA17 := make([]byte, len(m.Sequences)*10) + var j16 int + for _, num := range m.Sequences { + for num >= 1<<7 { + dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j16++ } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + dAtA17[j16] = uint8(num) + j16++ } + i -= j16 + copy(dAtA[i:], dAtA17[:j16]) + i = encodeVarintQuery(dAtA, i, uint64(j16)) i-- - dAtA[i] = 0x12 - } - if len(m.Acknowledgements) > 0 { - for iNdEx := len(m.Acknowledgements) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Acknowledgements[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketReceiptRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedAcksRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2614,39 +2059,45 @@ func (m *QueryPacketReceiptRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPacketReceiptRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedAcksRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Sequence != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x18 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.PacketAckSequences) > 0 { + dAtA19 := make([]byte, len(m.PacketAckSequences)*10) + var j18 int + for _, num := range m.PacketAckSequences { + for num >= 1<<7 { + dAtA19[j18] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j18++ + } + dAtA19[j18] = uint8(num) + j18++ + } + i -= j18 + copy(dAtA[i:], dAtA19[:j18]) + i = encodeVarintQuery(dAtA, i, uint64(j18)) i-- dAtA[i] = 0x12 } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPacketReceiptResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryUnreceivedAcksResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2656,18 +2107,18 @@ func (m *QueryPacketReceiptResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPacketReceiptResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryUnreceivedAcksResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2675,221 +2126,24 @@ func (m *QueryPacketReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) - i-- - dAtA[i] = 0x1a - } - if m.Received { - i-- - if m.Received { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + dAtA[i] = 0x12 + if len(m.Sequences) > 0 { + dAtA22 := make([]byte, len(m.Sequences)*10) + var j21 int + for _, num := range m.Sequences { + for num >= 1<<7 { + dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j21++ + } + dAtA22[j21] = uint8(num) + j21++ } + i -= j21 + copy(dAtA[i:], dAtA22[:j21]) + i = encodeVarintQuery(dAtA, i, uint64(j21)) i-- - dAtA[i] = 0x10 - } - return len(dAtA) - i, nil -} - -func (m *QueryUnreceivedPacketsRequest) 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 *QueryUnreceivedPacketsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Sequences) > 0 { - dAtA19 := make([]byte, len(m.Sequences)*10) - var j18 int - for _, num := range m.Sequences { - for num >= 1<<7 { - dAtA19[j18] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j18++ - } - dAtA19[j18] = uint8(num) - j18++ - } - i -= j18 - copy(dAtA[i:], dAtA19[:j18]) - i = encodeVarintQuery(dAtA, i, uint64(j18)) - i-- - dAtA[i] = 0x12 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryUnreceivedPacketsResponse) 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 *QueryUnreceivedPacketsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Sequences) > 0 { - dAtA22 := make([]byte, len(m.Sequences)*10) - var j21 int - for _, num := range m.Sequences { - for num >= 1<<7 { - dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j21++ - } - dAtA22[j21] = uint8(num) - j21++ - } - i -= j21 - copy(dAtA[i:], dAtA22[:j21]) - i = encodeVarintQuery(dAtA, i, uint64(j21)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryUnreceivedAcksRequest) 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 *QueryUnreceivedAcksRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PacketAckSequences) > 0 { - dAtA24 := make([]byte, len(m.PacketAckSequences)*10) - var j23 int - for _, num := range m.PacketAckSequences { - for num >= 1<<7 { - dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j23++ - } - dAtA24[j23] = uint8(num) - j23++ - } - i -= j23 - copy(dAtA[i:], dAtA24[:j23]) - i = encodeVarintQuery(dAtA, i, uint64(j23)) - i-- - dAtA[i] = 0x12 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryUnreceivedAcksResponse) 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 *QueryUnreceivedAcksResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Sequences) > 0 { - dAtA27 := make([]byte, len(m.Sequences)*10) - var j26 int - for _, num := range m.Sequences { - for num >= 1<<7 { - dAtA27[j26] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j26++ - } - dAtA27[j26] = uint8(num) - j26++ - } - i -= j26 - copy(dAtA[i:], dAtA27[:j26]) - i = encodeVarintQuery(dAtA, i, uint64(j26)) - i-- - dAtA[i] = 0xa + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -2905,111 +2159,13 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryChannelRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryChannelResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Channel.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryChannelClientStateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryChannelClientStateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IdentifiedClientState != nil { - l = m.IdentifiedClientState.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Proof) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryChannelConsensusStateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.RevisionNumber != 0 { - n += 1 + sovQuery(uint64(m.RevisionNumber)) - } - if m.RevisionHeight != 0 { - n += 1 + sovQuery(uint64(m.RevisionHeight)) - } - return n -} - -func (m *QueryChannelConsensusStateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ConsensusState != nil { - l = m.ConsensusState.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Proof) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func (m *QueryNextSequenceSendRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3040,7 +2196,7 @@ func (m *QueryPacketCommitmentRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3075,7 +2231,7 @@ func (m *QueryPacketCommitmentsRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3113,7 +2269,7 @@ func (m *QueryPacketAcknowledgementRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3148,7 +2304,7 @@ func (m *QueryPacketAcknowledgementsRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3193,11 +2349,7 @@ func (m *QueryPacketReceiptRequest) Size() (n int) { } var l int _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3231,7 +2383,7 @@ func (m *QueryUnreceivedPacketsRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ClientId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -3267,750 +2419,45 @@ func (m *QueryUnreceivedAcksRequest) Size() (n int) { if m == nil { return 0 } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.PacketAckSequences) > 0 { - l = 0 - for _, e := range m.PacketAckSequences { - l += sovQuery(uint64(e)) - } - n += 1 + sovQuery(uint64(l)) + l - } - return n -} - -func (m *QueryUnreceivedAcksResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Sequences) > 0 { - l = 0 - for _, e := range m.Sequences { - l += sovQuery(uint64(e)) - } - n += 1 + sovQuery(uint64(l)) + l - } - l = m.Height.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryChannelRequest) 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 ErrIntOverflowQuery - } - 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: QueryChannelRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelResponse) 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 ErrIntOverflowQuery - } - 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: QueryChannelResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelClientStateRequest) 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 ErrIntOverflowQuery - } - 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: QueryChannelClientStateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelClientStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelClientStateResponse) 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 ErrIntOverflowQuery - } - 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: QueryChannelClientStateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelClientStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedClientState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.IdentifiedClientState == nil { - m.IdentifiedClientState = &types.IdentifiedClientState{} - } - if err := m.IdentifiedClientState.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 byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelConsensusStateRequest) 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 ErrIntOverflowQuery - } - 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: QueryChannelConsensusStateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelConsensusStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RevisionNumber", wireType) - } - m.RevisionNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RevisionNumber |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RevisionHeight", wireType) - } - m.RevisionHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RevisionHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.PacketAckSequences) > 0 { + l = 0 + for _, e := range m.PacketAckSequences { + l += sovQuery(uint64(e)) } + n += 1 + sovQuery(uint64(l)) + l } + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *QueryUnreceivedAcksResponse) Size() (n int) { + if m == nil { + return 0 } - return nil -} -func (m *QueryChannelConsensusStateResponse) 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 ErrIntOverflowQuery - } - 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: QueryChannelConsensusStateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelConsensusStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConsensusState == nil { - m.ConsensusState = &types1.Any{} - } - if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - 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 Proof", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + var l int + _ = l + if len(m.Sequences) > 0 { + l = 0 + for _, e := range m.Sequences { + l += sovQuery(uint64(e)) } + n += 1 + sovQuery(uint64(l)) + l } + l = m.Height.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -4043,7 +2490,7 @@ func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4071,7 +2518,7 @@ func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -4261,7 +2708,7 @@ func (m *QueryPacketCommitmentRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4289,7 +2736,7 @@ func (m *QueryPacketCommitmentRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { @@ -4513,7 +2960,7 @@ func (m *QueryPacketCommitmentsRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4541,7 +2988,7 @@ func (m *QueryPacketCommitmentsRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4784,7 +3231,7 @@ func (m *QueryPacketAcknowledgementRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4812,7 +3259,7 @@ func (m *QueryPacketAcknowledgementRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { @@ -5036,7 +3483,7 @@ func (m *QueryPacketAcknowledgementsRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5064,7 +3511,7 @@ func (m *QueryPacketAcknowledgementsRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -5383,7 +3830,7 @@ func (m *QueryPacketReceiptRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5411,41 +3858,9 @@ func (m *QueryPacketReceiptRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PortId = string(dAtA[iNdEx:postIndex]) + m.ClientId = 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } @@ -5653,7 +4068,7 @@ func (m *QueryUnreceivedPacketsRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5681,7 +4096,7 @@ func (m *QueryUnreceivedPacketsRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType == 0 { @@ -5970,7 +4385,7 @@ func (m *QueryUnreceivedAcksRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5998,7 +4413,7 @@ func (m *QueryUnreceivedAcksRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType == 0 { diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 2d87052d3ba..63572d446cc 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -33,186 +33,6 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - msg, err := client.Channel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - msg, err := server.Channel(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ChannelClientState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelClientStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - msg, err := client.ChannelClientState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ChannelClientState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelClientStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - msg, err := server.ChannelClientState(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_ChannelConsensusState_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelConsensusStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.ChannelConsensusState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelConsensusStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.ChannelConsensusState(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNextSequenceSendRequest var metadata runtime.ServerMetadata @@ -224,15 +44,15 @@ func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } msg, err := client.NextSequenceSend(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -251,15 +71,15 @@ func local_request_Query_NextSequenceSend_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } msg, err := server.NextSequenceSend(ctx, &protoReq) @@ -278,15 +98,15 @@ func request_Query_PacketCommitment_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -316,15 +136,15 @@ func local_request_Query_PacketCommitment_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -344,7 +164,7 @@ func local_request_Query_PacketCommitment_0(ctx context.Context, marshaler runti } var ( - filter_Query_PacketCommitments_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_PacketCommitments_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Query_PacketCommitments_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -358,15 +178,15 @@ func request_Query_PacketCommitments_0(ctx context.Context, marshaler runtime.Ma _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } if err := req.ParseForm(); err != nil { @@ -392,15 +212,15 @@ func local_request_Query_PacketCommitments_0(ctx context.Context, marshaler runt _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } if err := req.ParseForm(); err != nil { @@ -426,15 +246,15 @@ func request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtim _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -464,15 +284,15 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -492,7 +312,7 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler } var ( - filter_Query_PacketAcknowledgements_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_PacketAcknowledgements_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -506,15 +326,15 @@ func request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } if err := req.ParseForm(); err != nil { @@ -540,15 +360,15 @@ func local_request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } if err := req.ParseForm(); err != nil { @@ -563,10 +383,6 @@ func local_request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler } -var ( - filter_Query_PacketReceipt_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0, "sequence": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} -) - func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryPacketReceiptRequest var metadata runtime.ServerMetadata @@ -578,15 +394,15 @@ func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -600,13 +416,6 @@ func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketReceipt_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.PacketReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -623,15 +432,15 @@ func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime. _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequence"] @@ -645,13 +454,6 @@ func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketReceipt_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.PacketReceipt(ctx, &protoReq) return msg, metadata, err @@ -668,15 +470,15 @@ func request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runtime.Ma _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequences"] @@ -706,15 +508,15 @@ func local_request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runt _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["sequences"] @@ -744,15 +546,15 @@ func request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marsh _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["packet_ack_sequences"] @@ -782,15 +584,15 @@ func local_request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime _ = err ) - val, ok = pathParams["channel_id"] + val, ok = pathParams["client_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ClientId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } val, ok = pathParams["packet_ack_sequences"] @@ -815,75 +617,6 @@ func local_request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Channel_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ChannelClientState_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelConsensusState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ChannelConsensusState_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1109,66 +842,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Channel_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ChannelClientState_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelConsensusState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ChannelConsensusState_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1333,36 +1006,24 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "client_state"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "consensus_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_commitments", "sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v2", "clients", "client_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Channel_0 = runtime.ForwardResponseMessage - - forward_Query_ChannelClientState_0 = runtime.ForwardResponseMessage - - forward_Query_ChannelConsensusState_0 = runtime.ForwardResponseMessage - forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage diff --git a/modules/core/04-channel/v2/types/tx.pb.go b/modules/core/04-channel/v2/types/tx.pb.go index b40a86332a0..ba67180f946 100644 --- a/modules/core/04-channel/v2/types/tx.pb.go +++ b/modules/core/04-channel/v2/types/tx.pb.go @@ -11,7 +11,6 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -67,172 +66,9 @@ func (ResponseResultType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_d421c7119e969b99, []int{0} } -// MsgCreateChannel defines the message used to create a v2 Channel. -type MsgCreateChannel struct { - // the client identifier of the light client representing the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgCreateChannel) Reset() { *m = MsgCreateChannel{} } -func (m *MsgCreateChannel) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannel) ProtoMessage() {} -func (*MsgCreateChannel) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{0} -} -func (m *MsgCreateChannel) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateChannel.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 *MsgCreateChannel) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannel.Merge(m, src) -} -func (m *MsgCreateChannel) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateChannel) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannel.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateChannel proto.InternalMessageInfo - -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -type MsgCreateChannelResponse struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *MsgCreateChannelResponse) Reset() { *m = MsgCreateChannelResponse{} } -func (m *MsgCreateChannelResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateChannelResponse) ProtoMessage() {} -func (*MsgCreateChannelResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{1} -} -func (m *MsgCreateChannelResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateChannelResponse.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 *MsgCreateChannelResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateChannelResponse.Merge(m, src) -} -func (m *MsgCreateChannelResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateChannelResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateChannelResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateChannelResponse proto.InternalMessageInfo - -// MsgRegisterCounterparty defines the message used to provide the counterparty channel -// identifier. -type MsgRegisterCounterparty struct { - // unique identifier we will use to write all packet messages sent to counterparty - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // counterparty channel identifier - CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgRegisterCounterparty) Reset() { *m = MsgRegisterCounterparty{} } -func (m *MsgRegisterCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterCounterparty) ProtoMessage() {} -func (*MsgRegisterCounterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{2} -} -func (m *MsgRegisterCounterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterCounterparty.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 *MsgRegisterCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterCounterparty.Merge(m, src) -} -func (m *MsgRegisterCounterparty) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterCounterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterCounterparty proto.InternalMessageInfo - -// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. -type MsgRegisterCounterpartyResponse struct { -} - -func (m *MsgRegisterCounterpartyResponse) Reset() { *m = MsgRegisterCounterpartyResponse{} } -func (m *MsgRegisterCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterCounterpartyResponse) ProtoMessage() {} -func (*MsgRegisterCounterpartyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{3} -} -func (m *MsgRegisterCounterpartyResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterCounterpartyResponse.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 *MsgRegisterCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterCounterpartyResponse.Merge(m, src) -} -func (m *MsgRegisterCounterpartyResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterCounterpartyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterCounterpartyResponse proto.InternalMessageInfo - // MsgSendPacket sends an outgoing IBC packet. type MsgSendPacket struct { - SourceChannel string `protobuf:"bytes,1,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + SourceClient string `protobuf:"bytes,1,opt,name=source_client,json=sourceClient,proto3" json:"source_client,omitempty"` TimeoutTimestamp uint64 `protobuf:"varint,2,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` Payloads []Payload `protobuf:"bytes,3,rep,name=payloads,proto3" json:"payloads"` Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` @@ -242,7 +78,7 @@ func (m *MsgSendPacket) Reset() { *m = MsgSendPacket{} } func (m *MsgSendPacket) String() string { return proto.CompactTextString(m) } func (*MsgSendPacket) ProtoMessage() {} func (*MsgSendPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{4} + return fileDescriptor_d421c7119e969b99, []int{0} } func (m *MsgSendPacket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +116,7 @@ func (m *MsgSendPacketResponse) Reset() { *m = MsgSendPacketResponse{} } func (m *MsgSendPacketResponse) String() string { return proto.CompactTextString(m) } func (*MsgSendPacketResponse) ProtoMessage() {} func (*MsgSendPacketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{5} + return fileDescriptor_d421c7119e969b99, []int{1} } func (m *MsgSendPacketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -321,7 +157,7 @@ func (m *MsgRecvPacket) Reset() { *m = MsgRecvPacket{} } func (m *MsgRecvPacket) String() string { return proto.CompactTextString(m) } func (*MsgRecvPacket) ProtoMessage() {} func (*MsgRecvPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{6} + return fileDescriptor_d421c7119e969b99, []int{2} } func (m *MsgRecvPacket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -359,7 +195,7 @@ func (m *MsgRecvPacketResponse) Reset() { *m = MsgRecvPacketResponse{} } func (m *MsgRecvPacketResponse) String() string { return proto.CompactTextString(m) } func (*MsgRecvPacketResponse) ProtoMessage() {} func (*MsgRecvPacketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{7} + return fileDescriptor_d421c7119e969b99, []int{3} } func (m *MsgRecvPacketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -400,7 +236,7 @@ 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_d421c7119e969b99, []int{8} + return fileDescriptor_d421c7119e969b99, []int{4} } func (m *MsgTimeout) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -438,7 +274,7 @@ func (m *MsgTimeoutResponse) Reset() { *m = MsgTimeoutResponse{} } func (m *MsgTimeoutResponse) String() string { return proto.CompactTextString(m) } func (*MsgTimeoutResponse) ProtoMessage() {} func (*MsgTimeoutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{9} + return fileDescriptor_d421c7119e969b99, []int{5} } func (m *MsgTimeoutResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -480,7 +316,7 @@ 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_d421c7119e969b99, []int{10} + return fileDescriptor_d421c7119e969b99, []int{6} } func (m *MsgAcknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -518,7 +354,7 @@ func (m *MsgAcknowledgementResponse) Reset() { *m = MsgAcknowledgementRe func (m *MsgAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*MsgAcknowledgementResponse) ProtoMessage() {} func (*MsgAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d421c7119e969b99, []int{11} + return fileDescriptor_d421c7119e969b99, []int{7} } func (m *MsgAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -549,10 +385,6 @@ var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo func init() { proto.RegisterEnum("ibc.core.channel.v2.ResponseResultType", ResponseResultType_name, ResponseResultType_value) - proto.RegisterType((*MsgCreateChannel)(nil), "ibc.core.channel.v2.MsgCreateChannel") - proto.RegisterType((*MsgCreateChannelResponse)(nil), "ibc.core.channel.v2.MsgCreateChannelResponse") - proto.RegisterType((*MsgRegisterCounterparty)(nil), "ibc.core.channel.v2.MsgRegisterCounterparty") - proto.RegisterType((*MsgRegisterCounterpartyResponse)(nil), "ibc.core.channel.v2.MsgRegisterCounterpartyResponse") proto.RegisterType((*MsgSendPacket)(nil), "ibc.core.channel.v2.MsgSendPacket") proto.RegisterType((*MsgSendPacketResponse)(nil), "ibc.core.channel.v2.MsgSendPacketResponse") proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v2.MsgRecvPacket") @@ -566,70 +398,58 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/tx.proto", fileDescriptor_d421c7119e969b99) } var fileDescriptor_d421c7119e969b99 = []byte{ - // 993 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x5d, 0x6f, 0xdb, 0x54, - 0x18, 0xc7, 0xe3, 0x26, 0xeb, 0xda, 0x27, 0xed, 0x12, 0xcc, 0x46, 0x83, 0x57, 0x92, 0x10, 0x31, - 0xb5, 0x14, 0x1a, 0x33, 0x33, 0x90, 0x3a, 0x21, 0xa6, 0x2e, 0x64, 0x22, 0xd2, 0xd2, 0x46, 0x4e, - 0x32, 0x89, 0x17, 0x61, 0x39, 0xce, 0x99, 0x63, 0x35, 0xf6, 0x31, 0x3e, 0x4e, 0x58, 0xb9, 0x42, - 0x5c, 0x4d, 0xbd, 0xe2, 0x96, 0x8b, 0x4a, 0x48, 0x7c, 0x81, 0x5e, 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 0xa1, 0xe9, 0x58, 0x0b, 0x00, - 0x00, + // 803 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4d, 0x6f, 0xda, 0x48, + 0x18, 0xc7, 0x71, 0x70, 0x48, 0x76, 0x20, 0x0b, 0xeb, 0x7d, 0x63, 0xbd, 0x11, 0x58, 0xec, 0x4a, + 0xc9, 0xb2, 0x8a, 0xbd, 0x61, 0x77, 0x0f, 0x89, 0x56, 0x5b, 0x25, 0xd4, 0x51, 0x23, 0xe5, 0x05, + 0xd9, 0x50, 0xa9, 0x6d, 0x54, 0x04, 0x66, 0x6a, 0xac, 0x60, 0x8f, 0xcb, 0x18, 0xda, 0xdc, 0xaa, + 0x9e, 0x22, 0x4e, 0xfd, 0x02, 0x91, 0x2a, 0xf5, 0x0b, 0xe4, 0xd0, 0x0f, 0x11, 0xf5, 0x94, 0x63, + 0x4e, 0x55, 0x14, 0x0e, 0xf9, 0x1a, 0x95, 0x67, 0x86, 0xd7, 0x98, 0x26, 0x52, 0xe9, 0x09, 0xcf, + 0x7f, 0x7e, 0xcf, 0xf3, 0xcc, 0xf3, 0x1f, 0x33, 0x63, 0xb0, 0x68, 0x55, 0x0d, 0xc5, 0x40, 0x4d, + 0xa8, 0x18, 0xf5, 0x8a, 0xe3, 0xc0, 0x86, 0xd2, 0xce, 0x29, 0xde, 0x4b, 0xd9, 0x6d, 0x22, 0x0f, + 0x09, 0xdf, 0x5b, 0x55, 0x43, 0xf6, 0x67, 0x65, 0x36, 0x2b, 0xb7, 0x73, 0xe2, 0x0f, 0x26, 0x32, + 0x11, 0x99, 0x57, 0xfc, 0x27, 0x8a, 0x8a, 0x3f, 0x1b, 0x08, 0xdb, 0x08, 0x2b, 0x36, 0x36, 0x95, + 0xf6, 0xaa, 0xff, 0xc3, 0x26, 0xa4, 0xa0, 0x0a, 0x6e, 0xc5, 0x38, 0x84, 0x1e, 0x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0x6e, 0xf3, 0xe1, 0xd9, 0x55, 0x8a, 0x3b, 0xbf, 0x4a, 0x71, 0x97, 0x57, 0x29, 0xee, 0x4d, 0x37, + 0x15, 0x3a, 0xef, 0xa6, 0x42, 0x17, 0xdd, 0x54, 0xe8, 0xf1, 0x7f, 0xa6, 0xe5, 0xd5, 0x5b, 0x55, + 0xd9, 0x40, 0xb6, 0xc2, 0x3e, 0x09, 0xac, 0xaa, 0xb1, 0x62, 0x22, 0xa5, 0xbd, 0xa6, 0xd8, 0xa8, + 0xd6, 0x6a, 0x40, 0x4c, 0x2f, 0xfb, 0xbf, 0xfe, 0x59, 0x19, 0xfe, 0xe6, 0x38, 0x72, 0x21, 0xae, + 0x46, 0xc8, 0x85, 0xff, 0xf7, 0xa7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xb6, 0x94, 0x19, 0x97, + 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -644,10 +464,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // CreateChannel defines a rpc handler method for MsgCreateChannel - CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) - // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. - RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -666,24 +482,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) CreateChannel(ctx context.Context, in *MsgCreateChannel, opts ...grpc.CallOption) (*MsgCreateChannelResponse, error) { - out := new(MsgCreateChannelResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/CreateChannel", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) RegisterCounterparty(ctx context.Context, in *MsgRegisterCounterparty, opts ...grpc.CallOption) (*MsgRegisterCounterpartyResponse, error) { - out := new(MsgRegisterCounterpartyResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/RegisterCounterparty", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) SendPacket(ctx context.Context, in *MsgSendPacket, opts ...grpc.CallOption) (*MsgSendPacketResponse, error) { out := new(MsgSendPacketResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Msg/SendPacket", in, out, opts...) @@ -722,10 +520,6 @@ func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, // MsgServer is the server API for Msg service. type MsgServer interface { - // CreateChannel defines a rpc handler method for MsgCreateChannel - CreateChannel(context.Context, *MsgCreateChannel) (*MsgCreateChannelResponse, error) - // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. - RegisterCounterparty(context.Context, *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) // SendPacket defines a rpc handler method for MsgSendPacket. SendPacket(context.Context, *MsgSendPacket) (*MsgSendPacketResponse, error) // RecvPacket defines a rpc handler method for MsgRecvPacket. @@ -740,12 +534,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) CreateChannel(ctx context.Context, req *MsgCreateChannel) (*MsgCreateChannelResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") -} -func (*UnimplementedMsgServer) RegisterCounterparty(ctx context.Context, req *MsgRegisterCounterparty) (*MsgRegisterCounterpartyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterparty not implemented") -} func (*UnimplementedMsgServer) SendPacket(ctx context.Context, req *MsgSendPacket) (*MsgSendPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SendPacket not implemented") } @@ -763,42 +551,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateChannel) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateChannel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v2.Msg/CreateChannel", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateChannel(ctx, req.(*MsgCreateChannel)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_RegisterCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterCounterparty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterCounterparty(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v2.Msg/RegisterCounterparty", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterCounterparty(ctx, req.(*MsgRegisterCounterparty)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_SendPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSendPacket) if err := dec(in); err != nil { @@ -875,14 +627,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v2.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "CreateChannel", - Handler: _Msg_CreateChannel_Handler, - }, - { - MethodName: "RegisterCounterparty", - Handler: _Msg_RegisterCounterparty_Handler, - }, { MethodName: "SendPacket", Handler: _Msg_SendPacket_Handler, @@ -904,7 +648,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/core/channel/v2/tx.proto", } -func (m *MsgCreateChannel) Marshal() (dAtA []byte, err error) { +func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -914,12 +658,12 @@ func (m *MsgCreateChannel) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateChannel) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendPacket) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -929,29 +673,38 @@ func (m *MsgCreateChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Payloads) > 0 { + for iNdEx := len(m.Payloads) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Payloads[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + if m.TimeoutTimestamp != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x10 + } + if len(m.SourceClient) > 0 { + i -= len(m.SourceClient) + copy(dAtA[i:], m.SourceClient) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceClient))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgCreateChannelResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSendPacketResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -961,27 +714,25 @@ func (m *MsgCreateChannelResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateChannelResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendPacketResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendPacketResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgRegisterCounterparty) Marshal() (dAtA []byte, err error) { +func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -991,12 +742,12 @@ func (m *MsgRegisterCounterparty) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRegisterCounterparty) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRegisterCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1006,26 +757,39 @@ func (m *MsgRegisterCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x1a + if len(m.ProofCommitment) > 0 { + i -= len(m.ProofCommitment) + copy(dAtA[i:], m.ProofCommitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) i-- dAtA[i] = 0x12 } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0xa + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgRegisterCounterpartyResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1035,20 +799,25 @@ func (m *MsgRegisterCounterpartyResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRegisterCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRegisterCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { +func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1058,12 +827,12 @@ func (m *MsgSendPacket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSendPacket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1073,193 +842,24 @@ func (m *MsgSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } - if len(m.Payloads) > 0 { - for iNdEx := len(m.Payloads) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Payloads[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.TimeoutTimestamp != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x1a + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) i-- - dAtA[i] = 0x10 - } - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSendPacketResponse) 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 *MsgSendPacketResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSendPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgRecvPacket) 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 *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecvPacket) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ProofCommitment) > 0 { - i -= len(m.ProofCommitment) - copy(dAtA[i:], m.ProofCommitment) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgRecvPacketResponse) 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 *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 - } - 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 = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ProofUnreceived) > 0 { - i -= len(m.ProofUnreceived) - copy(dAtA[i:], m.ProofUnreceived) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) - i-- - dAtA[i] = 0x12 + dAtA[i] = 0x12 } { size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) @@ -1408,75 +1008,13 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgCreateChannel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateChannelResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRegisterCounterparty) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRegisterCounterpartyResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgSendPacket) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.SourceChannel) + l = len(m.SourceClient) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1615,431 +1153,6 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgCreateChannel) 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 ErrIntOverflowTx - } - 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: MsgCreateChannel: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannel: 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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 MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgCreateChannelResponse) 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 ErrIntOverflowTx - } - 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: MsgCreateChannelResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRegisterCounterparty) 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 ErrIntOverflowTx - } - 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: MsgRegisterCounterparty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRegisterCounterpartyResponse) 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 ErrIntOverflowTx - } - 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: MsgRegisterCounterpartyResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2071,7 +1184,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SourceClient", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2099,7 +1212,7 @@ func (m *MsgSendPacket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) + m.SourceClient = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 6e8472c6847..4a8f53f5a16 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -91,7 +91,7 @@ func (suite *AnteTestSuite) createRecvPacketMessageV2(isRedundant bool) *channel err = suite.path.EndpointB.UpdateClient() suite.Require().NoError(err) - packetKey := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) + packetKey := hostv2.PacketCommitmentKey(packet.SourceClient, packet.Sequence) proof, proofHeight := suite.chainA.QueryProof(packetKey) return channeltypesv2.NewMsgRecvPacket(packet, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) @@ -134,7 +134,7 @@ func (suite *AnteTestSuite) createAcknowledgementMessageV2(isRedundant bool) *ch suite.Require().NoError(err) } - packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationClient, packet.Sequence) proof, proofHeight := suite.chainA.QueryProof(packetKey) return channeltypesv2.NewMsgAcknowledgement(packet, ack, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) @@ -184,7 +184,7 @@ func (suite *AnteTestSuite) createTimeoutMessageV2(isRedundant bool) *channeltyp suite.Require().NoError(err) } - packetKey := hostv2.PacketReceiptKey(packet.SourceChannel, packet.Sequence) + packetKey := hostv2.PacketReceiptKey(packet.SourceClient, packet.Sequence) proof, proofHeight := suite.chainA.QueryProof(packetKey) return channeltypesv2.NewMsgTimeout(packet, proof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) diff --git a/modules/core/internal/v2/telemetry/packet.go b/modules/core/internal/v2/telemetry/packet.go index 8d12f785960..a126f085725 100644 --- a/modules/core/internal/v2/telemetry/packet.go +++ b/modules/core/internal/v2/telemetry/packet.go @@ -16,9 +16,9 @@ func ReportRecvPacket(packet types.Packet) { 1, []metrics.Label{ telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), - telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceClient), telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), - telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationClient), }, ) } @@ -31,9 +31,9 @@ func ReportTimeoutPacket(packet types.Packet) { 1, []metrics.Label{ telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), - telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceClient), telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), - telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationClient), telemetry.NewLabel(ibcmetrics.LabelTimeoutType, "height"), }, ) @@ -47,9 +47,9 @@ func ReportAcknowledgePacket(packet types.Packet) { 1, []metrics.Label{ telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), - telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceClient), telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), - telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationClient), }, ) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e99b58d3b9c..5bb96f2dff4 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -18,9 +18,10 @@ import ( ) var ( - _ clienttypes.MsgServer = (*Keeper)(nil) - _ connectiontypes.MsgServer = (*Keeper)(nil) - _ channeltypes.MsgServer = (*Keeper)(nil) + _ clienttypes.MsgServer = (*Keeper)(nil) + _ clienttypes.CounterpartyMsgServer = (*Keeper)(nil) + _ connectiontypes.MsgServer = (*Keeper)(nil) + _ channeltypes.MsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. @@ -40,9 +41,33 @@ func (k *Keeper) CreateClient(ctx context.Context, msg *clienttypes.MsgCreateCli return nil, err } + // set the client creator so that eureka counterparty can be set by same relayer + k.ClientKeeper.SetClientCreator(ctx, clientID, sdk.AccAddress(msg.Signer)) + return &clienttypes.MsgCreateClientResponse{ClientId: clientID}, nil } +// RegisterCounterparty will register the eureka counterparty info for the given client id +// it must be called by the same relayer that called CreateClient +func (k *Keeper) RegisterCounterparty(ctx context.Context, msg *clienttypes.MsgRegisterCounterparty) (*clienttypes.MsgRegisterCounterpartyResponse, error) { + creator := k.ClientKeeper.GetClientCreator(ctx, msg.ClientId) + if !creator.Equals(sdk.AccAddress(msg.Signer)) { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected same signer as createClient submittor %s, got %s", creator, msg.Signer) + } + + counterpartyInfo := clienttypes.CounterpartyInfo{ + MerklePrefix: msg.CounterpartyMerklePrefix, + ClientId: msg.CounterpartyClientId, + } + k.ClientKeeper.SetClientCounterparty(ctx, msg.ClientId, counterpartyInfo) + + // initialize next sequence send to enable packet flow + k.ChannelKeeperV2.SetNextSequenceSend(ctx, msg.ClientId, 1) + + k.ClientKeeper.DeleteClientCreator(ctx, msg.ClientId) + return &clienttypes.MsgRegisterCounterpartyResponse{}, nil +} + // UpdateClient defines a rpc handler method for MsgUpdateClient. func (k *Keeper) UpdateClient(ctx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) { clientMsg, err := clienttypes.UnpackClientMessage(msg.ClientMessage) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 83f444f1c7d..fc76dff18a0 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -31,6 +31,64 @@ var ( maxSequence = uint64(10) ) +// TestRegisterCounterparty tests that counterpartyInfo is correctly stored +// and only if the submittor is the same submittor as prior createClient msg +func (suite *KeeperTestSuite) TestRegisterCounterparty() { + var path *ibctesting.Path + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() { + path.SetupClients() + }, + nil, + }, + { + "client not created first", + func() {}, + ibcerrors.ErrUnauthorized, + }, + { + "creator is different than expected", + func() { + path.SetupClients() + path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.SetClientCreator(suite.chainA.GetContext(), path.EndpointA.ClientID, sdk.AccAddress(ibctesting.TestAccAddress)) + }, + ibcerrors.ErrUnauthorized, + }, + } + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + path = ibctesting.NewPath(suite.chainA, suite.chainB) + + tc.malleate() + merklePrefix := [][]byte{[]byte("ibc"), []byte("channel-7")} + msg := clienttypes.NewMsgRegisterCounterparty(path.EndpointA.ClientID, merklePrefix, path.EndpointB.ClientID, suite.chainA.SenderAccount.GetAddress().String()) + _, err := suite.chainA.App.GetIBCKeeper().RegisterCounterparty(suite.chainA.GetContext(), msg) + if tc.expError != nil { + suite.Require().Error(err) + suite.Require().True(errors.Is(err, tc.expError)) + } else { + suite.Require().NoError(err) + counterpartyInfo, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(ok) + suite.Require().Equal(counterpartyInfo, clienttypes.NewCounterpartyInfo(merklePrefix, path.EndpointB.ClientID)) + nextSeqSend, ok := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(ok) + suite.Require().Equal(nextSeqSend, uint64(1)) + creator := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().Empty(creator) + } + }) + } +} + // tests the IBC handler receiving a packet on ordered and unordered channels. // It verifies that the storing of an acknowledgement on success occurs. It // tests high level properties like ordering and basic sanity checks. More diff --git a/modules/core/module.go b/modules/core/module.go index e330c99043e..2855c1cf65f 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -126,6 +126,7 @@ func (AppModule) RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) + clienttypes.RegisterCounterpartyMsgServer(cfg.MsgServer(), am.keeper) connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypesv2.RegisterMsgServer(cfg.MsgServer(), am.keeper.ChannelKeeperV2) diff --git a/proto/ibc/core/channel/v2/channel.proto b/proto/ibc/core/channel/v2/channel.proto deleted file mode 100644 index f3ac209cdd9..00000000000 --- a/proto/ibc/core/channel/v2/channel.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v2; - -option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/commitment/v2/commitment.proto"; - -// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol -// Each side will maintain its own Channel to create an IBC channel -// The channel will be referenced by a channelID which will be used to send packets -// to the counterparty -// The channel will contain the client identifier that will provide proof verification for the channel -// and the counterparty channel identifier that the other channel end will be using -// to send packets to our channel end. -message Channel { - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the counterparty identifier that must be used by packets sent by counterparty - // to our channel end. - string counterparty_channel_id = 2; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create - // the final path. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; -} - -// IdentifiedChannel defines a channel with an additional channel identifier field. -message IdentifiedChannel { - option (gogoproto.goproto_getters) = false; - - // channel identified. - Channel channel = 1 [(gogoproto.nullable) = false]; - // channel identifier - string channel_id = 2; -} diff --git a/proto/ibc/core/channel/v2/genesis.proto b/proto/ibc/core/channel/v2/genesis.proto index a4c54a91977..cb32dca06ea 100644 --- a/proto/ibc/core/channel/v2/genesis.proto +++ b/proto/ibc/core/channel/v2/genesis.proto @@ -5,17 +5,13 @@ package ibc.core.channel.v2; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; import "gogoproto/gogo.proto"; -import "ibc/core/channel/v2/channel.proto"; // GenesisState defines the ibc channel/v2 submodule's genesis state. message GenesisState { - repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; - repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; - repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; - repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; - repeated PacketSequence send_sequences = 5 [(gogoproto.nullable) = false]; - // the sequence for the next generated channel identifier - uint64 next_channel_sequence = 6; + repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; + repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; + repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; + repeated PacketSequence send_sequences = 5 [(gogoproto.nullable) = false]; } // PacketState defines the generic type necessary to retrieve and store @@ -25,8 +21,8 @@ message GenesisState { message PacketState { option (gogoproto.goproto_getters) = false; - // channel unique identifier. - string channel_id = 1; + // client unique identifier. + string client_id = 1; // packet sequence. uint64 sequence = 2; // embedded data that represents packet state. @@ -35,8 +31,8 @@ message PacketState { // PacketSequence defines the genesis type necessary to retrieve and store next send sequences. message PacketSequence { - // channel unique identifier. - string channel_id = 1; + // client unique identifier. + string client_id = 1; // packet sequence uint64 sequence = 2; } diff --git a/proto/ibc/core/channel/v2/packet.proto b/proto/ibc/core/channel/v2/packet.proto index ea14112c643..8a311967237 100644 --- a/proto/ibc/core/channel/v2/packet.proto +++ b/proto/ibc/core/channel/v2/packet.proto @@ -13,10 +13,10 @@ message Packet { // with an earlier sequence number must be sent and received before a Packet // with a later sequence number. uint64 sequence = 1; - // identifies the sending chain. - string source_channel = 2; - // identifies the receiving chain. - string destination_channel = 3; + // identifies the sending client on the sending chain. + string source_client = 2; + // identifies the receiving client on the receiving chain. + string destination_client = 3; // timeout timestamp in seconds after which the packet times out. uint64 timeout_timestamp = 4; // a list of payloads, each one for a specific application. diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 9d16a457a9e..3efb9fcfe7d 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -5,132 +5,60 @@ package ibc.core.channel.v2; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "ibc/core/channel/v2/channel.proto"; import "ibc/core/channel/v2/genesis.proto"; import "ibc/core/client/v1/client.proto"; import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; // Query provides defines the gRPC querier service service Query { - // Channel queries the counterparty of an IBC client. - rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}"; - } - - // ChannelClientState queries for the client state for the channel associated - // with the provided channel identifiers. - rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/client_state"; - } - - // ChannelConsensusState queries for the consensus state for the channel associated - // with the provided channel identifiers. - rpc ChannelConsensusState(QueryChannelConsensusStateRequest) returns (QueryChannelConsensusStateResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/consensus_state"; - } - // NextSequenceSend returns the next send sequence for a given channel. rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/next_sequence_send"; } // PacketCommitment queries a stored packet commitment hash. rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{sequence}"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_commitments/{sequence}"; } // PacketCommitments queries a stored packet commitment hash. rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_commitments"; } // PacketAcknowledgement queries a stored acknowledgement commitment hash. rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acks/{sequence}"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_acks/{sequence}"; } // PacketAcknowledgements returns all packet acknowledgements associated with a channel. rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_acknowledgements"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_acknowledgements"; } // PacketReceipt queries a stored packet receipt. rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_receipts/{sequence}"; + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_receipts/{sequence}"; } // UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { - option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/" + option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/packet_commitments/" "{sequences}/unreceived_packets"; } // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { option (google.api.http).get = - "/ibc/core/channel/v2/channels/{channel_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks"; + "/ibc/core/channel/v2/clients/{client_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks"; } } -// QueryChannelRequest is the request type for the Query/Channel RPC method -message QueryChannelRequest { - string channel_id = 1; -} - -// QueryChannelRequest is the response type for the Query/Channel RPC method -message QueryChannelResponse { - // the channel associated with the provided channel id - Channel channel = 1 [(gogoproto.nullable) = false]; -} - -// QueryChannelClientStateRequest is the request type for the Query/ClientState -// RPC method -message QueryChannelClientStateRequest { - // channel unique identifier - string channel_id = 1; -} - -// QueryChannelClientStateResponse is the Response type for the -// Query/QueryChannelClientState RPC method -message QueryChannelClientStateResponse { - // client state associated with the channel - ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState -// RPC method -message QueryChannelConsensusStateRequest { - // channel unique identifier - string channel_id = 1; - // revision number of the consensus state - uint64 revision_number = 2; - // revision height of the consensus state - uint64 revision_height = 3; -} - -// QueryChannelConsensusStateResponse is the Response type for the -// Query/QueryChannelConsensusState RPC method -message QueryChannelConsensusStateResponse { - // consensus state associated with the channel - google.protobuf.Any consensus_state = 1; - // client ID associated with the consensus state - string client_id = 2; - // merkle proof of existence - bytes proof = 3; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; -} - // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method message QueryNextSequenceSendRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; } // QueryNextSequenceSendResponse is the response type for the Query/QueryNextSequenceSend RPC method @@ -145,8 +73,8 @@ message QueryNextSequenceSendResponse { // QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method. message QueryPacketCommitmentRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // packet sequence uint64 sequence = 2; } @@ -163,8 +91,8 @@ message QueryPacketCommitmentResponse { // QueryPacketCommitmentsRequest is the request type for the Query/PacketCommitments RPC method. message QueryPacketCommitmentsRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // pagination request cosmos.base.query.v1beta1.PageRequest pagination = 2; } @@ -181,8 +109,8 @@ message QueryPacketCommitmentsResponse { // QueryPacketAcknowledgementRequest is the request type for the Query/PacketAcknowledgement RPC method. message QueryPacketAcknowledgementRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // packet sequence uint64 sequence = 2; } @@ -200,8 +128,8 @@ message QueryPacketAcknowledgementResponse { // QueryPacketAcknowledgementsRequest is the request type for the // Query/QueryPacketCommitments RPC method message QueryPacketAcknowledgementsRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // pagination request cosmos.base.query.v1beta1.PageRequest pagination = 2; // list of packet sequences @@ -220,12 +148,10 @@ message QueryPacketAcknowledgementsResponse { // QueryPacketReceiptRequest is the request type for the Query/PacketReceipt RPC method. message QueryPacketReceiptRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; + // client unique identifier + string client_id = 1; // packet sequence - uint64 sequence = 3; + uint64 sequence = 2; } // QueryPacketReceiptResponse is the response type for the Query/PacketReceipt RPC method. @@ -240,8 +166,8 @@ message QueryPacketReceiptResponse { // QueryUnreceivedPacketsRequest is the request type for the Query/UnreceivedPackets RPC method message QueryUnreceivedPacketsRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // list of packet sequences repeated uint64 sequences = 2; } @@ -253,11 +179,12 @@ message QueryUnreceivedPacketsResponse { // query block height ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; } + // QueryUnreceivedAcks is the request type for the // Query/UnreceivedAcks RPC method message QueryUnreceivedAcksRequest { - // channel unique identifier - string channel_id = 1; + // client unique identifier + string client_id = 1; // list of acknowledgement sequences repeated uint64 packet_ack_sequences = 2; } diff --git a/proto/ibc/core/channel/v2/tx.proto b/proto/ibc/core/channel/v2/tx.proto index 27eaa08c805..6c3c224c2ea 100644 --- a/proto/ibc/core/channel/v2/tx.proto +++ b/proto/ibc/core/channel/v2/tx.proto @@ -8,18 +8,11 @@ import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/core/channel/v2/packet.proto"; import "ibc/core/client/v1/client.proto"; -import "ibc/core/commitment/v2/commitment.proto"; // Msg defines the ibc/channel/v2 Msg service. service Msg { option (cosmos.msg.v1.service) = true; - // CreateChannel defines a rpc handler method for MsgCreateChannel - rpc CreateChannel(MsgCreateChannel) returns (MsgCreateChannelResponse); - - // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. - rpc RegisterCounterparty(MsgRegisterCounterparty) returns (MsgRegisterCounterpartyResponse); - // SendPacket defines a rpc handler method for MsgSendPacket. rpc SendPacket(MsgSendPacket) returns (MsgSendPacketResponse); @@ -33,52 +26,12 @@ service Msg { rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); } -// MsgCreateChannel defines the message used to create a v2 Channel. -message MsgCreateChannel { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // the client identifier of the light client representing the counterparty chain - string client_id = 1; - // the key path used to store packet flow messages that the counterparty - // will use to send to us. - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; - // signer address - string signer = 3; -} - -// MsgCreateChannelResponse defines the Msg/CreateChannel response type. -message MsgCreateChannelResponse { - option (gogoproto.goproto_getters) = false; - - string channel_id = 1; -} - -// MsgRegisterCounterparty defines the message used to provide the counterparty channel -// identifier. -message MsgRegisterCounterparty { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // unique identifier we will use to write all packet messages sent to counterparty - string channel_id = 1; - // counterparty channel identifier - string counterparty_channel_id = 2; - // signer address - string signer = 3; -} - -// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. -message MsgRegisterCounterpartyResponse {} - // MsgSendPacket sends an outgoing IBC packet. message MsgSendPacket { option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.goproto_getters) = false; - string source_channel = 1; + string source_client = 1; uint64 timeout_timestamp = 2; repeated Payload payloads = 3 [(gogoproto.nullable) = false]; string signer = 4; diff --git a/proto/ibc/core/client/v2/counterparty.proto b/proto/ibc/core/client/v2/counterparty.proto new file mode 100644 index 00000000000..4ed4f6e03ed --- /dev/null +++ b/proto/ibc/core/client/v2/counterparty.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +package ibc.core.client.v2; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"; + +import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; + +// CounterpartyInfo defines the key that the counterparty will use to message our client +message CounterpartyInfo { + // merkle prefix key is the prefix that ics provable keys are stored under + repeated bytes merkle_prefix = 1; + // client identifier is the identifier used to send packet messages to our client + string client_id = 2; +} + +// CounterpartyMsg defines the ibc/client CounterpartyMsg service. +service CounterpartyMsg { + option (cosmos.msg.v1.service) = true; + + // RegisterCounterparty defines a rpc handler method for MsgRegisterCounterparty. + rpc RegisterCounterparty(MsgRegisterCounterparty) returns (MsgRegisterCounterpartyResponse); +} + +// MsgRegisterCounterparty defines a message to register a counterparty on a client +message MsgRegisterCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // client identifier + string client_id = 1; + // counterparty merkle prefix + repeated bytes counterparty_merkle_prefix = 2; + // counterparty client identifier + string counterparty_client_id = 3; + // signer address + string signer = 4; +} + +// MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type. +message MsgRegisterCounterpartyResponse {} \ No newline at end of file diff --git a/testing/endpoint_v2.go b/testing/endpoint_v2.go index be1fd011aa8..cbde15f925c 100644 --- a/testing/endpoint_v2.go +++ b/testing/endpoint_v2.go @@ -5,32 +5,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ) -// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. -func (endpoint *Endpoint) CreateChannel() (err error) { - endpoint.IncrementNextChannelSequence() - msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, endpoint.MerklePathPrefix, endpoint.Chain.SenderAccount.GetAddress().String()) - - // create channel - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events) - if err != nil { - return err - } - - return nil -} - // RegisterCounterparty will construct and execute a MsgRegisterCounterparty on the associated endpoint. func (endpoint *Endpoint) RegisterCounterparty() (err error) { - msg := channeltypesv2.NewMsgRegisterCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := clienttypes.NewMsgRegisterCounterparty(endpoint.ClientID, endpoint.Counterparty.MerklePathPrefix.KeyPath, endpoint.Counterparty.ClientID, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) @@ -50,7 +32,7 @@ func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channel // MsgSendPacketWithSender sends a packet on the associated endpoint using the provided sender. The constructed packet is returned. func (endpoint *Endpoint) MsgSendPacketWithSender(timeoutTimestamp uint64, payload channeltypesv2.Payload, sender SenderAccount) (channeltypesv2.Packet, error) { - msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, sender.SenderAccount.GetAddress().String(), payload) + msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ClientID, timeoutTimestamp, sender.SenderAccount.GetAddress().String(), payload) res, err := endpoint.Chain.SendMsgsWithSender(sender, msgSendPacket) if err != nil { @@ -74,7 +56,7 @@ func (endpoint *Endpoint) MsgSendPacketWithSender(timeoutTimestamp uint64, paylo if err != nil { return channeltypesv2.Packet{}, err } - packet := channeltypesv2.NewPacket(sendResponse.Sequence, endpoint.ChannelID, endpoint.Counterparty.ChannelID, timeoutTimestamp, payload) + packet := channeltypesv2.NewPacket(sendResponse.Sequence, endpoint.ClientID, endpoint.Counterparty.ClientID, timeoutTimestamp, payload) return packet, nil } @@ -82,7 +64,7 @@ func (endpoint *Endpoint) MsgSendPacketWithSender(timeoutTimestamp uint64, paylo // MsgRecvPacket sends a MsgRecvPacket on the associated endpoint with the provided packet. func (endpoint *Endpoint) MsgRecvPacket(packet channeltypesv2.Packet) error { // get proof of packet commitment from chainA - packetKey := hostv2.PacketCommitmentKey(packet.SourceChannel, packet.Sequence) + packetKey := hostv2.PacketCommitmentKey(packet.SourceClient, packet.Sequence) proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) msg := channeltypesv2.NewMsgRecvPacket(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) @@ -96,7 +78,7 @@ func (endpoint *Endpoint) MsgRecvPacket(packet channeltypesv2.Packet) error { // MsgAcknowledgePacket sends a MsgAcknowledgement on the associated endpoint with the provided packet and ack. func (endpoint *Endpoint) MsgAcknowledgePacket(packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) error { - packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationChannel, packet.Sequence) + packetKey := hostv2.PacketAcknowledgementKey(packet.DestinationClient, packet.Sequence) proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) msg := channeltypesv2.NewMsgAcknowledgement(packet, ack, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) @@ -110,7 +92,7 @@ func (endpoint *Endpoint) MsgAcknowledgePacket(packet channeltypesv2.Packet, ack // MsgTimeoutPacket sends a MsgTimeout on the associated endpoint with the provided packet. func (endpoint *Endpoint) MsgTimeoutPacket(packet channeltypesv2.Packet) error { - packetKey := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence) + packetKey := hostv2.PacketReceiptKey(packet.DestinationClient, packet.Sequence) proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) msg := channeltypesv2.NewMsgTimeout(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) diff --git a/testing/path.go b/testing/path.go index 862b03d3691..a63cb3da563 100644 --- a/testing/path.go +++ b/testing/path.go @@ -160,8 +160,6 @@ func (path *Path) Setup() { func (path *Path) SetupV2() { path.SetupClients() - path.CreateChannelsV2() - path.SetupCounterparties() } @@ -262,19 +260,6 @@ func (path *Path) CreateChannels() { } } -// CreateChannelsV2 initializes two channel endpoints by executing CreateChannel on both chainA and chainB. -func (path *Path) CreateChannelsV2() { - err := path.EndpointA.CreateChannel() - if err != nil { - panic(err) - } - - err = path.EndpointB.CreateChannel() - if err != nil { - panic(err) - } -} - // EnableFeeOnPath enables fee on a channel given a path. func EnableFeeOnPath(path *Path) *Path { path.EndpointA.ChannelConfig.Version = ibcmock.MockFeeVersion From 3fefb28196f690d981c3c6473ccbc27d7f536091 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Mon, 20 Jan 2025 19:48:06 +0100 Subject: [PATCH 165/172] Compare Timeout timestamps in seconds instead of nanoseconds (#7857) * compare seconds instead of nanoseconds * remove unnecessary helper func * improve naming --- modules/core/04-channel/v2/keeper/packet.go | 27 ++++++++++++--------- modules/core/04-channel/v2/types/packet.go | 6 ----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index ce00443cfe9..a0254d9ca64 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "strconv" + "time" errorsmod "cosmossdk.io/errors" @@ -53,16 +54,17 @@ func (k *Keeper) sendPacket( return 0, "", errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceClient) } - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceClient, latestHeight) + // client timestamps are in nanoseconds while packet timeouts are in seconds + // thus to compare them, we convert the client timestamp to seconds in uint64 + // to be consistent with IBC V2 specified timeout behaviour + latestTimestampNano, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceClient, latestHeight) if err != nil { return 0, "", err } + latestTimestamp := uint64(time.Unix(0, int64(latestTimestampNano)).Unix()) - // client timestamps are in nanoseconds while packet timeouts are in seconds - // thus to compare them, we convert the packet timeout to nanoseconds - timeoutTimestamp = types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) - if latestTimestamp >= timeoutTimestamp { - return 0, "", errorsmod.Wrapf(types.ErrTimeoutElapsed, "latest timestamp: %d, timeout timestamp: %d", latestTimestamp, timeoutTimestamp) + if latestTimestamp >= packet.TimeoutTimestamp { + return 0, "", errorsmod.Wrapf(types.ErrTimeoutElapsed, "latest timestamp: %d, timeout timestamp: %d", latestTimestamp, packet.TimeoutTimestamp) } commitment := types.CommitPacket(packet) @@ -264,15 +266,18 @@ func (k *Keeper) timeoutPacket( return errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty id (%s) does not match packet destination id (%s)", counterparty.ClientId, packet.DestinationClient) } - // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceClient, proofHeight) + // check that timeout timestamp has passed on the other end + // client timestamps are in nanoseconds while packet timeouts are in seconds + // so we convert client timestamp to seconds in uint64 to be consistent + // with IBC V2 timeout behaviour + proofTimestampNano, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceClient, proofHeight) if err != nil { return err } + proofTimestamp := uint64(time.Unix(0, int64(proofTimestampNano)).Unix()) - timeoutTimestamp := types.TimeoutTimestampToNanos(packet.TimeoutTimestamp) - if proofTimestamp < timeoutTimestamp { - return errorsmod.Wrapf(types.ErrTimeoutNotReached, "proof timestamp: %d, timeout timestamp: %d", proofTimestamp, timeoutTimestamp) + if proofTimestamp < packet.TimeoutTimestamp { + return errorsmod.Wrapf(types.ErrTimeoutNotReached, "proof timestamp: %d, timeout timestamp: %d", proofTimestamp, packet.TimeoutTimestamp) } // check that the commitment has not been cleared and that it matches the packet sent by relayer diff --git a/modules/core/04-channel/v2/types/packet.go b/modules/core/04-channel/v2/types/packet.go index e78a598fa6e..21525033f2a 100644 --- a/modules/core/04-channel/v2/types/packet.go +++ b/modules/core/04-channel/v2/types/packet.go @@ -2,7 +2,6 @@ package types import ( "strings" - "time" errorsmod "cosmossdk.io/errors" @@ -79,8 +78,3 @@ func (p Payload) ValidateBasic() error { } return nil } - -// TimeoutTimestampToNanos takes seconds as a uint64 and returns Unix nanoseconds as uint64. -func TimeoutTimestampToNanos(seconds uint64) uint64 { - return uint64(time.Unix(int64(seconds), 0).UnixNano()) -} From 379e3d2388091eb1ea3639f1b27a784a999b0c72 Mon Sep 17 00:00:00 2001 From: srdtrk <59252793+srdtrk@users.noreply.github.com> Date: Thu, 23 Jan 2025 18:47:32 +0800 Subject: [PATCH 166/172] imp: simplified `BuildMerklePath` (#7863) * imp: simplified BuildMerklePath * imp: review item * test: improved test structure --- modules/core/04-channel/v2/keeper/packet.go | 10 ++---- modules/core/04-channel/v2/types/merkle.go | 27 +++++--------- .../core/04-channel/v2/types/merkle_test.go | 35 +++++++++++-------- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index a0254d9ca64..f760f3fe5b5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -12,7 +12,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -121,8 +120,7 @@ func (k *Keeper) recvPacket( } path := hostv2.PacketCommitmentKey(packet.SourceClient, packet.Sequence) - merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) - merklePath := types.BuildMerklePath(merklePrefix, path) + merklePath := types.BuildMerklePath(counterparty.MerklePrefix, path) commitment := types.CommitPacket(packet) @@ -219,8 +217,7 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack } path := hostv2.PacketAcknowledgementKey(packet.DestinationClient, packet.Sequence) - merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) - merklePath := types.BuildMerklePath(merklePrefix, path) + merklePath := types.BuildMerklePath(counterparty.MerklePrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -298,8 +295,7 @@ func (k *Keeper) timeoutPacket( // verify packet receipt absence path := hostv2.PacketReceiptKey(packet.DestinationClient, packet.Sequence) - merklePrefix := commitmenttypes.NewMerklePath(counterparty.MerklePrefix...) - merklePath := types.BuildMerklePath(merklePrefix, path) + merklePath := types.BuildMerklePath(counterparty.MerklePrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/04-channel/v2/types/merkle.go b/modules/core/04-channel/v2/types/merkle.go index 59be153c960..30d6cbfc000 100644 --- a/modules/core/04-channel/v2/types/merkle.go +++ b/modules/core/04-channel/v2/types/merkle.go @@ -1,31 +1,20 @@ package types import ( - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" ) // BuildMerklePath takes the merkle path prefix and an ICS24 path // and builds a new path by appending the ICS24 path to the last element of the merkle path prefix. -func BuildMerklePath(prefix commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath { - if prefix.Empty() { - return commitmenttypes.NewMerklePath(path) +func BuildMerklePath(prefix [][]byte, path []byte) commitmenttypesv2.MerklePath { + prefixLength := len(prefix) + if prefixLength == 0 { + panic("cannot build merkle path with empty prefix") } - // avoid mutating the provided prefix - prefixKeys := make([][]byte, len(prefix.KeyPath)) - copy(prefixKeys, prefix.KeyPath) - - lastElement := prefixKeys[len(prefixKeys)-1] + // copy prefix to avoid modifying the original slice + fullPath := append([][]byte(nil), prefix...) // append path to last element - newLastElement := cloneAppend(lastElement, path) - prefixKeys[len(prefixKeys)-1] = newLastElement - return commitmenttypes.NewMerklePath(prefixKeys...) -} - -func cloneAppend(bz []byte, tail []byte) []byte { - res := make([]byte, len(bz)+len(tail)) - copy(res, bz) - copy(res[len(bz):], tail) - return res + fullPath[prefixLength-1] = append(fullPath[prefixLength-1], path...) + return commitmenttypesv2.NewMerklePath(fullPath...) } diff --git a/modules/core/04-channel/v2/types/merkle_test.go b/modules/core/04-channel/v2/types/merkle_test.go index df239bc17d7..0eac1e68428 100644 --- a/modules/core/04-channel/v2/types/merkle_test.go +++ b/modules/core/04-channel/v2/types/merkle_test.go @@ -2,7 +2,6 @@ package types_test import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -12,14 +11,16 @@ func (s *TypesTestSuite) TestBuildMerklePath() { path := ibctesting.NewPath(s.chainA, s.chainB) path.SetupV2() - prefixPath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + prefixPath := [][]byte{[]byte("ibc"), []byte("")} packetCommitmentKey := host.PacketCommitmentKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, 1) + emptyPrefixPanicMsg := "cannot build merkle path with empty prefix" testCases := []struct { - name string - prefix commitmenttypesv2.MerklePath - path []byte - expPath commitmenttypesv2.MerklePath + name string + prefix [][]byte + path []byte + expPath commitmenttypesv2.MerklePath + expPanics *string }{ { name: "standard ibc path", @@ -29,21 +30,21 @@ func (s *TypesTestSuite) TestBuildMerklePath() { }, { name: "non-empty last element prefix path", - prefix: commitmenttypes.NewMerklePath([]byte("ibc"), []byte("abc")), + prefix: [][]byte{[]byte("ibc"), []byte("abc")}, path: packetCommitmentKey, expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), append([]byte("abc"), packetCommitmentKey...)), }, { name: "many elements in prefix path", - prefix: commitmenttypes.NewMerklePath([]byte("ibc"), []byte("a"), []byte("b"), []byte("c"), []byte("d")), + prefix: [][]byte{[]byte("ibc"), []byte("a"), []byte("b"), []byte("c"), []byte("d")}, path: packetCommitmentKey, expPath: commitmenttypesv2.NewMerklePath([]byte("ibc"), []byte("a"), []byte("b"), []byte("c"), append([]byte("d"), packetCommitmentKey...)), }, { - name: "empty prefix", - prefix: commitmenttypesv2.MerklePath{}, - path: packetCommitmentKey, - expPath: commitmenttypesv2.NewMerklePath(packetCommitmentKey), + name: "empty prefix", + prefix: [][]byte{}, + path: packetCommitmentKey, + expPanics: &emptyPrefixPanicMsg, }, { name: "empty path", @@ -57,8 +58,14 @@ func (s *TypesTestSuite) TestBuildMerklePath() { tc := tc s.Run(tc.name, func() { - merklePath := types.BuildMerklePath(tc.prefix, tc.path) - s.Require().Equal(tc.expPath, merklePath) + if tc.expPanics == nil { + merklePath := types.BuildMerklePath(tc.prefix, tc.path) + s.Require().Equal(tc.expPath, merklePath) + } else { + s.Require().PanicsWithValue(*tc.expPanics, func() { + _ = types.BuildMerklePath(tc.prefix, tc.path) + }) + } }) } } From ddce44186a5ef6a9a3a5e0545e5f3340f4f1a2f6 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 23 Jan 2025 12:03:18 +0100 Subject: [PATCH 167/172] refactor: make transfer module v2 use same core paths as v1 (#7754) * reuse transfer keeper in v2 * remove keeper from transfer module v2 * moved some comments around and disabled forwarding * code review fixes * Update modules/apps/transfer/keeper/relay_test.go --------- Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- modules/apps/transfer/ibc_module.go | 46 +- modules/apps/transfer/keeper/events.go | 3 +- modules/apps/transfer/keeper/export_test.go | 5 - modules/apps/transfer/keeper/forwarding.go | 4 +- modules/apps/transfer/keeper/keeper.go | 2 +- .../apps/transfer/keeper/mbt_relay_test.go | 15 +- modules/apps/transfer/keeper/msg_server.go | 62 +- modules/apps/transfer/keeper/relay.go | 231 +++--- .../transfer/keeper/relay_forwarding_test.go | 85 +- modules/apps/transfer/keeper/relay_test.go | 50 +- modules/apps/transfer/v2/ibc_module.go | 63 +- modules/apps/transfer/v2/keeper/keeper.go | 253 ------ .../apps/transfer/v2/keeper/keeper_test.go | 58 -- .../transfer/v2/keeper/msg_server_test.go | 750 ------------------ .../08-wasm/testing/simapp/app.go | 5 +- testing/endpoint.go | 14 +- testing/simapp/app.go | 5 +- 17 files changed, 327 insertions(+), 1324 deletions(-) delete mode 100644 modules/apps/transfer/v2/keeper/keeper.go delete mode 100644 modules/apps/transfer/v2/keeper/keeper_test.go delete mode 100644 modules/apps/transfer/v2/keeper/msg_server_test.go diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index bca2274b81a..9922ea456fd 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/telemetry" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" @@ -171,12 +172,11 @@ func (im IBCModule) OnRecvPacket( relayer sdk.AccAddress, ) ibcexported.Acknowledgement { var ( + ack ibcexported.Acknowledgement ackErr error data types.FungibleTokenPacketDataV2 ) - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - // we are explicitly wrapping this emit event call in an anonymous function so that // the packet data is evaluated after it has been assigned a value. defer func() { @@ -192,12 +192,36 @@ func (im IBCModule) OnRecvPacket( return ack } - if ackErr = im.keeper.OnRecvPacket(ctx, packet, data); ackErr != nil { + receivedCoins, ackErr := im.keeper.OnRecvPacket( + ctx, + data, + packet.SourcePort, + packet.SourceChannel, + packet.DestinationPort, + packet.DestinationChannel, + ) + if ackErr != nil { ack = channeltypes.NewErrorAcknowledgement(ackErr) im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) return ack } + if data.HasForwarding() { + // we are now sending from the forward escrow address to the final receiver address. + if ackErr = im.keeper.ForwardPacket(ctx, data, packet, receivedCoins); ackErr != nil { + ack = channeltypes.NewErrorAcknowledgement(ackErr) + im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) + return ack + + } + + ack = nil + } + + ack = channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + + telemetry.ReportOnRecvPacket(packet, data.Tokens) + im.keeper.Logger.Info("successfully handled ICS-20 packet", "sequence", packet.Sequence) if data.HasForwarding() { @@ -227,10 +251,16 @@ func (im IBCModule) OnAcknowledgementPacket( return err } - if err := im.keeper.OnAcknowledgementPacket(ctx, packet, data, ack); err != nil { + if err := im.keeper.OnAcknowledgementPacket(ctx, packet.SourcePort, packet.SourceChannel, data, ack); err != nil { return err } + if forwardedPacket, isForwarded := im.keeper.GetForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence); isForwarded { + if err := im.keeper.HandleForwardedPacketAcknowledgement(ctx, packet, forwardedPacket, data, ack); err != nil { + return err + } + } + return im.keeper.EmitOnAcknowledgementPacketEvent(ctx, data, ack) } @@ -247,10 +277,16 @@ func (im IBCModule) OnTimeoutPacket( } // refund tokens - if err := im.keeper.OnTimeoutPacket(ctx, packet, data); err != nil { + if err := im.keeper.OnTimeoutPacket(ctx, packet.SourcePort, packet.SourceChannel, data); err != nil { return err } + if forwardedPacket, isForwarded := im.keeper.GetForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence); isForwarded { + if err := im.keeper.HandleForwardedPacketTimeout(ctx, packet, forwardedPacket, data); err != nil { + return err + } + } + return im.keeper.EmitOnTimeoutEvent(ctx, data) } diff --git a/modules/apps/transfer/keeper/events.go b/modules/apps/transfer/keeper/events.go index c30fdaabd9f..312454a6359 100644 --- a/modules/apps/transfer/keeper/events.go +++ b/modules/apps/transfer/keeper/events.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ) // EmitTransferEvent emits an ibc transfer event on successful transfers. @@ -36,7 +37,7 @@ func (k Keeper) EmitTransferEvent(ctx context.Context, sender, receiver string, } // EmitOnRecvPacketEvent emits a fungible token packet event in the OnRecvPacket callback -func (k Keeper) EmitOnRecvPacketEvent(ctx context.Context, packetData types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement, ackErr error) error { +func (k Keeper) EmitOnRecvPacketEvent(ctx context.Context, packetData types.FungibleTokenPacketDataV2, ack ibcexported.Acknowledgement, ackErr error) error { tokensStr := mustMarshalJSON(packetData.Tokens) forwardingHopStr := mustMarshalJSON(packetData.Forwarding.Hops) diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go index dedfd560b9b..7aa98f74e9b 100644 --- a/modules/apps/transfer/keeper/export_test.go +++ b/modules/apps/transfer/keeper/export_test.go @@ -39,11 +39,6 @@ func (k Keeper) UnwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgT return k.unwindHops(ctx, msg) } -// GetForwardedPacket is a wrapper around getForwardedPacket for testing purposes. -func (k Keeper) GetForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64) (channeltypes.Packet, bool) { - return k.getForwardedPacket(ctx, portID, channelID, sequence) -} - // SetForwardedPacket is a wrapper around setForwardedPacket for testing purposes. func (k Keeper) SetForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64, packet channeltypes.Packet) { k.setForwardedPacket(ctx, portID, channelID, sequence, packet) diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index e0232caf4aa..fba9748d8d2 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -13,8 +13,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) -// forwardPacket forwards a fungible FungibleTokenPacketDataV2 to the next hop in the forwarding path. -func (k Keeper) forwardPacket(ctx context.Context, data types.FungibleTokenPacketDataV2, packet channeltypes.Packet, receivedCoins sdk.Coins) error { +// ForwardPacket forwards a fungible FungibleTokenPacketDataV2 to the next hop in the forwarding path. +func (k Keeper) ForwardPacket(ctx context.Context, data types.FungibleTokenPacketDataV2, packet channeltypes.Packet, receivedCoins sdk.Coins) error { var nextForwardingPath *types.Forwarding if len(data.Forwarding.Hops) > 1 { // remove the first hop since we are going to send to the first hop now and we want to propagate the rest of the hops to the receiver diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index ee6442b0ae9..0b54e84957f 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -308,7 +308,7 @@ func (k Keeper) setForwardedPacket(ctx context.Context, portID, channelID string } // getForwardedPacket gets the forwarded packet from the store. -func (k Keeper) getForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64) (channeltypes.Packet, bool) { +func (k Keeper) GetForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64) (channeltypes.Packet, bool) { store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(types.PacketForwardKey(portID, channelID, sequence)) if err != nil { diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index c06b625c5d9..8174b1960f5 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -365,20 +365,27 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { } case "OnRecvPacket": - err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, tc.packet.Data) + _, err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket( + suite.chainB.GetContext(), + tc.packet.Data, + packet.SourcePort, + packet.SourceChannel, + packet.DestinationPort, + packet.DestinationChannel, + ) case "OnTimeoutPacket": registerDenomFn() - err = suite.chainB.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainB.GetContext(), packet, tc.packet.Data) + err = suite.chainB.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, tc.packet.Data) case "OnRecvAcknowledgementResult": err = suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket( - suite.chainB.GetContext(), packet, tc.packet.Data, + suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, tc.packet.Data, channeltypes.NewResultAcknowledgement(nil)) case "OnRecvAcknowledgementError": registerDenomFn() err = suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket( - suite.chainB.GetContext(), packet, tc.packet.Data, + suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, tc.packet.Data, channeltypes.NewErrorAcknowledgement(fmt.Errorf("MBT Error Acknowledgement"))) default: err = fmt.Errorf("Unknown handler: %s", tc.handler) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 1fab80dfa94..034c2c078e0 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -8,7 +8,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/telemetry" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) @@ -25,30 +27,70 @@ func (k Keeper) Transfer(ctx context.Context, msg *types.MsgTransfer) (*types.Ms return nil, err } - coins := msg.GetCoins() + if msg.Forwarding.GetUnwind() { + msg, err = k.unwindHops(ctx, msg) + if err != nil { + return nil, err + } + } - if err := k.BankKeeper.IsSendEnabledCoins(ctx, coins...); err != nil { - return nil, errorsmod.Wrap(types.ErrSendDisabled, err.Error()) + channel, found := k.channelKeeper.GetChannel(ctx, msg.SourcePort, msg.SourceChannel) + if !found { + return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.SourcePort, msg.SourceChannel) } - if k.IsBlockedAddr(sender) { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) + appVersion, found := k.ics4Wrapper.GetAppVersion(ctx, msg.SourcePort, msg.SourceChannel) + if !found { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "application version not found for source port: %s and source channel: %s", msg.SourcePort, msg.SourceChannel) } - if msg.Forwarding.GetUnwind() { - msg, err = k.unwindHops(ctx, msg) + coins := msg.GetCoins() + hops := msg.Forwarding.GetHops() + if appVersion == types.V1 { + // ics20-1 only supports a single coin, so if that is the current version, we must only process a single coin. + if len(coins) > 1 { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot transfer multiple coins with %s", types.V1) + } + + // ics20-1 does not support forwarding, so if that is the current version, we must reject the transfer. + if len(hops) > 0 { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot forward coins with %s", types.V1) + } + } + + tokens := make([]types.Token, len(coins)) + + for i, coin := range coins { + tokens[i], err = k.tokenFromCoin(ctx, coin) if err != nil { return nil, err } } - sequence, err := k.sendTransfer( - ctx, msg.SourcePort, msg.SourceChannel, coins, sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp, - msg.Memo, msg.Forwarding.GetHops()) + if err := k.SendTransfer(ctx, msg.SourcePort, msg.SourceChannel, tokens, sender); err != nil { + return nil, err + } + + packetDataBytes, err := createPacketDataBytesFromVersion( + appVersion, sender.String(), msg.Receiver, msg.Memo, tokens, hops, + ) if err != nil { return nil, err } + sequence, err := k.ics4Wrapper.SendPacket(ctx, msg.SourcePort, msg.SourceChannel, msg.TimeoutHeight, msg.TimeoutTimestamp, packetDataBytes) + if err != nil { + return nil, err + } + + if err := k.EmitTransferEvent(ctx, sender.String(), msg.Receiver, tokens, msg.Memo, hops); err != nil { + return nil, err + } + + destinationPort := channel.Counterparty.PortId + destinationChannel := channel.Counterparty.ChannelId + telemetry.ReportTransfer(msg.SourcePort, msg.SourceChannel, destinationPort, destinationChannel, tokens) + k.Logger.Info("IBC fungible token transfer", "tokens", coins, "sender", msg.Sender, "receiver", msg.Receiver) return &types.MsgTransferResponse{Sequence: sequence}, nil diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index bfb2adfc73a..5d90f112792 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -10,15 +10,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/telemetry" internaltypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/types" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ) -// sendTransfer handles transfer sending logic. There are 2 possible cases: +// SendTransfer handles transfer sending logic. There are 2 possible cases: // // 1. Sender chain is acting as the source zone. The coins are transferred // to an escrow address (i.e locked) on the sender chain and then transferred @@ -50,62 +48,39 @@ import ( // 4. A -> C : sender chain is sink zone. Denom upon receiving: 'C/B/denom' // 5. C -> B : sender chain is sink zone. Denom upon receiving: 'B/denom' // 6. B -> A : sender chain is sink zone. Denom upon receiving: 'denom' -func (k Keeper) sendTransfer( +func (k Keeper) SendTransfer( ctx context.Context, - sourcePort, + sourcePort string, sourceChannel string, - coins sdk.Coins, + tokens types.Tokens, sender sdk.AccAddress, - receiver string, - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, - memo string, - hops []types.Hop, -) (uint64, error) { - channel, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) - if !found { - return 0, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) +) error { + if !k.GetParams(ctx).SendEnabled { + return types.ErrSendDisabled } - appVersion, found := k.ics4Wrapper.GetAppVersion(ctx, sourcePort, sourceChannel) - if !found { - return 0, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "application version not found for source port: %s and source channel: %s", sourcePort, sourceChannel) + if k.IsBlockedAddr(sender) { + return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) } - if appVersion == types.V1 { - // ics20-1 only supports a single coin, so if that is the current version, we must only process a single coin. - if len(coins) > 1 { - return 0, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot transfer multiple coins with %s", types.V1) + for _, token := range tokens { + coin, err := token.ToCoin() + if err != nil { + return err } - // ics20-1 does not support forwarding, so if that is the current version, we must reject the transfer. - if len(hops) > 0 { - return 0, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot forward coins with %s", types.V1) + if err := k.BankKeeper.IsSendEnabledCoins(ctx, coin); err != nil { + return errorsmod.Wrap(types.ErrSendDisabled, err.Error()) } - } - - destinationPort := channel.Counterparty.PortId - destinationChannel := channel.Counterparty.ChannelId - - // begin createOutgoingPacket logic - // See spec for this logic: https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#packet-relay - tokens := make([]types.Token, 0, len(coins)) - - for _, coin := range coins { // Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom. if coin.Amount.Equal(types.UnboundedSpendLimit()) { coin.Amount = k.BankKeeper.SpendableCoin(ctx, sender, coin.Denom).Amount if coin.Amount.IsZero() { - return 0, errorsmod.Wrapf(types.ErrInvalidAmount, "empty spendable balance for %s", coin.Denom) + return errorsmod.Wrapf(types.ErrInvalidAmount, "empty spendable balance for %s", coin.Denom) } } - token, err := k.tokenFromCoin(ctx, coin) - if err != nil { - return 0, err - } - // NOTE: SendTransfer simply sends the denomination as it exists on its own // chain inside the packet data. The receiving chain will perform denom // prefixing as necessary. @@ -117,7 +92,7 @@ func (k Keeper) sendTransfer( if err := k.BankKeeper.SendCoinsFromAccountToModule( ctx, sender, types.ModuleName, sdk.NewCoins(coin), ); err != nil { - return 0, err + return err } if err := k.BankKeeper.BurnCoins( @@ -132,30 +107,14 @@ func (k Keeper) sendTransfer( // obtain the escrow address for the source channel end escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) if err := k.EscrowCoin(ctx, sender, escrowAddress, coin); err != nil { - return 0, err + return err } } tokens = append(tokens, token) } - packetDataBytes, err := createPacketDataBytesFromVersion(appVersion, sender.String(), receiver, memo, tokens, hops) - if err != nil { - return 0, err - } - - sequence, err := k.ics4Wrapper.SendPacket(ctx, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetDataBytes) - if err != nil { - return 0, err - } - - if err := k.EmitTransferEvent(ctx, sender.String(), receiver, tokens, memo, hops); err != nil { - return 0, err - } - - telemetry.ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChannel, tokens) - - return sequence, nil + return nil } // OnRecvPacket processes a cross chain fungible token transfer. @@ -167,23 +126,30 @@ func (k Keeper) sendTransfer( // // In the case of packet forwarding, the packet is sent on the next hop as specified // in the packet's ForwardingPacketData. -func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2) error { +func (k Keeper) OnRecvPacket( + ctx context.Context, + data types.FungibleTokenPacketDataV2, + sourcePort string, + sourceChannel string, + destPort string, + destChannel string, +) (sdk.Coins, error) { // validate packet data upon receiving if err := data.ValidateBasic(); err != nil { - return errorsmod.Wrapf(err, "error validating ICS-20 transfer packet data") + return nil, errorsmod.Wrapf(err, "error validating ICS-20 transfer packet data") } if !k.GetParams(ctx).ReceiveEnabled { - return types.ErrReceiveDisabled + return nil, types.ErrReceiveDisabled } receiver, err := k.getReceiverFromPacketData(data) if err != nil { - return err + return nil, err } if k.IsBlockedAddr(receiver) { - return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", receiver) + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", receiver) } receivedCoins := make(sdk.Coins, 0, len(data.Tokens)) @@ -191,7 +157,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da // parse the transfer amount transferAmount, ok := sdkmath.NewIntFromString(token.Amount) if !ok { - return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount: %s", token.Amount) + return nil, errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount: %s", token.Amount) } // This is the prefix that would have been prefixed to the denomination @@ -201,7 +167,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da // NOTE: We use SourcePort and SourceChannel here, because the counterparty // chain would have prefixed with DestPort and DestChannel when originally // receiving this token. - if token.Denom.HasPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) { + if token.Denom.HasPrefix(sourcePort, sourceChannel) { // sender chain is not the source, unescrow tokens // remove prefix added by sender chain @@ -209,9 +175,9 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da coin := sdk.NewCoin(token.Denom.IBCDenom(), transferAmount) - escrowAddress := types.GetEscrowAddress(packet.GetDestPort(), packet.GetDestChannel()) + escrowAddress := types.GetEscrowAddress(destPort, destChannel) if err := k.UnescrowCoin(ctx, escrowAddress, receiver, coin); err != nil { - return err + return nil, err } // Appending token. The new denom has been computed @@ -220,7 +186,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da // sender chain is the source, mint vouchers // since SendPacket did not prefix the denomination, we must add the destination port and channel to the trace - trace := []types.Hop{types.NewHop(packet.DestinationPort, packet.DestinationChannel)} + trace := []types.Hop{types.NewHop(destPort, destChannel)} token.Denom.Trace = append(trace, token.Denom.Trace...) if !k.HasDenom(ctx, token.Denom.Hash()) { @@ -233,7 +199,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da } if err := k.EmitDenomEvent(ctx, token); err != nil { - return err + return nil, err } voucher := sdk.NewCoin(voucherDenom, transferAmount) @@ -242,7 +208,7 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da if err := k.BankKeeper.MintCoins( ctx, types.ModuleName, sdk.NewCoins(voucher), ); err != nil { - return errorsmod.Wrap(err, "failed to mint IBC tokens") + return nil, errorsmod.Wrap(err, "failed to mint IBC tokens") } // send to receiver @@ -250,102 +216,109 @@ func (k Keeper) OnRecvPacket(ctx context.Context, packet channeltypes.Packet, da if err := k.BankKeeper.SendCoins( ctx, moduleAddr, receiver, sdk.NewCoins(voucher), ); err != nil { - return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String()) + return nil, errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String()) } receivedCoins = append(receivedCoins, voucher) } } - if data.HasForwarding() { - // we are now sending from the forward escrow address to the final receiver address. - if err := k.forwardPacket(ctx, data, packet, receivedCoins); err != nil { - return err - } - } - - telemetry.ReportOnRecvPacket(packet, data.Tokens) - // The ibc_module.go module will return the proper ack. - return nil + return receivedCoins, nil } // OnAcknowledgementPacket responds to the success or failure of a packet acknowledgment // written on the receiving chain. // -// If no forwarding occurs and the acknowledgement was a success then nothing occurs. Otherwise, +// If the acknowledgement was a success then nothing occurs. Otherwise, // if the acknowledgement failed, then the sender is refunded their tokens. -// -// If forwarding is used and the acknowledgement was a success, a successful acknowledgement is written -// for the forwarded packet. Otherwise, if the acknowledgement failed, after refunding the sender, the -// tokens of the forwarded packet that were received are in turn either refunded or burned. -func (k Keeper) OnAcknowledgementPacket(ctx context.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement) error { - forwardedPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - +func (k Keeper) OnAcknowledgementPacket( + ctx context.Context, + sourcePort string, + sourceChannel string, + data types.FungibleTokenPacketDataV2, + ack channeltypes.Acknowledgement, +) error { switch ack.Response.(type) { case *channeltypes.Acknowledgement_Result: - if isForwarded { - // Write a successful async ack for the forwardedPacket - forwardAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) - } - // the acknowledgement succeeded on the receiving chain so nothing // needs to be executed and no error needs to be returned return nil case *channeltypes.Acknowledgement_Error: - // We refund the tokens from the escrow address to the sender - if err := k.refundPacketTokens(ctx, packet, data); err != nil { + if err := k.refundPacketTokens(ctx, sourcePort, sourceChannel, data); err != nil { return err } - if isForwarded { - // the forwarded packet has failed, thus the funds have been refunded to the intermediate address. - // we must revert the changes that came from successfully receiving the tokens on our chain - // before propagating the error acknowledgement back to original sender chain - if err := k.revertForwardedPacket(ctx, forwardedPacket, data); err != nil { - return err - } - - forwardAck := internaltypes.NewForwardErrorAcknowledgement(packet, ack) - return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) - } - return nil default: return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected one of [%T, %T], got %T", channeltypes.Acknowledgement_Result{}, channeltypes.Acknowledgement_Error{}, ack.Response) } } -// OnTimeoutPacket processes a transfer packet timeout. +// HandleForwardedPacketAcknowledgement processes an acknowledgement for a packet that was sent from the chain as an intermediate. // -// If no forwarding occurs, it refunds the tokens to the sender. -// -// If forwarding is used and the chain acted as a middle hop on a multihop transfer, after refunding -// the tokens to the sender, the tokens of the forwarded packet that were received are in turn -// either refunded or burned. -func (k Keeper) OnTimeoutPacket(ctx context.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2) error { - if err := k.refundPacketTokens(ctx, packet, data); err != nil { - return err - } +// If the acknowledgement was a success, a successful acknowledgement is written +// for the forwarded packet. Otherwise, if the acknowledgement failed, after refunding the sender, the +// tokens of the forwarded packet that were received are in turn either refunded or burned. +func (k Keeper) HandleForwardedPacketAcknowledgement( + ctx context.Context, + packet channeltypes.Packet, + forwardedPacket channeltypes.Packet, + data types.FungibleTokenPacketDataV2, + ack channeltypes.Acknowledgement, +) error { + var forwardAck channeltypes.Acknowledgement - forwardedPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - if isForwarded { + switch ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + // Write a successful async ack for the forwardedPacket + forwardAck = channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + case *channeltypes.Acknowledgement_Error: + // the forwarded packet has failed, thus the funds have been refunded to the intermediate address. + // we must revert the changes that came from successfully receiving the tokens on our chain + // before propagating the error acknowledgement back to original sender chain if err := k.revertForwardedPacket(ctx, forwardedPacket, data); err != nil { return err } - forwardAck := internaltypes.NewForwardTimeoutAcknowledgement(packet) - return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) + forwardAck = internaltypes.NewForwardErrorAcknowledgement(packet, ack) + default: + return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected one of [%T, %T], got %T", channeltypes.Acknowledgement_Result{}, channeltypes.Acknowledgement_Error{}, ack.Response) } - return nil + return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) +} + +// OnTimeoutPacket processes a transfer packet timeout by refunding the tokens to the sender +func (k Keeper) OnTimeoutPacket( + ctx context.Context, + sourcePort string, + sourceChannel string, + data types.FungibleTokenPacketDataV2, +) error { + return k.refundPacketTokens(ctx, sourcePort, sourceChannel, data) +} + +// HandleForwardedTimeout processes a timeout packet that was sent from the chain as an intermediate. +// The packet is reverted and the tokens are refunded to the sender. +func (k Keeper) HandleForwardedPacketTimeout(ctx context.Context, packet channeltypes.Packet, forwardedPacket channeltypes.Packet, data types.FungibleTokenPacketDataV2) error { + if err := k.revertForwardedPacket(ctx, forwardedPacket, data); err != nil { + return err + } + + forwardAck := internaltypes.NewForwardTimeoutAcknowledgement(packet) + return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) } // refundPacketTokens will unescrow and send back the tokens back to sender // if the sending chain was the source chain. Otherwise, the sent tokens // were burnt in the original send so new tokens are minted and sent to // the sending address. -func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2) error { +func (k Keeper) refundPacketTokens( + ctx context.Context, + sourcePort string, + sourceChannel string, + data types.FungibleTokenPacketDataV2, +) error { // NOTE: packet data type already checked in handler.go sender, err := sdk.AccAddressFromBech32(data.Sender) @@ -357,7 +330,7 @@ func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Pack } // escrow address for unescrowing tokens back to sender - escrowAddress := types.GetEscrowAddress(packet.GetSourcePort(), packet.GetSourceChannel()) + escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) moduleAccountAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) for _, token := range data.Tokens { @@ -368,7 +341,7 @@ func (k Keeper) refundPacketTokens(ctx context.Context, packet channeltypes.Pack // if the token we must refund is prefixed by the source port and channel // then the tokens were burnt when the packet was sent and we must mint new tokens - if token.Denom.HasPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) { + if token.Denom.HasPrefix(sourcePort, sourceChannel) { // mint vouchers back to sender if err := k.BankKeeper.MintCoins( ctx, types.ModuleName, sdk.NewCoins(coin), diff --git a/modules/apps/transfer/keeper/relay_forwarding_test.go b/modules/apps/transfer/keeper/relay_forwarding_test.go index f3756c34f95..95a8787b58f 100644 --- a/modules/apps/transfer/keeper/relay_forwarding_test.go +++ b/modules/apps/transfer/keeper/relay_forwarding_test.go @@ -1055,18 +1055,22 @@ func (suite *ForwardingTestSuite) TestOnTimeoutPacketForwarding() { suite.Require().NoError(err) // message committed // parse the packet from result events and recv packet on chainB - packet, err := ibctesting.ParsePacketFromEvents(result.Events) + packetFromAToB, err := ibctesting.ParsePacketFromEvents(result.Events) suite.Require().NoError(err) - suite.Require().NotNil(packet) + suite.Require().NotNil(packetFromAToB) err = pathAtoB.EndpointB.UpdateClient() suite.Require().NoError(err) // Receive packet on B. - result, err = pathAtoB.EndpointB.RecvPacketWithResult(packet) + result, err = pathAtoB.EndpointB.RecvPacketWithResult(packetFromAToB) suite.Require().NoError(err) suite.Require().NotNil(result) + packetFromBToC, err := ibctesting.ParsePacketFromEvents(result.Events) + suite.Require().NoError(err) + suite.Require().NotNil(packetFromBToC) + err = pathBtoC.EndpointA.UpdateClient() suite.Require().NoError(err) @@ -1078,74 +1082,33 @@ func (suite *ForwardingTestSuite) TestOnTimeoutPacketForwarding() { suite.assertAmountOnChain(suite.chainB, escrow, amount, denomAB.IBCDenom()) // Check that forwarded packet exists - forwardedPacket, found := suite.chainB.GetSimApp().TransferKeeper.GetForwardedPacket(suite.chainB.GetContext(), pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID, packet.Sequence) + forwardedPacket, found := suite.chainB.GetSimApp().TransferKeeper.GetForwardedPacket(suite.chainB.GetContext(), pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID, packetFromAToB.Sequence) suite.Require().True(found, "Chain B has no forwarded packet") - suite.Require().Equal(packet, forwardedPacket, "ForwardedPacket stored in ChainB is not the same that was sent") - - address := suite.chainB.GetSimApp().AuthKeeper.GetModuleAddress(types.ModuleName).String() - data := types.NewFungibleTokenPacketDataV2( - []types.Token{ - { - Denom: types.NewDenom(sdk.DefaultBondDenom, types.NewHop(pathAtoB.EndpointB.ChannelConfig.PortID, pathAtoB.EndpointB.ChannelID)), - Amount: "100", - }, - }, - address, - receiver.GetAddress().String(), - "", ibctesting.EmptyForwardingPacketData, - ) - - packet = channeltypes.NewPacket( - data.GetBytes(), - 1, - pathBtoC.EndpointA.ChannelConfig.PortID, - pathBtoC.EndpointA.ChannelID, - pathBtoC.EndpointB.ChannelConfig.PortID, - pathBtoC.EndpointB.ChannelID, - packet.TimeoutHeight, - packet.TimeoutTimestamp) + suite.Require().Equal(packetFromAToB, forwardedPacket, "ForwardedPacket stored in ChainB is not the same that was sent") - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(pathBtoC.EndpointA.ChannelConfig.PortID) - suite.Require().True(ok) + // Time out packet + suite.coordinator.IncrementTimeBy(time.Minute * 5) + err = pathBtoC.EndpointA.UpdateClient() + suite.Require().NoError(err) - // Trigger OnTimeoutPacket for chainB - err = cbs.OnTimeoutPacket(suite.chainB.GetContext(), pathBtoC.EndpointA.GetChannel().Version, packet, nil) + result, err = pathBtoC.EndpointA.TimeoutPacketWithResult(packetFromBToC) + suite.Require().NoError(err) + ack, err := ibctesting.ParseAckFromEvents(result.Events) suite.Require().NoError(err) // Ensure that chainB has an ack. - storedAck, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), pathAtoB.EndpointB.ChannelConfig.PortID, pathAtoB.EndpointB.ChannelID, packet.GetSequence()) + storedAck, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), pathAtoB.EndpointB.ChannelConfig.PortID, pathAtoB.EndpointB.ChannelID, packetFromBToC.GetSequence()) suite.Require().True(found, "chainB does not have an ack") // And that this ack is of the type we expect (Error due to time out) - ack := internaltypes.NewForwardTimeoutAcknowledgement(packet) - ackbytes := channeltypes.CommitAcknowledgement(ack.Acknowledgement()) - suite.Require().Equal(ackbytes, storedAck) - - forwardingPacketData := types.NewForwardingPacketData("", forwarding.Hops...) - data = types.NewFungibleTokenPacketDataV2( - []types.Token{ - { - Denom: types.NewDenom(sdk.DefaultBondDenom), - Amount: "100", - }, - }, - sender.GetAddress().String(), - receiver.GetAddress().String(), - "", forwardingPacketData, - ) + expectedAck := internaltypes.NewForwardTimeoutAcknowledgement(packetFromBToC) + expectedAckBytes := channeltypes.CommitAcknowledgement(expectedAck.Acknowledgement()) + suite.Require().Equal(expectedAckBytes, storedAck) + suite.Require().Equal(expectedAck.Acknowledgement(), ack) - packet = channeltypes.NewPacket( - data.GetBytes(), - 1, - pathAtoB.EndpointA.ChannelConfig.PortID, - pathAtoB.EndpointA.ChannelID, - pathAtoB.EndpointB.ChannelConfig.PortID, - pathAtoB.EndpointB.ChannelID, - packet.TimeoutHeight, - packet.TimeoutTimestamp) - - // Send the ack to chain A. - err = suite.chainA.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, data, ack) + err = pathAtoB.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = pathAtoB.EndpointA.AcknowledgePacket(packetFromAToB, ack) suite.Require().NoError(err) // Finally, check that A,B, and C escrow accounts do not have fund. diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index b544ee0cf5d..a752a6f2530 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -92,24 +92,15 @@ func (suite *KeeperTestSuite) TestSendTransfer() { { "successful transfer of native token with ics20-1", func() { - coins = sdk.NewCoins(coins[0]) + denom := types.NewDenom(ibctesting.TestCoin.Denom) + coins = sdk.NewCoins(sdk.NewCoin(denom.IBCDenom(), ibctesting.TestCoin.Amount)) // Set version to isc20-1. path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.Version = types.V1 }) - }, - nil, - }, - { - "successful transfer with empty forwarding hops and ics20-1", - func() { - coins = sdk.NewCoins(coins[0]) - // Set version to isc20-1. - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.Version = types.V1 - }) + expEscrowAmounts = []sdkmath.Int{defaultAmount} }, nil, }, @@ -463,7 +454,14 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { denoms = append(denoms, types.NewDenom(token.Denom.Base, types.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID))) } - err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, packetData) + _, err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket( + suite.chainB.GetContext(), + packetData, + packet.SourcePort, + packet.SourceChannel, + packet.DestinationPort, + packet.DestinationChannel, + ) if tc.expError == nil { suite.Require().NoError(err) @@ -589,7 +587,14 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { tc.malleate() packet := channeltypes.NewPacket(packetData.GetBytes(), uint64(1), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0) - err = suite.chainA.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainA.GetContext(), packet, packetData) + _, err = suite.chainA.GetSimApp().TransferKeeper.OnRecvPacket( + suite.chainA.GetContext(), + packetData, + packet.SourcePort, + packet.SourceChannel, + packet.DestinationPort, + packet.DestinationChannel, + ) if tc.expError == nil { suite.Require().NoError(err) @@ -699,7 +704,14 @@ func (suite *KeeperTestSuite) TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCT suite.Require().Equal(defaultAmount, totalEscrowChainB.Amount) // execute onRecvPacket, when chaninB receives the source token the escrow amount should decrease - err := suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data) + _, err := suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket( + suite.chainB.GetContext(), + data, + packet.SourcePort, + packet.SourceChannel, + packet.DestinationPort, + packet.DestinationChannel, + ) suite.Require().NoError(err) // check total amount in escrow of sent token on receiving chain @@ -800,7 +812,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { packet := channeltypes.NewPacket(data.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) preAcknowledgementBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) - err := suite.chainA.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, data, tc.ack) + err := suite.chainA.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, data, tc.ack) // check total amount in escrow of sent token denom on sending chain totalEscrow := suite.chainA.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainA.GetContext(), denom.IBCDenom()) @@ -906,7 +918,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacketSetsTotalEscrowAmountFo totalEscrowChainB := suite.chainB.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainB.GetContext(), coin.GetDenom()) suite.Require().Equal(defaultAmount, totalEscrowChainB.Amount) - err := suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainB.GetContext(), packet, data, ack) + err := suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, data, ack) suite.Require().NoError(err) // check total amount in escrow of sent token on sending chain @@ -1034,7 +1046,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { packet := channeltypes.NewPacket(data.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) preTimeoutBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) - err := suite.chainA.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainA.GetContext(), packet, data) + err := suite.chainA.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, data) postTimeoutBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) deltaAmount := postTimeoutBalance.Amount.Sub(preTimeoutBalance.Amount) @@ -1130,7 +1142,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacketSetsTotalEscrowAmountForSourceI totalEscrowChainB := suite.chainB.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainB.GetContext(), coin.GetDenom()) suite.Require().Equal(defaultAmount, totalEscrowChainB.Amount) - err := suite.chainB.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainB.GetContext(), packet, data) + err := suite.chainB.GetSimApp().TransferKeeper.OnTimeoutPacket(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, data) suite.Require().NoError(err) // check total amount in escrow of sent token on sending chain diff --git a/modules/apps/transfer/v2/ibc_module.go b/modules/apps/transfer/v2/ibc_module.go index 84b25e259db..800e7e07e59 100644 --- a/modules/apps/transfer/v2/ibc_module.go +++ b/modules/apps/transfer/v2/ibc_module.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/api" @@ -19,33 +19,42 @@ import ( var _ api.IBCModule = (*IBCModule)(nil) // NewIBCModule creates a new IBCModule given the keeper -func NewIBCModule(k *keeper.Keeper) *IBCModule { +func NewIBCModule(k keeper.Keeper) *IBCModule { return &IBCModule{ keeper: k, } } type IBCModule struct { - keeper *keeper.Keeper + keeper keeper.Keeper } func (im *IBCModule) OnSendPacket(goCtx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, signer sdk.AccAddress) error { - ctx := sdk.UnwrapSDKContext(goCtx) + data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) + if err != nil { + return err + } - if !im.keeper.GetParams(ctx).SendEnabled { - return transfertypes.ErrSendDisabled + sender, err := sdk.AccAddressFromBech32(data.Sender) + if err != nil { + return err } - if im.keeper.IsBlockedAddr(signer) { - return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", signer) + if !signer.Equals(sender) { + return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "sender %s is different from signer %s", sender, signer) } - data, err := transfertypes.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) - if err != nil { + if err := im.keeper.SendTransfer(goCtx, payload.SourcePort, sourceChannel, data.Tokens, signer); err != nil { return err } - return im.keeper.OnSendPacket(ctx, sourceChannel, payload, data, signer) + // TODO: events + // events.EmitTransferEvent(ctx, sender.String(), receiver, tokens, memo, hops) + + // TODO: telemetry + // telemetry.ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChannel, tokens) + + return nil } func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { @@ -77,7 +86,14 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des } } - if ackErr = im.keeper.OnRecvPacket(ctx, sourceChannel, destinationChannel, payload, data); ackErr != nil { + if _, ackErr = im.keeper.OnRecvPacket( + ctx, + data, + payload.SourcePort, + sourceChannel, + payload.DestinationPort, + destinationChannel, + ); ackErr != nil { ack = channeltypes.NewErrorAcknowledgement(ackErr) im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), sequence)) return types.RecvPacketResult{ @@ -88,11 +104,26 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des im.keeper.Logger.Info("successfully handled ICS-20 packet", "sequence", sequence) + // TODO: telemetry + // telemetry.ReportOnRecvPacket(packet, data.Tokens) + if data.HasForwarding() { - // NOTE: acknowledgement will be written asynchronously + // we are now sending from the forward escrow address to the final receiver address. + ack = channeltypes.NewErrorAcknowledgement(fmt.Errorf("forwarding not yet supported")) return types.RecvPacketResult{ - Status: types.PacketStatus_Async, + Status: types.PacketStatus_Failure, + Acknowledgement: ack.Acknowledgement(), } + // TODO: handle forwarding + // TODO: inside this version of the function, we should fetch the packet that was stored in IBC core in order to set it for forwarding. + // if err := k.forwardPacket(ctx, data, packet, receivedCoins); err != nil { + // return err + // } + + // NOTE: acknowledgement will be written asynchronously + // return types.RecvPacketResult{ + // Status: types.PacketStatus_Async, + // } } // NOTE: acknowledgement will be written synchronously during IBC handler execution. @@ -110,6 +141,8 @@ func (im *IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, return err } + // TODO: handle forwarding + return im.keeper.EmitOnTimeoutEvent(ctx, data) } @@ -128,5 +161,7 @@ func (im *IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel return err } + // TODO: handle forwarding + return im.keeper.EmitOnAcknowledgementPacketEvent(ctx, data, ack) } diff --git a/modules/apps/transfer/v2/keeper/keeper.go b/modules/apps/transfer/v2/keeper/keeper.go deleted file mode 100644 index cb2d271c6f2..00000000000 --- a/modules/apps/transfer/v2/keeper/keeper.go +++ /dev/null @@ -1,253 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - transferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channelkeeperv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" -) - -type Keeper struct { - transferkeeper.Keeper - channelKeeperV2 *channelkeeperv2.Keeper -} - -func NewKeeper(transferKeeper transferkeeper.Keeper, channelKeeperV2 *channelkeeperv2.Keeper) *Keeper { - return &Keeper{ - Keeper: transferKeeper, - channelKeeperV2: channelKeeperV2, - } -} - -func (k *Keeper) OnSendPacket(ctx context.Context, sourceChannel string, payload channeltypesv2.Payload, data types.FungibleTokenPacketDataV2, sender sdk.AccAddress) error { - for _, token := range data.Tokens { - coin, err := token.ToCoin() - if err != nil { - return err - } - - if coin.Amount.Equal(types.UnboundedSpendLimit()) { - coin.Amount = k.BankKeeper.SpendableCoin(ctx, sender, coin.Denom).Amount - if coin.Amount.IsZero() { - return errorsmod.Wrapf(types.ErrInvalidAmount, "empty spendable balance for %s", coin.Denom) - } - } - - // NOTE: SendTransfer simply sends the denomination as it exists on its own - // chain inside the packet data. The receiving chain will perform denom - // prefixing as necessary. - - // if the denom is prefixed by the port and channel on which we are sending - // the token, then we must be returning the token back to the chain they originated from - if token.Denom.HasPrefix(payload.SourcePort, sourceChannel) { - // transfer the coins to the module account and burn them - if err := k.BankKeeper.SendCoinsFromAccountToModule( - ctx, sender, types.ModuleName, sdk.NewCoins(coin), - ); err != nil { - return err - } - - if err := k.BankKeeper.BurnCoins( - ctx, k.AuthKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin), - ); err != nil { - // NOTE: should not happen as the module account was - // retrieved on the step above and it has enough balance - // to burn. - panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %v", err)) - } - } else { - // obtain the escrow address for the source channel end - escrowAddress := types.GetEscrowAddress(payload.SourcePort, sourceChannel) - if err := k.EscrowCoin(ctx, sender, escrowAddress, coin); err != nil { - return err - } - } - } - - // TODO: events - // events.EmitTransferEvent(ctx, sender.String(), receiver, tokens, memo, hops) - - // TODO: telemetry - // telemetry.ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChannel, tokens) - - return nil -} - -func (k *Keeper) OnRecvPacket(ctx context.Context, sourceChannel, destChannel string, payload channeltypesv2.Payload, data types.FungibleTokenPacketDataV2) error { - // validate packet data upon receiving - if err := data.ValidateBasic(); err != nil { - return errorsmod.Wrapf(err, "error validating ICS-20 transfer packet data") - } - - if !k.GetParams(ctx).ReceiveEnabled { - return types.ErrReceiveDisabled - } - - receiver, err := sdk.AccAddressFromBech32(data.Receiver) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "failed to decode receiver address %s: %v", data.Receiver, err) - } - - if k.IsBlockedAddr(receiver) { - return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", receiver) - } - - receivedCoins := make(sdk.Coins, 0, len(data.Tokens)) - for _, token := range data.Tokens { - // parse the transfer amount - transferAmount, ok := sdkmath.NewIntFromString(token.Amount) - if !ok { - return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount: %s", token.Amount) - } - - // This is the prefix that would have been prefixed to the denomination - // on sender chain IF and only if the token originally came from the - // receiving chain. - // - // NOTE: We use SourcePort and SourceChannel here, because the counterparty - // chain would have prefixed with DestPort and DestChannel when originally - // receiving this token. - if token.Denom.HasPrefix(payload.SourcePort, sourceChannel) { - // sender chain is not the source, unescrow tokens - - // remove prefix added by sender chain - token.Denom.Trace = token.Denom.Trace[1:] - - coin := sdk.NewCoin(token.Denom.IBCDenom(), transferAmount) - - escrowAddress := types.GetEscrowAddress(payload.DestinationPort, destChannel) - if err := k.UnescrowCoin(ctx, escrowAddress, receiver, coin); err != nil { - return err - } - - // Appending token. The new denom has been computed - receivedCoins = append(receivedCoins, coin) - } else { - // sender chain is the source, mint vouchers - - // since SendPacket did not prefix the denomination, we must add the destination port and channel to the trace - trace := []types.Hop{types.NewHop(payload.DestinationPort, destChannel)} - token.Denom.Trace = append(trace, token.Denom.Trace...) - - if !k.HasDenom(ctx, token.Denom.Hash()) { - k.SetDenom(ctx, token.Denom) - } - - voucherDenom := token.Denom.IBCDenom() - if !k.BankKeeper.HasDenomMetaData(ctx, voucherDenom) { - k.SetDenomMetadata(ctx, token.Denom) - } - - if err := k.EmitDenomEvent(ctx, token); err != nil { - return err - } - - voucher := sdk.NewCoin(voucherDenom, transferAmount) - - // mint new tokens if the source of the transfer is the same chain - if err := k.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins(voucher), - ); err != nil { - return errorsmod.Wrap(err, "failed to mint IBC tokens") - } - - // send to receiver - moduleAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) - if err := k.BankKeeper.SendCoins( - ctx, moduleAddr, receiver, sdk.NewCoins(voucher), - ); err != nil { - return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String()) - } - - receivedCoins = append(receivedCoins, voucher) - } - } - - _ = receivedCoins // TODO: remove this line when forwarding is implemented - // TODO: forwarding - // if data.HasForwarding() { - // // we are now sending from the forward escrow address to the final receiver address. - // TODO: inside this version of the function, we should fetch the packet that was stored in IBC core in order to set it for forwarding. - // if err := k.forwardPacket(ctx, data, packet, receivedCoins); err != nil { - // return err - // } - // } - - // TODO: telemetry - // telemetry.ReportOnRecvPacket(packet, data.Tokens) - - // The ibc_module.go module will return the proper ack. - return nil -} - -func (k *Keeper) OnAcknowledgementPacket(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement) error { - switch ack.Response.(type) { - case *channeltypes.Acknowledgement_Result: - // the acknowledgement succeeded on the receiving chain so nothing - // needs to be executed and no error needs to be returned - return nil - case *channeltypes.Acknowledgement_Error: - // We refund the tokens from the escrow address to the sender - return k.refundPacketTokens(ctx, sourcePort, sourceChannel, data) - default: - return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected one of [%T, %T], got %T", channeltypes.Acknowledgement_Result{}, channeltypes.Acknowledgement_Error{}, ack.Response) - } -} - -func (k *Keeper) OnTimeoutPacket(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2) error { - return k.refundPacketTokens(ctx, sourcePort, sourceChannel, data) -} - -func (k Keeper) refundPacketTokens(ctx context.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketDataV2) error { - // NOTE: packet data type already checked in handler.go - - sender, err := sdk.AccAddressFromBech32(data.Sender) - if err != nil { - return err - } - if k.IsBlockedAddr(sender) { - return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to receive funds", sender) - } - - // escrow address for unescrowing tokens back to sender - escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) - - moduleAccountAddr := k.AuthKeeper.GetModuleAddress(types.ModuleName) - for _, token := range data.Tokens { - coin, err := token.ToCoin() - if err != nil { - return err - } - - // if the token we must refund is prefixed by the source port and channel - // then the tokens were burnt when the packet was sent and we must mint new tokens - if token.Denom.HasPrefix(sourcePort, sourceChannel) { - // mint vouchers back to sender - if err := k.BankKeeper.MintCoins( - ctx, types.ModuleName, sdk.NewCoins(coin), - ); err != nil { - return err - } - - if err := k.BankKeeper.SendCoins(ctx, moduleAccountAddr, sender, sdk.NewCoins(coin)); err != nil { - panic(fmt.Errorf("unable to send coins from module to account despite previously minting coins to module account: %v", err)) - } - } else { - if err := k.UnescrowCoin(ctx, escrowAddress, sender, coin); err != nil { - return err - } - } - } - - return nil -} diff --git a/modules/apps/transfer/v2/keeper/keeper_test.go b/modules/apps/transfer/v2/keeper/keeper_test.go deleted file mode 100644 index 69836b14120..00000000000 --- a/modules/apps/transfer/v2/keeper/keeper_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - testifysuite "github.com/stretchr/testify/suite" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - ibctesting "github.com/cosmos/ibc-go/v9/testing" -) - -type KeeperTestSuite struct { - testifysuite.Suite - - coordinator *ibctesting.Coordinator - - // testing chains used for convenience and readability - chainA *ibctesting.TestChain - chainB *ibctesting.TestChain - chainC *ibctesting.TestChain -} - -func (suite *KeeperTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) -} - -type amountType int - -const ( - escrow amountType = iota - balance -) - -func (suite *KeeperTestSuite) assertAmountOnChain(chain *ibctesting.TestChain, balanceType amountType, amount sdkmath.Int, denom string) { - var total sdk.Coin - switch balanceType { - case escrow: - total = chain.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(chain.GetContext(), denom) - totalV2 := chain.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(chain.GetContext(), denom) - suite.Require().Equal(total, totalV2, "escrow balance mismatch") - case balance: - total = chain.GetSimApp().BankKeeper.GetBalance(chain.GetContext(), chain.SenderAccounts[0].SenderAccount.GetAddress(), denom) - default: - suite.Fail("invalid amountType %s", balanceType) - } - suite.Require().Equal(amount, total.Amount, fmt.Sprintf("Chain %s: got balance of %s, wanted %s", chain.Name(), total.Amount.String(), amount.String())) -} - -func TestKeeperTestSuite(t *testing.T) { - testifysuite.Run(t, new(KeeperTestSuite)) -} diff --git a/modules/apps/transfer/v2/keeper/msg_server_test.go b/modules/apps/transfer/v2/keeper/msg_server_test.go deleted file mode 100644 index b4ab8e61016..00000000000 --- a/modules/apps/transfer/v2/keeper/msg_server_test.go +++ /dev/null @@ -1,750 +0,0 @@ -package keeper_test - -import ( - "bytes" - "encoding/json" - "time" - - "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - ibctesting "github.com/cosmos/ibc-go/v9/testing" - mockv2 "github.com/cosmos/ibc-go/v9/testing/mock/v2" -) - -// TestMsgSendPacketTransfer tests the MsgSendPacket rpc handler for the transfer v2 application. -func (suite *KeeperTestSuite) TestMsgSendPacketTransfer() { - var ( - payload channeltypesv2.Payload - path *ibctesting.Path - expEscrowAmounts []transfertypes.Token // total amounts in escrow for each token - sender ibctesting.SenderAccount - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success: v2 payload", - func() {}, - nil, - }, - { - "success: v1 payload", - func() { - ftpd := transfertypes.NewFungibleTokenPacketData(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount.String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "") - bz, err := json.Marshal(ftpd) - suite.Require().NoError(err) - payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingJSON, bz) - }, - nil, - }, - { - "success: v1 ABI encoded payload", - func() { - bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ - Denom: sdk.DefaultBondDenom, - Amount: ibctesting.DefaultCoinAmount.BigInt(), - Sender: suite.chainA.SenderAccount.GetAddress().String(), - Receiver: suite.chainB.SenderAccount.GetAddress().String(), - Memo: "", - }) - suite.Require().NoError(err) - payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) - }, - nil, - }, - // TODO: Update - // { - // "successful transfer of entire spendable balance with vesting account", - // func() { - // // create vesting account - // vestingAccPrivKey := secp256k1.GenPrivKey() - // vestingAccAddress := sdk.AccAddress(vestingAccPrivKey.PubKey().Address()) - // - // vestingCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount)) - // _, err := suite.chainA.SendMsgs(vestingtypes.NewMsgCreateVestingAccount( - // suite.chainA.SenderAccount.GetAddress(), - // vestingAccAddress, - // vestingCoins, - // suite.chainA.GetContext().BlockTime().Add(time.Hour).Unix(), - // false, - // )) - // suite.Require().NoError(err) - // - // // transfer some spendable coins to vesting account - // spendableAmount := sdkmath.NewInt(42) - // transferCoins := sdk.NewCoins(sdk.NewCoin(vestingCoins[0].Denom, spendableAmount)) - // _, err = suite.chainA.SendMsgs(banktypes.NewMsgSend(suite.chainA.SenderAccount.GetAddress(), vestingAccAddress, transferCoins)) - // suite.Require().NoError(err) - // - // // just to prove that the vesting account has a balance (but only spendableAmount is spendable) - // vestingAccBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), vestingAccAddress, vestingCoins[0].Denom) - // suite.Require().Equal(vestingCoins[0].Amount.Uint64()+spendableAmount.Uint64(), vestingAccBalance.Amount.Uint64()) - // vestinSpendableBalance := suite.chainA.GetSimApp().BankKeeper.SpendableCoins(suite.chainA.GetContext(), vestingAccAddress) - // suite.Require().Equal(spendableAmount.Uint64(), vestinSpendableBalance.AmountOf(vestingCoins[0].Denom).Uint64()) - // - // bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ - // Denom: sdk.DefaultBondDenom, - // Amount: transfertypes.UnboundedSpendLimit().BigInt(), - // Sender: vestingAccAddress.String(), - // Receiver: suite.chainB.SenderAccount.GetAddress().String(), - // Memo: "", - // }) - // suite.Require().NoError(err) - // payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) - // - // sender = suite.chainA.GetSenderAccount(vestingAccPrivKey) - // - // expEscrowAmounts = []transfertypes.Token{ - // { - // Denom: transfertypes.NewDenom(sdk.DefaultBondDenom), - // Amount: spendableAmount.String(), // The only spendable amount - // }, - // } - // }, - // nil, - // }, - // { - // "failure: no spendable coins for vesting account", - // func() { - // // create vesting account - // vestingAccPrivKey := secp256k1.GenPrivKey() - // vestingAccAddress := sdk.AccAddress(vestingAccPrivKey.PubKey().Address()) - // - // vestingCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount)) - // _, err := suite.chainA.SendMsgs(vestingtypes.NewMsgCreateVestingAccount( - // suite.chainA.SenderAccount.GetAddress(), - // vestingAccAddress, - // vestingCoins, - // suite.chainA.GetContext().BlockTime().Add(time.Hour).Unix(), - // false, - // )) - // suite.Require().NoError(err) - // - // // just to prove that the vesting account has a balance (but not spendable) - // vestingAccBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), vestingAccAddress, vestingCoins[0].Denom) - // suite.Require().Equal(vestingCoins[0].Amount.Uint64(), vestingAccBalance.Amount.Uint64()) - // vestinSpendableBalance := suite.chainA.GetSimApp().BankKeeper.SpendableCoins(suite.chainA.GetContext(), vestingAccAddress) - // suite.Require().Zero(vestinSpendableBalance.AmountOf(vestingCoins[0].Denom).Uint64()) - // - // // try to transfer the entire spendable balance (which is zero) - // bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ - // Denom: sdk.DefaultBondDenom, - // Amount: transfertypes.UnboundedSpendLimit().BigInt(), - // Sender: vestingAccAddress.String(), - // Receiver: suite.chainB.SenderAccount.GetAddress().String(), - // Memo: "", - // }) - // suite.Require().NoError(err) - // payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) - // - // sender = suite.chainA.GetSenderAccount(vestingAccPrivKey) - // }, - // transfertypes.ErrInvalidAmount, - // }, - { - "failure: send transfers disabled", - func() { - suite.chainA.GetSimApp().TransferKeeperV2.SetParams(suite.chainA.GetContext(), - transfertypes.Params{ - SendEnabled: false, - }, - ) - }, - transfertypes.ErrSendDisabled, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - tokens := []transfertypes.Token{ - { - Denom: transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: nil, - }, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - expEscrowAmounts = tokens - sender = suite.chainA.SenderAccounts[0] - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainA.Codec.MustMarshal(&ftpd) - - timestamp := suite.chainA.GetTimeoutTimestampSecs() - payload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - - tc.malleate() - packet, err := path.EndpointA.MsgSendPacketWithSender(timestamp, payload, sender) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().NotEmpty(packet) - - // ensure every token sent is escrowed. - for i, t := range tokens { - escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - expected, err := expEscrowAmounts[i].ToCoin() - suite.Require().NoError(err) - suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") - } - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) - suite.Require().Empty(packet) - } - }) - } -} - -// TestMsgRecvPacketTransfer tests the MsgRecvPacket rpc handler for the transfer v2 application. -func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() { - var ( - path *ibctesting.Path - packet channeltypesv2.Packet - expectedAck channeltypesv2.Acknowledgement - sendPayload channeltypesv2.Payload - ) - - testCases := []struct { - name string - malleateSend func() - malleate func() - expError error - }{ - { - "success: v2 payload", - func() {}, - func() {}, - nil, - }, - { - "success: v1 payload", - func() { - ftpd := transfertypes.NewFungibleTokenPacketData(sdk.DefaultBondDenom, ibctesting.DefaultCoinAmount.String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "") - bz, err := json.Marshal(ftpd) - suite.Require().NoError(err) - sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingJSON, bz) - }, - func() {}, - nil, - }, - { - "success: v1 ABI encoded payload", - func() { - bz, err := ics20lib.EncodeFungibleTokenPacketData(ics20lib.ICS20LibFungibleTokenPacketData{ - Denom: sdk.DefaultBondDenom, - Amount: ibctesting.DefaultCoinAmount.BigInt(), - Sender: suite.chainA.SenderAccount.GetAddress().String(), - Receiver: suite.chainB.SenderAccount.GetAddress().String(), - Memo: "", - }) - suite.Require().NoError(err) - sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V1, transfertypes.EncodingABI, bz) - }, - func() {}, - nil, - }, - { - "failure: invalid destination client on received packet", - func() {}, - func() { - packet.DestinationClient = ibctesting.InvalidID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "failure: counter party client does not match source client", - func() {}, - func() { - packet.SourceClient = ibctesting.InvalidID - }, - clienttypes.ErrInvalidCounterparty, - }, - { - "failure: receive is disabled", - func() {}, - func() { - expectedAck.AppAcknowledgements[0] = channeltypes.NewErrorAcknowledgement(transfertypes.ErrReceiveDisabled).Acknowledgement() - suite.chainB.GetSimApp().TransferKeeperV2.SetParams(suite.chainB.GetContext(), - transfertypes.Params{ - ReceiveEnabled: false, - }) - }, - nil, - }, - // TODO: async tests - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - tokens := []transfertypes.Token{ - { - Denom: transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: nil, - }, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainA.Codec.MustMarshal(&ftpd) - - timestamp := suite.chainA.GetTimeoutTimestampSecs() - sendPayload = channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - tc.malleateSend() - var err error - packet, err = path.EndpointA.MsgSendPacket(timestamp, sendPayload) - suite.Require().NoError(err) - - // by default, we assume a successful acknowledgement will be written. - ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() - expectedAck = channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} - tc.malleate() - - err = path.EndpointB.MsgRecvPacket(packet) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - actualAckHash := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeperV2.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) - expectedHash := channeltypesv2.CommitAcknowledgement(expectedAck) - - suite.Require().Equal(expectedHash, actualAckHash) - - denom := transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: []transfertypes.Hop{ - transfertypes.NewHop(sendPayload.DestinationPort, packet.DestinationClient), - }, - } - - actualBalance := path.EndpointB.Chain.GetSimApp().BankKeeper.GetBalance(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), denom.IBCDenom()) - - var expectedBalance sdk.Coin - // on a successful ack we expect the full amount to be transferred - if bytes.Equal(expectedAck.AppAcknowledgements[0], ackBytes) { - expectedBalance = sdk.NewCoin(denom.IBCDenom(), ibctesting.DefaultCoinAmount) - } else { - // otherwise the tokens do not make it to the address. - expectedBalance = sdk.NewCoin(denom.IBCDenom(), sdkmath.NewInt(0)) - } - - suite.Require().Equal(expectedBalance.Amount, actualBalance.Amount) - - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) - } - }) - } -} - -// TestMsgAckPacketTransfer tests the MsgAcknowledgePacket rpc handler for the transfer v2 application. -func (suite *KeeperTestSuite) TestMsgAckPacketTransfer() { - var ( - path *ibctesting.Path - packet channeltypesv2.Packet - expectedAck channeltypesv2.Acknowledgement - ) - - testCases := []struct { - name string - malleate func() - expError error - causeFailureOnRecv bool - }{ - { - "success", - func() {}, - nil, - false, - }, - { - "failure: proof verification failure", - func() { - expectedAck.AppAcknowledgements[0] = mockv2.MockFailRecvPacketResult.Acknowledgement - }, - commitmenttypes.ErrInvalidProof, - false, - }, - { - "failure: escrowed tokens are refunded", - func() { - expectedAck.AppAcknowledgements[0] = channeltypes.NewErrorAcknowledgement(transfertypes.ErrReceiveDisabled).Acknowledgement() - }, - nil, - true, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - tokens := []transfertypes.Token{ - { - Denom: transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: nil, - }, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainA.Codec.MustMarshal(&ftpd) - - timestamp := suite.chainA.GetTimeoutTimestampSecs() - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - - var err error - packet, err = path.EndpointA.MsgSendPacket(timestamp, payload) - suite.Require().NoError(err) - - if tc.causeFailureOnRecv { - // ensure that the recv packet fails at the application level, but succeeds at the IBC handler level - // this will ensure that a failed ack will be written to state. - suite.chainB.GetSimApp().TransferKeeperV2.SetParams(suite.chainB.GetContext(), - transfertypes.Params{ - ReceiveEnabled: false, - }) - } - - err = path.EndpointB.MsgRecvPacket(packet) - suite.Require().NoError(err) - - ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() - expectedAck = channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} - tc.malleate() - - err = path.EndpointA.MsgAcknowledgePacket(packet, expectedAck) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - if bytes.Equal(expectedAck.AppAcknowledgements[0], ackBytes) { - // tokens remain escrowed - for _, t := range tokens { - escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - expected, err := t.ToCoin() - suite.Require().NoError(err) - suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") - } - } else { - // tokens have been unescrowed - for _, t := range tokens { - escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - suite.Require().Equal(sdk.NewCoin(t.Denom.IBCDenom(), sdkmath.NewInt(0)), escrowedAmount, "escrowed amount is not equal to expected amount") - } - } - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) - } - }) - } -} - -// TestMsgTimeoutPacketTransfer tests the MsgTimeoutPacket rpc handler for the transfer v2 application. -func (suite *KeeperTestSuite) TestMsgTimeoutPacketTransfer() { - var ( - path *ibctesting.Path - packet channeltypesv2.Packet - timeoutTimestamp uint64 - ) - - testCases := []struct { - name string - malleate func() - timeoutPacket bool - expError error - }{ - { - "success", - func() {}, - true, - nil, - }, - { - "failure: packet has not timed out", - func() {}, - false, - channeltypes.ErrTimeoutNotReached, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - tokens := []transfertypes.Token{ - { - Denom: transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: nil, - }, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainA.Codec.MustMarshal(&ftpd) - - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - - var err error - packet, err = path.EndpointA.MsgSendPacket(timeoutTimestamp, payload) - suite.Require().NoError(err) - - if tc.timeoutPacket { - suite.coordinator.IncrementTimeBy(time.Hour * 2) - } - - // ensure that chainA has an update to date client of chain B. - suite.Require().NoError(path.EndpointA.UpdateClient()) - - tc.malleate() - - err = path.EndpointA.MsgTimeoutPacket(packet) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - // ensure funds are un-escrowed - for _, t := range tokens { - escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - suite.Require().Equal(sdk.NewCoin(t.Denom.IBCDenom(), sdkmath.NewInt(0)), escrowedAmount, "escrowed amount is not equal to expected amount") - } - - } else { - ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError, "expected error %q but got %q", tc.expError, err) - // tokens remain escrowed if there is a timeout failure - for _, t := range tokens { - escrowedAmount := suite.chainA.GetSimApp().TransferKeeperV2.GetTotalEscrowForDenom(suite.chainA.GetContext(), t.Denom.IBCDenom()) - expected, err := t.ToCoin() - suite.Require().NoError(err) - suite.Require().Equal(expected, escrowedAmount, "escrowed amount is not equal to expected amount") - } - } - }) - } -} - -func (suite *KeeperTestSuite) TestV2RetainsFungibility() { - suite.SetupTest() - - path := ibctesting.NewTransferPath(suite.chainA, suite.chainB) - path.Setup() - - pathv2 := ibctesting.NewPath(suite.chainB, suite.chainC) - pathv2.SetupV2() - - denomA := transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - } - - denomAtoB := transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: []transfertypes.Hop{ - transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), - }, - } - - denomBtoC := transfertypes.Denom{ - Base: sdk.DefaultBondDenom, - Trace: []transfertypes.Hop{ - transfertypes.NewHop(transfertypes.ModuleName, pathv2.EndpointB.ClientID), - transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), - }, - } - - ackBytes := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() - successfulAck := channeltypesv2.Acknowledgement{AppAcknowledgements: [][]byte{ackBytes}} - - originalAmount, ok := sdkmath.NewIntFromString(ibctesting.DefaultGenesisAccBalance) - suite.Require().True(ok) - - suite.Run("between A and B", func() { - var packet channeltypes.Packet - suite.Run("transfer packet", func() { - transferMsg := transfertypes.NewMsgTransfer( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - sdk.NewCoins(sdk.NewCoin(denomA.IBCDenom(), ibctesting.TestCoin.Amount)), - suite.chainA.SenderAccount.GetAddress().String(), - suite.chainB.SenderAccount.GetAddress().String(), - clienttypes.ZeroHeight(), - suite.chainA.GetTimeoutTimestamp(), - "memo", - nil, - ) - - result, err := suite.chainA.SendMsgs(transferMsg) - suite.Require().NoError(err) // message committed - - remainingAmount := originalAmount.Sub(ibctesting.DefaultCoinAmount) - suite.assertAmountOnChain(suite.chainA, balance, remainingAmount, denomA.IBCDenom()) - - packet, err = ibctesting.ParsePacketFromEvents(result.Events) - suite.Require().NoError(err) - }) - - suite.Run("recv and ack packet", func() { - err := path.RelayPacket(packet) - suite.Require().NoError(err) - }) - }) - - suite.Run("between B and C", func() { - var packetV2 channeltypesv2.Packet - - suite.Run("send packet", func() { - tokens := []transfertypes.Token{ - { - Denom: denomAtoB, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainB.Codec.MustMarshal(&ftpd) - - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - - var err error - packetV2, err = pathv2.EndpointA.MsgSendPacket(timeoutTimestamp, payload) - suite.Require().NoError(err) - // the escrow account on chain B should have escrowed the tokens after sending from B to C - suite.assertAmountOnChain(suite.chainB, escrow, ibctesting.DefaultCoinAmount, denomAtoB.IBCDenom()) - }) - - suite.Run("recv packet", func() { - err := pathv2.EndpointB.MsgRecvPacket(packetV2) - suite.Require().NoError(err) - - // the receiving chain should have received the tokens - suite.assertAmountOnChain(suite.chainC, balance, ibctesting.DefaultCoinAmount, denomBtoC.IBCDenom()) - }) - - suite.Run("ack packet", func() { - err := pathv2.EndpointA.MsgAcknowledgePacket(packetV2, successfulAck) - suite.Require().NoError(err) - }) - }) - - suite.Run("between C and B", func() { - var packetV2 channeltypesv2.Packet - - suite.Run("send packet", func() { - // send from C to B - tokens := []transfertypes.Token{ - { - Denom: denomBtoC, - Amount: ibctesting.DefaultCoinAmount.String(), - }, - } - - ftpd := transfertypes.NewFungibleTokenPacketDataV2(tokens, suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", transfertypes.ForwardingPacketData{}) - bz := suite.chainC.Codec.MustMarshal(&ftpd) - - timeoutTimestamp := uint64(suite.chainC.GetContext().BlockTime().Unix()) + uint64(time.Hour.Seconds()) - payload := channeltypesv2.NewPayload(transfertypes.ModuleName, transfertypes.ModuleName, transfertypes.V2, transfertypes.EncodingProtobuf, bz) - - var err error - packetV2, err = pathv2.EndpointB.MsgSendPacket(timeoutTimestamp, payload) - suite.Require().NoError(err) - - // tokens have been sent from chain C, and the balance is now empty. - suite.assertAmountOnChain(suite.chainC, balance, sdkmath.NewInt(0), denomBtoC.IBCDenom()) - }) - - suite.Run("recv packet", func() { - err := pathv2.EndpointA.MsgRecvPacket(packetV2) - suite.Require().NoError(err) - - // chain B should have received the tokens from chain C. - suite.assertAmountOnChain(suite.chainB, balance, ibctesting.DefaultCoinAmount, denomAtoB.IBCDenom()) - }) - - suite.Run("ack packet", func() { - err := pathv2.EndpointB.MsgAcknowledgePacket(packetV2, successfulAck) - suite.Require().NoError(err) - }) - }) - - suite.Run("between B and A", func() { - var packet channeltypes.Packet - - suite.Run("transfer packet", func() { - // send from B to A using MsgTransfer - transferMsg := transfertypes.NewMsgTransfer( - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - sdk.NewCoins(sdk.NewCoin(denomAtoB.IBCDenom(), ibctesting.TestCoin.Amount)), - suite.chainB.SenderAccount.GetAddress().String(), - suite.chainA.SenderAccount.GetAddress().String(), - clienttypes.ZeroHeight(), - suite.chainB.GetTimeoutTimestamp(), - "memo", - nil, - ) - - result, err := suite.chainB.SendMsgs(transferMsg) - suite.Require().NoError(err) // message committed - - suite.assertAmountOnChain(suite.chainB, balance, sdkmath.NewInt(0), denomAtoB.IBCDenom()) - - packet, err = ibctesting.ParsePacketFromEvents(result.Events) - suite.Require().NoError(err) - }) - suite.Run("recv and ack packet", func() { - // in order to recv in the other direction, we create a new path and recv - // on that with the endpoints reversed. - err := path.Reversed().RelayPacket(packet) - suite.Require().NoError(err) - - suite.assertAmountOnChain(suite.chainA, balance, originalAmount, denomA.IBCDenom()) - }) - }) -} diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index f6b7978d09f..59176605eae 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -131,7 +131,6 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" transferv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2" - ibctransferkeeperv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" ibc "github.com/cosmos/ibc-go/v9/modules/core" ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" @@ -210,7 +209,6 @@ type SimApp struct { ICAHostKeeper icahostkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper - TransferKeeperV2 *ibctransferkeeperv2.Keeper WasmClientKeeper wasmkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper @@ -692,8 +690,7 @@ func NewSimApp( ibcRouter.AddRoute(MockFeePort, feeWithMockModule) // register the transfer v2 module. - app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) - ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeperV2)) + ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeper)) // Seal the IBC Routers. app.IBCKeeper.SetRouter(ibcRouter) diff --git a/testing/endpoint.go b/testing/endpoint.go index 869f92a8ee8..7994df5b512 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -542,8 +542,8 @@ func (endpoint *Endpoint) AcknowledgePacketWithResult(packet channeltypes.Packet return endpoint.Chain.SendMsgs(ackMsg) } -// TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint. -func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { +// TimeoutPacketWithResult sends a MsgTimeout to the channel associated with the endpoint. +func (endpoint *Endpoint) TimeoutPacketWithResult(packet channeltypes.Packet) (*abci.ExecTxResult, error) { // get proof for timeout based on channel order var packetKey []byte @@ -553,7 +553,7 @@ func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { case channeltypes.UNORDERED: packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) default: - return fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) + return nil, fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) } counterparty := endpoint.Counterparty @@ -566,7 +566,13 @@ func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(), ) - return endpoint.Chain.sendMsgs(timeoutMsg) + return endpoint.Chain.SendMsgs(timeoutMsg) +} + +// TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint. +func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { + _, err := endpoint.TimeoutPacketWithResult(packet) + return err } // TimeoutOnClose sends a MsgTimeoutOnClose to the channel associated with the endpoint. diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 9b0a6f9e1e5..0f85e05e200 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -130,7 +130,6 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" transferv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2" - ibctransferkeeperv2 "github.com/cosmos/ibc-go/v9/modules/apps/transfer/v2/keeper" ibc "github.com/cosmos/ibc-go/v9/modules/core" ibcclienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" @@ -216,7 +215,6 @@ type SimApp struct { ICAControllerKeeper icacontrollerkeeper.Keeper ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper - TransferKeeperV2 *ibctransferkeeperv2.Keeper // make IBC modules public for test purposes // these modules are never directly routed to by the IBC Router @@ -655,8 +653,7 @@ func NewSimApp( app.MockModuleV2B = mockV2B // register the transfer v2 module. - app.TransferKeeperV2 = ibctransferkeeperv2.NewKeeper(app.TransferKeeper, app.IBCKeeper.ChannelKeeperV2) - ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeperV2)) + ibcRouterV2.AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeper)) // Seal the IBC Router app.IBCKeeper.SetRouter(ibcRouter) From ffdb9d06c8db6fbabbb730dcf2c2a7e579dd6f28 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:04:36 +0100 Subject: [PATCH 168/172] Simplify WriteAck API for async acks (#7869) * simplify writeack api * fix tests --- modules/core/04-channel/v2/keeper/keeper.go | 32 +++++++++++++++++ .../core/04-channel/v2/keeper/msg_server.go | 5 ++- modules/core/04-channel/v2/keeper/packet.go | 34 ++++++++++++++++--- .../core/04-channel/v2/keeper/packet_test.go | 16 ++++++++- modules/core/04-channel/v2/types/keys.go | 11 ++++++ 5 files changed, 92 insertions(+), 6 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index a63e644f83e..00076b6e903 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -162,3 +162,35 @@ func (k *Keeper) SetNextSequenceSend(ctx context.Context, clientID string, seque panic(err) } } + +// SetAsyncPacket writes the packet under the async path +func (k *Keeper) SetAsyncPacket(ctx context.Context, clientID string, sequence uint64, packet types.Packet) { + store := k.KVStoreService.OpenKVStore(ctx) + bz := k.cdc.MustMarshal(&packet) + if err := store.Set(types.AsyncPacketKey(clientID, sequence), bz); err != nil { + panic(err) + } +} + +// GetAsyncPacket fetches the packet from the async path +func (k *Keeper) GetAsyncPacket(ctx context.Context, clientID string, sequence uint64) (types.Packet, bool) { + store := k.KVStoreService.OpenKVStore(ctx) + bz, err := store.Get(types.AsyncPacketKey(clientID, sequence)) + if err != nil { + panic(err) + } + if len(bz) == 0 { + return types.Packet{}, false + } + var packet types.Packet + k.cdc.MustUnmarshal(bz, &packet) + return packet, true +} + +// DeleteAsyncPacket deletes the packet from the async path +func (k *Keeper) DeleteAsyncPacket(ctx context.Context, clientID string, sequence uint64) { + store := k.KVStoreService.OpenKVStore(ctx) + if err := store.Delete(types.AsyncPacketKey(clientID, sequence)); err != nil { + panic(err) + } +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index aaadfc8fc80..070072942e5 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -135,9 +135,12 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *types.MsgRecvPacket) (*typ // Set packet acknowledgement only if the acknowledgement is not async. // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the // acknowledgement is async. - if err := k.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { + if err := k.writeAcknowledgement(ctx, msg.Packet, ack); err != nil { return nil, err } + } else { + // store the packet temporarily until the application returns an acknowledgement + k.SetAsyncPacket(ctx, msg.Packet.DestinationClient, msg.Packet.Sequence, msg.Packet) } // TODO: store the packet for async applications to access if required. diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index f760f3fe5b5..3dbc0b67ef5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -146,9 +146,9 @@ func (k *Keeper) recvPacket( return nil } -// WriteAcknowledgement writes the acknowledgement to the store. -// TODO: change this function to accept destPort, destChannel, sequence, ack -func (k Keeper) WriteAcknowledgement( +// writeAcknowledgement writes the acknowledgement to the store and emits the packet and acknowledgement +// for relayers to relay the acknowledgement to the counterparty chain. +func (k Keeper) writeAcknowledgement( ctx context.Context, packet types.Packet, ack types.Acknowledgement, @@ -184,7 +184,33 @@ func (k Keeper) WriteAcknowledgement( emitWriteAcknowledgementEvents(ctx, packet, ack) - // TODO: delete the packet that has been stored in ibc-core. + return nil +} + +// WriteAcknowledgement writes the acknowledgement and emits events for asynchronous acknowledgements +// this is the method to be called by external apps when they want to write an acknowledgement asyncrhonously +func (k *Keeper) WriteAcknowledgement(ctx context.Context, clientID string, sequence uint64, ack types.Acknowledgement) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Validate the acknowledgement + if err := ack.Validate(); err != nil { + sdkCtx.Logger().Error("write acknowledgement failed", "error", errorsmod.Wrap(err, "invalid acknowledgement")) + return errorsmod.Wrap(err, "invalid acknowledgement") + } + + packet, ok := k.GetAsyncPacket(ctx, clientID, sequence) + if !ok { + return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, "packet with clientID (%s) and sequence (%d) not found for async acknowledgement", clientID, sequence) + } + + // Write the acknowledgement to the store + if err := k.writeAcknowledgement(ctx, packet, ack); err != nil { + sdkCtx.Logger().Error("write acknowledgement failed", "error", errorsmod.Wrap(err, "write acknowledgement failed")) + return errorsmod.Wrap(err, "write acknowledgement failed") + } + + // Delete the packet from the async store + k.DeleteAsyncPacket(ctx, clientID, sequence) return nil } diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index 4c988d2ee69..094cc1b85e1 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -253,6 +253,8 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { "failure: client not found", func() { packet.DestinationClient = ibctesting.InvalidID + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetAsyncPacket(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, packet) }, clienttypes.ErrCounterpartyNotFound, }, @@ -260,6 +262,8 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { "failure: counterparty client identifier different than source client", func() { packet.SourceClient = unusedChannel + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetAsyncPacket(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, packet) }, clienttypes.ErrInvalidCounterparty, }, @@ -275,9 +279,17 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { "failure: receipt not found for packet", func() { packet.Sequence = 2 + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetAsyncPacket(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, packet) }, types.ErrInvalidPacket, }, + { + "failure: async packet not found", + func() { + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.DeleteAsyncPacket(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) + }, + types.ErrInvalidAcknowledgement, + }, } for _, tc := range testCases { @@ -301,11 +313,13 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { AppAcknowledgements: [][]byte{mockv2.MockRecvPacketResult.Acknowledgement}, } + // mock receive with async acknowledgement suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence) + suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetAsyncPacket(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, packet) tc.malleate() - err := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.WriteAcknowledgement(suite.chainB.GetContext(), packet, ack) + err := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.WriteAcknowledgement(suite.chainB.GetContext(), packet.DestinationClient, packet.Sequence, ack) expPass := tc.expError == nil if expPass { diff --git a/modules/core/04-channel/v2/types/keys.go b/modules/core/04-channel/v2/types/keys.go index 98c8e520b46..68a55d0e073 100644 --- a/modules/core/04-channel/v2/types/keys.go +++ b/modules/core/04-channel/v2/types/keys.go @@ -1,6 +1,17 @@ package types +import "fmt" + const ( // SubModuleName defines the channelv2 module name. SubModuleName = "channelv2" + + // KeyAsyncPacket defines the key to store the async packet. + KeyAsyncPacket = "async_packet" ) + +// AsyncPacketKey returns the key under which the packet is stored +// if the receiving application returns an async acknowledgement. +func AsyncPacketKey(clientID string, sequence uint64) []byte { + return []byte(fmt.Sprintf("%s/%s/%d", KeyAsyncPacket, clientID, sequence)) +} From 016a98ee65ed9e58add53325c12d3664e820db1c Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 24 Jan 2025 04:40:02 +0100 Subject: [PATCH 169/172] fix: send entire balance not working as expected (#7871) --- e2e/tests/transfer/base_test.go | 3 +- modules/apps/transfer/keeper/msg_server.go | 8 +++ modules/apps/transfer/keeper/relay.go | 8 --- modules/apps/transfer/transfer_test.go | 60 ++++++++++++++++------ 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index 0fbe809f160..0f69bcc52ee 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -592,7 +592,6 @@ func (s *TransferTestSuite) TestMsgTransfer_EntireBalance() { }) chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) - t.Run("packets relayed", func(t *testing.T) { s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom()) @@ -619,7 +618,7 @@ func (s *TransferTestSuite) TestMsgTransfer_EntireBalance() { chainAIBCToken := testsuite.GetIBCToken(chainB.Config().Denom, channelA.PortID, channelA.ChannelID) t.Run("packets relayed", func(t *testing.T) { // test that chainA has the entire balance back of its native token. - s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) + s.AssertPacketRelayed(ctx, chainB, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) actualBalance, err := query.Balance(ctx, chainA, chainAAddress, chainADenom) s.Require().NoError(err) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 034c2c078e0..ef62397da53 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -61,6 +61,14 @@ func (k Keeper) Transfer(ctx context.Context, msg *types.MsgTransfer) (*types.Ms tokens := make([]types.Token, len(coins)) for i, coin := range coins { + // Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom. + if coin.Amount.Equal(types.UnboundedSpendLimit()) { + coin.Amount = k.BankKeeper.SpendableCoin(ctx, sender, coin.Denom).Amount + if coin.Amount.IsZero() { + return nil, errorsmod.Wrapf(types.ErrInvalidAmount, "empty spendable balance for %s", coin.Denom) + } + } + tokens[i], err = k.tokenFromCoin(ctx, coin) if err != nil { return nil, err diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 5d90f112792..138391e269a 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -73,14 +73,6 @@ func (k Keeper) SendTransfer( return errorsmod.Wrap(types.ErrSendDisabled, err.Error()) } - // Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom. - if coin.Amount.Equal(types.UnboundedSpendLimit()) { - coin.Amount = k.BankKeeper.SpendableCoin(ctx, sender, coin.Denom).Amount - if coin.Amount.IsZero() { - return errorsmod.Wrapf(types.ErrInvalidAmount, "empty spendable balance for %s", coin.Denom) - } - } - // NOTE: SendTransfer simply sends the denomination as it exists on its own // chain inside the packet data. The receiving chain will perform denom // prefixing as necessary. diff --git a/modules/apps/transfer/transfer_test.go b/modules/apps/transfer/transfer_test.go index aa7f5954c90..cd8e78d47d4 100644 --- a/modules/apps/transfer/transfer_test.go +++ b/modules/apps/transfer/transfer_test.go @@ -37,17 +37,38 @@ func (suite *TransferTestSuite) SetupTest() { // 2 - from chainB to chainC // 3 - from chainC to chainB func (suite *TransferTestSuite) TestHandleMsgTransfer() { - testCases := []struct { - name string + var ( sourceDenomsToTransfer []string + msgAmount sdkmath.Int + ) + + testCases := []struct { + name string + malleate func() }{ { "transfer single denom", - []string{sdk.DefaultBondDenom}, + func() {}, + }, + { + "transfer amount larger than int64", + func() { + var ok bool + msgAmount, ok = sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + suite.Require().True(ok) + }, }, { "transfer multiple denoms", - []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom}, + func() { + sourceDenomsToTransfer = []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom} + }, + }, + { + "transfer entire balance", + func() { + msgAmount = types.UnboundedSpendLimit() + }, }, } @@ -63,19 +84,22 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { pathAToB.Setup() traceAToB := types.NewHop(pathAToB.EndpointB.ChannelConfig.PortID, pathAToB.EndpointB.ChannelID) + sourceDenomsToTransfer = []string{sdk.DefaultBondDenom} + msgAmount = ibctesting.DefaultCoinAmount + + tc.malleate() + originalBalances := sdk.NewCoins() - for _, denom := range tc.sourceDenomsToTransfer { + for _, denom := range sourceDenomsToTransfer { originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom) originalBalances = originalBalances.Add(originalBalance) } timeoutHeight := clienttypes.NewHeight(1, 110) - amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) - suite.Require().True(ok) originalCoins := sdk.NewCoins() - for _, denom := range tc.sourceDenomsToTransfer { - coinToSendToB := sdk.NewCoin(denom, amount) + for _, denom := range sourceDenomsToTransfer { + coinToSendToB := sdk.NewCoin(denom, msgAmount) originalCoins = originalCoins.Add(coinToSendToB) } @@ -87,6 +111,12 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { packet, err := ibctesting.ParsePacketFromEvents(res.Events) suite.Require().NoError(err) + // Get the packet data to determine the amount of tokens being transferred (needed for sending entire balance) + packetData, err := types.UnmarshalPacketData(packet.GetData(), pathAToB.EndpointA.GetChannel().Version, "") + suite.Require().NoError(err) + transferAmount, ok := sdkmath.NewIntFromString(packetData.Tokens[0].Amount) + suite.Require().True(ok) + // relay send err = pathAToB.RelayPacket(packet) suite.Require().NoError(err) // relay committed @@ -96,16 +126,16 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { for _, coin := range originalCoins { // check that the balance for chainA is updated chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) - suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + suite.Require().True(originalBalances.AmountOf(coin.Denom).Sub(transferAmount).Equal(chainABalance.Amount)) // check that module account escrow address has locked the tokens chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) - suite.Require().Equal(coin, chainAEscrowBalance) + suite.Require().True(transferAmount.Equal(chainAEscrowBalance.Amount)) // check that voucher exists on chain B chainBDenom := types.NewDenom(coin.Denom, traceAToB) chainBBalance := suite.chainB.GetSimApp().BankKeeper.GetBalance(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), chainBDenom.IBCDenom()) - coinSentFromAToB := sdk.NewCoin(chainBDenom.IBCDenom(), amount) + coinSentFromAToB := sdk.NewCoin(chainBDenom.IBCDenom(), transferAmount) suite.Require().Equal(coinSentFromAToB, chainBBalance) coinsSentFromAToB = coinsSentFromAToB.Add(coinSentFromAToB) @@ -137,7 +167,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { chainCDenom := types.NewDenom(coin.Denom, traceBToC, traceAToB) // check that the balance is updated on chainC - coinSentFromBToC := sdk.NewCoin(chainCDenom.IBCDenom(), amount) + coinSentFromBToC := sdk.NewCoin(chainCDenom.IBCDenom(), transferAmount) chainCBalance := suite.chainC.GetSimApp().BankKeeper.GetBalance(suite.chainC.GetContext(), suite.chainC.SenderAccount.GetAddress(), coinSentFromBToC.Denom) suite.Require().Equal(coinSentFromBToC, chainCBalance) @@ -182,12 +212,12 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { for _, coin := range originalCoins { // check that the balance is unchanged chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) - suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + suite.Require().True(originalBalances.AmountOf(coin.Denom).Sub(transferAmount).Equal(chainABalance.Amount)) // check that module account escrow address is unchanged escrowAddress = types.GetEscrowAddress(pathAToB.EndpointA.ChannelConfig.PortID, pathAToB.EndpointA.ChannelID) chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) - suite.Require().Equal(coin, chainAEscrowBalance) + suite.Require().True(transferAmount.Equal(chainAEscrowBalance.Amount)) } }) } From d7d25e65988f52aa407de137c96fff1f137ff0fd Mon Sep 17 00:00:00 2001 From: srdtrk <59252793+srdtrk@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:25:59 +0800 Subject: [PATCH 170/172] imp: updated events to remove channels (#7874) * imp: updated channel v2 events * fix: removed event --- modules/core/04-channel/v2/keeper/events.go | 20 ++++++------- modules/core/04-channel/v2/types/events.go | 31 +++++++++------------ testing/events.go | 3 +- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 33b3f3bc275..5db1229fc14 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -24,8 +24,8 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSendPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), + sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -49,8 +49,8 @@ func emitRecvPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), + sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -79,8 +79,8 @@ func emitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeWriteAck, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), + sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -105,8 +105,8 @@ func emitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcknowledgePacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), + sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), @@ -130,8 +130,8 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient), + sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient), + sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)), sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)), diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 1ef33d80491..d1d42fdc73a 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -6,28 +6,23 @@ import ( ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// IBC channel events +// IBC Eureka core events const ( - EventTypeCreateChannel = "create_channel" - EventTypeRegisterCounterparty = "register_counterparty" - EventTypeSendPacket = "send_packet" - EventTypeRecvPacket = "recv_packet" - EventTypeTimeoutPacket = "timeout_packet" - EventTypeAcknowledgePacket = "acknowledge_packet" - EventTypeWriteAck = "write_acknowledgement" + EventTypeSendPacket = "send_packet" + EventTypeRecvPacket = "recv_packet" + EventTypeTimeoutPacket = "timeout_packet" + EventTypeAcknowledgePacket = "acknowledge_packet" + EventTypeWriteAck = "write_acknowledgement" - AttributeKeyChannelID = "channel_id" - AttributeKeyClientID = "client_id" - AttributeKeyCounterpartyChannelID = "counterparty_channel_id" - AttributeKeySrcChannel = "packet_source_channel" - AttributeKeyDstChannel = "packet_dest_channel" - AttributeKeySequence = "packet_sequence" - AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" - AttributeKeyEncodedPacketHex = "encoded_packet_hex" - AttributeKeyEncodedAckHex = "encoded_acknowledgement_hex" + AttributeKeySrcClient = "packet_source_client" + AttributeKeyDstClient = "packet_dest_client" + AttributeKeySequence = "packet_sequence" + AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" + AttributeKeyEncodedPacketHex = "encoded_packet_hex" + AttributeKeyEncodedAckHex = "encoded_acknowledgement_hex" ) -// IBC channel events vars +// IBC Eureka core events vars var ( AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) ) diff --git a/testing/events.go b/testing/events.go index 22f52ffebd2..56426bb34e2 100644 --- a/testing/events.go +++ b/testing/events.go @@ -14,7 +14,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) // ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the @@ -48,7 +47,7 @@ func ParseConnectionIDFromEvents(events []abci.Event) (string, error) { // MsgChannelOpenTry or a MsgCreateChannel and returns the channel identifier. func ParseChannelIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { - if ev.Type == channeltypesv2.EventTypeCreateChannel || ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { + if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { if attribute, found := attributeByKey(ev.Attributes, channeltypes.AttributeKeyChannelID); found { return attribute.Value, nil } From 4ff42e4d4a3c6c131bc395f8ac9e787c22dcc5ad Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Mon, 27 Jan 2025 16:36:54 +0100 Subject: [PATCH 171/172] fix: build wasm image on native architecture (#7884) * distribute build on native OS for wasm builds * fix build-wasm-simd-image-from-tag.yml * add buildx * Add install go for macos runner * setup docker before login * use linux arm instead of macos * fix image name * reference issue in TODO --- .../build-wasm-simd-image-from-tag.yml | 137 ++++++++++++------ 1 file changed, 90 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build-wasm-simd-image-from-tag.yml b/.github/workflows/build-wasm-simd-image-from-tag.yml index 7cef57de825..0968aceb92d 100644 --- a/.github/workflows/build-wasm-simd-image-from-tag.yml +++ b/.github/workflows/build-wasm-simd-image-from-tag.yml @@ -8,52 +8,95 @@ on: type: string env: - REGISTRY: ghcr.io - ORG: cosmos - IMAGE_NAME: ibc-go-wasm-simd - GIT_TAG: "${{ inputs.tag }}" + REGISTRY: ghcr.io + ORG: cosmos + IMAGE_NAME: ibc-go-wasm-simd + GIT_TAG: "${{ inputs.tag }}" jobs: - build-image-at-tag: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - uses: actions/checkout@v4 - with: - ref: "${{ env.GIT_TAG }}" - fetch-depth: 0 - - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: make python-install-deps - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Log in to the Container registry - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get arguments and docker tag - run: | - echo "LIBWASM_VERSION=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_ENV - # remove all `/` or `+` characters from the docker tag and replace them with a -. - # this ensures the docker tag is valid. - echo "DOCKER_TAG=$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" >> $GITHUB_ENV - - - name: Build and push - uses: docker/build-push-action@v6 - with: - platforms: linux/amd64,linux/arm64, - push: true - tags: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} - file: modules/light-clients/08-wasm/Dockerfile - build-args: LIBWASM_VERSION=${{ env.LIBWASM_VERSION }} + build-image-at-tag: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + platform: linux/amd64 + - os: ubuntu-24.04-arm + platform: linux/arm64 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + ref: "${{ env.GIT_TAG }}" + fetch-depth: 0 + + # TODO: #7885 Get rid of this script, it is super unecessary and can probably be done in the Dockerfile or a bash script + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: make python-install-deps + - name: Get arguments + run: echo "LIBWASM_VERSION=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: build + uses: docker/build-push-action@v6 + with: + platforms: ${{ matrix.platform }} + file: modules/light-clients/08-wasm/Dockerfile + build-args: LIBWASM_VERSION=${{ env.LIBWASM_VERSION }} + outputs: type=image,"name=${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.os }} # If we end up running more builds on the same OS, we need to differentiate more here + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - build-image-at-tag + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Get docker tag + # remove all `/` or `+` characters from the docker tag and replace them with a -. + # this ensures the docker tag is valid. + run: echo "DOCKER_TAG=$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} $(printf '${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) From 0d58d592a35f0e9e74d0abef3aff25db6a63236f Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Sat, 1 Feb 2025 18:56:15 +0100 Subject: [PATCH 172/172] test: add initial eureka transfer tests (#7901) --- modules/apps/transfer/keeper/export_test.go | 5 - modules/apps/transfer/keeper/msg_server.go | 6 +- modules/apps/transfer/keeper/relay.go | 2 +- modules/apps/transfer/v2/ibc_module_test.go | 449 ++++++++++++++++++++ 4 files changed, 453 insertions(+), 9 deletions(-) create mode 100644 modules/apps/transfer/v2/ibc_module_test.go diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go index 7aa98f74e9b..ba500ad2ddc 100644 --- a/modules/apps/transfer/keeper/export_test.go +++ b/modules/apps/transfer/keeper/export_test.go @@ -29,11 +29,6 @@ func (k Keeper) GetAllDenomTraces(ctx sdk.Context) []internaltypes.DenomTrace { return traces } -// TokenFromCoin is a wrapper around tokenFromCoin for testing purposes. -func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, error) { - return k.tokenFromCoin(ctx, coin) -} - // UnwindHops is a wrapper around unwindHops for testing purposes. func (k Keeper) UnwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) { return k.unwindHops(ctx, msg) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index ef62397da53..ea414057d0e 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -69,7 +69,7 @@ func (k Keeper) Transfer(ctx context.Context, msg *types.MsgTransfer) (*types.Ms } } - tokens[i], err = k.tokenFromCoin(ctx, coin) + tokens[i], err = k.TokenFromCoin(ctx, coin) if err != nil { return nil, err } @@ -145,7 +145,7 @@ func (k Keeper) getUnwindHops(ctx context.Context, coins sdk.Coins) ([]types.Hop return nil, errorsmod.Wrap(types.ErrInvalidForwarding, "coins cannot be empty") } - token, err := k.tokenFromCoin(ctx, coins[0]) + token, err := k.TokenFromCoin(ctx, coins[0]) if err != nil { return nil, err } @@ -156,7 +156,7 @@ func (k Keeper) getUnwindHops(ctx context.Context, coins sdk.Coins) ([]types.Hop unwindTrace := token.Denom.Trace for _, coin := range coins[1:] { - token, err := k.tokenFromCoin(ctx, coin) + token, err := k.TokenFromCoin(ctx, coin) if err != nil { return nil, err } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 138391e269a..691394c578e 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -390,7 +390,7 @@ func (k Keeper) UnescrowCoin(ctx context.Context, escrowAddress, receiver sdk.Ac } // tokenFromCoin constructs an IBC token given an SDK coin. -func (k Keeper) tokenFromCoin(ctx context.Context, coin sdk.Coin) (types.Token, error) { +func (k Keeper) TokenFromCoin(ctx context.Context, coin sdk.Coin) (types.Token, error) { // if the coin does not have an IBC denom, return as is if !strings.HasPrefix(coin.Denom, "ibc/") { return types.Token{ diff --git a/modules/apps/transfer/v2/ibc_module_test.go b/modules/apps/transfer/v2/ibc_module_test.go new file mode 100644 index 00000000000..aa1363199d0 --- /dev/null +++ b/modules/apps/transfer/v2/ibc_module_test.go @@ -0,0 +1,449 @@ +package v2_test + +import ( + "testing" + "time" + + testifysuite "github.com/stretchr/testify/suite" + + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +type TransferTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + chainC *ibctesting.TestChain + + pathAToB *ibctesting.Path + pathBToC *ibctesting.Path +} + +func (suite *TransferTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) + + // setup between chainA and chainB + // NOTE: + // pathAToB.EndpointA = endpoint on chainA + // pathAToB.EndpointB = endpoint on chainB + suite.pathAToB = ibctesting.NewPath(suite.chainA, suite.chainB) + + // setup between chainB and chainC + // pathBToC.EndpointA = endpoint on chainB + // pathBToC.EndpointB = endpoint on chainC + suite.pathBToC = ibctesting.NewPath(suite.chainB, suite.chainC) + + // setup eureka paths between the chains + suite.pathAToB.SetupV2() + suite.pathBToC.SetupV2() +} + +func TestTransferTestSuite(t *testing.T) { + testifysuite.Run(t, new(TransferTestSuite)) +} + +func (suite *TransferTestSuite) TestOnSendPacket() { + testCases := []struct { + name string + sourceDenomsToTransfer []string + }{ + { + "transfer single denom", + []string{sdk.DefaultBondDenom}, + }, + { + "transfer multiple denoms", + []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom}, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + originalBalances := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom) + originalBalances = originalBalances.Add(originalBalance) + } + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + suite.Require().True(ok) + originalCoins := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + coinToSendToB := sdk.NewCoin(denom, amount) + originalCoins = originalCoins.Add(coinToSendToB) + } + + tokens := make([]types.Token, len(originalCoins)) + + for i, coin := range originalCoins { + var err error + tokens[i], err = suite.chainA.GetSimApp().TransferKeeper.TokenFromCoin(suite.chainA.GetContext(), coin) + suite.Require().NoError(err) + } + + transferData := types.NewFungibleTokenPacketDataV2( + tokens, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + "", + types.ForwardingPacketData{}, + ) + bz := suite.chainA.Codec.MustMarshal(&transferData) + payload := channeltypesv2.NewPayload( + types.PortID, types.PortID, types.V2, + types.EncodingProtobuf, bz, + ) + msg := channeltypesv2.NewMsgSendPacket( + suite.pathAToB.EndpointA.ClientID, + timeoutTimestamp, + suite.chainA.SenderAccount.GetAddress().String(), + payload, + ) + + _, err := suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) // message committed + + // TODO parse packet from result events and check against expected events + + escrowAddress := types.GetEscrowAddress(types.PortID, suite.pathAToB.EndpointA.ClientID) + for _, coin := range originalCoins { + // check that the balance for chainA is updated + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + + // check that module account escrow address has locked the tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(coin, chainAEscrowBalance) + + } + }) + } +} + +func (suite *TransferTestSuite) TestOnRecvPacket() { + testCases := []struct { + name string + sourceDenomsToTransfer []string + }{ + { + "transfer single denom", + []string{sdk.DefaultBondDenom}, + }, + { + "transfer multiple denoms", + []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom}, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + originalBalances := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom) + originalBalances = originalBalances.Add(originalBalance) + } + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + suite.Require().True(ok) + originalCoins := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + coinToSendToB := sdk.NewCoin(denom, amount) + originalCoins = originalCoins.Add(coinToSendToB) + } + + tokens := make([]types.Token, len(originalCoins)) + + for i, coin := range originalCoins { + var err error + tokens[i], err = suite.chainA.GetSimApp().TransferKeeper.TokenFromCoin(suite.chainA.GetContext(), coin) + suite.Require().NoError(err) + } + + transferData := types.NewFungibleTokenPacketDataV2( + tokens, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + "", + types.ForwardingPacketData{}, + ) + bz := suite.chainA.Codec.MustMarshal(&transferData) + payload := channeltypesv2.NewPayload( + types.PortID, types.PortID, types.V2, + types.EncodingProtobuf, bz, + ) + msg := channeltypesv2.NewMsgSendPacket( + suite.pathAToB.EndpointA.ClientID, + timeoutTimestamp, + suite.chainA.SenderAccount.GetAddress().String(), + payload, + ) + + _, err := suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) // message committed + + ctx := suite.chainB.GetContext() + cbs := suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.Router.Route(ibctesting.TransferPort) + + recvResult := cbs.OnRecvPacket( + ctx, suite.pathAToB.EndpointA.ClientID, suite.pathAToB.EndpointB.ClientID, + 1, payload, suite.chainB.SenderAccount.GetAddress(), + ) + + suite.Require().Equal(channeltypesv2.PacketStatus_Success, recvResult.Status) + suite.Require().Equal(channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement(), recvResult.Acknowledgement) + + escrowAddress := types.GetEscrowAddress(types.PortID, suite.pathAToB.EndpointA.ClientID) + for _, coin := range originalCoins { + // check that the balance for chainA is updated + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + + // check that module account escrow address has locked the tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(coin, chainAEscrowBalance) + + traceAToB := types.NewHop(types.PortID, suite.pathAToB.EndpointB.ClientID) + + // check that voucher exists on chain B + chainBDenom := types.NewDenom(coin.Denom, traceAToB) + chainBBalance := suite.chainB.GetSimApp().BankKeeper.GetBalance(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), chainBDenom.IBCDenom()) + coinSentFromAToB := sdk.NewCoin(chainBDenom.IBCDenom(), amount) + suite.Require().Equal(coinSentFromAToB, chainBBalance) + + } + }) + } +} + +func (suite *TransferTestSuite) TestOnAckPacket() { + testCases := []struct { + name string + sourceDenomsToTransfer []string + }{ + { + "transfer single denom", + []string{sdk.DefaultBondDenom}, + }, + { + "transfer multiple denoms", + []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom}, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + originalBalances := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom) + originalBalances = originalBalances.Add(originalBalance) + } + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + suite.Require().True(ok) + originalCoins := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + coinToSendToB := sdk.NewCoin(denom, amount) + originalCoins = originalCoins.Add(coinToSendToB) + } + + tokens := make([]types.Token, len(originalCoins)) + + for i, coin := range originalCoins { + var err error + tokens[i], err = suite.chainA.GetSimApp().TransferKeeper.TokenFromCoin(suite.chainA.GetContext(), coin) + suite.Require().NoError(err) + } + + transferData := types.NewFungibleTokenPacketDataV2( + tokens, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + "", + types.ForwardingPacketData{}, + ) + bz := suite.chainA.Codec.MustMarshal(&transferData) + payload := channeltypesv2.NewPayload( + types.PortID, types.PortID, types.V2, + types.EncodingProtobuf, bz, + ) + msg := channeltypesv2.NewMsgSendPacket( + suite.pathAToB.EndpointA.ClientID, + timeoutTimestamp, + suite.chainA.SenderAccount.GetAddress().String(), + payload, + ) + + _, err := suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) // message committed + + ctx := suite.chainA.GetContext() + cbs := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.Router.Route(ibctesting.TransferPort) + + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + + err = cbs.OnAcknowledgementPacket( + ctx, suite.pathAToB.EndpointA.ClientID, suite.pathAToB.EndpointB.ClientID, + 1, ack.Acknowledgement(), payload, suite.chainA.SenderAccount.GetAddress(), + ) + suite.Require().NoError(err) + + // on successful ack, the tokens sent in packets should still be in escrow + escrowAddress := types.GetEscrowAddress(types.PortID, suite.pathAToB.EndpointA.ClientID) + for _, coin := range originalCoins { + // check that the balance for chainA is updated + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + + // check that module account escrow address has locked the tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(coin, chainAEscrowBalance) + } + + // create error ack and replay the callback to check that funds are returned to sender + // we can replay for simplicity here since replay protection is done in the core handlers + errAck := channeltypes.NewErrorAcknowledgement(types.ErrInvalidAmount) + err = cbs.OnAcknowledgementPacket( + ctx, suite.pathAToB.EndpointA.ClientID, suite.pathAToB.EndpointB.ClientID, + 1, errAck.Acknowledgement(), payload, suite.chainA.SenderAccount.GetAddress(), + ) + suite.Require().NoError(err) + + // on error ack, the tokens sent in packets should be returned to sender + for _, coin := range originalCoins { + // check that the balance for chainA is refunded + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom), chainABalance.Amount) + + // check that module account escrow address has no tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(sdk.NewCoin(coin.Denom, sdkmath.ZeroInt()), chainAEscrowBalance) + } + }) + } +} + +func (suite *TransferTestSuite) TestOnTimeoutPacket() { + testCases := []struct { + name string + sourceDenomsToTransfer []string + }{ + { + "transfer single denom", + []string{sdk.DefaultBondDenom}, + }, + { + "transfer multiple denoms", + []string{sdk.DefaultBondDenom, ibctesting.SecondaryDenom}, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + originalBalances := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom) + originalBalances = originalBalances.Add(originalBalance) + } + + timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) + + amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + suite.Require().True(ok) + originalCoins := sdk.NewCoins() + for _, denom := range tc.sourceDenomsToTransfer { + coinToSendToB := sdk.NewCoin(denom, amount) + originalCoins = originalCoins.Add(coinToSendToB) + } + + tokens := make([]types.Token, len(originalCoins)) + + for i, coin := range originalCoins { + var err error + tokens[i], err = suite.chainA.GetSimApp().TransferKeeper.TokenFromCoin(suite.chainA.GetContext(), coin) + suite.Require().NoError(err) + } + + transferData := types.NewFungibleTokenPacketDataV2( + tokens, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + "", + types.ForwardingPacketData{}, + ) + bz := suite.chainA.Codec.MustMarshal(&transferData) + payload := channeltypesv2.NewPayload( + types.PortID, types.PortID, types.V2, + types.EncodingProtobuf, bz, + ) + msg := channeltypesv2.NewMsgSendPacket( + suite.pathAToB.EndpointA.ClientID, + timeoutTimestamp, + suite.chainA.SenderAccount.GetAddress().String(), + payload, + ) + + _, err := suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) // message committed + + // on successful send, the tokens sent in packets should be in escrow + escrowAddress := types.GetEscrowAddress(types.PortID, suite.pathAToB.EndpointA.ClientID) + for _, coin := range originalCoins { + // check that the balance for chainA is updated + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom).Sub(amount).Int64(), chainABalance.Amount.Int64()) + + // check that module account escrow address has locked the tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(coin, chainAEscrowBalance) + } + + ctx := suite.chainA.GetContext() + cbs := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.Router.Route(ibctesting.TransferPort) + + err = cbs.OnTimeoutPacket( + ctx, suite.pathAToB.EndpointA.ClientID, suite.pathAToB.EndpointB.ClientID, + 1, payload, suite.chainA.SenderAccount.GetAddress(), + ) + suite.Require().NoError(err) + + // on timeout, the tokens sent in packets should be returned to sender + for _, coin := range originalCoins { + // check that the balance for chainA is refunded + chainABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), coin.Denom) + suite.Require().Equal(originalBalances.AmountOf(coin.Denom), chainABalance.Amount) + + // check that module account escrow address has no tokens + chainAEscrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, coin.Denom) + suite.Require().Equal(sdk.NewCoin(coin.Denom, sdkmath.ZeroInt()), chainAEscrowBalance) + } + }) + } +}