From 3224eb1f6819ef37f8d05ba735299f345fdbf77b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:47:41 +0300 Subject: [PATCH 01/60] imp: initial modification of tx.proto --- .../interchain_accounts/host/v1/tx.proto | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto index 5a8073bc931..7738f779aa0 100644 --- a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto +++ b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto @@ -7,6 +7,7 @@ option go_package = "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-acco import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/applications/interchain_accounts/host/v1/host.proto"; +import "google/protobuf/any.proto"; // Msg defines the 27-interchain-accounts/host Msg service. service Msg { @@ -14,6 +15,9 @@ service Msg { // UpdateParams defines a rpc handler for MsgUpdateParams. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. + rpc ModuleSafeQuery(MsgModuleSafeQuery) returns (MsgModuleSafeQueryResponse); } // MsgUpdateParams defines the payload for Msg/UpdateParams @@ -33,3 +37,22 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response for Msg/UpdateParams message MsgUpdateParamsResponse {} + +// MsgModuleSafeQuery defines the payload for Msg/ModuleSafeQuery +message MsgModuleSafeQuery { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // signer address + string signer = 1; + + // queries defines the module safe queries to execute. + repeated google.protobuf.Any queries = 2; +} + +// MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery +message MsgModuleSafeQueryResponse { + // results defines the results of the module safe queries. + repeated google.protobuf.Any results = 1; +} From 6e1d4de1d8f4d22526f78ca00be7bc13afd9a37f Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:56:14 +0300 Subject: [PATCH 02/60] imp: ran 'make proto-all' --- .../host/types/tx.pb.go | 496 +++++++++++++++++- 1 file changed, 473 insertions(+), 23 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/tx.pb.go b/modules/apps/27-interchain-accounts/host/types/tx.pb.go index ebcc8995cb5..3cf2d601090 100644 --- a/modules/apps/27-interchain-accounts/host/types/tx.pb.go +++ b/modules/apps/27-interchain-accounts/host/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -109,9 +110,98 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgModuleSafeQuery defines the payload for Msg/ModuleSafeQuery +type MsgModuleSafeQuery struct { + // signer address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // queries defines the module safe queries to execute. + Queries []*types.Any `protobuf:"bytes,2,rep,name=queries,proto3" json:"queries,omitempty"` +} + +func (m *MsgModuleSafeQuery) Reset() { *m = MsgModuleSafeQuery{} } +func (m *MsgModuleSafeQuery) String() string { return proto.CompactTextString(m) } +func (*MsgModuleSafeQuery) ProtoMessage() {} +func (*MsgModuleSafeQuery) Descriptor() ([]byte, []int) { + return fileDescriptor_fa437afde7f1e7ae, []int{2} +} +func (m *MsgModuleSafeQuery) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgModuleSafeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgModuleSafeQuery.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 *MsgModuleSafeQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgModuleSafeQuery.Merge(m, src) +} +func (m *MsgModuleSafeQuery) XXX_Size() int { + return m.Size() +} +func (m *MsgModuleSafeQuery) XXX_DiscardUnknown() { + xxx_messageInfo_MsgModuleSafeQuery.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgModuleSafeQuery proto.InternalMessageInfo + +// MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery +type MsgModuleSafeQueryResponse struct { + // results defines the results of the module safe queries. + Results []*types.Any `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +} + +func (m *MsgModuleSafeQueryResponse) Reset() { *m = MsgModuleSafeQueryResponse{} } +func (m *MsgModuleSafeQueryResponse) String() string { return proto.CompactTextString(m) } +func (*MsgModuleSafeQueryResponse) ProtoMessage() {} +func (*MsgModuleSafeQueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fa437afde7f1e7ae, []int{3} +} +func (m *MsgModuleSafeQueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgModuleSafeQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgModuleSafeQueryResponse.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 *MsgModuleSafeQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgModuleSafeQueryResponse.Merge(m, src) +} +func (m *MsgModuleSafeQueryResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgModuleSafeQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgModuleSafeQueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgModuleSafeQueryResponse proto.InternalMessageInfo + +func (m *MsgModuleSafeQueryResponse) GetResults() []*types.Any { + if m != nil { + return m.Results + } + return nil +} + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "ibc.applications.interchain_accounts.host.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "ibc.applications.interchain_accounts.host.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgModuleSafeQuery)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleSafeQuery") + proto.RegisterType((*MsgModuleSafeQueryResponse)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleSafeQueryResponse") } func init() { @@ -119,29 +209,36 @@ func init() { } var fileDescriptor_fa437afde7f1e7ae = []byte{ - // 352 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xcd, 0x4c, 0x4a, 0xd6, - 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0xcf, 0xcc, 0x2b, - 0x49, 0x2d, 0x4a, 0xce, 0x48, 0xcc, 0xcc, 0x8b, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, - 0xd6, 0xcf, 0xc8, 0x2f, 0x2e, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xd2, 0xc9, 0x4c, 0x4a, 0xd6, 0x43, 0xd6, 0xa6, 0x87, 0x45, 0x9b, 0x1e, 0x48, 0x9b, - 0x5e, 0x99, 0xa1, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0xa3, 0x3e, 0x88, 0x05, 0x31, 0x43, - 0x4a, 0x3c, 0x39, 0xbf, 0x38, 0x37, 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0x64, 0x76, 0x6e, 0x71, - 0x3a, 0x54, 0xc2, 0x9c, 0x24, 0x37, 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6, 0x4d, 0xcf, 0xd7, - 0x2f, 0xb3, 0xd0, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0x06, 0x45, 0x62, 0xb1, 0xbe, 0x91, - 0xb9, 0x2e, 0xc2, 0x05, 0xba, 0xa8, 0xf1, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x8e, - 0x3e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x76, 0xa2, 0x96, 0x3e, 0x8d, 0x02, 0x00, 0x00, + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x33, 0xad, 0xae, 0x38, 0x15, 0x0a, 0xa1, 0xd8, 0x6d, 0x0e, 0x69, 0xd9, 0xd3, 0x52, + 0xdc, 0x19, 0xba, 0x2a, 0x15, 0x41, 0xd0, 0x82, 0x20, 0xe2, 0x82, 0x46, 0xbc, 0x78, 0x91, 0xc9, + 0xec, 0x74, 0x76, 0x20, 0x99, 0x89, 0x79, 0x27, 0x8b, 0xb9, 0x89, 0x27, 0x4f, 0xe2, 0xc1, 0xab, + 0xe0, 0x47, 0xe8, 0x77, 0xf0, 0xd2, 0x63, 0x8f, 0x9e, 0x44, 0x76, 0x0f, 0xfd, 0x1a, 0x92, 0x7f, + 0x6a, 0x53, 0x15, 0x42, 0x6f, 0x19, 0xe6, 0x7d, 0x7e, 0xef, 0xf3, 0x3e, 0x99, 0x17, 0xdf, 0x56, + 0x21, 0xa7, 0x2c, 0x49, 0x22, 0xc5, 0x99, 0x55, 0x46, 0x03, 0x55, 0xda, 0x8a, 0x94, 0xcf, 0x98, + 0xd2, 0xaf, 0x18, 0xe7, 0x26, 0xd3, 0x16, 0xe8, 0xcc, 0x80, 0xa5, 0xf3, 0x3d, 0x6a, 0xdf, 0x90, + 0x24, 0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, 0xe7, 0x9d, 0x3c, 0xc1, 0xde, 0xf9, 0x76, 0x8d, + 0x99, 0x02, 0x9f, 0x0a, 0xc8, 0x22, 0x0b, 0x7d, 0xf4, 0x3f, 0x7c, 0x5d, 0x34, 0xfe, 0xba, 0x82, + 0x57, 0x27, 0x20, 0xdd, 0x4f, 0x08, 0x5f, 0x3b, 0x93, 0xf6, 0xbd, 0x6e, 0x29, 0xb6, 0xc2, 0xf1, + 0x1e, 0x5e, 0x48, 0xfe, 0x6b, 0x9c, 0xcf, 0xc5, 0x3b, 0x68, 0x25, 0x7b, 0xbf, 0x33, 0xba, 0x45, + 0xf0, 0x1e, 0x5d, 0x94, 0xd0, 0xf8, 0xf3, 0x2e, 0xbf, 0x3d, 0x3d, 0xda, 0x45, 0x07, 0xd3, 0xe3, + 0x85, 0x8f, 0x4e, 0x16, 0x3e, 0xfa, 0xb1, 0xf0, 0xd1, 0xc7, 0xa5, 0xef, 0x9c, 0x2c, 0x7d, 0xe7, + 0xdb, 0xd2, 0x77, 0x5e, 0x3e, 0x96, 0xca, 0xce, 0xb2, 0x90, 0x70, 0x13, 0xd3, 0x7a, 0x81, 0x54, + 0xc8, 0x47, 0xd2, 0xd0, 0xf9, 0x1d, 0x1a, 0x97, 0x54, 0x28, 0x96, 0x07, 0xe8, 0x78, 0x7f, 0xf4, + 0xdb, 0xc4, 0xe8, 0xec, 0xde, 0xd8, 0x3c, 0x11, 0x10, 0xf6, 0xca, 0x5f, 0x78, 0xf3, 0x67, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xf9, 0x1d, 0xfd, 0x8c, 0x05, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,6 +255,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // UpdateParams defines a rpc handler for MsgUpdateParams. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. + ModuleSafeQuery(ctx context.Context, in *MsgModuleSafeQuery, opts ...grpc.CallOption) (*MsgModuleSafeQueryResponse, error) } type msgClient struct { @@ -177,10 +276,21 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) ModuleSafeQuery(ctx context.Context, in *MsgModuleSafeQuery, opts ...grpc.CallOption) (*MsgModuleSafeQueryResponse, error) { + out := new(MsgModuleSafeQueryResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleSafeQuery", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a rpc handler for MsgUpdateParams. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. + ModuleSafeQuery(context.Context, *MsgModuleSafeQuery) (*MsgModuleSafeQueryResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -190,6 +300,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) ModuleSafeQuery(ctx context.Context, req *MsgModuleSafeQuery) (*MsgModuleSafeQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ModuleSafeQuery not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -213,6 +326,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_ModuleSafeQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgModuleSafeQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ModuleSafeQuery(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleSafeQuery", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ModuleSafeQuery(ctx, req.(*MsgModuleSafeQuery)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.interchain_accounts.host.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -221,6 +352,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "ModuleSafeQuery", + Handler: _Msg_ModuleSafeQuery_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/interchain_accounts/host/v1/tx.proto", @@ -289,6 +424,87 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgModuleSafeQuery) 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 *MsgModuleSafeQuery) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgModuleSafeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Queries) > 0 { + for iNdEx := len(m.Queries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Queries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgModuleSafeQueryResponse) 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 *MsgModuleSafeQueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgModuleSafeQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].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 encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -324,6 +540,40 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgModuleSafeQuery) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Queries) > 0 { + for _, e := range m.Queries { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgModuleSafeQueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -495,6 +745,206 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgModuleSafeQuery) 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: MsgModuleSafeQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgModuleSafeQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Queries", 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.Queries = append(m.Queries, &types.Any{}) + if err := m.Queries[len(m.Queries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgModuleSafeQueryResponse) 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: MsgModuleSafeQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgModuleSafeQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", 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.Results = append(m.Results, &types.Any{}) + if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 From d2ce96f9d4cd811a2a00d5c9a4a614b41ca21d77 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:59:45 +0300 Subject: [PATCH 03/60] fix: compiler errors --- .../apps/27-interchain-accounts/host/keeper/msg_server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index c71dba65576..cbfee295c26 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -23,6 +23,12 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } +// UpdateParams updates the host submodule's params. +func (m msgServer) ModuleSafeQuery(goCtx context.Context, msg *types.MsgModuleSafeQuery) (*types.MsgModuleSafeQueryResponse, error) { + // TODO: implement + return &types.MsgModuleSafeQueryResponse{}, nil +} + // UpdateParams updates the host submodule's params. func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if m.GetAuthority() != msg.Signer { From 47d8fb16095b008b96c35ef6525239eafa68bf17 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 17:09:10 +0300 Subject: [PATCH 04/60] imp: added query router interface --- modules/apps/27-interchain-accounts/types/router.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/apps/27-interchain-accounts/types/router.go b/modules/apps/27-interchain-accounts/types/router.go index 007091b9d0d..32a334f5f46 100644 --- a/modules/apps/27-interchain-accounts/types/router.go +++ b/modules/apps/27-interchain-accounts/types/router.go @@ -10,3 +10,11 @@ import ( type MessageRouter interface { Handler(msg sdk.Msg) baseapp.MsgServiceHandler } + +// QueryRouter ADR 021 query type routing +// https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md +type QueryRouter interface { + // Route returns the GRPCQueryHandler for a given query route path or nil + // if not found + Route(path string) baseapp.GRPCQueryHandler +} From 47fdeedba2505eaaf7a65e15a9bfe6d19e31fb6e Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 17:15:33 +0300 Subject: [PATCH 05/60] imp: added queryRouter to icahost keeper --- modules/apps/27-interchain-accounts/host/keeper/keeper.go | 6 ++++-- .../apps/27-interchain-accounts/host/keeper/keeper_test.go | 3 +++ testing/simapp/app.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index ce8bdad1234..51170341902 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -36,7 +36,8 @@ type Keeper struct { scopedKeeper exported.ScopedKeeper - msgRouter icatypes.MessageRouter + msgRouter icatypes.MessageRouter + queryRouter icatypes.QueryRouter // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -48,7 +49,7 @@ func NewKeeper( cdc codec.Codec, key storetypes.StoreKey, legacySubspace icatypes.ParamSubspace, ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper, scopedKeeper exported.ScopedKeeper, msgRouter icatypes.MessageRouter, - authority string, + queryRouter icatypes.QueryRouter, authority string, ) Keeper { // ensure ibc interchain accounts module account is set if addr := accountKeeper.GetModuleAddress(icatypes.ModuleName); addr == nil { @@ -69,6 +70,7 @@ func NewKeeper( accountKeeper: accountKeeper, scopedKeeper: scopedKeeper, msgRouter: msgRouter, + queryRouter: queryRouter, authority: authority, } } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index 6af0abb67ca..37e26c7807a 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -147,6 +147,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { suite.chainA.GetSimApp().AccountKeeper, suite.chainA.GetSimApp().ScopedICAHostKeeper, suite.chainA.GetSimApp().MsgServiceRouter(), + suite.chainA.GetSimApp().GRPCQueryRouter(), suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), ) }, true}, @@ -161,6 +162,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { authkeeper.AccountKeeper{}, // empty account keeper suite.chainA.GetSimApp().ScopedICAHostKeeper, suite.chainA.GetSimApp().MsgServiceRouter(), + suite.chainA.GetSimApp().GRPCQueryRouter(), suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), ) }, false}, @@ -175,6 +177,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { suite.chainA.GetSimApp().AccountKeeper, suite.chainA.GetSimApp().ScopedICAHostKeeper, suite.chainA.GetSimApp().MsgServiceRouter(), + suite.chainA.GetSimApp().GRPCQueryRouter(), "", // authority ) }, false}, diff --git a/testing/simapp/app.go b/testing/simapp/app.go index dc44a54bd14..0359bef052c 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -458,8 +458,8 @@ func NewSimApp( app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack - app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, - app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, app.AccountKeeper, + scopedICAHostKeeper, app.MsgServiceRouter(), app.GRPCQueryRouter(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) From adea94ecb7e4c5401806def02ebeaf4274522148 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 17:40:44 +0300 Subject: [PATCH 06/60] imp: improved proto definitions --- .../interchain_accounts/host/v1/host.proto | 11 +++++++++++ .../applications/interchain_accounts/host/v1/tx.proto | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/proto/ibc/applications/interchain_accounts/host/v1/host.proto b/proto/ibc/applications/interchain_accounts/host/v1/host.proto index f036857113a..9165f36e794 100644 --- a/proto/ibc/applications/interchain_accounts/host/v1/host.proto +++ b/proto/ibc/applications/interchain_accounts/host/v1/host.proto @@ -12,3 +12,14 @@ message Params { // allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. repeated string allow_messages = 2; } + +// QueryRequest defines the parameters for a particular query request +// by an interchain account. +message QueryRequest { + // path defines the path of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + string path = 1; + // data defines the payload of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + bytes data = 2; +} diff --git a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto index 7738f779aa0..26eb40ad612 100644 --- a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto +++ b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto @@ -7,7 +7,6 @@ option go_package = "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-acco import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/applications/interchain_accounts/host/v1/host.proto"; -import "google/protobuf/any.proto"; // Msg defines the 27-interchain-accounts/host Msg service. service Msg { @@ -48,11 +47,11 @@ message MsgModuleSafeQuery { string signer = 1; // queries defines the module safe queries to execute. - repeated google.protobuf.Any queries = 2; + repeated QueryRequest queries = 2; } // MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery message MsgModuleSafeQueryResponse { - // results defines the results of the module safe queries. - repeated google.protobuf.Any results = 1; + // protobuf encoded responses for each query + repeated bytes results = 1; } From 4c9ee5ee4af25fd6447699707ed224d3f3360af3 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 17:45:47 +0300 Subject: [PATCH 07/60] imp: ran 'make proto-all' --- .../host/types/host.pb.go | 265 ++++++++++++++++-- .../host/types/tx.pb.go | 98 +++---- 2 files changed, 293 insertions(+), 70 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/host.pb.go b/modules/apps/27-interchain-accounts/host/types/host.pb.go index 77db265b6b5..54df248f119 100644 --- a/modules/apps/27-interchain-accounts/host/types/host.pb.go +++ b/modules/apps/27-interchain-accounts/host/types/host.pb.go @@ -78,8 +78,67 @@ func (m *Params) GetAllowMessages() []string { return nil } +// QueryRequest defines the parameters for a particular query request +// by an interchain account. +type QueryRequest struct { + // path defines the path of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + // data defines the payload of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_48e202774f13d08e, []int{1} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.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 *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func (m *QueryRequest) GetPath() string { + if m != nil { + return m.Path + } + return "" +} + +func (m *QueryRequest) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + func init() { proto.RegisterType((*Params)(nil), "ibc.applications.interchain_accounts.host.v1.Params") + proto.RegisterType((*QueryRequest)(nil), "ibc.applications.interchain_accounts.host.v1.QueryRequest") } func init() { @@ -87,23 +146,25 @@ func init() { } var fileDescriptor_48e202774f13d08e = []byte{ - // 246 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xcf, 0xbf, 0x4a, 0xc4, 0x40, - 0x10, 0xc7, 0xf1, 0x44, 0xe1, 0xd0, 0xf8, 0xa7, 0x48, 0x75, 0xd5, 0x72, 0x0a, 0xc2, 0x15, 0x66, - 0x97, 0xd3, 0xe2, 0xac, 0x05, 0x1b, 0x41, 0x90, 0x94, 0x36, 0x61, 0x77, 0xb2, 0x24, 0x0b, 0xbb, - 0x3b, 0x21, 0xb3, 0x89, 0xf8, 0x16, 0x3e, 0x96, 0xe5, 0x95, 0x96, 0x92, 0xbc, 0x88, 0x24, 0x0a, - 0x2a, 0x58, 0x0d, 0x7c, 0xe0, 0x07, 0xf3, 0x4d, 0xb6, 0x46, 0x81, 0x90, 0x4d, 0x63, 0x0d, 0xc8, - 0x60, 0xd0, 0x93, 0x30, 0x3e, 0xe8, 0x16, 0x6a, 0x69, 0x7c, 0x21, 0x01, 0xb0, 0xf3, 0x81, 0x44, - 0x8d, 0x14, 0x44, 0xbf, 0x99, 0x2f, 0x6f, 0x5a, 0x0c, 0x98, 0x5e, 0x1a, 0x05, 0xfc, 0xf7, 0x90, - 0xff, 0x33, 0xe4, 0xf3, 0xa0, 0xdf, 0x9c, 0xe7, 0xc9, 0xe2, 0x51, 0xb6, 0xd2, 0x51, 0x7a, 0x96, - 0x1c, 0x4f, 0x58, 0x68, 0x2f, 0x95, 0xd5, 0xe5, 0x32, 0x5e, 0xc5, 0xeb, 0x83, 0xfc, 0x68, 0xb2, - 0xbb, 0x2f, 0x4a, 0x2f, 0x92, 0x53, 0x69, 0x2d, 0x3e, 0x17, 0x4e, 0x13, 0xc9, 0x4a, 0xd3, 0x72, - 0x6f, 0xb5, 0xbf, 0x3e, 0xcc, 0x4f, 0x66, 0x7d, 0xf8, 0xc6, 0xdb, 0xf2, 0x6d, 0x60, 0xf1, 0x6e, - 0x60, 0xf1, 0xc7, 0xc0, 0xe2, 0xd7, 0x91, 0x45, 0xbb, 0x91, 0x45, 0xef, 0x23, 0x8b, 0x9e, 0xee, - 0x2b, 0x13, 0xea, 0x4e, 0x71, 0x40, 0x27, 0x00, 0xc9, 0x21, 0x09, 0xa3, 0x20, 0xab, 0x50, 0xf4, - 0x37, 0xc2, 0x61, 0xd9, 0x59, 0x4d, 0x53, 0x34, 0x89, 0xab, 0x6d, 0xf6, 0xf3, 0x76, 0xf6, 0xb7, - 0x37, 0xbc, 0x34, 0x9a, 0xd4, 0x62, 0xce, 0xbd, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x51, 0x50, - 0x78, 0xd7, 0x29, 0x01, 0x00, 0x00, + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xd0, 0x31, 0x4b, 0xfc, 0x30, + 0x18, 0x06, 0xf0, 0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, 0x21, 0x7c, 0xbe, 0x4e, 0x5f, + 0x7b, 0x46, 0xf6, 0x3d, 0x23, 0xef, 0x3d, 0x23, 0x2f, 0x03, 0x9b, 0xec, 0x07, 0x36, 0x79, 0x1b, + 0xd8, 0xe4, 0xf1, 0x36, 0x33, 0x2e, 0x6f, 0x65, 0xac, 0x6c, 0xc9, 0x95, 0xc5, 0xd2, 0x22, 0x37, + 0x52, 0x45, 0x99, 0xe5, 0xdd, 0x15, 0x2f, 0x6d, 0xda, 0x16, 0x1a, 0xc7, 0xb1, 0x90, 0x9f, 0x6f, + 0xa3, 0xef, 0x73, 0xa3, 0xdf, 0x3b, 0xb9, 0x5d, 0xad, 0x51, 0xce, 0xfc, 0x4c, 0x17, 0x1f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x56, 0xc6, 0xd2, 0x5a, 0x61, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -148,6 +209,43 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryRequest) 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 *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) 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 = encodeVarintHost(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintHost(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintHost(dAtA []byte, offset int, v uint64) int { offset -= sovHost(v) base := offset @@ -177,6 +275,23 @@ func (m *Params) Size() (n int) { return n } +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Path) + if l > 0 { + n += 1 + l + sovHost(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovHost(uint64(l)) + } + return n +} + func sovHost(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -285,6 +400,122 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryRequest) 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 ErrIntOverflowHost + } + 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: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHost + } + 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 ErrInvalidLengthHost + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthHost + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowHost + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthHost + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthHost + } + 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 := skipHost(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHost + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipHost(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/27-interchain-accounts/host/types/tx.pb.go b/modules/apps/27-interchain-accounts/host/types/tx.pb.go index 3cf2d601090..1a55721381b 100644 --- a/modules/apps/27-interchain-accounts/host/types/tx.pb.go +++ b/modules/apps/27-interchain-accounts/host/types/tx.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -115,7 +114,7 @@ type MsgModuleSafeQuery struct { // signer address Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` // queries defines the module safe queries to execute. - Queries []*types.Any `protobuf:"bytes,2,rep,name=queries,proto3" json:"queries,omitempty"` + Queries []*QueryRequest `protobuf:"bytes,2,rep,name=queries,proto3" json:"queries,omitempty"` } func (m *MsgModuleSafeQuery) Reset() { *m = MsgModuleSafeQuery{} } @@ -153,8 +152,8 @@ var xxx_messageInfo_MsgModuleSafeQuery proto.InternalMessageInfo // MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery type MsgModuleSafeQueryResponse struct { - // results defines the results of the module safe queries. - Results []*types.Any `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` + // protobuf encoded responses for each query + Results [][]byte `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` } func (m *MsgModuleSafeQueryResponse) Reset() { *m = MsgModuleSafeQueryResponse{} } @@ -190,7 +189,7 @@ func (m *MsgModuleSafeQueryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgModuleSafeQueryResponse proto.InternalMessageInfo -func (m *MsgModuleSafeQueryResponse) GetResults() []*types.Any { +func (m *MsgModuleSafeQueryResponse) GetResults() [][]byte { if m != nil { return m.Results } @@ -209,36 +208,36 @@ func init() { } var fileDescriptor_fa437afde7f1e7ae = []byte{ - // 460 bytes of a gzipped FileDescriptorProto + // 449 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0xad, 0xae, 0x38, 0x15, 0x0a, 0xa1, 0xd8, 0x6d, 0x0e, 0x69, 0xd9, 0xd3, 0x52, - 0xdc, 0x19, 0xba, 0x2a, 0x15, 0x41, 0xd0, 0x82, 0x20, 0xe2, 0x82, 0x46, 0xbc, 0x78, 0x91, 0xc9, - 0xec, 0x74, 0x76, 0x20, 0x99, 0x89, 0x79, 0x27, 0x8b, 0xb9, 0x89, 0x27, 0x4f, 0xe2, 0xc1, 0xab, - 0xe0, 0x47, 0xe8, 0x77, 0xf0, 0xd2, 0x63, 0x8f, 0x9e, 0x44, 0x76, 0x0f, 0xfd, 0x1a, 0x92, 0x7f, - 0x6a, 0x53, 0x15, 0x42, 0x6f, 0x19, 0xe6, 0x7d, 0x7e, 0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8, 0x78, 0xee, 0xa1, 0x93, 0xb9, 0x87, 0x7e, 0xcd, 0x3d, 0xf4, 0x69, + 0xe1, 0x59, 0x27, 0x0b, 0xcf, 0xfa, 0xb1, 0xf0, 0xac, 0x57, 0x4f, 0xa4, 0x32, 0x93, 0x22, 0x26, + 0x5c, 0x27, 0xb4, 0xae, 0x8d, 0x8a, 0xf9, 0x48, 0x6a, 0x3a, 0xbb, 0x4f, 0x93, 0x8a, 0x0a, 0x65, + 0x65, 0x80, 0x06, 0xbb, 0xa3, 0xbf, 0x12, 0xa3, 0xf3, 0x6d, 0x31, 0x87, 0x99, 0x80, 0xb8, 0x5f, + 0x95, 0xe5, 0xf6, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xde, 0x9a, 0xb6, 0x8f, 0xfb, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -490,14 +489,9 @@ func (m *MsgModuleSafeQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = l if len(m.Results) > 0 { for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } + i -= len(m.Results[iNdEx]) + copy(dAtA[i:], m.Results[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Results[iNdEx]))) i-- dAtA[i] = 0xa } @@ -566,8 +560,8 @@ func (m *MsgModuleSafeQueryResponse) Size() (n int) { var l int _ = l if len(m.Results) > 0 { - for _, e := range m.Results { - l = e.Size() + for _, b := range m.Results { + l = len(b) n += 1 + l + sovTx(uint64(l)) } } @@ -835,7 +829,7 @@ func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Queries = append(m.Queries, &types.Any{}) + m.Queries = append(m.Queries, &QueryRequest{}) if err := m.Queries[len(m.Queries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -894,7 +888,7 @@ func (m *MsgModuleSafeQueryResponse) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -904,25 +898,23 @@ func (m *MsgModuleSafeQueryResponse) 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 ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Results = append(m.Results, &types.Any{}) - if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Results = append(m.Results, make([]byte, postIndex-iNdEx)) + copy(m.Results[len(m.Results)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From 4846f807ecede7d4408c50775b33553a5765969b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 17:54:14 +0300 Subject: [PATCH 08/60] imp: added sdk.Msg helpers --- .../27-interchain-accounts/host/types/msgs.go | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/types/msgs.go b/modules/apps/27-interchain-accounts/host/types/msgs.go index 8b23b5040e1..83d2d50a00f 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs.go @@ -11,6 +11,9 @@ import ( var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) + + _ sdk.Msg = (*MsgModuleSafeQuery)(nil) + _ sdk.HasValidateBasic = (*MsgModuleSafeQuery)(nil) ) // NewMsgUpdateParams creates a new MsgUpdateParams instance @@ -21,7 +24,7 @@ func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams { } } -// ValidateBasic implements sdk.Msg +// ValidateBasic implements sdk.HasValidateBasic func (msg MsgUpdateParams) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -30,3 +33,25 @@ func (msg MsgUpdateParams) ValidateBasic() error { return msg.Params.Validate() } + +// NewMsgModuleSafeQuery creates a new MsgModuleSafeQuery instance +func NewMsgModuleSafeQuery(signer string, queries []*QueryRequest) *MsgModuleSafeQuery { + return &MsgModuleSafeQuery{ + Signer: signer, + Queries: queries, + } +} + +// ValidateBasic implements sdk.HasValidateBasic +func (msg MsgModuleSafeQuery) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if len(msg.Queries) == 0 { + return errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no queries provided") + } + + return nil +} From ea72aed226405e6920fa2eec74d13723c97d61f5 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 18:20:49 +0300 Subject: [PATCH 09/60] feat: basic implementation --- .../host/keeper/msg_server.go | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index cbfee295c26..5b01e7917de 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -7,6 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) @@ -25,8 +27,32 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { // UpdateParams updates the host submodule's params. func (m msgServer) ModuleSafeQuery(goCtx context.Context, msg *types.MsgModuleSafeQuery) (*types.MsgModuleSafeQueryResponse, error) { - // TODO: implement - return &types.MsgModuleSafeQueryResponse{}, nil + // sender is not used in this handler + + ctx := sdk.UnwrapSDKContext(goCtx) + + var responses = make([][]byte, len(msg.Queries)) + for i, query := range msg.Queries { + route := m.queryRouter.Route(query.Path) + if route == nil { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no route to query: %s", query.Path) + } + + res, err := route(ctx, &abci.RequestQuery{ + Path: query.Path, + Data: query.Data, + }) + if err != nil { + return nil, err + } + if res == nil || res.Value == nil { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no response for query: %s", query.Path) + } + + responses[i] = res.Value + } + + return &types.MsgModuleSafeQueryResponse{Results: responses}, nil } // UpdateParams updates the host submodule's params. From cf6db8150d2f395fd19ea9a0261191b318d08c1b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 18:39:15 +0300 Subject: [PATCH 10/60] style: improved field names --- .../interchain_accounts/host/v1/tx.proto | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto index 26eb40ad612..24b4a73d7a0 100644 --- a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto +++ b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto @@ -15,8 +15,8 @@ service Msg { // UpdateParams defines a rpc handler for MsgUpdateParams. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); - // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. - rpc ModuleSafeQuery(MsgModuleSafeQuery) returns (MsgModuleSafeQueryResponse); + // ModuleQuerySafe defines a rpc handler for MsgModuleQuerySafe. + rpc ModuleQuerySafe(MsgModuleQuerySafe) returns (MsgModuleQuerySafeResponse); } // MsgUpdateParams defines the payload for Msg/UpdateParams @@ -37,8 +37,8 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response for Msg/UpdateParams message MsgUpdateParamsResponse {} -// MsgModuleSafeQuery defines the payload for Msg/ModuleSafeQuery -message MsgModuleSafeQuery { +// MsgModuleQuerySafe defines the payload for Msg/ModuleQuerySafe +message MsgModuleQuerySafe { option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.goproto_getters) = false; @@ -46,12 +46,12 @@ message MsgModuleSafeQuery { // signer address string signer = 1; - // queries defines the module safe queries to execute. - repeated QueryRequest queries = 2; + // requests defines the module safe queries to execute. + repeated QueryRequest requests = 2; } -// MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery -message MsgModuleSafeQueryResponse { +// MsgModuleQuerySafeResponse defines the response for Msg/ModuleQuerySafe +message MsgModuleQuerySafeResponse { // protobuf encoded responses for each query - repeated bytes results = 1; + repeated bytes responses = 1; } From 322734e0c41af8adab4b5efc12b22c11124c8dea Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:43:25 +0100 Subject: [PATCH 11/60] imp: ran 'make proto-all' --- .../host/types/tx.pb.go | 227 +++++++++--------- 1 file changed, 113 insertions(+), 114 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/tx.pb.go b/modules/apps/27-interchain-accounts/host/types/tx.pb.go index 1a55721381b..a834ff5ac1c 100644 --- a/modules/apps/27-interchain-accounts/host/types/tx.pb.go +++ b/modules/apps/27-interchain-accounts/host/types/tx.pb.go @@ -109,26 +109,26 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -// MsgModuleSafeQuery defines the payload for Msg/ModuleSafeQuery -type MsgModuleSafeQuery struct { +// MsgModuleQuerySafe defines the payload for Msg/ModuleQuerySafe +type MsgModuleQuerySafe struct { // signer address Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - // queries defines the module safe queries to execute. - Queries []*QueryRequest `protobuf:"bytes,2,rep,name=queries,proto3" json:"queries,omitempty"` + // requests defines the module safe queries to execute. + Requests []*QueryRequest `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests,omitempty"` } -func (m *MsgModuleSafeQuery) Reset() { *m = MsgModuleSafeQuery{} } -func (m *MsgModuleSafeQuery) String() string { return proto.CompactTextString(m) } -func (*MsgModuleSafeQuery) ProtoMessage() {} -func (*MsgModuleSafeQuery) Descriptor() ([]byte, []int) { +func (m *MsgModuleQuerySafe) Reset() { *m = MsgModuleQuerySafe{} } +func (m *MsgModuleQuerySafe) String() string { return proto.CompactTextString(m) } +func (*MsgModuleQuerySafe) ProtoMessage() {} +func (*MsgModuleQuerySafe) Descriptor() ([]byte, []int) { return fileDescriptor_fa437afde7f1e7ae, []int{2} } -func (m *MsgModuleSafeQuery) XXX_Unmarshal(b []byte) error { +func (m *MsgModuleQuerySafe) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgModuleSafeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgModuleQuerySafe) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgModuleSafeQuery.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgModuleQuerySafe.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -138,36 +138,36 @@ func (m *MsgModuleSafeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgModuleSafeQuery) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgModuleSafeQuery.Merge(m, src) +func (m *MsgModuleQuerySafe) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgModuleQuerySafe.Merge(m, src) } -func (m *MsgModuleSafeQuery) XXX_Size() int { +func (m *MsgModuleQuerySafe) XXX_Size() int { return m.Size() } -func (m *MsgModuleSafeQuery) XXX_DiscardUnknown() { - xxx_messageInfo_MsgModuleSafeQuery.DiscardUnknown(m) +func (m *MsgModuleQuerySafe) XXX_DiscardUnknown() { + xxx_messageInfo_MsgModuleQuerySafe.DiscardUnknown(m) } -var xxx_messageInfo_MsgModuleSafeQuery proto.InternalMessageInfo +var xxx_messageInfo_MsgModuleQuerySafe proto.InternalMessageInfo -// MsgModuleSafeQueryResponse defines the response for Msg/ModuleSafeQuery -type MsgModuleSafeQueryResponse struct { +// MsgModuleQuerySafeResponse defines the response for Msg/ModuleQuerySafe +type MsgModuleQuerySafeResponse struct { // protobuf encoded responses for each query - Results [][]byte `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` + Responses [][]byte `protobuf:"bytes,1,rep,name=responses,proto3" json:"responses,omitempty"` } -func (m *MsgModuleSafeQueryResponse) Reset() { *m = MsgModuleSafeQueryResponse{} } -func (m *MsgModuleSafeQueryResponse) String() string { return proto.CompactTextString(m) } -func (*MsgModuleSafeQueryResponse) ProtoMessage() {} -func (*MsgModuleSafeQueryResponse) Descriptor() ([]byte, []int) { +func (m *MsgModuleQuerySafeResponse) Reset() { *m = MsgModuleQuerySafeResponse{} } +func (m *MsgModuleQuerySafeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgModuleQuerySafeResponse) ProtoMessage() {} +func (*MsgModuleQuerySafeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_fa437afde7f1e7ae, []int{3} } -func (m *MsgModuleSafeQueryResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgModuleQuerySafeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgModuleSafeQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgModuleQuerySafeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgModuleSafeQueryResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgModuleQuerySafeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -177,21 +177,21 @@ func (m *MsgModuleSafeQueryResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgModuleSafeQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgModuleSafeQueryResponse.Merge(m, src) +func (m *MsgModuleQuerySafeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgModuleQuerySafeResponse.Merge(m, src) } -func (m *MsgModuleSafeQueryResponse) XXX_Size() int { +func (m *MsgModuleQuerySafeResponse) XXX_Size() int { return m.Size() } -func (m *MsgModuleSafeQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgModuleSafeQueryResponse.DiscardUnknown(m) +func (m *MsgModuleQuerySafeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgModuleQuerySafeResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgModuleSafeQueryResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgModuleQuerySafeResponse proto.InternalMessageInfo -func (m *MsgModuleSafeQueryResponse) GetResults() [][]byte { +func (m *MsgModuleQuerySafeResponse) GetResponses() [][]byte { if m != nil { - return m.Results + return m.Responses } return nil } @@ -199,8 +199,8 @@ func (m *MsgModuleSafeQueryResponse) GetResults() [][]byte { func init() { proto.RegisterType((*MsgUpdateParams)(nil), "ibc.applications.interchain_accounts.host.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "ibc.applications.interchain_accounts.host.v1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgModuleSafeQuery)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleSafeQuery") - proto.RegisterType((*MsgModuleSafeQueryResponse)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleSafeQueryResponse") + proto.RegisterType((*MsgModuleQuerySafe)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafe") + proto.RegisterType((*MsgModuleQuerySafeResponse)(nil), "ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafeResponse") } func init() { @@ -208,36 +208,35 @@ func init() { } var fileDescriptor_fa437afde7f1e7ae = []byte{ - // 449 bytes of a gzipped FileDescriptorProto + // 447 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0x5d, 0xdd, 0xe2, 0xb4, 0x50, 0x08, 0x62, 0x63, 0x0e, 0xe9, 0xb2, 0xa7, 0x50, - 0xdc, 0x19, 0x1a, 0xff, 0x54, 0x0a, 0x82, 0x14, 0x04, 0x11, 0x02, 0x1a, 0xf5, 0xe2, 0x45, 0x26, - 0xb3, 0xe3, 0xec, 0xc0, 0x26, 0x93, 0xe6, 0x9d, 0x2c, 0xf6, 0x26, 0x9e, 0x3c, 0x89, 0xa0, 0x57, - 0xc1, 0x8f, 0xd0, 0xef, 0xe0, 0xa5, 0xc7, 0x1e, 0x3d, 0x89, 0xec, 0x1e, 0xfa, 0x35, 0x24, 0x69, - 0xa2, 0x36, 0xb5, 0x87, 0xb0, 0xb7, 0x0c, 0xc9, 0xf3, 0x7b, 0x7f, 0x79, 0x99, 0x07, 0xdf, 0x55, - 0x31, 0xa7, 0x2c, 0xcb, 0xa6, 0x8a, 0x33, 0xa3, 0x74, 0x0a, 0x54, 0xa5, 0x46, 0xe4, 0x7c, 0xc2, - 0x54, 0xfa, 0x9a, 0x71, 0xae, 0x8b, 0xd4, 0x00, 0x9d, 0x68, 0x30, 0x74, 0xb6, 0x43, 0xcd, 0x5b, - 0x92, 0xe5, 0xda, 0x68, 0xfb, 0x96, 0x8a, 0x39, 0xf9, 0x37, 0x46, 0xfe, 0x13, 0x23, 0x65, 0x8c, - 0xcc, 0x76, 0xdc, 0xeb, 0x52, 0x4b, 0x5d, 0x05, 0x69, 0xf9, 0x74, 0xc6, 0x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39, + 0x7b, 0x23, 0xfe, 0xab, 0xfb, 0x12, 0x5f, 0xcb, 0xc4, 0xdb, 0x5c, 0x80, 0x29, 0x84, 0x5b, 0xde, + 0x96, 0x3f, 0x68, 0x26, 0x5c, 0x8e, 0x08, 0x67, 0x88, 0x70, 0xce, 0x5a, 0x55, 0x1e, 0x60, 0x67, + 0x55, 0xeb, 0xd2, 0xda, 0xbe, 0x85, 0x37, 0xb3, 0x6a, 0x0d, 0x1d, 0xd4, 0x6d, 0x79, 0xdb, 0xe1, + 0xe2, 0x86, 0xff, 0x63, 0x03, 0xb7, 0x02, 0x90, 0xf6, 0x17, 0x84, 0xb7, 0x97, 0x7e, 0xc2, 0x83, + 0x66, 0xae, 0xb5, 0x3d, 0x73, 0x1e, 0xad, 0x15, 0x9f, 0xcb, 0x7f, 0x2b, 0x8e, 0x47, 0x6d, 0xbf, + 0x1f, 0x36, 0x46, 0xd7, 0x08, 0xce, 0xe3, 0x75, 0x09, 0x97, 0x7e, 0xce, 0xd5, 0xf7, 0x17, 0xa7, + 0xfb, 0xe8, 0x68, 0x78, 0x36, 0x71, 0xd1, 0xf9, 0xc4, 0x45, 0xbf, 0x27, 0x2e, 0xfa, 0x3c, 0x75, + 0xad, 0xf3, 0xa9, 0x6b, 0xfd, 0x9c, 0xba, 0xd6, 0xab, 0x27, 0x52, 0x99, 0x51, 0x1e, 0x11, 0xae, + 0x63, 0x5a, 0x95, 0x47, 0x45, 0xbc, 0x2f, 0x35, 0x1d, 0xdf, 0xa7, 0x71, 0x49, 0x85, 0xa2, 0x38, + 0x40, 0xfd, 0xc3, 0xfe, 0x42, 0xa2, 0xbf, 0xdc, 0x19, 0x73, 0x92, 0x0a, 0x88, 0xda, 0x65, 0x65, + 0xee, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xf6, 0x20, 0xb2, 0x01, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -254,8 +253,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // UpdateParams defines a rpc handler for MsgUpdateParams. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) - // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. - ModuleSafeQuery(ctx context.Context, in *MsgModuleSafeQuery, opts ...grpc.CallOption) (*MsgModuleSafeQueryResponse, error) + // ModuleQuerySafe defines a rpc handler for MsgModuleQuerySafe. + ModuleQuerySafe(ctx context.Context, in *MsgModuleQuerySafe, opts ...grpc.CallOption) (*MsgModuleQuerySafeResponse, error) } type msgClient struct { @@ -275,9 +274,9 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } -func (c *msgClient) ModuleSafeQuery(ctx context.Context, in *MsgModuleSafeQuery, opts ...grpc.CallOption) (*MsgModuleSafeQueryResponse, error) { - out := new(MsgModuleSafeQueryResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleSafeQuery", in, out, opts...) +func (c *msgClient) ModuleQuerySafe(ctx context.Context, in *MsgModuleQuerySafe, opts ...grpc.CallOption) (*MsgModuleQuerySafeResponse, error) { + out := new(MsgModuleQuerySafeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleQuerySafe", in, out, opts...) if err != nil { return nil, err } @@ -288,8 +287,8 @@ func (c *msgClient) ModuleSafeQuery(ctx context.Context, in *MsgModuleSafeQuery, type MsgServer interface { // UpdateParams defines a rpc handler for MsgUpdateParams. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) - // ModuleSafeQuery defines a rpc handler for MsgModuleSafeQuery. - ModuleSafeQuery(context.Context, *MsgModuleSafeQuery) (*MsgModuleSafeQueryResponse, error) + // ModuleQuerySafe defines a rpc handler for MsgModuleQuerySafe. + ModuleQuerySafe(context.Context, *MsgModuleQuerySafe) (*MsgModuleQuerySafeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -299,8 +298,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } -func (*UnimplementedMsgServer) ModuleSafeQuery(ctx context.Context, req *MsgModuleSafeQuery) (*MsgModuleSafeQueryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ModuleSafeQuery not implemented") +func (*UnimplementedMsgServer) ModuleQuerySafe(ctx context.Context, req *MsgModuleQuerySafe) (*MsgModuleQuerySafeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ModuleQuerySafe not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -325,20 +324,20 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Msg_ModuleSafeQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgModuleSafeQuery) +func _Msg_ModuleQuerySafe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgModuleQuerySafe) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).ModuleSafeQuery(ctx, in) + return srv.(MsgServer).ModuleQuerySafe(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleSafeQuery", + FullMethod: "/ibc.applications.interchain_accounts.host.v1.Msg/ModuleQuerySafe", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ModuleSafeQuery(ctx, req.(*MsgModuleSafeQuery)) + return srv.(MsgServer).ModuleQuerySafe(ctx, req.(*MsgModuleQuerySafe)) } return interceptor(ctx, in, info, handler) } @@ -352,8 +351,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdateParams_Handler, }, { - MethodName: "ModuleSafeQuery", - Handler: _Msg_ModuleSafeQuery_Handler, + MethodName: "ModuleQuerySafe", + Handler: _Msg_ModuleQuerySafe_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -423,7 +422,7 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgModuleSafeQuery) Marshal() (dAtA []byte, err error) { +func (m *MsgModuleQuerySafe) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -433,20 +432,20 @@ func (m *MsgModuleSafeQuery) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgModuleSafeQuery) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgModuleQuerySafe) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgModuleSafeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgModuleQuerySafe) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Queries) > 0 { - for iNdEx := len(m.Queries) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Queries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -467,7 +466,7 @@ func (m *MsgModuleSafeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgModuleSafeQueryResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgModuleQuerySafeResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -477,21 +476,21 @@ func (m *MsgModuleSafeQueryResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgModuleSafeQueryResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgModuleQuerySafeResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgModuleSafeQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgModuleQuerySafeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Results) > 0 { - for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Results[iNdEx]) - copy(dAtA[i:], m.Results[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Results[iNdEx]))) + if len(m.Responses) > 0 { + for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Responses[iNdEx]) + copy(dAtA[i:], m.Responses[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Responses[iNdEx]))) i-- dAtA[i] = 0xa } @@ -534,7 +533,7 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } -func (m *MsgModuleSafeQuery) Size() (n int) { +func (m *MsgModuleQuerySafe) Size() (n int) { if m == nil { return 0 } @@ -544,8 +543,8 @@ func (m *MsgModuleSafeQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Queries) > 0 { - for _, e := range m.Queries { + if len(m.Requests) > 0 { + for _, e := range m.Requests { l = e.Size() n += 1 + l + sovTx(uint64(l)) } @@ -553,14 +552,14 @@ func (m *MsgModuleSafeQuery) Size() (n int) { return n } -func (m *MsgModuleSafeQueryResponse) Size() (n int) { +func (m *MsgModuleQuerySafeResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Results) > 0 { - for _, b := range m.Results { + if len(m.Responses) > 0 { + for _, b := range m.Responses { l = len(b) n += 1 + l + sovTx(uint64(l)) } @@ -739,7 +738,7 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { +func (m *MsgModuleQuerySafe) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -762,10 +761,10 @@ func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgModuleSafeQuery: wiretype end group for non-group") + return fmt.Errorf("proto: MsgModuleQuerySafe: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgModuleSafeQuery: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgModuleQuerySafe: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -802,7 +801,7 @@ func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Queries", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -829,8 +828,8 @@ func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Queries = append(m.Queries, &QueryRequest{}) - if err := m.Queries[len(m.Queries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Requests = append(m.Requests, &QueryRequest{}) + if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -855,7 +854,7 @@ func (m *MsgModuleSafeQuery) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgModuleSafeQueryResponse) Unmarshal(dAtA []byte) error { +func (m *MsgModuleQuerySafeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -878,15 +877,15 @@ func (m *MsgModuleSafeQueryResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgModuleSafeQueryResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgModuleQuerySafeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgModuleSafeQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgModuleQuerySafeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -913,8 +912,8 @@ func (m *MsgModuleSafeQueryResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Results = append(m.Results, make([]byte, postIndex-iNdEx)) - copy(m.Results[len(m.Results)-1], dAtA[iNdEx:postIndex]) + m.Responses = append(m.Responses, make([]byte, postIndex-iNdEx)) + copy(m.Responses[len(m.Responses)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From 0195490e01b5961b61290510481841c2aea133bc Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:46:58 +0100 Subject: [PATCH 12/60] fix: compiler errors --- .../host/keeper/msg_server.go | 13 ++++++------- .../27-interchain-accounts/host/types/msgs.go | 18 +++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 5b01e7917de..ad770c2739d 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -25,14 +25,13 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } -// UpdateParams updates the host submodule's params. -func (m msgServer) ModuleSafeQuery(goCtx context.Context, msg *types.MsgModuleSafeQuery) (*types.MsgModuleSafeQueryResponse, error) { - // sender is not used in this handler - +// ModuleQuerySafe routes the queries to the keeper's query router if they are module_query_safe. +// This handler doesn't use the signer. +func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQuerySafe) (*types.MsgModuleQuerySafeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - var responses = make([][]byte, len(msg.Queries)) - for i, query := range msg.Queries { + var responses = make([][]byte, len(msg.Requests)) + for i, query := range msg.Requests { route := m.queryRouter.Route(query.Path) if route == nil { return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no route to query: %s", query.Path) @@ -52,7 +51,7 @@ func (m msgServer) ModuleSafeQuery(goCtx context.Context, msg *types.MsgModuleSa responses[i] = res.Value } - return &types.MsgModuleSafeQueryResponse{Results: responses}, nil + return &types.MsgModuleQuerySafeResponse{Responses: responses}, nil } // UpdateParams updates the host submodule's params. diff --git a/modules/apps/27-interchain-accounts/host/types/msgs.go b/modules/apps/27-interchain-accounts/host/types/msgs.go index 83d2d50a00f..092ff1df850 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs.go @@ -12,8 +12,8 @@ var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) - _ sdk.Msg = (*MsgModuleSafeQuery)(nil) - _ sdk.HasValidateBasic = (*MsgModuleSafeQuery)(nil) + _ sdk.Msg = (*MsgModuleQuerySafe)(nil) + _ sdk.HasValidateBasic = (*MsgModuleQuerySafe)(nil) ) // NewMsgUpdateParams creates a new MsgUpdateParams instance @@ -34,22 +34,22 @@ func (msg MsgUpdateParams) ValidateBasic() error { return msg.Params.Validate() } -// NewMsgModuleSafeQuery creates a new MsgModuleSafeQuery instance -func NewMsgModuleSafeQuery(signer string, queries []*QueryRequest) *MsgModuleSafeQuery { - return &MsgModuleSafeQuery{ - Signer: signer, - Queries: queries, +// NewMsgModuleQuerySafe creates a new MsgModuleQuerySafe instance +func NewMsgModuleQuerySafe(signer string, requests []*QueryRequest) *MsgModuleQuerySafe { + return &MsgModuleQuerySafe{ + Signer: signer, + Requests: requests, } } // ValidateBasic implements sdk.HasValidateBasic -func (msg MsgModuleSafeQuery) ValidateBasic() error { +func (msg MsgModuleQuerySafe) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) } - if len(msg.Queries) == 0 { + if len(msg.Requests) == 0 { return errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no queries provided") } From 915d51553778f034dd76605f7ce1d659f2fde241 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 29 Jan 2024 16:47:10 +0100 Subject: [PATCH 13/60] imp: ran gofumpt --- modules/apps/27-interchain-accounts/host/keeper/msg_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index ad770c2739d..f5e31107901 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -30,7 +30,7 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQuerySafe) (*types.MsgModuleQuerySafeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - var responses = make([][]byte, len(msg.Requests)) + responses := make([][]byte, len(msg.Requests)) for i, query := range msg.Requests { route := m.queryRouter.Route(query.Path) if route == nil { From 5665d04b596b6b09c734967037da0338a1e2ae23 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 30 Jan 2024 18:15:43 +0100 Subject: [PATCH 14/60] feat: tests passing --- .../host/types/query.go | 50 +++++++++++++++++++ .../host/types/query_test.go | 43 ++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 modules/apps/27-interchain-accounts/host/types/query.go create mode 100644 modules/apps/27-interchain-accounts/host/types/query_test.go diff --git a/modules/apps/27-interchain-accounts/host/types/query.go b/modules/apps/27-interchain-accounts/host/types/query.go new file mode 100644 index 00000000000..ad0d69ec08f --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/types/query.go @@ -0,0 +1,50 @@ +package types + +import ( + gogoproto "github.com/cosmos/gogoproto/proto" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + queryv1 "cosmossdk.io/api/cosmos/query/v1" + errorsmod "cosmossdk.io/errors" + + ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" +) + +// isModuleQuerySafe checks whether the service has the +// `(cosmos.query.v1.module_query_safe) = true` proto annotation. +func isModuleQuerySafe(sd protoreflect.MethodDescriptor) bool { + ext := proto.GetExtension(sd.Options(), queryv1.E_ModuleQuerySafe) + isModuleQuerySafe, ok := ext.(bool) + if !ok { + return false + } + + return isModuleQuerySafe +} + +// IsModuleSafeQuery checks whether the method with the given methodPath has the +// `(cosmos.query.v1.module_query_safe) = true` proto annotation. +func IsModuleQuerySafe(methodPath string) (bool, error) { + protoFiles, err := gogoproto.MergedRegistry() + if err != nil { + // This should never happen + panic(err) + } + if protoFiles == nil { + protoFiles = protoregistry.GlobalFiles + } + + fullName := protoreflect.FullName(methodPath) + if !fullName.IsValid() { + return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid query method path") + } + + serviceDesc, err := protoFiles.FindDescriptorByName(fullName) + if err != nil { + return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find descriptor") + } + + return isModuleQuerySafe(serviceDesc.(protoreflect.MethodDescriptor)), nil +} diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go new file mode 100644 index 00000000000..94e83818b2b --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/types/query_test.go @@ -0,0 +1,43 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" +) + +func TestIsModuleQuerySafe(t *testing.T) { + testCases := []struct { + name string + servicePath string + isModuleQuerySafe bool + expErr error + }{ + { + "success", + "cosmos.bank.v1beta1.Query.Balance", + true, + nil, + }, + { + "failure", + "ibc.applications.transfer.v1.Query.DenomTraces", + false, + nil, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + _ = ibctesting.NewCoordinator(t, 1) + + res, err := types.IsModuleQuerySafe(tc.servicePath) + require.Equal(t, tc.isModuleQuerySafe, res) + require.Equal(t, tc.expErr, err) + }) + } +} From a8fa43ac25e675fd6d456863d776df241afc4e92 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 30 Jan 2024 18:23:37 +0100 Subject: [PATCH 15/60] feat: tests improved --- .../host/types/query_test.go | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go index 94e83818b2b..409dd4471a1 100644 --- a/modules/apps/27-interchain-accounts/host/types/query_test.go +++ b/modules/apps/27-interchain-accounts/host/types/query_test.go @@ -5,7 +5,10 @@ import ( "github.com/stretchr/testify/require" + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -17,17 +20,29 @@ func TestIsModuleQuerySafe(t *testing.T) { expErr error }{ { - "success", + "success: module query safe", "cosmos.bank.v1beta1.Query.Balance", true, nil, }, { - "failure", + "success: not module query safe", "ibc.applications.transfer.v1.Query.DenomTraces", false, nil, }, + { + "failure: invalid method path", + "invalid", + false, + errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid query method path"), + }, + { + "failure: service path not found", + "invalid.Query.Balance", + false, + errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find descriptor"), + }, } for _, tc := range testCases { @@ -37,7 +52,7 @@ func TestIsModuleQuerySafe(t *testing.T) { res, err := types.IsModuleQuerySafe(tc.servicePath) require.Equal(t, tc.isModuleQuerySafe, res) - require.Equal(t, tc.expErr, err) + require.ErrorIs(t, err, tc.expErr) }) } } From 330bd2498902094d718bc52f51c7921a9aeb8557 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 30 Jan 2024 18:29:25 +0100 Subject: [PATCH 16/60] test: removed unneeded code --- modules/apps/27-interchain-accounts/host/types/query_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go index 409dd4471a1..50bdd4a497c 100644 --- a/modules/apps/27-interchain-accounts/host/types/query_test.go +++ b/modules/apps/27-interchain-accounts/host/types/query_test.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" - ibctesting "github.com/cosmos/ibc-go/v8/testing" ) func TestIsModuleQuerySafe(t *testing.T) { @@ -48,8 +47,6 @@ func TestIsModuleQuerySafe(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - _ = ibctesting.NewCoordinator(t, 1) - res, err := types.IsModuleQuerySafe(tc.servicePath) require.Equal(t, tc.isModuleQuerySafe, res) require.ErrorIs(t, err, tc.expErr) From f4ac33703a0402bd1dd53aa128bf39d75a2d6b98 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 31 Jan 2024 11:17:48 +0100 Subject: [PATCH 17/60] imp: improved 'IsModuleSafe' function --- .../host/types/query.go | 54 ++++++++++++++----- .../host/types/query_test.go | 18 ++++--- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/query.go b/modules/apps/27-interchain-accounts/host/types/query.go index ad0d69ec08f..e5e0c045783 100644 --- a/modules/apps/27-interchain-accounts/host/types/query.go +++ b/modules/apps/27-interchain-accounts/host/types/query.go @@ -1,6 +1,9 @@ package types import ( + "fmt" + "strings" + gogoproto "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" @@ -12,21 +15,17 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) -// isModuleQuerySafe checks whether the service has the +// IsModuleSafeQuery checks whether the method with the given grpcServicePath has the // `(cosmos.query.v1.module_query_safe) = true` proto annotation. -func isModuleQuerySafe(sd protoreflect.MethodDescriptor) bool { - ext := proto.GetExtension(sd.Options(), queryv1.E_ModuleQuerySafe) - isModuleQuerySafe, ok := ext.(bool) - if !ok { - return false +// +// For example, `/cosmos.bank.v1beta1.Query/Balance` is module safe, but +// `/cosmos.reflection.v1.ReflectionService/FileDescriptors` is not. +func IsModuleQuerySafe(grpcServicePath string) (bool, error) { + methodPath, err := toMethodPath(grpcServicePath) + if err != nil { + return false, err } - return isModuleQuerySafe -} - -// IsModuleSafeQuery checks whether the method with the given methodPath has the -// `(cosmos.query.v1.module_query_safe) = true` proto annotation. -func IsModuleQuerySafe(methodPath string) (bool, error) { protoFiles, err := gogoproto.MergedRegistry() if err != nil { // This should never happen @@ -38,13 +37,40 @@ func IsModuleQuerySafe(methodPath string) (bool, error) { fullName := protoreflect.FullName(methodPath) if !fullName.IsValid() { - return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid query method path") + return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("invalid method path: %s", methodPath)) } serviceDesc, err := protoFiles.FindDescriptorByName(fullName) if err != nil { - return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find descriptor") + return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("failed to find the descriptor: %s", methodPath)) } return isModuleQuerySafe(serviceDesc.(protoreflect.MethodDescriptor)), nil } + +// isModuleQuerySafe checks whether the service has the +// `(cosmos.query.v1.module_query_safe) = true` proto annotation. +func isModuleQuerySafe(sd protoreflect.MethodDescriptor) bool { + ext := proto.GetExtension(sd.Options(), queryv1.E_ModuleQuerySafe) + isModuleQuerySafe, ok := ext.(bool) + if !ok { + return false + } + + return isModuleQuerySafe +} + +// toMethodPath converts a gRPC service path to a protobuf method path. +// +// For example, `/cosmos.bank.v1beta1.Query/Balance` becomes `cosmos.bank.v1beta1.Query.Balance`. +func toMethodPath(grpcServicePath string) (string, error) { + if !strings.HasPrefix(grpcServicePath, "/") { + return "", errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("invalid gRPC service path: %s", grpcServicePath)) + } + + // Remove the leading slash + grpcServicePath = grpcServicePath[1:] + + // Convert the remaining slashes to dots + return strings.ReplaceAll(grpcServicePath, "/", "."), nil +} diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go index 50bdd4a497c..f24d5806c7a 100644 --- a/modules/apps/27-interchain-accounts/host/types/query_test.go +++ b/modules/apps/27-interchain-accounts/host/types/query_test.go @@ -20,27 +20,33 @@ func TestIsModuleQuerySafe(t *testing.T) { }{ { "success: module query safe", - "cosmos.bank.v1beta1.Query.Balance", + "/cosmos.bank.v1beta1.Query/Balance", true, nil, }, { "success: not module query safe", - "ibc.applications.transfer.v1.Query.DenomTraces", + "/ibc.applications.transfer.v1.Query/DenomTraces", false, nil, }, { - "failure: invalid method path", + "failure: invalid service path", "invalid", false, - errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid query method path"), + errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid gRPC service path: invalid"), + }, + { + "failure: invalid method path", + "/invalid", + false, + errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid method path: invalid"), }, { "failure: service path not found", - "invalid.Query.Balance", + "/invalid.Query/Balance", false, - errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find descriptor"), + errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find the descriptor: invalid.Query.Balance"), }, } From 67a1870be1717ee838b862ad4686c10dfc7f4640 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 31 Jan 2024 11:22:14 +0100 Subject: [PATCH 18/60] imp: added IsModuleQuerySafe to msg_server --- .../apps/27-interchain-accounts/host/keeper/msg_server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index f5e31107901..5cdcc859331 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -32,6 +32,14 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu responses := make([][]byte, len(msg.Requests)) for i, query := range msg.Requests { + isModuleQuerySafe, err := types.IsModuleQuerySafe(query.Path) + if err != nil { + return nil, err + } + if !isModuleQuerySafe { + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "not module query safe: %s", query.Path) + } + route := m.queryRouter.Route(query.Path) if route == nil { return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "no route to query: %s", query.Path) From e1853fb1752e1745181cf63056095ef55a749b9b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 31 Jan 2024 12:47:23 +0100 Subject: [PATCH 19/60] imp: added more test cases --- .../host/keeper/msg_server_test.go | 147 ++++++++++++++++++ .../08-wasm/testing/simapp/app.go | 2 +- 2 files changed, 148 insertions(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go index 4cc47f781d2..ecb0ba26b9e 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go @@ -1,10 +1,157 @@ package keeper_test import ( + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +func (suite *KeeperTestSuite) TestModuleQuerySafe() { + var ( + msg *types.MsgModuleQuerySafe + expResponses [][]byte + ) + testCases := []struct { + name string + malleate func() + expErr error + }{ + { + "success", + func() { + queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + suite.Require().NoError(err) + + queryReq := types.QueryRequest{ + Path: "/cosmos.bank.v1beta1.Query/Balance", + Data: queryBz, + } + + msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq}) + + balance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + + expResp := banktypes.QueryBalanceResponse{Balance: &balance} + expRespBz, err := expResp.Marshal() + suite.Require().NoError(err) + + expResponses = [][]byte{expRespBz} + }, + nil, + }, + { + "success: multiple queries", + func() { + queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + suite.Require().NoError(err) + + queryReq := types.QueryRequest{ + Path: "/cosmos.bank.v1beta1.Query/Balance", + Data: queryBz, + } + + paramsQuery := stakingtypes.QueryParamsRequest{} + paramsQueryBz, err := paramsQuery.Marshal() + suite.Require().NoError(err) + + paramsQueryReq := types.QueryRequest{ + Path: "/cosmos.staking.v1beta1.Query/Params", + Data: paramsQueryBz, + } + + msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq, ¶msQueryReq}) + + balance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + + expResp := banktypes.QueryBalanceResponse{Balance: &balance} + expRespBz, err := expResp.Marshal() + suite.Require().NoError(err) + + params, err := suite.chainA.GetSimApp().StakingKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().NoError(err) + expParamsResp := stakingtypes.QueryParamsResponse{Params: params} + expParamsRespBz, err := expParamsResp.Marshal() + suite.Require().NoError(err) + + expResponses = [][]byte{expRespBz, expParamsRespBz} + }, + nil, + }, + { + "failure: not module query safe", + func() { + queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + suite.Require().NoError(err) + + queryReq := types.QueryRequest{ + Path: "/cosmos.bank.v1beta1.Query/Balance", + Data: queryBz, + } + + paramsQuery := transfertypes.QueryParamsRequest{} + paramsQueryBz, err := paramsQuery.Marshal() + suite.Require().NoError(err) + + paramsQueryReq := types.QueryRequest{ + Path: "/ibc.applications.transfer.v1.Query/Params", + Data: paramsQueryBz, + } + + msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq, ¶msQueryReq}) + }, + ibcerrors.ErrInvalidRequest, + }, + { + "failure: invalid query path", + func() { + queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + suite.Require().NoError(err) + + queryReq := types.QueryRequest{ + Path: "/cosmos.invalid.Query/Invalid", + Data: queryBz, + } + + msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq}) + }, + ibcerrors.ErrInvalidRequest, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + // reset + msg = nil + expResponses = nil + + tc.malleate() + + ctx := suite.chainA.GetContext() + msgServer := keeper.NewMsgServerImpl(&suite.chainA.GetSimApp().ICAHostKeeper) + res, err := msgServer.ModuleQuerySafe(ctx, msg) + + if tc.expErr == nil { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + suite.Require().ElementsMatch(expResponses, res.Responses) + } else { + suite.Require().ErrorIs(err, tc.expErr) + suite.Require().Nil(res) + } + }) + } +} + func (suite *KeeperTestSuite) TestUpdateParams() { testCases := []struct { name string diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 830ca619957..87416f9a529 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -503,7 +503,7 @@ func NewSimApp( app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.GRPCQueryRouter(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Create IBC Router From 578d006d9d2b1122c7aa00d651ff3461bbd2d6ad Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 31 Jan 2024 13:09:19 +0100 Subject: [PATCH 20/60] fix: callbacks compiler --- modules/apps/callbacks/testing/simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 56cce8c58d2..bfe0b7d825c 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -464,7 +464,7 @@ func NewSimApp( app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.GRPCQueryRouter(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Create IBC Router From 53cb24e249e8fdbc9fbdd495c5fa5d9b16180632 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 11 Mar 2024 13:05:04 +0700 Subject: [PATCH 21/60] fix: non determinancy issues --- .../host/keeper/msg_server.go | 8 +++----- .../host/types/query.go | 20 ++++++++++++++----- .../host/types/query_test.go | 13 +++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 5cdcc859331..67daf84ce48 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -29,15 +29,13 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { // This handler doesn't use the signer. func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQuerySafe) (*types.MsgModuleQuerySafeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + logger := m.Logger(ctx) responses := make([][]byte, len(msg.Requests)) for i, query := range msg.Requests { - isModuleQuerySafe, err := types.IsModuleQuerySafe(query.Path) - if err != nil { - return nil, err - } + isModuleQuerySafe := types.IsModuleQuerySafe(logger, query.Path) if !isModuleQuerySafe { - return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "not module query safe: %s", query.Path) + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot verify module query safe: %s", query.Path) } route := m.queryRouter.Route(query.Path) diff --git a/modules/apps/27-interchain-accounts/host/types/query.go b/modules/apps/27-interchain-accounts/host/types/query.go index e5e0c045783..02d742de194 100644 --- a/modules/apps/27-interchain-accounts/host/types/query.go +++ b/modules/apps/27-interchain-accounts/host/types/query.go @@ -11,6 +11,7 @@ import ( queryv1 "cosmossdk.io/api/cosmos/query/v1" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) @@ -20,10 +21,11 @@ import ( // // For example, `/cosmos.bank.v1beta1.Query/Balance` is module safe, but // `/cosmos.reflection.v1.ReflectionService/FileDescriptors` is not. -func IsModuleQuerySafe(grpcServicePath string) (bool, error) { +func IsModuleQuerySafe(logger log.Logger, grpcServicePath string) bool { methodPath, err := toMethodPath(grpcServicePath) if err != nil { - return false, err + logger.Debug("failed to convert gRPC service path to method path", "grpcServicePath", grpcServicePath, "err", err) + return false } protoFiles, err := gogoproto.MergedRegistry() @@ -37,15 +39,23 @@ func IsModuleQuerySafe(grpcServicePath string) (bool, error) { fullName := protoreflect.FullName(methodPath) if !fullName.IsValid() { - return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("invalid method path: %s", methodPath)) + logger.Debug("invalid method path", "methodPath", methodPath) + return false } serviceDesc, err := protoFiles.FindDescriptorByName(fullName) if err != nil { - return false, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("failed to find the descriptor: %s", methodPath)) + logger.Debug("failed to find the descriptor", "methodPath", methodPath, "err", err) + return false + } + + methodDesc, ok := serviceDesc.(protoreflect.MethodDescriptor) + if !ok { + logger.Debug("invalid method descriptor", "methodPath", methodPath) + return false } - return isModuleQuerySafe(serviceDesc.(protoreflect.MethodDescriptor)), nil + return isModuleQuerySafe(methodDesc) } // isModuleQuerySafe checks whether the service has the diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go index f24d5806c7a..6dd34f1404f 100644 --- a/modules/apps/27-interchain-accounts/host/types/query_test.go +++ b/modules/apps/27-interchain-accounts/host/types/query_test.go @@ -5,10 +5,9 @@ import ( "github.com/stretchr/testify/require" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) func TestIsModuleQuerySafe(t *testing.T) { @@ -16,46 +15,40 @@ func TestIsModuleQuerySafe(t *testing.T) { name string servicePath string isModuleQuerySafe bool - expErr error }{ { "success: module query safe", "/cosmos.bank.v1beta1.Query/Balance", true, - nil, }, { "success: not module query safe", "/ibc.applications.transfer.v1.Query/DenomTraces", false, - nil, }, { "failure: invalid service path", "invalid", false, - errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid gRPC service path: invalid"), }, { "failure: invalid method path", "/invalid", false, - errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "invalid method path: invalid"), }, { "failure: service path not found", "/invalid.Query/Balance", false, - errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "failed to find the descriptor: invalid.Query.Balance"), }, } for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - res, err := types.IsModuleQuerySafe(tc.servicePath) + logger := log.NewTestLogger(t) + res := types.IsModuleQuerySafe(logger, tc.servicePath) require.Equal(t, tc.isModuleQuerySafe, res) - require.ErrorIs(t, err, tc.expErr) }) } } From cf010ee3ac6691329c5adee467c7553d382b29fc Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 11 Mar 2024 14:18:48 +0700 Subject: [PATCH 22/60] fix: added query msg to codec --- modules/apps/27-interchain-accounts/host/types/codec.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/apps/27-interchain-accounts/host/types/codec.go b/modules/apps/27-interchain-accounts/host/types/codec.go index 8752640e767..710d732573b 100644 --- a/modules/apps/27-interchain-accounts/host/types/codec.go +++ b/modules/apps/27-interchain-accounts/host/types/codec.go @@ -11,6 +11,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgUpdateParams{}, + &MsgModuleQuerySafe{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) From fe541bef80a5a90257ebbd2b348d9a29ee456ac5 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Thu, 14 Mar 2024 20:46:07 +0700 Subject: [PATCH 23/60] imp: whitelist logic added --- .../host/keeper/keeper.go | 48 +++++++++++ .../host/keeper/msg_server.go | 4 +- .../host/types/query.go | 86 ------------------- .../host/types/query_test.go | 54 ------------ 4 files changed, 50 insertions(+), 142 deletions(-) delete mode 100644 modules/apps/27-interchain-accounts/host/types/query.go delete mode 100644 modules/apps/27-interchain-accounts/host/types/query_test.go diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 51170341902..5a32669a6fa 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -5,6 +5,12 @@ import ( "fmt" "strings" + gogoproto "github.com/cosmos/gogoproto/proto" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + msgv1 "cosmossdk.io/api/cosmos/msg/v1" + queryv1 "cosmossdk.io/api/cosmos/query/v1" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -39,6 +45,9 @@ type Keeper struct { msgRouter icatypes.MessageRouter queryRouter icatypes.QueryRouter + // whitelist of module safe queries + mqsWhitelist []string + // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. authority string @@ -71,6 +80,7 @@ func NewKeeper( scopedKeeper: scopedKeeper, msgRouter: msgRouter, queryRouter: queryRouter, + mqsWhitelist: newModuleQuerySafeWhitelist(), authority: authority, } } @@ -258,3 +268,41 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { bz := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), bz) } + +func newModuleQuerySafeWhitelist() []string { + // Create a whitelist of module safe queries + whitelist := []string{} + + protoFiles, err := gogoproto.MergedRegistry() + if err != nil { + panic(err) + } + + protoFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool { + for i := 0; i < fd.Services().Len(); i++ { + // Get the service descriptor + sd := fd.Services().Get(i) + + // Skip services that are annotated with the "cosmos.msg.v1.service" option. + if ext := proto.GetExtension(sd.Options(), msgv1.E_Service); ext != nil && ext.(bool) { + continue + } + + for j := 0; j < sd.Methods().Len(); j++ { + // Get the method descriptor + md := sd.Methods().Get(j) + + // Skip methods that are not annotated with the "cosmos.query.v1.module_query_safe" option. + if ext := proto.GetExtension(md.Options(), queryv1.E_ModuleQuerySafe); ext == nil || !ext.(bool) { + continue + } + + // Add the method to the whitelist + whitelist = append(whitelist, fmt.Sprintf("/%s/%s", sd.FullName(), md.Name())) + } + } + return true + }) + + return whitelist +} diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 67daf84ce48..c0ca8b629f2 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "slices" errorsmod "cosmossdk.io/errors" @@ -29,11 +30,10 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { // This handler doesn't use the signer. func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQuerySafe) (*types.MsgModuleQuerySafeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - logger := m.Logger(ctx) responses := make([][]byte, len(msg.Requests)) for i, query := range msg.Requests { - isModuleQuerySafe := types.IsModuleQuerySafe(logger, query.Path) + isModuleQuerySafe := slices.Contains(m.mqsWhitelist, query.Path) if !isModuleQuerySafe { return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot verify module query safe: %s", query.Path) } diff --git a/modules/apps/27-interchain-accounts/host/types/query.go b/modules/apps/27-interchain-accounts/host/types/query.go deleted file mode 100644 index 02d742de194..00000000000 --- a/modules/apps/27-interchain-accounts/host/types/query.go +++ /dev/null @@ -1,86 +0,0 @@ -package types - -import ( - "fmt" - "strings" - - gogoproto "github.com/cosmos/gogoproto/proto" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - - queryv1 "cosmossdk.io/api/cosmos/query/v1" - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" - - ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" -) - -// IsModuleSafeQuery checks whether the method with the given grpcServicePath has the -// `(cosmos.query.v1.module_query_safe) = true` proto annotation. -// -// For example, `/cosmos.bank.v1beta1.Query/Balance` is module safe, but -// `/cosmos.reflection.v1.ReflectionService/FileDescriptors` is not. -func IsModuleQuerySafe(logger log.Logger, grpcServicePath string) bool { - methodPath, err := toMethodPath(grpcServicePath) - if err != nil { - logger.Debug("failed to convert gRPC service path to method path", "grpcServicePath", grpcServicePath, "err", err) - return false - } - - protoFiles, err := gogoproto.MergedRegistry() - if err != nil { - // This should never happen - panic(err) - } - if protoFiles == nil { - protoFiles = protoregistry.GlobalFiles - } - - fullName := protoreflect.FullName(methodPath) - if !fullName.IsValid() { - logger.Debug("invalid method path", "methodPath", methodPath) - return false - } - - serviceDesc, err := protoFiles.FindDescriptorByName(fullName) - if err != nil { - logger.Debug("failed to find the descriptor", "methodPath", methodPath, "err", err) - return false - } - - methodDesc, ok := serviceDesc.(protoreflect.MethodDescriptor) - if !ok { - logger.Debug("invalid method descriptor", "methodPath", methodPath) - return false - } - - return isModuleQuerySafe(methodDesc) -} - -// isModuleQuerySafe checks whether the service has the -// `(cosmos.query.v1.module_query_safe) = true` proto annotation. -func isModuleQuerySafe(sd protoreflect.MethodDescriptor) bool { - ext := proto.GetExtension(sd.Options(), queryv1.E_ModuleQuerySafe) - isModuleQuerySafe, ok := ext.(bool) - if !ok { - return false - } - - return isModuleQuerySafe -} - -// toMethodPath converts a gRPC service path to a protobuf method path. -// -// For example, `/cosmos.bank.v1beta1.Query/Balance` becomes `cosmos.bank.v1beta1.Query.Balance`. -func toMethodPath(grpcServicePath string) (string, error) { - if !strings.HasPrefix(grpcServicePath, "/") { - return "", errorsmod.Wrap(ibcerrors.ErrInvalidRequest, fmt.Sprintf("invalid gRPC service path: %s", grpcServicePath)) - } - - // Remove the leading slash - grpcServicePath = grpcServicePath[1:] - - // Convert the remaining slashes to dots - return strings.ReplaceAll(grpcServicePath, "/", "."), nil -} diff --git a/modules/apps/27-interchain-accounts/host/types/query_test.go b/modules/apps/27-interchain-accounts/host/types/query_test.go deleted file mode 100644 index 6dd34f1404f..00000000000 --- a/modules/apps/27-interchain-accounts/host/types/query_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "cosmossdk.io/log" - - "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" -) - -func TestIsModuleQuerySafe(t *testing.T) { - testCases := []struct { - name string - servicePath string - isModuleQuerySafe bool - }{ - { - "success: module query safe", - "/cosmos.bank.v1beta1.Query/Balance", - true, - }, - { - "success: not module query safe", - "/ibc.applications.transfer.v1.Query/DenomTraces", - false, - }, - { - "failure: invalid service path", - "invalid", - false, - }, - { - "failure: invalid method path", - "/invalid", - false, - }, - { - "failure: service path not found", - "/invalid.Query/Balance", - false, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - logger := log.NewTestLogger(t) - res := types.IsModuleQuerySafe(logger, tc.servicePath) - require.Equal(t, tc.isModuleQuerySafe, res) - }) - } -} From 4f9dff7317f6d3885b6a803cea68f85132497f24 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 18 Mar 2024 22:00:18 +0700 Subject: [PATCH 24/60] e2e: new test added --- e2e/tests/interchain_accounts/query_test.go | 115 ++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 e2e/tests/interchain_accounts/query_test.go diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go new file mode 100644 index 00000000000..9b3441547d7 --- /dev/null +++ b/e2e/tests/interchain_accounts/query_test.go @@ -0,0 +1,115 @@ +//go:build !test_e2e + +package interchainaccounts + +import ( + "context" + "testing" + + "github.com/cosmos/gogoproto/proto" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + testifysuite "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testvalues" + controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" +) + +func TestInterchainAccountsQueryTestSuite(t *testing.T) { + testifysuite.Run(t, new(InterchainAccountsTestSuite)) +} + +type InterchainAccountsQueryTestSuite struct { + testsuite.E2ETestSuite +} + +func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { + t := s.T() + ctx := context.TODO() + + // setup relayers and connection-0 between two chains + // channel-0 is a transfer channel but it will not be used in this test case + relayer, _ := s.SetupChainsRelayerAndChannel(ctx, nil) + chainA, chainB := s.GetChains() + + // setup 2 accounts: controller account on chain A, a second chain B account. + // host account will be created when the ICA is registered + controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + controllerAddress := controllerAccount.FormattedAddress() + chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) + var hostAccount string + + t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { + // explicitly set the version string because we don't want to use incentivized channels. + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.UNORDERED) + + txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) + s.AssertTxSuccess(txResp) + }) + + t.Run("start relayer", func(t *testing.T) { + s.StartRelayer(relayer) + }) + + t.Run("verify interchain account", func(t *testing.T) { + var err error + hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) + s.Require().NoError(err) + s.Require().NotZero(len(hostAccount)) + + channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) + s.Require().NoError(err) + s.Require().Equal(len(channels), 2) + }) + + t.Run("query via interchain account", func(t *testing.T) { + // the host account need not be funded + t.Run("broadcast query packet", func(t *testing.T) { + balanceQuery := banktypes.NewQueryBalanceRequest(chainBAccount.Address(), chainB.Config().Denom) + queryBz, err := balanceQuery.Marshal() + s.Require().NoError(err) + + queryMsg := icahosttypes.NewMsgModuleQuerySafe(hostAccount, []*icahosttypes.QueryRequest{ + { + Path: "/cosmos.bank.v1beta1.Query/Balance", + Data: queryBz, + }, + }) + + txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, queryMsg) + s.AssertTxSuccess(txResp) + + s.Require().NoError(testutil.WaitForBlocks(ctx, 10, chainA, chainB)) + }) + + t.Run("verify query response", func(t *testing.T) { + // query packet acknowledgement + ackReq := &channeltypes.QueryPacketAcknowledgementRequest{ + PortId: icatypes.HostPortID, + ChannelId: "channel-1", + Sequence: uint64(1), + } + ackResp, err := s.GetChainGRCPClients(chainB).ChannelQueryClient.PacketAcknowledgement(ctx, ackReq) + s.Require().NoError(err) + s.Require().NotNil(ackResp) + s.Require().NotEmpty(ackResp.Acknowledgement) + + icaAck := &sdk.TxMsgData{} + err = proto.Unmarshal(ackResp.Acknowledgement, icaAck) + s.Require().NoError(err) + + queryResp := &banktypes.QueryBalanceResponse{} + err = proto.Unmarshal(icaAck.MsgResponses[0].GetValue(), queryResp) + s.Require().NoError(err) + s.Require().Equal(testvalues.StartingTokenAmount, queryResp.Balance.Amount.Int64()) + }) + }) +} From 75e3fdfb85c2a6acfa2bb1e046385d4b27dff257 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 18 Mar 2024 23:06:29 +0700 Subject: [PATCH 25/60] fix: new test --- e2e/tests/interchain_accounts/query_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 9b3441547d7..4501e82d858 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -23,7 +23,7 @@ import ( ) func TestInterchainAccountsQueryTestSuite(t *testing.T) { - testifysuite.Run(t, new(InterchainAccountsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsQueryTestSuite)) } type InterchainAccountsQueryTestSuite struct { From 79acd69eb1749a9ef171c70ad249a9821f3ffdf3 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 18 Mar 2024 23:34:47 +0700 Subject: [PATCH 26/60] fix: test --- e2e/tests/interchain_accounts/query_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 4501e82d858..e6302262146 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -5,6 +5,7 @@ package interchainaccounts import ( "context" "testing" + "time" "github.com/cosmos/gogoproto/proto" "github.com/strangelove-ventures/interchaintest/v8/testutil" @@ -84,7 +85,19 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { }, }) - txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, queryMsg) + cdc := testsuite.Codec() + bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{queryMsg}, icatypes.EncodingProtobuf) + s.Require().NoError(err) + + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: bz, + Memo: "e2e", + } + + icaQueryMsg := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData) + + txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, icaQueryMsg) s.AssertTxSuccess(txResp) s.Require().NoError(testutil.WaitForBlocks(ctx, 10, chainA, chainB)) From 8a60e6240736af259750588f9d9af258fdf9e121 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 19 Mar 2024 13:27:56 +0700 Subject: [PATCH 27/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index e6302262146..b4b8e0f0904 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -4,6 +4,7 @@ package interchainaccounts import ( "context" + "encoding/json" "testing" "time" @@ -115,8 +116,13 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { s.Require().NotNil(ackResp) s.Require().NotEmpty(ackResp.Acknowledgement) + // unmarshal the acknowledgement + ack := &channeltypes.Acknowledgement{} + err = json.Unmarshal(ackResp.Acknowledgement, ack) + s.Require().NoError(err) + icaAck := &sdk.TxMsgData{} - err = proto.Unmarshal(ackResp.Acknowledgement, icaAck) + err = proto.Unmarshal(ack.GetResult(), icaAck) s.Require().NoError(err) queryResp := &banktypes.QueryBalanceResponse{} From 98e850d006782d17580071a419f0a4e568b4374b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 19 Mar 2024 13:41:13 +0700 Subject: [PATCH 28/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index b4b8e0f0904..c52aa5eaedb 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -4,7 +4,6 @@ package interchainaccounts import ( "context" - "encoding/json" "testing" "time" @@ -118,7 +117,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { // unmarshal the acknowledgement ack := &channeltypes.Acknowledgement{} - err = json.Unmarshal(ackResp.Acknowledgement, ack) + err = channeltypes.SubModuleCdc.UnmarshalJSON(ackResp.Acknowledgement, ack) s.Require().NoError(err) icaAck := &sdk.TxMsgData{} From 678c98d53ac9e1eb3f192a40d713c3d30bbba439 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 11:15:05 +0700 Subject: [PATCH 29/60] imp(e2e): added the QueryTxsByEvents function --- e2e/testsuite/codec.go | 2 ++ e2e/testsuite/tx.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/e2e/testsuite/codec.go b/e2e/testsuite/codec.go index b9240aeb326..7669a4b14b1 100644 --- a/e2e/testsuite/codec.go +++ b/e2e/testsuite/codec.go @@ -14,6 +14,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -88,6 +89,7 @@ func codecAndEncodingConfig() (*codec.ProtoCodec, simappparams.EncodingConfig) { grouptypes.RegisterInterfaces(cfg.InterfaceRegistry) proposaltypes.RegisterInterfaces(cfg.InterfaceRegistry) authz.RegisterInterfaces(cfg.InterfaceRegistry) + tx.RegisterInterfaces(cfg.InterfaceRegistry) cdc := codec.NewProtoCodec(cfg.InterfaceRegistry) return cdc, cfg diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index c3f39b8685c..14e68eb0365 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -16,6 +16,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -297,3 +298,36 @@ func (s *E2ETestSuite) PruneAcknowledgements( msg := channeltypes.NewMsgPruneAcknowledgements(portID, channelID, limit, user.FormattedAddress()) return s.BroadcastMessages(ctx, chain, user, msg) } + +// QueryTxsByEvents runs the QueryTxsByEvents command on the given chain. +// https://github.com/cosmos/cosmos-sdk/blob/65ab2530cc654fd9e252b124ed24cbaa18023b2b/x/auth/client/cli/query.go#L33 +func (*E2ETestSuite) QueryTxsByEvents( + ctx context.Context, chain ibc.Chain, + page, limit int, query, orderBy string, +) (*sdk.SearchTxsResult, error) { + cosmosChain, ok := chain.(*cosmos.CosmosChain) + if !ok { + return nil, fmt.Errorf("QueryTxsByEvents must be passed a cosmos.CosmosChain") + } + + cmd := []string{"txs", "--query", query} + if orderBy != "" { + cmd = append(cmd, "--order_by", orderBy) + } + if page != 0 { + cmd = append(cmd, "--"+flags.FlagPage, strconv.Itoa(page)) + } + if limit != 0 { + cmd = append(cmd, "--"+flags.FlagLimit, strconv.Itoa(limit)) + } + + stdout, _, err := cosmosChain.GetNode().ExecQuery(ctx, cmd...) + if err != nil { + return nil, err + } + + var result *sdk.SearchTxsResult + Codec().MustUnmarshalJSON(stdout, result) + + return result, nil +} From 49acca4400f494c22167c60cdaf003a845d52db9 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 11:49:15 +0700 Subject: [PATCH 30/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 58 +++++++++++++++------ 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index c52aa5eaedb..40a48a49a48 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -4,6 +4,8 @@ package interchainaccounts import ( "context" + "encoding/hex" + "encoding/json" "testing" "time" @@ -104,30 +106,56 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { }) t.Run("verify query response", func(t *testing.T) { - // query packet acknowledgement - ackReq := &channeltypes.QueryPacketAcknowledgementRequest{ - PortId: icatypes.HostPortID, - ChannelId: "channel-1", - Sequence: uint64(1), - } - ackResp, err := s.GetChainGRCPClients(chainB).ChannelQueryClient.PacketAcknowledgement(ctx, ackReq) + txSearchRes, err := s.QueryTxsByEvents(ctx, chainB, 1, 1, "message.action='/ibc.core.channel.v1.MsgRecvPacket'", "") s.Require().NoError(err) - s.Require().NotNil(ackResp) - s.Require().NotEmpty(ackResp.Acknowledgement) + s.Require().Len(txSearchRes.Txs, 1) - // unmarshal the acknowledgement + // get acknowledgement + ackFound := false ack := &channeltypes.Acknowledgement{} - err = channeltypes.SubModuleCdc.UnmarshalJSON(ackResp.Acknowledgement, ack) - s.Require().NoError(err) + search_ack: + for _, event := range txSearchRes.Txs[0].Events { + if event.Type != icatypes.EventTypePacket { + continue + } + + for _, attr := range event.Attributes { + if attr.Key != channeltypes.AttributeKeyAckHex { + continue + } + + ackBz, err := hex.DecodeString(attr.Value) + s.Require().NoError(err) + + err = json.Unmarshal(ackBz, ack) + s.Require().NoError(err) + + ackFound = true + + break search_ack + } + } + s.Require().True(ackFound) + + // unmarshal the ica response icaAck := &sdk.TxMsgData{} err = proto.Unmarshal(ack.GetResult(), icaAck) s.Require().NoError(err) + s.Require().Len(icaAck.MsgResponses, 1) + + // unmarshal the tx response + queryTxResp := &icahosttypes.MsgModuleQuerySafeResponse{} + err = proto.Unmarshal(icaAck.MsgResponses[0].Value, queryTxResp) + s.Require().NoError(err) + s.Require().Len(queryTxResp.Responses, 1) - queryResp := &banktypes.QueryBalanceResponse{} - err = proto.Unmarshal(icaAck.MsgResponses[0].GetValue(), queryResp) + // unmarshal the bank query response + balanceResp := &banktypes.QueryBalanceResponse{} + err = proto.Unmarshal(queryTxResp.Responses[0], balanceResp) s.Require().NoError(err) - s.Require().Equal(testvalues.StartingTokenAmount, queryResp.Balance.Amount.Int64()) + s.Require().Equal(balanceResp.Balance.Denom, chainB.Config().Denom) + s.Require().Equal(balanceResp.Balance.Amount, testvalues.StartingTokenAmount) }) }) } From 78917a111d2f0c2d5c92ca2500c309b4581e2664 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 11:50:18 +0700 Subject: [PATCH 31/60] e2e: lint fix --- e2e/tests/upgrades/genesis_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 4b387bb128b..3a39f041aae 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -125,7 +125,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks") t.Run("Halt chain and export genesis", func(t *testing.T) { - s.HaltChainAndExportGenesis(ctx, chainA.(*cosmos.CosmosChain), relayer, int64(haltHeight)) + s.HaltChainAndExportGenesis(ctx, chainA.(*cosmos.CosmosChain), relayer, haltHeight) }) t.Run("ics20: native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) { @@ -242,5 +242,5 @@ func (s *GenesisTestSuite) HaltChainAndExportGenesis(ctx context.Context, chain height, err := chain.Height(ctx) s.Require().NoError(err, "error fetching height after halt") - s.Require().Greater(int64(height), haltHeight, "height did not increment after halt") + s.Require().Greater(height, haltHeight, "height did not increment after halt") } From 62d7358ee9242fd78060fc3500783f51c0b97f91 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 12:04:51 +0700 Subject: [PATCH 32/60] fix: e2e --- e2e/testsuite/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index 14e68eb0365..1f92600a1f4 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -326,7 +326,7 @@ func (*E2ETestSuite) QueryTxsByEvents( return nil, err } - var result *sdk.SearchTxsResult + result := &sdk.SearchTxsResult{} Codec().MustUnmarshalJSON(stdout, result) return result, nil From 22d0fc87f627cde46ba97e2953c4850b418a16c2 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 16:12:00 +0700 Subject: [PATCH 33/60] e2e: debug --- e2e/tests/interchain_accounts/query_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 40a48a49a48..6ee28d83576 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -112,6 +112,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { // get acknowledgement ackFound := false + eventFound := false ack := &channeltypes.Acknowledgement{} search_ack: @@ -120,7 +121,11 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { continue } + eventFound = true + for _, attr := range event.Attributes { + s.T().Logf("ack_key: %s", attr.Key) + if attr.Key != channeltypes.AttributeKeyAckHex { continue } @@ -136,6 +141,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { break search_ack } } + s.Require().True(eventFound) s.Require().True(ackFound) // unmarshal the ica response From f61f0c639bd8a0336c89bf49faee9db2de840c5b Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 16:20:01 +0700 Subject: [PATCH 34/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 6ee28d83576..56ca35e0773 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -112,20 +112,15 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { // get acknowledgement ackFound := false - eventFound := false ack := &channeltypes.Acknowledgement{} search_ack: for _, event := range txSearchRes.Txs[0].Events { - if event.Type != icatypes.EventTypePacket { + if event.Type != channeltypes.EventTypeWriteAck { continue } - eventFound = true - for _, attr := range event.Attributes { - s.T().Logf("ack_key: %s", attr.Key) - if attr.Key != channeltypes.AttributeKeyAckHex { continue } @@ -141,7 +136,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { break search_ack } } - s.Require().True(eventFound) s.Require().True(ackFound) // unmarshal the ica response From 3f241642c2aad56a73fe9a90a52da432407244d0 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 16:36:47 +0700 Subject: [PATCH 35/60] test: debug helpers --- e2e/tests/interchain_accounts/query_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 56ca35e0773..40806cce146 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -137,12 +137,16 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { } } s.Require().True(ackFound) + s.Require().NotZero(ack) + s.Require().NotZero(ack.GetResult()) + s.Require().True(ack.Success()) // unmarshal the ica response icaAck := &sdk.TxMsgData{} err = proto.Unmarshal(ack.GetResult(), icaAck) s.Require().NoError(err) - s.Require().Len(icaAck.MsgResponses, 1) + s.Require().Equal("", icaAck.String()) + s.Require().Len(icaAck.GetMsgResponses(), 1) // unmarshal the tx response queryTxResp := &icahosttypes.MsgModuleQuerySafeResponse{} From d31dbbb61458d19c163baaaf9ab0e7d8a020c5cf Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 16:54:34 +0700 Subject: [PATCH 36/60] debug --- e2e/tests/interchain_accounts/query_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 40806cce146..d3a0df1bded 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -128,6 +128,8 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { ackBz, err := hex.DecodeString(attr.Value) s.Require().NoError(err) + s.Require().Equal("", string(ackBz)) + err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) From dfbef770c931b997f3a277533192ae1c23a46db1 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 17:14:30 +0700 Subject: [PATCH 37/60] test: added codec_test case --- modules/apps/27-interchain-accounts/host/types/codec_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/types/codec_test.go b/modules/apps/27-interchain-accounts/host/types/codec_test.go index 6fb2591cf47..581a9401e2b 100644 --- a/modules/apps/27-interchain-accounts/host/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/host/types/codec_test.go @@ -23,6 +23,11 @@ func TestCodecTypeRegistration(t *testing.T) { sdk.MsgTypeURL(&types.MsgUpdateParams{}), true, }, + { + "success: MsgModuleQuerySafe", + sdk.MsgTypeURL(&types.MsgModuleQuerySafe{}), + true, + }, { "type not registered on codec", "ibc.invalid.MsgTypeURL", From a1597a9eb9eee6d7d3aceddb1b7dafe9ceff7096 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 17:20:43 +0700 Subject: [PATCH 38/60] imp: additional test case --- e2e/tests/interchain_accounts/query_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index d3a0df1bded..851ef7f4984 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -91,6 +91,10 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{queryMsg}, icatypes.EncodingProtobuf) s.Require().NoError(err) + // test that it is deserializeable + _, err = icatypes.DeserializeCosmosTx(cdc, bz, icatypes.EncodingProtobuf) + s.Require().NoError(err) + packetData := icatypes.InterchainAccountPacketData{ Type: icatypes.EXECUTE_TX, Data: bz, @@ -128,7 +132,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { ackBz, err := hex.DecodeString(attr.Value) s.Require().NoError(err) - s.Require().Equal("", string(ackBz)) + // s.Require().Equal("", string(ackBz)) err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) @@ -140,8 +144,8 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { } s.Require().True(ackFound) s.Require().NotZero(ack) - s.Require().NotZero(ack.GetResult()) s.Require().True(ack.Success()) + s.Require().NotZero(ack.GetResult()) // unmarshal the ica response icaAck := &sdk.TxMsgData{} From 85038bfbd14c663de20d3b87de187594808acbf5 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 17:44:29 +0700 Subject: [PATCH 39/60] imp: added important unit test --- .../host/keeper/relay_test.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 9ad0ef02f12..ac5d41378e3 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -274,6 +274,38 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { }, nil, }, + { + "interchain account successfully executes icahosttypes.MsgModuleQuerySafe", + func(encoding string) { + interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID) + suite.Require().True(found) + + balanceQuery := banktypes.NewQueryBalanceRequest(suite.chainB.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + queryBz, err := balanceQuery.Marshal() + suite.Require().NoError(err) + + msg := types.NewMsgModuleQuerySafe(interchainAccountAddr, []*types.QueryRequest{ + { + Path: "/cosmos.bank.v1beta1.Query/Balance", + Data: queryBz, + }, + }) + + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}, encoding) + suite.Require().NoError(err) + + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: data, + } + + packetData = icaPacketData.GetBytes() + + params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)}) + suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params) + }, + nil, + }, { "interchain account successfully executes disttypes.MsgSetWithdrawAddress", func(encoding string) { From 4fa3c2803b3bd3672c2e5ff0aed021c43ffbcd9d Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 17:47:59 +0700 Subject: [PATCH 40/60] r4r --- e2e/tests/interchain_accounts/query_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 851ef7f4984..0c810391f87 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -132,8 +132,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { ackBz, err := hex.DecodeString(attr.Value) s.Require().NoError(err) - // s.Require().Equal("", string(ackBz)) - err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) From 91a985a6eeca82ed17119b601afb0424fb5fadc7 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 18:29:37 +0700 Subject: [PATCH 41/60] e2e: debug --- e2e/tests/interchain_accounts/query_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 0c810391f87..eed7a0f19da 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -91,10 +91,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{queryMsg}, icatypes.EncodingProtobuf) s.Require().NoError(err) - // test that it is deserializeable - _, err = icatypes.DeserializeCosmosTx(cdc, bz, icatypes.EncodingProtobuf) - s.Require().NoError(err) - packetData := icatypes.InterchainAccountPacketData{ Type: icatypes.EXECUTE_TX, Data: bz, @@ -142,7 +138,10 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { } s.Require().True(ackFound) s.Require().NotZero(ack) - s.Require().True(ack.Success()) + if !ack.Success() { + t.Logf("ack failed: %s", ack.String()) + s.Require().FailNow(ack.String()) + } s.Require().NotZero(ack.GetResult()) // unmarshal the ica response From 197c6459b66ded0d2bbe3a127947686198be9e7e Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 18:42:58 +0700 Subject: [PATCH 42/60] imp: added logs --- e2e/tests/interchain_accounts/query_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index eed7a0f19da..ad5a67df157 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -128,9 +128,13 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { ackBz, err := hex.DecodeString(attr.Value) s.Require().NoError(err) + s.T().Logf("ack found: %s", string(ackBz)) + err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) + s.T().Logf("ack deserialized: %s", ack.String()) + ackFound = true break search_ack @@ -138,10 +142,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { } s.Require().True(ackFound) s.Require().NotZero(ack) - if !ack.Success() { - t.Logf("ack failed: %s", ack.String()) - s.Require().FailNow(ack.String()) - } s.Require().NotZero(ack.GetResult()) // unmarshal the ica response From 8dc0dd6c870c4e6386fbccb389ff0206ab98f2c9 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 19:43:48 +0700 Subject: [PATCH 43/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index ad5a67df157..bb891312518 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -112,7 +112,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { // get acknowledgement ackFound := false - ack := &channeltypes.Acknowledgement{} + ack := &channeltypes.Acknowledgement_Result{} search_ack: for _, event := range txSearchRes.Txs[0].Events { @@ -133,8 +133,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) - s.T().Logf("ack deserialized: %s", ack.String()) - ackFound = true break search_ack @@ -142,11 +140,10 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { } s.Require().True(ackFound) s.Require().NotZero(ack) - s.Require().NotZero(ack.GetResult()) // unmarshal the ica response icaAck := &sdk.TxMsgData{} - err = proto.Unmarshal(ack.GetResult(), icaAck) + err = proto.Unmarshal(ack.Result, icaAck) s.Require().NoError(err) s.Require().Equal("", icaAck.String()) s.Require().Len(icaAck.GetMsgResponses(), 1) From 660e088788c92da88b5c5f5243c5817c76e39d61 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 20:29:48 +0700 Subject: [PATCH 44/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index bb891312518..358d2d4e750 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -145,7 +145,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { icaAck := &sdk.TxMsgData{} err = proto.Unmarshal(ack.Result, icaAck) s.Require().NoError(err) - s.Require().Equal("", icaAck.String()) s.Require().Len(icaAck.GetMsgResponses(), 1) // unmarshal the tx response From b97179195c32cc86571109e713fc15e10d4efdca Mon Sep 17 00:00:00 2001 From: srdtrk Date: Wed, 20 Mar 2024 23:10:05 +0700 Subject: [PATCH 45/60] fix: e2e --- e2e/tests/interchain_accounts/query_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 358d2d4e750..7c9b364a93c 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -157,8 +157,8 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { balanceResp := &banktypes.QueryBalanceResponse{} err = proto.Unmarshal(queryTxResp.Responses[0], balanceResp) s.Require().NoError(err) - s.Require().Equal(balanceResp.Balance.Denom, chainB.Config().Denom) - s.Require().Equal(balanceResp.Balance.Amount, testvalues.StartingTokenAmount) + s.Require().Equal(chainB.Config().Denom, balanceResp.Balance.Denom) + s.Require().Equal(testvalues.StartingTokenAmount, balanceResp.Balance.Amount.Int64()) }) }) } From 1569f765aae332e2aa33663e820d825f99dcfd3d Mon Sep 17 00:00:00 2001 From: srdtrk Date: Sun, 24 Mar 2024 11:52:18 +0700 Subject: [PATCH 46/60] imp: added height to proto response --- proto/ibc/applications/interchain_accounts/host/v1/tx.proto | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto index 24b4a73d7a0..22e8c9b3567 100644 --- a/proto/ibc/applications/interchain_accounts/host/v1/tx.proto +++ b/proto/ibc/applications/interchain_accounts/host/v1/tx.proto @@ -52,6 +52,9 @@ message MsgModuleQuerySafe { // MsgModuleQuerySafeResponse defines the response for Msg/ModuleQuerySafe message MsgModuleQuerySafeResponse { + // height at which the responses were queried + uint64 height = 1; + // protobuf encoded responses for each query - repeated bytes responses = 1; + repeated bytes responses = 2; } From 2a553e7b746e4a2797c992e9163991923f5eb20f Mon Sep 17 00:00:00 2001 From: srdtrk Date: Sun, 24 Mar 2024 11:53:48 +0700 Subject: [PATCH 47/60] imp: ran 'make proto-all' --- .../host/types/tx.pb.go | 99 +++++++++++++------ 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/types/tx.pb.go b/modules/apps/27-interchain-accounts/host/types/tx.pb.go index a834ff5ac1c..8663234557f 100644 --- a/modules/apps/27-interchain-accounts/host/types/tx.pb.go +++ b/modules/apps/27-interchain-accounts/host/types/tx.pb.go @@ -152,8 +152,10 @@ var xxx_messageInfo_MsgModuleQuerySafe proto.InternalMessageInfo // MsgModuleQuerySafeResponse defines the response for Msg/ModuleQuerySafe type MsgModuleQuerySafeResponse struct { + // height at which the responses were queried + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` // protobuf encoded responses for each query - Responses [][]byte `protobuf:"bytes,1,rep,name=responses,proto3" json:"responses,omitempty"` + Responses [][]byte `protobuf:"bytes,2,rep,name=responses,proto3" json:"responses,omitempty"` } func (m *MsgModuleQuerySafeResponse) Reset() { *m = MsgModuleQuerySafeResponse{} } @@ -189,6 +191,13 @@ func (m *MsgModuleQuerySafeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgModuleQuerySafeResponse proto.InternalMessageInfo +func (m *MsgModuleQuerySafeResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + func (m *MsgModuleQuerySafeResponse) GetResponses() [][]byte { if m != nil { return m.Responses @@ -208,35 +217,36 @@ func init() { } var fileDescriptor_fa437afde7f1e7ae = []byte{ - // 447 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0x5d, 0x5d, 0xec, 0xb4, 0x50, 0x08, 0x62, 0xd7, 0x20, 0xe9, 0xb2, 0xa7, 0x50, - 0xdc, 0x19, 0x1a, 0x95, 0xca, 0x82, 0x20, 0x05, 0x41, 0x84, 0x80, 0x46, 0xf4, 0xe0, 0x45, 0x26, - 0xb3, 0xe3, 0xec, 0x40, 0x93, 0x89, 0x79, 0x27, 0x8b, 0xbd, 0x89, 0x27, 0x4f, 0xe2, 0x41, 0x8f, - 0x82, 0x1f, 0xa1, 0xdf, 0xc1, 0x4b, 0x8f, 0x3d, 0x7a, 0x12, 0xd9, 0x3d, 0xf4, 0x6b, 0x48, 0x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 0x87, 0xf9, 0xb1, 0x78, 0x96, 0x8b, 0xec, 0xe4, 0x39, - 0x7b, 0x23, 0xfe, 0xab, 0xfb, 0x12, 0x5f, 0xcb, 0xc4, 0xdb, 0x5c, 0x80, 0x29, 0x84, 0x5b, 0xde, - 0x96, 0x3f, 0x68, 0x26, 0x5c, 0x8e, 0x08, 0x67, 0x88, 0x70, 0xce, 0x5a, 0x55, 0x1e, 0x60, 0x67, - 0x55, 0xeb, 0xd2, 0xda, 0xbe, 0x85, 0x37, 0xb3, 0x6a, 0x0d, 0x1d, 0xd4, 0x6d, 0x79, 0xdb, 0xe1, - 0xe2, 0x86, 0xff, 0x63, 0x03, 0xb7, 0x02, 0x90, 0xf6, 0x17, 0x84, 0xb7, 0x97, 0x7e, 0xc2, 0x83, - 0x66, 0xae, 0xb5, 0x3d, 0x73, 0x1e, 0xad, 0x15, 0x9f, 0xcb, 0x7f, 0x2b, 0x8e, 0x47, 0x6d, 0xbf, - 0x1f, 0x36, 0x46, 0xd7, 0x08, 0xce, 0xe3, 0x75, 0x09, 0x97, 0x7e, 0xce, 0xd5, 0xf7, 0x17, 0xa7, - 0xfb, 0xe8, 0x68, 0x78, 0x36, 0x71, 0xd1, 0xf9, 0xc4, 0x45, 0xbf, 0x27, 0x2e, 0xfa, 0x3c, 0x75, - 0xad, 0xf3, 0xa9, 0x6b, 0xfd, 0x9c, 0xba, 0xd6, 0xab, 0x27, 0x52, 0x99, 0x51, 0x1e, 0x11, 0xae, - 0x63, 0x5a, 0x95, 0x47, 0x45, 0xbc, 0x2f, 0x35, 0x1d, 0xdf, 0xa7, 0x71, 0x49, 0x85, 0xa2, 0x38, - 0x40, 0xfd, 0xc3, 0xfe, 0x42, 0xa2, 0xbf, 0xdc, 0x19, 0x73, 0x92, 0x0a, 0x88, 0xda, 0x65, 0x65, - 0xee, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xf6, 0x20, 0xb2, 0x01, 0x04, 0x00, 0x00, + // 456 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x33, 0x6d, 0x5d, 0xec, 0xb4, 0x50, 0x08, 0x62, 0x6b, 0x90, 0xb4, 0xec, 0x69, 0x29, + 0xee, 0x0c, 0x5d, 0x95, 0x4a, 0x41, 0x90, 0x82, 0x20, 0x42, 0x40, 0x47, 0xf4, 0xe0, 0x45, 0x26, + 0xb3, 0xe3, 0x64, 0xa0, 0xc9, 0xc4, 0xbc, 0xc9, 0x62, 0x6f, 0xe2, 0xc9, 0x93, 0x78, 0xd0, 0xa3, + 0xe0, 0x47, 0xe8, 0x77, 0xf0, 0xd2, 0x63, 0x8f, 0x9e, 0x44, 0x76, 0x0f, 0xfd, 0x1a, 0x92, 0x49, + 0xda, 0xda, 0xd4, 0x1e, 0x42, 0x6f, 0x99, 0x64, 0xfe, 0xbf, 0xf7, 0x7b, 0x99, 0x79, 0xf8, 0xbe, + 0x8e, 0x05, 0xe5, 0x79, 0xbe, 0xa7, 0x05, 0xb7, 0xda, 0x64, 0x40, 0x75, 0x66, 0x65, 0x21, 0x12, + 0xae, 0xb3, 0x37, 0x5c, 0x08, 0x53, 0x66, 0x16, 0x68, 0x62, 0xc0, 0xd2, 0xc9, 0x16, 0xb5, 0xef, + 0x49, 0x5e, 0x18, 0x6b, 0xfc, 0x3b, 0x3a, 0x16, 0xe4, 0xdf, 0x18, 0xf9, 0x4f, 0x8c, 0x54, 0x31, + 0x32, 0xd9, 0x0a, 0x6e, 0x28, 0xa3, 0x8c, 0x0b, 0xd2, 0xea, 0xa9, 0x66, 0x04, 0xab, 0xc2, 0x40, + 0x6a, 0x80, 0xa6, 0xa0, 0x2a, 0x76, 0x0a, 0xaa, 0xf9, 0xb0, 0xdd, 0xc9, 0xc9, 0x15, 0x71, 0xc1, + 0xfe, 0x67, 0x84, 0x57, 0x22, 0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2d, 0x42, 0xf0, 0xe4, 0xaa, + 0x84, 0x13, 0xbf, 0xe0, 0xda, 0x87, 0xe3, 0x83, 0x4d, 0xb4, 0x3b, 0x3e, 0x9c, 0x86, 0xe8, 0x68, + 0x1a, 0xa2, 0x3f, 0xd3, 0x10, 0x7d, 0x99, 0x85, 0xde, 0xd1, 0x2c, 0xf4, 0x7e, 0xcd, 0x42, 0xef, + 0xf5, 0x53, 0xa5, 0x6d, 0x52, 0xc6, 0x44, 0x98, 0x94, 0x36, 0x43, 0xa5, 0x63, 0x31, 0x54, 0x86, + 0x4e, 0x1e, 0xd0, 0xd4, 0x51, 0xa1, 0x1a, 0x28, 0xa0, 0xa3, 0xed, 0xe1, 0x99, 0xc4, 0xf0, 0xfc, + 0x2c, 0xd9, 0xfd, 0x5c, 0x42, 0xdc, 0x73, 0xa3, 0x74, 0xf7, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x49, 0x5c, 0x48, 0xd7, 0x19, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -492,9 +502,14 @@ func (m *MsgModuleQuerySafeResponse) MarshalToSizedBuffer(dAtA []byte) (int, err copy(dAtA[i:], m.Responses[iNdEx]) i = encodeVarintTx(dAtA, i, uint64(len(m.Responses[iNdEx]))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 } } + if m.Height != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -558,6 +573,9 @@ func (m *MsgModuleQuerySafeResponse) Size() (n int) { } var l int _ = l + if m.Height != 0 { + n += 1 + sovTx(uint64(m.Height)) + } if len(m.Responses) > 0 { for _, b := range m.Responses { l = len(b) @@ -884,6 +902,25 @@ func (m *MsgModuleQuerySafeResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) } From 0b031b720db20cd5009f26ff532b23cd24c8db73 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Sun, 24 Mar 2024 11:57:22 +0700 Subject: [PATCH 48/60] imp: added height --- modules/apps/27-interchain-accounts/host/keeper/msg_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index c0ca8b629f2..3880ba3f185 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -57,7 +57,7 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu responses[i] = res.Value } - return &types.MsgModuleQuerySafeResponse{Responses: responses}, nil + return &types.MsgModuleQuerySafeResponse{Responses: responses, Height: uint64(ctx.BlockHeight())}, nil } // UpdateParams updates the host submodule's params. From b7466445430662aefc5fcdd629d7cc4634c48bd3 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Sun, 24 Mar 2024 11:59:52 +0700 Subject: [PATCH 49/60] e2e: updated e2e to test height --- e2e/tests/interchain_accounts/query_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 7c9b364a93c..c111d9bd843 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -152,6 +152,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { err = proto.Unmarshal(icaAck.MsgResponses[0].Value, queryTxResp) s.Require().NoError(err) s.Require().Len(queryTxResp.Responses, 1) + s.Require().Equal(uint64(txSearchRes.Txs[0].Height), queryTxResp.Height) // unmarshal the bank query response balanceResp := &banktypes.QueryBalanceResponse{} From 3a5533499a16a3b7eea68e55a11b36c296008ebe Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 25 Mar 2024 11:28:41 +0700 Subject: [PATCH 50/60] imp: review suggestions --- .../host/keeper/msg_server.go | 2 +- .../host/keeper/msg_server_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 3880ba3f185..3d85f6dc82a 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -35,7 +35,7 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu for i, query := range msg.Requests { isModuleQuerySafe := slices.Contains(m.mqsWhitelist, query.Path) if !isModuleQuerySafe { - return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot verify module query safe: %s", query.Path) + return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "not module query safe: %s", query.Path) } route := m.queryRouter.Route(query.Path) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go index ecb0ba26b9e..d358303fc12 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go @@ -24,12 +24,12 @@ func (suite *KeeperTestSuite) TestModuleQuerySafe() { { "success", func() { - queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + balanceQueryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() suite.Require().NoError(err) queryReq := types.QueryRequest{ Path: "/cosmos.bank.v1beta1.Query/Balance", - Data: queryBz, + Data: balanceQueryBz, } msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq}) @@ -47,12 +47,12 @@ func (suite *KeeperTestSuite) TestModuleQuerySafe() { { "success: multiple queries", func() { - queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + balanceQueryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() suite.Require().NoError(err) queryReq := types.QueryRequest{ Path: "/cosmos.bank.v1beta1.Query/Balance", - Data: queryBz, + Data: balanceQueryBz, } paramsQuery := stakingtypes.QueryParamsRequest{} @@ -85,12 +85,12 @@ func (suite *KeeperTestSuite) TestModuleQuerySafe() { { "failure: not module query safe", func() { - queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + balanceQueryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() suite.Require().NoError(err) queryReq := types.QueryRequest{ Path: "/cosmos.bank.v1beta1.Query/Balance", - Data: queryBz, + Data: balanceQueryBz, } paramsQuery := transfertypes.QueryParamsRequest{} @@ -109,12 +109,12 @@ func (suite *KeeperTestSuite) TestModuleQuerySafe() { { "failure: invalid query path", func() { - queryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() + balanceQueryBz, err := banktypes.NewQueryBalanceRequest(suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom).Marshal() suite.Require().NoError(err) queryReq := types.QueryRequest{ Path: "/cosmos.invalid.Query/Invalid", - Data: queryBz, + Data: balanceQueryBz, } msg = types.NewMsgModuleQuerySafe(suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(), []*types.QueryRequest{&queryReq}) From 4878ea753304e7801229dd46f431e78e2b24a3fd Mon Sep 17 00:00:00 2001 From: srdtrk Date: Mon, 25 Mar 2024 11:35:27 +0700 Subject: [PATCH 51/60] e2e: remove unneeded log --- e2e/tests/interchain_accounts/query_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index c111d9bd843..abb66031709 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -128,8 +128,6 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { ackBz, err := hex.DecodeString(attr.Value) s.Require().NoError(err) - s.T().Logf("ack found: %s", string(ackBz)) - err = json.Unmarshal(ackBz, ack) s.Require().NoError(err) From 8ab8f7748f9b8099aa8e66a6ced71465c3057734 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 00:19:11 +0700 Subject: [PATCH 52/60] refactor: refactored 'ExtractValueFromEvents' --- e2e/tests/interchain_accounts/query_test.go | 37 +++++++-------------- e2e/testsuite/tx.go | 23 +++++++++++++ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index abb66031709..3159d1e91e6 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -110,34 +110,21 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { s.Require().NoError(err) s.Require().Len(txSearchRes.Txs, 1) - // get acknowledgement - ackFound := false - ack := &channeltypes.Acknowledgement_Result{} - - search_ack: - for _, event := range txSearchRes.Txs[0].Events { - if event.Type != channeltypes.EventTypeWriteAck { - continue - } - - for _, attr := range event.Attributes { - if attr.Key != channeltypes.AttributeKeyAckHex { - continue - } - - ackBz, err := hex.DecodeString(attr.Value) - s.Require().NoError(err) + ackHexValue, isFound := s.ExtractValueFromEvents( + txSearchRes.Txs[0].Events, + channeltypes.EventTypeWriteAck, + channeltypes.AttributeKeyAckHex, + ) - err = json.Unmarshal(ackBz, ack) - s.Require().NoError(err) + s.Require().True(isFound) + s.Require().NotEmpty(ackHexValue) - ackFound = true + ack := &channeltypes.Acknowledgement_Result{} + ackBz, err := hex.DecodeString(ackHexValue) + s.Require().NoError(err) - break search_ack - } - } - s.Require().True(ackFound) - s.Require().NotZero(ack) + err = json.Unmarshal(ackBz, ack) + s.Require().NoError(err) // unmarshal the ica response icaAck := &sdk.TxMsgData{} diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index 1f92600a1f4..c172fd695c6 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -24,6 +24,8 @@ import ( govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/ibc-go/e2e/testsuite/sanitize" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" @@ -331,3 +333,24 @@ func (*E2ETestSuite) QueryTxsByEvents( return result, nil } + +// ExtractValueFromEvents extracts the value of an attribute from a list of events. +// If the attribute is not found, the function returns an empty string and false. +// If the attribute is found, the function returns the value and true. +func (*E2ETestSuite) ExtractValueFromEvents(events []abci.Event, eventType, attrKey string) (string, bool) { + for _, event := range events { + if event.Type != eventType { + continue + } + + for _, attr := range event.Attributes { + if attr.Key != attrKey { + continue + } + + return attr.Value, true + } + } + + return "", false +} From 779848b3c4cbbd0aa6943c5baf660e7b62fe7011 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 12:08:33 +0700 Subject: [PATCH 53/60] e2e: review item --- e2e/testsuite/tx.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index c172fd695c6..ecbde19b3ad 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -329,7 +329,10 @@ func (*E2ETestSuite) QueryTxsByEvents( } result := &sdk.SearchTxsResult{} - Codec().MustUnmarshalJSON(stdout, result) + err = Codec().UnmarshalJSON(stdout, result) + if err != nil { + return nil, err + } return result, nil } From f2fb96cfec67d4d5bf54c8f098618ade62a13a6a Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 12:24:50 +0700 Subject: [PATCH 54/60] imp: review item --- e2e/tests/interchain_accounts/query_test.go | 75 ++++++++++++--------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/e2e/tests/interchain_accounts/query_test.go b/e2e/tests/interchain_accounts/query_test.go index 3159d1e91e6..b8db5f067a6 100644 --- a/e2e/tests/interchain_accounts/query_test.go +++ b/e2e/tests/interchain_accounts/query_test.go @@ -70,7 +70,7 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) s.Require().NoError(err) - s.Require().Equal(len(channels), 2) + s.Require().Len(channels, 2) }) t.Run("query via interchain account", func(t *testing.T) { @@ -106,45 +106,56 @@ func (s *InterchainAccountsQueryTestSuite) TestInterchainAccountsQuery() { }) t.Run("verify query response", func(t *testing.T) { - txSearchRes, err := s.QueryTxsByEvents(ctx, chainB, 1, 1, "message.action='/ibc.core.channel.v1.MsgRecvPacket'", "") - s.Require().NoError(err) - s.Require().Len(txSearchRes.Txs, 1) - - ackHexValue, isFound := s.ExtractValueFromEvents( - txSearchRes.Txs[0].Events, - channeltypes.EventTypeWriteAck, - channeltypes.AttributeKeyAckHex, - ) - - s.Require().True(isFound) - s.Require().NotEmpty(ackHexValue) + var expQueryHeight uint64 ack := &channeltypes.Acknowledgement_Result{} - ackBz, err := hex.DecodeString(ackHexValue) - s.Require().NoError(err) - - err = json.Unmarshal(ackBz, ack) - s.Require().NoError(err) + t.Run("retrieve acknowledgement", func(t *testing.T) { + txSearchRes, err := s.QueryTxsByEvents( + ctx, chainB, 1, 1, + "message.action='/ibc.core.channel.v1.MsgRecvPacket'", "", + ) + s.Require().NoError(err) + s.Require().Len(txSearchRes.Txs, 1) + + expQueryHeight = uint64(txSearchRes.Txs[0].Height) + + ackHexValue, isFound := s.ExtractValueFromEvents( + txSearchRes.Txs[0].Events, + channeltypes.EventTypeWriteAck, + channeltypes.AttributeKeyAckHex, + ) + s.Require().True(isFound) + s.Require().NotEmpty(ackHexValue) + + ackBz, err := hex.DecodeString(ackHexValue) + s.Require().NoError(err) + + err = json.Unmarshal(ackBz, ack) + s.Require().NoError(err) + }) - // unmarshal the ica response icaAck := &sdk.TxMsgData{} - err = proto.Unmarshal(ack.Result, icaAck) - s.Require().NoError(err) - s.Require().Len(icaAck.GetMsgResponses(), 1) + t.Run("unmarshal ica response", func(t *testing.T) { + err := proto.Unmarshal(ack.Result, icaAck) + s.Require().NoError(err) + s.Require().Len(icaAck.GetMsgResponses(), 1) + }) - // unmarshal the tx response queryTxResp := &icahosttypes.MsgModuleQuerySafeResponse{} - err = proto.Unmarshal(icaAck.MsgResponses[0].Value, queryTxResp) - s.Require().NoError(err) - s.Require().Len(queryTxResp.Responses, 1) - s.Require().Equal(uint64(txSearchRes.Txs[0].Height), queryTxResp.Height) + t.Run("unmarshal MsgModuleQuerySafeResponse", func(t *testing.T) { + err := proto.Unmarshal(icaAck.MsgResponses[0].Value, queryTxResp) + s.Require().NoError(err) + s.Require().Len(queryTxResp.Responses, 1) + s.Require().Equal(expQueryHeight, queryTxResp.Height) + }) - // unmarshal the bank query response balanceResp := &banktypes.QueryBalanceResponse{} - err = proto.Unmarshal(queryTxResp.Responses[0], balanceResp) - s.Require().NoError(err) - s.Require().Equal(chainB.Config().Denom, balanceResp.Balance.Denom) - s.Require().Equal(testvalues.StartingTokenAmount, balanceResp.Balance.Amount.Int64()) + t.Run("unmarshal and verify bank query response", func(t *testing.T) { + err := proto.Unmarshal(queryTxResp.Responses[0], balanceResp) + s.Require().NoError(err) + s.Require().Equal(chainB.Config().Denom, balanceResp.Balance.Denom) + s.Require().Equal(testvalues.StartingTokenAmount, balanceResp.Balance.Amount.Int64()) + }) }) }) } From 15a1ccd3ddd734aeaf696f61477f32981bd77704 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 12:26:05 +0700 Subject: [PATCH 55/60] nit: review item --- e2e/testsuite/codec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/testsuite/codec.go b/e2e/testsuite/codec.go index 7669a4b14b1..ca08e41c491 100644 --- a/e2e/testsuite/codec.go +++ b/e2e/testsuite/codec.go @@ -14,7 +14,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module/testutil" - "github.com/cosmos/cosmos-sdk/types/tx" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -89,7 +89,7 @@ func codecAndEncodingConfig() (*codec.ProtoCodec, simappparams.EncodingConfig) { grouptypes.RegisterInterfaces(cfg.InterfaceRegistry) proposaltypes.RegisterInterfaces(cfg.InterfaceRegistry) authz.RegisterInterfaces(cfg.InterfaceRegistry) - tx.RegisterInterfaces(cfg.InterfaceRegistry) + txtypes.RegisterInterfaces(cfg.InterfaceRegistry) cdc := codec.NewProtoCodec(cfg.InterfaceRegistry) return cdc, cfg From d76ff538e2b7d578519584d2346a58177587bda1 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 15:08:48 +0700 Subject: [PATCH 56/60] docs: added godocs --- modules/apps/27-interchain-accounts/host/keeper/keeper.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index b54a4d66873..8dcec38d4c0 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -274,15 +274,14 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { store.Set([]byte(types.ParamsKey), bz) } +// newModuleQuerySafeWhitelist returns a list of all query paths labeled with module_query_safe in the proto files. func newModuleQuerySafeWhitelist() []string { - // Create a whitelist of module safe queries - whitelist := []string{} - protoFiles, err := gogoproto.MergedRegistry() if err != nil { panic(err) } + whitelist := []string{} protoFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool { for i := 0; i < fd.Services().Len(); i++ { // Get the service descriptor From 4083edcc03318807615dba2c2fcf5ea91630cd55 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 15:57:24 +0700 Subject: [PATCH 57/60] test: unit test for mqsWhitelist added --- .../host/keeper/export_test.go | 5 ++++ .../host/keeper/keeper_test.go | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/export_test.go b/modules/apps/27-interchain-accounts/host/keeper/export_test.go index bad2c32661a..38b1653259d 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/export_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/export_test.go @@ -14,3 +14,8 @@ import ( func (k Keeper) GetAppMetadata(ctx sdk.Context, portID, channelID string) (icatypes.Metadata, error) { return k.getAppMetadata(ctx, portID, channelID) } + +// NewModuleQuerySafeWhitelist is a wrapper around newModuleQuerySafeWhitelist to allow the function to be directly called in tests. +func NewModuleQuerySafeWhitelist() []string { + return newModuleQuerySafeWhitelist() +} diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index 37e26c7807a..afc5eabe4b8 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -201,6 +201,31 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } } +func (suite *KeeperTestSuite) TestNewModuleQuerySafeWhitelist() { + // Currently, all queries in bank, staking, auth, and circuit are marked safe + // Notably, the gov and distribution modules are not marked safe + + var whitelist []string + suite.Require().NotPanics(func() { + whitelist = keeper.NewModuleQuerySafeWhitelist() + }) + + suite.Require().NotEmpty(whitelist) + suite.Require().Contains(whitelist, "/cosmos.bank.v1beta1.Query/Balance") + suite.Require().Contains(whitelist, "/cosmos.bank.v1beta1.Query/AllBalances") + suite.Require().Contains(whitelist, "/cosmos.staking.v1beta1.Query/Validator") + suite.Require().Contains(whitelist, "/cosmos.staking.v1beta1.Query/Validators") + suite.Require().Contains(whitelist, "/cosmos.circuit.v1.Query/Account") + suite.Require().Contains(whitelist, "/cosmos.circuit.v1.Query/DisabledList") + suite.Require().Contains(whitelist, "/cosmos.auth.v1beta1.Query/Accounts") + suite.Require().Contains(whitelist, "/cosmos.auth.v1beta1.Query/ModuleAccountByName") + suite.Require().Contains(whitelist, "/ibc.core.client.v1.Query/VerifyMembership") + suite.Require().NotContains(whitelist, "/cosmos.gov.v1beta1.Query/Proposals") + suite.Require().NotContains(whitelist, "/cosmos.gov.v1.Query/Proposals") + suite.Require().NotContains(whitelist, "/cosmos.distribution.v1beta1.Query/Params") + suite.Require().NotContains(whitelist, "/cosmos.distribution.v1beta1.Query/DelegationRewards") +} + func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { suite.SetupTest() From 17531fa1489724dc7c38d9b5074a732e4d3faa7e Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 16:50:41 +0700 Subject: [PATCH 58/60] imp: added logging --- modules/apps/27-interchain-accounts/host/keeper/msg_server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 3d85f6dc82a..23bc70a8e24 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -48,6 +48,7 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu Data: query.Data, }) if err != nil { + m.Logger(ctx).Debug("query failed", "path", query.Path, "error", err) return nil, err } if res == nil || res.Value == nil { From b86b3a4a96b1b626e2d8a16d56e30b998bc1497f Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 26 Mar 2024 16:59:09 +0700 Subject: [PATCH 59/60] style: rename to allow list --- .../host/keeper/export_test.go | 6 ++-- .../host/keeper/keeper.go | 16 ++++----- .../host/keeper/keeper_test.go | 34 +++++++++---------- .../host/keeper/msg_server.go | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/export_test.go b/modules/apps/27-interchain-accounts/host/keeper/export_test.go index 38b1653259d..4f413005499 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/export_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/export_test.go @@ -15,7 +15,7 @@ func (k Keeper) GetAppMetadata(ctx sdk.Context, portID, channelID string) (icaty return k.getAppMetadata(ctx, portID, channelID) } -// NewModuleQuerySafeWhitelist is a wrapper around newModuleQuerySafeWhitelist to allow the function to be directly called in tests. -func NewModuleQuerySafeWhitelist() []string { - return newModuleQuerySafeWhitelist() +// NewModuleQuerySafeAllowList is a wrapper around newModuleQuerySafeAllowList to allow the function to be directly called in tests. +func NewModuleQuerySafeAllowList() []string { + return newModuleQuerySafeAllowList() } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 8dcec38d4c0..971e953f1ca 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -45,8 +45,8 @@ type Keeper struct { msgRouter icatypes.MessageRouter queryRouter icatypes.QueryRouter - // whitelist of module safe queries - mqsWhitelist []string + // mqsAllowList is a list of all module safe query paths + mqsAllowList []string // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -80,7 +80,7 @@ func NewKeeper( scopedKeeper: scopedKeeper, msgRouter: msgRouter, queryRouter: queryRouter, - mqsWhitelist: newModuleQuerySafeWhitelist(), + mqsAllowList: newModuleQuerySafeAllowList(), authority: authority, } } @@ -274,14 +274,14 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { store.Set([]byte(types.ParamsKey), bz) } -// newModuleQuerySafeWhitelist returns a list of all query paths labeled with module_query_safe in the proto files. -func newModuleQuerySafeWhitelist() []string { +// newModuleQuerySafeAllowList returns a list of all query paths labeled with module_query_safe in the proto files. +func newModuleQuerySafeAllowList() []string { protoFiles, err := gogoproto.MergedRegistry() if err != nil { panic(err) } - whitelist := []string{} + allowList := []string{} protoFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool { for i := 0; i < fd.Services().Len(); i++ { // Get the service descriptor @@ -302,11 +302,11 @@ func newModuleQuerySafeWhitelist() []string { } // Add the method to the whitelist - whitelist = append(whitelist, fmt.Sprintf("/%s/%s", sd.FullName(), md.Name())) + allowList = append(allowList, fmt.Sprintf("/%s/%s", sd.FullName(), md.Name())) } } return true }) - return whitelist + return allowList } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index afc5eabe4b8..3b25bf90a85 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -201,29 +201,29 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } } -func (suite *KeeperTestSuite) TestNewModuleQuerySafeWhitelist() { +func (suite *KeeperTestSuite) TestNewModuleQuerySafeAllowList() { // Currently, all queries in bank, staking, auth, and circuit are marked safe // Notably, the gov and distribution modules are not marked safe - var whitelist []string + var allowList []string suite.Require().NotPanics(func() { - whitelist = keeper.NewModuleQuerySafeWhitelist() + allowList = keeper.NewModuleQuerySafeAllowList() }) - suite.Require().NotEmpty(whitelist) - suite.Require().Contains(whitelist, "/cosmos.bank.v1beta1.Query/Balance") - suite.Require().Contains(whitelist, "/cosmos.bank.v1beta1.Query/AllBalances") - suite.Require().Contains(whitelist, "/cosmos.staking.v1beta1.Query/Validator") - suite.Require().Contains(whitelist, "/cosmos.staking.v1beta1.Query/Validators") - suite.Require().Contains(whitelist, "/cosmos.circuit.v1.Query/Account") - suite.Require().Contains(whitelist, "/cosmos.circuit.v1.Query/DisabledList") - suite.Require().Contains(whitelist, "/cosmos.auth.v1beta1.Query/Accounts") - suite.Require().Contains(whitelist, "/cosmos.auth.v1beta1.Query/ModuleAccountByName") - suite.Require().Contains(whitelist, "/ibc.core.client.v1.Query/VerifyMembership") - suite.Require().NotContains(whitelist, "/cosmos.gov.v1beta1.Query/Proposals") - suite.Require().NotContains(whitelist, "/cosmos.gov.v1.Query/Proposals") - suite.Require().NotContains(whitelist, "/cosmos.distribution.v1beta1.Query/Params") - suite.Require().NotContains(whitelist, "/cosmos.distribution.v1beta1.Query/DelegationRewards") + suite.Require().NotEmpty(allowList) + suite.Require().Contains(allowList, "/cosmos.bank.v1beta1.Query/Balance") + suite.Require().Contains(allowList, "/cosmos.bank.v1beta1.Query/AllBalances") + suite.Require().Contains(allowList, "/cosmos.staking.v1beta1.Query/Validator") + suite.Require().Contains(allowList, "/cosmos.staking.v1beta1.Query/Validators") + suite.Require().Contains(allowList, "/cosmos.circuit.v1.Query/Account") + suite.Require().Contains(allowList, "/cosmos.circuit.v1.Query/DisabledList") + suite.Require().Contains(allowList, "/cosmos.auth.v1beta1.Query/Accounts") + suite.Require().Contains(allowList, "/cosmos.auth.v1beta1.Query/ModuleAccountByName") + suite.Require().Contains(allowList, "/ibc.core.client.v1.Query/VerifyMembership") + suite.Require().NotContains(allowList, "/cosmos.gov.v1beta1.Query/Proposals") + suite.Require().NotContains(allowList, "/cosmos.gov.v1.Query/Proposals") + suite.Require().NotContains(allowList, "/cosmos.distribution.v1beta1.Query/Params") + suite.Require().NotContains(allowList, "/cosmos.distribution.v1beta1.Query/DelegationRewards") } func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 23bc70a8e24..1dba2815295 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -33,7 +33,7 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu responses := make([][]byte, len(msg.Requests)) for i, query := range msg.Requests { - isModuleQuerySafe := slices.Contains(m.mqsWhitelist, query.Path) + isModuleQuerySafe := slices.Contains(m.mqsAllowList, query.Path) if !isModuleQuerySafe { return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "not module query safe: %s", query.Path) } From 72561cc557c20523c114834c587d122c0d13293e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Tue, 26 Mar 2024 20:22:23 +0100 Subject: [PATCH 60/60] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 760c399b8ef..f1ac73885eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (apps/27-interchain-accounts) [\#5785](https://github.com/cosmos/ibc-go/pull/5785) Introduce a new tx message that ICA host submodule can use to query the chain (only those marked with `module_query_safe`) and write the responses to the acknowledgement. + ### Bug Fixes ## [v8.1.0](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0) - 2024-01-31