From e74d5d1393c4278cc0320e3bddb15092ade37dd2 Mon Sep 17 00:00:00 2001 From: Steve Miskovetz Date: Tue, 10 Oct 2023 11:01:38 -0600 Subject: [PATCH] Add mailbox query for delivered messages --- interchaintest/helpers/mailbox.go | 21 + interchaintest/tests/module_mailbox_test.go | 18 +- proto/hyperlane/mailbox/v1/query.proto | 15 +- x/mailbox/client/cli/cli.go | 3 +- x/mailbox/client/cli/query.go | 43 +- x/mailbox/keeper/grpc_query.go | 26 +- x/mailbox/types/query.pb.go | 447 ++++++++++++++++++-- x/mailbox/types/query.pb.gw.go | 77 ++++ 8 files changed, 607 insertions(+), 43 deletions(-) diff --git a/interchaintest/helpers/mailbox.go b/interchaintest/helpers/mailbox.go index edf749f..1e2dd16 100644 --- a/interchaintest/helpers/mailbox.go +++ b/interchaintest/helpers/mailbox.go @@ -141,6 +141,27 @@ func QueryCurrentTreeMetadata( return stdout } +// simd query hyperlane-mailbox delivered +func QueryMsgDelivered( + t *testing.T, + ctx context.Context, + chain *cosmos.CosmosChain, + msgId string, +) bool { + cmd := []string{ + "simd", "query", "hyperlane-mailbox", "delivered", msgId, + "--node", chain.GetRPCAddress(), + "--home", chain.HomeDir(), + "--chain-id", chain.Config().ChainID, + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + fmt.Println("MsgDelivered stdout: ", string(stdout)) + + return strings.Contains(string(stdout), "true") +} + // simd query hyperlane-mailbox tree func QueryCurrentTree( t *testing.T, diff --git a/interchaintest/tests/module_mailbox_test.go b/interchaintest/tests/module_mailbox_test.go index 7c1ef02..2be366b 100644 --- a/interchaintest/tests/module_mailbox_test.go +++ b/interchaintest/tests/module_mailbox_test.go @@ -27,6 +27,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v7/testutil" "github.com/stretchr/testify/require" + common "github.com/strangelove-ventures/hyperlane-cosmos/x/common" "github.com/strangelove-ventures/hyperlane-cosmos/x/ism/types/legacy_multisig" ) @@ -75,27 +76,32 @@ func TestHyperlaneMailbox(t *testing.T) { // Create first legacy multisig message from counter chain 1 sender := "0xbcb815f38D481a5EBA4D7ac4c9E74D9D0FC2A7e7" destDomain := uint32(12345) - message, proof := counterChain1.CreateMessage(sender, destDomain, destDomain, contract, "Legacy Multisig 1") + message, proof := counterChain1.CreateMessage(sender, 1, destDomain, contract, "Legacy Multisig 1") metadata := counterChain1.CreateLegacyMetadata(message, proof) + msgId := hexutil.Encode(common.Id(message)) + delivered := helpers.QueryMsgDelivered(t, ctx, simd, msgId) + require.False(t, delivered) helpers.CallProcessMsg(t, ctx, simd, user.KeyName(), hexutil.Encode(metadata), hexutil.Encode(message)) + delivered = helpers.QueryMsgDelivered(t, ctx, simd, msgId) + require.True(t, delivered) // Create second legacy multisig message from counter chain 1 - message, proof = counterChain1.CreateMessage(sender, destDomain, destDomain, contract, "Legacy Multisig 2") + message, proof = counterChain1.CreateMessage(sender, 1, destDomain, contract, "Legacy Multisig 2") metadata = counterChain1.CreateLegacyMetadata(message, proof) helpers.CallProcessMsg(t, ctx, simd, user.KeyName(), hexutil.Encode(metadata), hexutil.Encode(message)) // Create third legacy multisig message from counter chain 1 - message, proof = counterChain1.CreateMessage(sender, destDomain, destDomain, contract, "Legacy Multisig 3") + message, proof = counterChain1.CreateMessage(sender, 1, destDomain, contract, "Legacy Multisig 3") metadata = counterChain1.CreateLegacyMetadata(message, proof) helpers.CallProcessMsg(t, ctx, simd, user.KeyName(), hexutil.Encode(metadata), hexutil.Encode(message)) // Create first message id multisig message from counter chain 2 - message, _ = counterChain2.CreateMessage(sender, destDomain, destDomain, contract, "Message Id Multisig 1") + message, _ = counterChain2.CreateMessage(sender, 2, destDomain, contract, "Message Id Multisig 1") metadata = counterChain2.CreateMessageIdMetadata(message) helpers.CallProcessMsg(t, ctx, simd, user.KeyName(), hexutil.Encode(metadata), hexutil.Encode(message)) // Create first merkle root multisig message from counter chain 3 - message, proof = counterChain3.CreateMessage(sender, destDomain, destDomain, contract, "Merkle Root Multisig 1") + message, proof = counterChain3.CreateMessage(sender, 3, destDomain, contract, "Merkle Root Multisig 1") metadata = counterChain3.CreateMerkleRootMetadata(message, proof) helpers.CallProcessMsg(t, ctx, simd, user.KeyName(), hexutil.Encode(metadata), hexutil.Encode(message)) @@ -110,7 +116,7 @@ func TestHyperlaneMailbox(t *testing.T) { require.NoError(t, err) simd.ExecuteContract(ctx, user.KeyName(), contract, string(dipatchMsg)) - err = testutil.WaitForBlocks(ctx, 125, simd) + err = testutil.WaitForBlocks(ctx, 2, simd) require.NoError(t, err) } diff --git a/proto/hyperlane/mailbox/v1/query.proto b/proto/hyperlane/mailbox/v1/query.proto index c319df2..99c0079 100644 --- a/proto/hyperlane/mailbox/v1/query.proto +++ b/proto/hyperlane/mailbox/v1/query.proto @@ -22,6 +22,12 @@ service Query { rpc CurrentTree(QueryCurrentTreeRequest) returns (QueryCurrentTreeResponse) { option (google.api.http).get = "/hyperlane/mailbox/v1/tree"; } + + // Check if message was delivered + rpc MsgDelivered(QueryMsgDeliveredRequest) + returns (QueryMsgDeliveredResponse) { + option (google.api.http).get = "/hyperlane/mailbox/v1/delivered"; + } } // QueryCurrentTreeMetadataRequest is the request type for the Query/Tree @@ -49,4 +55,11 @@ message QueryCurrentTreeResponse { message QueryDomainRequest {} // QueryDomainResponse is the response type for the Query/Domain RPC method. -message QueryDomainResponse { uint32 domain = 1; } \ No newline at end of file +message QueryDomainResponse { uint32 domain = 1; } + +// QueryMsgDeliveredRequest is the request type to check if message was +// delivered +message QueryMsgDeliveredRequest { bytes message_id = 1; } + +// QueryMsgDeliveredResponse is the response type if message was delivered +message QueryMsgDeliveredResponse { bool delivered = 1; } diff --git a/x/mailbox/client/cli/cli.go b/x/mailbox/client/cli/cli.go index 25a3ccd..d831371 100644 --- a/x/mailbox/client/cli/cli.go +++ b/x/mailbox/client/cli/cli.go @@ -20,7 +20,8 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( getCurrentTreeMetadataCmd(), getCurrentTreeCmd(), - getDomain(), + getDomainCmd(), + getMsgDeliveredCmd(), ) return queryCmd diff --git a/x/mailbox/client/cli/query.go b/x/mailbox/client/cli/query.go index 45abb36..2d4a55d 100644 --- a/x/mailbox/client/cli/query.go +++ b/x/mailbox/client/cli/query.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/spf13/cobra" "github.com/strangelove-ventures/hyperlane-cosmos/x/mailbox/types" @@ -74,8 +75,8 @@ func getCurrentTreeCmd() *cobra.Command { return cmd } -// getCurrentTreeMetadataCmd defines the command to query the current tree metadata -func getDomain() *cobra.Command { +// getDomainCmd defines the command to query the chain domain +func getDomainCmd() *cobra.Command { cmd := &cobra.Command{ Use: "domain", Short: "Query domain", @@ -104,3 +105,41 @@ func getDomain() *cobra.Command { return cmd } + +// getMsgDeliveredCmd defines the command to query if a message has been delivered +func getMsgDeliveredCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "delivered [message-id-hex]", + Short: "Query message delivered", + Long: "Query whether a message has been delivered", + Example: fmt.Sprintf("%s query %s delivered [message-id-hex]", version.AppName, types.ModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + msgId, err := hexutil.Decode(args[0]) + if err != nil { + return err + } + + req := types.QueryMsgDeliveredRequest{ + MessageId: msgId, + } + + res, err := queryClient.MsgDelivered(context.Background(), &req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/mailbox/keeper/grpc_query.go b/x/mailbox/keeper/grpc_query.go index 94dc982..9e61794 100644 --- a/x/mailbox/keeper/grpc_query.go +++ b/x/mailbox/keeper/grpc_query.go @@ -8,6 +8,7 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/strangelove-ventures/hyperlane-cosmos/x/mailbox/types" ) @@ -31,11 +32,6 @@ func (k Keeper) CurrentTree(c context.Context, req *types.QueryCurrentTreeReques return nil, status.Error(codes.InvalidArgument, "empty request") } - /*branches := [][]byte{} - for _, branch := range k.Tree.GetProofForNextIndex() { - branches = append(branches, branch[:]) - }*/ - return &types.QueryCurrentTreeResponse{ Branches: k.Tree.Branch[:], Count: k.Tree.Count(), @@ -57,3 +53,23 @@ func (k Keeper) Domain(c context.Context, req *types.QueryDomainRequest) (*types Domain: domain, }, nil } + +// MsgDelivered implements the Query/MsgDelivered gRPC method +func (k Keeper) MsgDelivered(c context.Context, req *types.QueryMsgDeliveredRequest) (*types.QueryMsgDeliveredResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + delivered := false + msgId := hexutil.Encode(req.MessageId) + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(k.storeKey) + if store.Has(types.MailboxDeliveredKey(msgId)) { + delivered = true + } + + return &types.QueryMsgDeliveredResponse{ + Delivered: delivered, + }, nil +} diff --git a/x/mailbox/types/query.pb.go b/x/mailbox/types/query.pb.go index 87a1113..38a5957 100644 --- a/x/mailbox/types/query.pb.go +++ b/x/mailbox/types/query.pb.go @@ -323,6 +323,107 @@ func (m *QueryDomainResponse) GetDomain() uint32 { return 0 } +// QueryMsgDeliveredRequest is the request type to check if message was +// delivered +type QueryMsgDeliveredRequest struct { + MessageId []byte `protobuf:"bytes,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` +} + +func (m *QueryMsgDeliveredRequest) Reset() { *m = QueryMsgDeliveredRequest{} } +func (m *QueryMsgDeliveredRequest) String() string { return proto.CompactTextString(m) } +func (*QueryMsgDeliveredRequest) ProtoMessage() {} +func (*QueryMsgDeliveredRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_567dd9a34f8715cd, []int{6} +} + +func (m *QueryMsgDeliveredRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *QueryMsgDeliveredRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMsgDeliveredRequest.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 *QueryMsgDeliveredRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMsgDeliveredRequest.Merge(m, src) +} + +func (m *QueryMsgDeliveredRequest) XXX_Size() int { + return m.Size() +} + +func (m *QueryMsgDeliveredRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMsgDeliveredRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMsgDeliveredRequest proto.InternalMessageInfo + +func (m *QueryMsgDeliveredRequest) GetMessageId() []byte { + if m != nil { + return m.MessageId + } + return nil +} + +// QueryMsgDeliveredResponse is the response type if message was delivered +type QueryMsgDeliveredResponse struct { + Delivered bool `protobuf:"varint,1,opt,name=delivered,proto3" json:"delivered,omitempty"` +} + +func (m *QueryMsgDeliveredResponse) Reset() { *m = QueryMsgDeliveredResponse{} } +func (m *QueryMsgDeliveredResponse) String() string { return proto.CompactTextString(m) } +func (*QueryMsgDeliveredResponse) ProtoMessage() {} +func (*QueryMsgDeliveredResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_567dd9a34f8715cd, []int{7} +} + +func (m *QueryMsgDeliveredResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *QueryMsgDeliveredResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMsgDeliveredResponse.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 *QueryMsgDeliveredResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMsgDeliveredResponse.Merge(m, src) +} + +func (m *QueryMsgDeliveredResponse) XXX_Size() int { + return m.Size() +} + +func (m *QueryMsgDeliveredResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMsgDeliveredResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMsgDeliveredResponse proto.InternalMessageInfo + +func (m *QueryMsgDeliveredResponse) GetDelivered() bool { + if m != nil { + return m.Delivered + } + return false +} + func init() { proto.RegisterType((*QueryCurrentTreeMetadataRequest)(nil), "hyperlane.mailbox.v1.QueryCurrentTreeMetadataRequest") proto.RegisterType((*QueryCurrentTreeMetadataResponse)(nil), "hyperlane.mailbox.v1.QueryCurrentTreeMetadataResponse") @@ -330,39 +431,46 @@ func init() { proto.RegisterType((*QueryCurrentTreeResponse)(nil), "hyperlane.mailbox.v1.QueryCurrentTreeResponse") proto.RegisterType((*QueryDomainRequest)(nil), "hyperlane.mailbox.v1.QueryDomainRequest") proto.RegisterType((*QueryDomainResponse)(nil), "hyperlane.mailbox.v1.QueryDomainResponse") + proto.RegisterType((*QueryMsgDeliveredRequest)(nil), "hyperlane.mailbox.v1.QueryMsgDeliveredRequest") + proto.RegisterType((*QueryMsgDeliveredResponse)(nil), "hyperlane.mailbox.v1.QueryMsgDeliveredResponse") } func init() { proto.RegisterFile("hyperlane/mailbox/v1/query.proto", fileDescriptor_567dd9a34f8715cd) } var fileDescriptor_567dd9a34f8715cd = []byte{ - // 425 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xc1, 0x6e, 0xd3, 0x40, - 0x14, 0x45, 0x33, 0x2d, 0x8d, 0xd0, 0xd0, 0x6e, 0xa6, 0x11, 0x04, 0x2b, 0x32, 0xc6, 0x80, 0x64, - 0x84, 0xec, 0x51, 0x41, 0xb0, 0x46, 0xc0, 0x12, 0x16, 0x58, 0xac, 0xba, 0x41, 0x63,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0xfa, 0x11, 0x00, 0x00, 0xff, - 0xff, 0x15, 0x17, 0x10, 0x83, 0xb0, 0x03, 0x00, 0x00, + // 504 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xbf, 0x6e, 0xd3, 0x40, + 0x18, 0xcf, 0x95, 0x36, 0x6a, 0x8f, 0x74, 0xb9, 0x46, 0x90, 0x5a, 0xc1, 0x75, 0x0d, 0x88, 0x20, + 0x14, 0x5b, 0x05, 0x81, 0xd4, 0x0d, 0x41, 0x17, 0x24, 0x3a, 0x60, 0x31, 0x75, 0xa9, 0x2e, 0xf1, + 0x27, 0xc7, 0x92, 0x7d, 0xe7, 0xde, 0x9d, 0xad, 0x66, 0x85, 0x17, 0xa8, 0xc4, 0xc2, 0x6b, 0xf0, + 0x16, 0x8c, 0x95, 0x58, 0x18, 0x51, 0xc2, 0xce, 0x2b, 0x20, 0xce, 0xe7, 0xa4, 0x05, 0x27, 0xa4, + 0x5b, 0xee, 0xcb, 0xef, 0xdf, 0xf7, 0x47, 0xc6, 0xce, 0x68, 0x9c, 0x81, 0x48, 0x28, 0x03, 0x3f, + 0xa5, 0x71, 0x32, 0xe0, 0xe7, 0x7e, 0x71, 0xe0, 0x9f, 0xe5, 0x20, 0xc6, 0x5e, 0x26, 0xb8, 0xe2, + 0xa4, 0x3d, 0x43, 0x78, 0x06, 0xe1, 0x15, 0x07, 0x56, 0x37, 0xe2, 0x3c, 0x4a, 0xc0, 0xa7, 0x59, + 0xec, 0x53, 0xc6, 0xb8, 0xa2, 0x2a, 0xe6, 0x4c, 0x96, 0x1c, 0x77, 0x1f, 0xef, 0xbd, 0xfb, 0x23, + 0xf1, 0x3a, 0x17, 0x02, 0x98, 0x7a, 0x2f, 0x00, 0x8e, 0x41, 0xd1, 0x90, 0x2a, 0x1a, 0xc0, 0x59, + 0x0e, 0x52, 0xb9, 0x6f, 0xb1, 0xb3, 0x18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 0xb8, 0x59, 0x8e, + 0x97, 0xf4, 0x96, 0xf8, 0x5d, 0xdb, 0x8b, 0xf5, 0x78, 0x05, 0xa4, 0x09, 0xf3, 0x40, 0x87, 0xb1, + 0x49, 0xb7, 0x3e, 0x4c, 0xb9, 0x39, 0x72, 0x81, 0xf0, 0xed, 0x2b, 0x2d, 0x91, 0xfe, 0x6a, 0xad, + 0x57, 0x79, 0xbc, 0x55, 0xe1, 0x26, 0x94, 0xab, 0x43, 0x75, 0x89, 0xb5, 0x78, 0x42, 0xe4, 0x33, + 0xc2, 0xad, 0xab, 0xd7, 0x40, 0x96, 0x99, 0xd4, 0x5c, 0x9c, 0xe5, 0xaf, 0x8c, 0x37, 0xa9, 0x1e, + 0xe9, 0x54, 0xfb, 0x64, 0x6f, 0xc1, 0xa8, 0x2a, 0xc2, 0xab, 0x93, 0xaf, 0x13, 0x1b, 0x5d, 0x4e, + 0x6c, 0xf4, 0x63, 0x62, 0xa3, 0x8b, 0xa9, 0xdd, 0xb8, 0x9c, 0xda, 0x8d, 0xef, 0x53, 0xbb, 0x71, + 0xf2, 0x32, 0x8a, 0xd5, 0x28, 0x1f, 0x78, 0x43, 0x9e, 0xfa, 0x52, 0x09, 0xca, 0x22, 0x48, 0x78, + 0x01, 0xfd, 0x02, 0x98, 0xca, 0x05, 0xc8, 0xb9, 0x72, 0x7f, 0xc8, 0x65, 0xca, 0xa5, 0x7f, 0x3e, + 0xb3, 0x50, 0xe3, 0x0c, 0xe4, 0xa0, 0xa9, 0xbf, 0x34, 0xcf, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, + 0xdf, 0x4e, 0x60, 0xd4, 0xc1, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -385,6 +493,8 @@ type QueryClient interface { Domain(ctx context.Context, in *QueryDomainRequest, opts ...grpc.CallOption) (*QueryDomainResponse, error) // Get current tree CurrentTree(ctx context.Context, in *QueryCurrentTreeRequest, opts ...grpc.CallOption) (*QueryCurrentTreeResponse, error) + // Check if message was delivered + MsgDelivered(ctx context.Context, in *QueryMsgDeliveredRequest, opts ...grpc.CallOption) (*QueryMsgDeliveredResponse, error) } type queryClient struct { @@ -422,6 +532,15 @@ func (c *queryClient) CurrentTree(ctx context.Context, in *QueryCurrentTreeReque return out, nil } +func (c *queryClient) MsgDelivered(ctx context.Context, in *QueryMsgDeliveredRequest, opts ...grpc.CallOption) (*QueryMsgDeliveredResponse, error) { + out := new(QueryMsgDeliveredResponse) + err := c.cc.Invoke(ctx, "/hyperlane.mailbox.v1.Query/MsgDelivered", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Get current tree metadata @@ -430,6 +549,8 @@ type QueryServer interface { Domain(context.Context, *QueryDomainRequest) (*QueryDomainResponse, error) // Get current tree CurrentTree(context.Context, *QueryCurrentTreeRequest) (*QueryCurrentTreeResponse, error) + // Check if message was delivered + MsgDelivered(context.Context, *QueryMsgDeliveredRequest) (*QueryMsgDeliveredResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -447,6 +568,10 @@ func (*UnimplementedQueryServer) CurrentTree(ctx context.Context, req *QueryCurr return nil, status.Errorf(codes.Unimplemented, "method CurrentTree not implemented") } +func (*UnimplementedQueryServer) MsgDelivered(ctx context.Context, req *QueryMsgDeliveredRequest) (*QueryMsgDeliveredResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MsgDelivered not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } @@ -505,6 +630,24 @@ func _Query_CurrentTree_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_MsgDelivered_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryMsgDeliveredRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).MsgDelivered(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hyperlane.mailbox.v1.Query/MsgDelivered", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).MsgDelivered(ctx, req.(*QueryMsgDeliveredRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "hyperlane.mailbox.v1.Query", HandlerType: (*QueryServer)(nil), @@ -521,6 +664,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "CurrentTree", Handler: _Query_CurrentTree_Handler, }, + { + MethodName: "MsgDelivered", + Handler: _Query_MsgDelivered_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "hyperlane/mailbox/v1/query.proto", @@ -695,6 +842,69 @@ func (m *QueryDomainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryMsgDeliveredRequest) 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 *QueryMsgDeliveredRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMsgDeliveredRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MessageId) > 0 { + i -= len(m.MessageId) + copy(dAtA[i:], m.MessageId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MessageId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryMsgDeliveredResponse) 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 *QueryMsgDeliveredResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMsgDeliveredResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Delivered { + i-- + if m.Delivered { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -780,6 +990,31 @@ func (m *QueryDomainResponse) Size() (n int) { return n } +func (m *QueryMsgDeliveredRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MessageId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryMsgDeliveredResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Delivered { + n += 2 + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1217,6 +1452,162 @@ func (m *QueryDomainResponse) Unmarshal(dAtA []byte) error { return nil } +func (m *QueryMsgDeliveredRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryMsgDeliveredRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMsgDeliveredRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MessageId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MessageId = append(m.MessageId[:0], dAtA[iNdEx:postIndex]...) + if m.MessageId == nil { + m.MessageId = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *QueryMsgDeliveredResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryMsgDeliveredResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMsgDeliveredResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Delivered", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Delivered = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/mailbox/types/query.pb.gw.go b/x/mailbox/types/query.pb.gw.go index d4f5404..638f248 100644 --- a/x/mailbox/types/query.pb.gw.go +++ b/x/mailbox/types/query.pb.gw.go @@ -83,6 +83,38 @@ func local_request_Query_CurrentTree_0(ctx context.Context, marshaler runtime.Ma return msg, metadata, err } +var filter_Query_MsgDelivered_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_Query_MsgDelivered_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMsgDeliveredRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MsgDelivered_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.MsgDelivered(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Query_MsgDelivered_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMsgDeliveredRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MsgDelivered_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.MsgDelivered(ctx, &protoReq) + return msg, metadata, err +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -154,6 +186,28 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv forward_Query_CurrentTree_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle("GET", pattern_Query_MsgDelivered_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_MsgDelivered_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MsgDelivered_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil } @@ -251,6 +305,25 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie forward_Query_CurrentTree_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle("GET", pattern_Query_MsgDelivered_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_MsgDelivered_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MsgDelivered_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil } @@ -260,6 +333,8 @@ var ( pattern_Query_Domain_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hyperlane", "mailbox", "v1", "domain"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_CurrentTree_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hyperlane", "mailbox", "v1", "tree"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_MsgDelivered_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hyperlane", "mailbox", "v1", "delivered"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -268,4 +343,6 @@ var ( forward_Query_Domain_0 = runtime.ForwardResponseMessage forward_Query_CurrentTree_0 = runtime.ForwardResponseMessage + + forward_Query_MsgDelivered_0 = runtime.ForwardResponseMessage )