From eef648ce4df39752e2be567502e5f009b7eda412 Mon Sep 17 00:00:00 2001 From: Nate Beauregard <51711291+natebeauregard@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:41:27 -0500 Subject: [PATCH] Add x/rollup query server (#293) --- proto/rollup/v1/query.proto | 40 ++ x/rollup/keeper/deposits.go | 17 +- x/rollup/keeper/grpc_query.go | 37 ++ x/rollup/keeper/grpc_query_test.go | 30 + x/rollup/keeper/keeper.go | 15 + x/rollup/keeper/keeper_test.go | 8 + x/rollup/keeper/msg_server.go | 2 +- x/rollup/module.go | 5 +- x/rollup/types/errors.go | 3 +- x/rollup/types/query.pb.go | 872 +++++++++++++++++++++++++++++ 10 files changed, 1009 insertions(+), 20 deletions(-) create mode 100644 proto/rollup/v1/query.proto create mode 100644 x/rollup/keeper/grpc_query.go create mode 100644 x/rollup/keeper/grpc_query_test.go create mode 100644 x/rollup/types/query.pb.go diff --git a/proto/rollup/v1/query.proto b/proto/rollup/v1/query.proto new file mode 100644 index 00000000..dba64002 --- /dev/null +++ b/proto/rollup/v1/query.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package rollup.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "rollup/v1/rollup.proto"; + +option go_package = "github.com/polymerdao/monomer/x/rollup/types"; + +// Query defines all query endpoints for the rollup module. +service Query { + // Params returns all rollup module parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/rollup/v1/params"; + } + + // L1BlockInfo returns the block info derived from L1. + rpc L1BlockInfo(QueryL1BlockInfoRequest) returns (QueryL1BlockInfoResponse) { + option (google.api.http).get = "/rollup/v1/l1_block_info"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters for the rollup module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryL1BlockInfoRequest is the request type for the Query/L1BlockInfo RPC method. +message QueryL1BlockInfoRequest {} + +// QueryL1BlockInfoResponse is response type for the Query/L1BlockInfo RPC method. +message QueryL1BlockInfoResponse { + // l1_block_info holds the block info derived from L1. + L1BlockInfo l1_block_info = 1 [(gogoproto.nullable) = false]; +} diff --git a/x/rollup/keeper/deposits.go b/x/rollup/keeper/deposits.go index 85720f23..01ee31fb 100644 --- a/x/rollup/keeper/deposits.go +++ b/x/rollup/keeper/deposits.go @@ -22,21 +22,6 @@ import ( "github.com/samber/lo" ) -// setL1BlockInfo sets the L1 block info to the app state -// -// Persisted data conforms to optimism specs on L1 attributes: -// https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-predeployed-contract -func (k *Keeper) setL1BlockInfo(ctx sdk.Context, info types.L1BlockInfo) error { //nolint:gocritic - infoBytes, err := info.Marshal() - if err != nil { - return types.WrapError(err, "marshal L1 block info") - } - if err = k.storeService.OpenKVStore(ctx).Set([]byte(types.L1BlockInfoKey), infoBytes); err != nil { - return types.WrapError(err, "set latest L1 block info") - } - return nil -} - // processL1AttributesTx processes the L1 Attributes tx and returns the L1 block info. func (k *Keeper) processL1AttributesTx(ctx sdk.Context, txBytes []byte) (*types.L1BlockInfo, error) { //nolint:gocritic // hugeParam var tx ethtypes.Transaction @@ -132,7 +117,7 @@ func (k *Keeper) processL1UserDepositTxs( params, err := k.GetParams(ctx) if err != nil { - return nil, types.WrapError(types.ErrInitiateFeeWithdrawal, "failed to get params: %v", err) + return nil, types.WrapError(types.ErrParams, "failed to get params: %v", err) } // Convert the L1CrossDomainMessenger address to its L2 aliased address diff --git a/x/rollup/keeper/grpc_query.go b/x/rollup/keeper/grpc_query.go new file mode 100644 index 00000000..68e73e48 --- /dev/null +++ b/x/rollup/keeper/grpc_query.go @@ -0,0 +1,37 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/polymerdao/monomer/x/rollup/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = (*Keeper)(nil) + +// L1BlockInfo implements the Query/L1BlockInfo gRPC method +func (k *Keeper) L1BlockInfo(ctx context.Context, req *types.QueryL1BlockInfoRequest) (*types.QueryL1BlockInfoResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + l1BlockInfo, err := k.GetL1BlockInfo(sdk.UnwrapSDKContext(ctx)) + if err != nil { + return nil, fmt.Errorf("get L1 block info: %w", err) + } + return &types.QueryL1BlockInfoResponse{L1BlockInfo: *l1BlockInfo}, nil +} + +// Params implements the Query/Params gRPC method +func (k *Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + params, err := k.GetParams(sdk.UnwrapSDKContext(ctx)) + if err != nil { + return nil, fmt.Errorf("get params: %w", err) + } + return &types.QueryParamsResponse{Params: *params}, nil +} diff --git a/x/rollup/keeper/grpc_query_test.go b/x/rollup/keeper/grpc_query_test.go new file mode 100644 index 00000000..3f720e74 --- /dev/null +++ b/x/rollup/keeper/grpc_query_test.go @@ -0,0 +1,30 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/polymerdao/monomer/x/rollup/types" +) + +func (s *KeeperTestSuite) TestParamsQuery() { + params := types.DefaultParams() + err := s.rollupKeeper.SetParams(sdk.UnwrapSDKContext(s.ctx), ¶ms) + s.Require().NoError(err) + + response, err := s.rollupKeeper.Params(s.ctx, &types.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().Equal(&types.QueryParamsResponse{Params: params}, response) +} + +func (s *KeeperTestSuite) TestL1BlockInfoQuery() { + l1BlockInfo := types.L1BlockInfo{ + Number: 1, + Time: 1, + } + + err := s.rollupKeeper.SetL1BlockInfo(sdk.UnwrapSDKContext(s.ctx), l1BlockInfo) + s.Require().NoError(err) + + response, err := s.rollupKeeper.L1BlockInfo(s.ctx, &types.QueryL1BlockInfoRequest{}) + s.Require().NoError(err) + s.Require().Equal(&types.QueryL1BlockInfoResponse{L1BlockInfo: l1BlockInfo}, response) +} diff --git a/x/rollup/keeper/keeper.go b/x/rollup/keeper/keeper.go index 5c87162e..8e82cc61 100644 --- a/x/rollup/keeper/keeper.go +++ b/x/rollup/keeper/keeper.go @@ -61,6 +61,21 @@ func (k *Keeper) GetL1BlockInfo(ctx sdk.Context) (*types.L1BlockInfo, error) { / return &l1BlockInfo, nil } +// SetL1BlockInfo sets the derived L1 block info in the rollup store. +// +// Persisted data conforms to optimism specs on L1 attributes: +// https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-predeployed-contract +func (k *Keeper) SetL1BlockInfo(ctx sdk.Context, info types.L1BlockInfo) error { //nolint:gocritic + infoBytes, err := info.Marshal() + if err != nil { + return types.WrapError(err, "marshal L1 block info") + } + if err = k.storeService.OpenKVStore(ctx).Set([]byte(types.L1BlockInfoKey), infoBytes); err != nil { + return types.WrapError(err, "set latest L1 block info") + } + return nil +} + func (k *Keeper) GetParams(ctx sdk.Context) (*types.Params, error) { //nolint:gocritic // hugeParam paramsBz, err := k.storeService.OpenKVStore(ctx).Get([]byte(types.ParamsKey)) if err != nil { diff --git a/x/rollup/keeper/keeper_test.go b/x/rollup/keeper/keeper_test.go index 8185fe2f..7b6d2fc5 100644 --- a/x/rollup/keeper/keeper_test.go +++ b/x/rollup/keeper/keeper_test.go @@ -32,7 +32,15 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } +func (s *KeeperTestSuite) SetupTest() { + s.setup() +} + func (s *KeeperTestSuite) SetupSubTest() { + s.setup() +} + +func (s *KeeperTestSuite) setup() { storeKey := storetypes.NewKVStoreKey(types.StoreKey) s.ctx = testutil.DefaultContextWithDB( s.T(), diff --git a/x/rollup/keeper/msg_server.go b/x/rollup/keeper/msg_server.go index c0afe0d9..c4b4c51e 100644 --- a/x/rollup/keeper/msg_server.go +++ b/x/rollup/keeper/msg_server.go @@ -27,7 +27,7 @@ func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *types.MsgApplyL1Txs) (*t } // save L1 block info to AppState - if err = k.setL1BlockInfo(ctx, *l1blockInfo); err != nil { + if err = k.SetL1BlockInfo(ctx, *l1blockInfo); err != nil { return nil, types.WrapError(types.ErrL1BlockInfo, "save error: %v", err) } diff --git a/x/rollup/module.go b/x/rollup/module.go index 2412565d..93cc05a5 100644 --- a/x/rollup/module.go +++ b/x/rollup/module.go @@ -167,10 +167,11 @@ func (am AppModule) Name() string { // QuerierRoute returns the rollup module's query routing key. func (AppModule) QuerierRoute() string { return types.QuerierRoute } -// RegisterServices registers a GRPC query service to respond to the -// module-specific GRPC queries. +// RegisterServices registers a Msg service to respond to module-specific messages and a GRPC query service to respond +// to module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the rollup module's invariants. diff --git a/x/rollup/types/errors.go b/x/rollup/types/errors.go index 2d2b53f3..dabfc5bc 100644 --- a/x/rollup/types/errors.go +++ b/x/rollup/types/errors.go @@ -14,7 +14,8 @@ var ( ErrMintETH = registerErr("failed to mint ETH") ErrBurnETH = registerErr("failed to burn ETH") ErrInvalidSender = registerErr("invalid sender address") - ErrL1BlockInfo = registerErr("L1 block info") + ErrL1BlockInfo = registerErr("l1 block info") + ErrParams = registerErr("params") ErrProcessL1UserDepositTxs = registerErr("failed to process L1 user deposit txs") ErrProcessL1SystemDepositTx = registerErr("failed to process L1 system deposit tx") ErrInitiateFeeWithdrawal = registerErr("failed to initiate fee withdrawal") diff --git a/x/rollup/types/query.pb.go b/x/rollup/types/query.pb.go new file mode 100644 index 00000000..506c2525 --- /dev/null +++ b/x/rollup/types/query.pb.go @@ -0,0 +1,872 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rollup/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3e27fbb9d8b6a617, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters for the rollup module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3e27fbb9d8b6a617, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryL1BlockInfoRequest is the request type for the Query/L1BlockInfo RPC method. +type QueryL1BlockInfoRequest struct { +} + +func (m *QueryL1BlockInfoRequest) Reset() { *m = QueryL1BlockInfoRequest{} } +func (m *QueryL1BlockInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryL1BlockInfoRequest) ProtoMessage() {} +func (*QueryL1BlockInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3e27fbb9d8b6a617, []int{2} +} +func (m *QueryL1BlockInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryL1BlockInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryL1BlockInfoRequest.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 *QueryL1BlockInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryL1BlockInfoRequest.Merge(m, src) +} +func (m *QueryL1BlockInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryL1BlockInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryL1BlockInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryL1BlockInfoRequest proto.InternalMessageInfo + +// QueryL1BlockInfoResponse is response type for the Query/L1BlockInfo RPC method. +type QueryL1BlockInfoResponse struct { + // l1_block_info holds the block info derived from L1. + L1BlockInfo L1BlockInfo `protobuf:"bytes,1,opt,name=l1_block_info,json=l1BlockInfo,proto3" json:"l1_block_info"` +} + +func (m *QueryL1BlockInfoResponse) Reset() { *m = QueryL1BlockInfoResponse{} } +func (m *QueryL1BlockInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryL1BlockInfoResponse) ProtoMessage() {} +func (*QueryL1BlockInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3e27fbb9d8b6a617, []int{3} +} +func (m *QueryL1BlockInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryL1BlockInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryL1BlockInfoResponse.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 *QueryL1BlockInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryL1BlockInfoResponse.Merge(m, src) +} +func (m *QueryL1BlockInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryL1BlockInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryL1BlockInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryL1BlockInfoResponse proto.InternalMessageInfo + +func (m *QueryL1BlockInfoResponse) GetL1BlockInfo() L1BlockInfo { + if m != nil { + return m.L1BlockInfo + } + return L1BlockInfo{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "rollup.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "rollup.v1.QueryParamsResponse") + proto.RegisterType((*QueryL1BlockInfoRequest)(nil), "rollup.v1.QueryL1BlockInfoRequest") + proto.RegisterType((*QueryL1BlockInfoResponse)(nil), "rollup.v1.QueryL1BlockInfoResponse") +} + +func init() { proto.RegisterFile("rollup/v1/query.proto", fileDescriptor_3e27fbb9d8b6a617) } + +var fileDescriptor_3e27fbb9d8b6a617 = []byte{ + // 357 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xcd, 0x4e, 0xc2, 0x40, + 0x14, 0x85, 0x5b, 0xa3, 0x24, 0x0e, 0x71, 0xc1, 0x80, 0x08, 0x8d, 0x56, 0x52, 0x37, 0x2e, 0x4c, + 0x27, 0xc5, 0x17, 0x30, 0x2c, 0x48, 0x4c, 0x5c, 0x28, 0x4b, 0x63, 0x42, 0x5a, 0x1c, 0x6a, 0xe3, + 0x74, 0xee, 0xd0, 0x1f, 0x02, 0x5b, 0x9f, 0xc0, 0xc4, 0x97, 0x62, 0x49, 0xe2, 0xc6, 0x95, 0x31, + 0xa0, 0xef, 0x61, 0x98, 0x0e, 0x52, 0x24, 0xba, 0x6b, 0xce, 0x3d, 0x73, 0xbe, 0x73, 0x6f, 0x8a, + 0xf6, 0x23, 0x60, 0x2c, 0x15, 0x64, 0xe8, 0x90, 0x41, 0x4a, 0xa3, 0xb1, 0x2d, 0x22, 0x48, 0x00, + 0xef, 0x66, 0xb2, 0x3d, 0x74, 0x8c, 0x8a, 0x0f, 0x3e, 0x48, 0x95, 0x2c, 0xbe, 0x32, 0x83, 0x71, + 0xe8, 0x03, 0xf8, 0x8c, 0x12, 0x57, 0x04, 0xc4, 0xe5, 0x1c, 0x12, 0x37, 0x09, 0x80, 0xc7, 0x6a, + 0x5a, 0x5d, 0xa5, 0xaa, 0x20, 0xa9, 0x5b, 0x15, 0x84, 0x6f, 0x16, 0x94, 0x6b, 0x37, 0x72, 0xc3, + 0xb8, 0x43, 0x07, 0x29, 0x8d, 0x13, 0xab, 0x8d, 0xca, 0x6b, 0x6a, 0x2c, 0x80, 0xc7, 0x14, 0x13, + 0x54, 0x10, 0x52, 0xa9, 0xe9, 0x0d, 0xfd, 0xb4, 0xd8, 0x2c, 0xd9, 0x3f, 0xa5, 0xec, 0xcc, 0xda, + 0xda, 0x9e, 0xbc, 0x1f, 0x6b, 0x1d, 0x65, 0xb3, 0xea, 0xe8, 0x40, 0xe6, 0x5c, 0x39, 0x2d, 0x06, + 0xbd, 0xc7, 0x4b, 0xde, 0x87, 0x25, 0xe2, 0x0e, 0xd5, 0x36, 0x47, 0x8a, 0x73, 0x81, 0xf6, 0x98, + 0xd3, 0xf5, 0x16, 0x7a, 0x37, 0xe0, 0x7d, 0x50, 0xb8, 0x6a, 0x0e, 0x97, 0x7b, 0xa6, 0x98, 0x45, + 0xb6, 0x92, 0x9a, 0x5f, 0x3a, 0xda, 0x91, 0xf1, 0xd8, 0x43, 0x85, 0xac, 0x1a, 0x3e, 0xca, 0x3d, + 0xdf, 0xdc, 0xd9, 0x30, 0xff, 0x1a, 0x67, 0xa5, 0xac, 0xfa, 0xd3, 0xeb, 0xe7, 0xcb, 0x56, 0x19, + 0x97, 0xc8, 0xea, 0x94, 0xd9, 0x9a, 0x78, 0x84, 0x8a, 0xb9, 0x3e, 0xd8, 0xfa, 0x9d, 0xb4, 0xb9, + 0xbe, 0x71, 0xf2, 0xaf, 0x47, 0x21, 0x1b, 0x12, 0x69, 0xe0, 0x5a, 0x0e, 0xb9, 0x76, 0x98, 0x56, + 0x7b, 0x32, 0x33, 0xf5, 0xe9, 0xcc, 0xd4, 0x3f, 0x66, 0xa6, 0xfe, 0x3c, 0x37, 0xb5, 0xe9, 0xdc, + 0xd4, 0xde, 0xe6, 0xa6, 0x76, 0x7b, 0xe6, 0x07, 0xc9, 0x43, 0xea, 0xd9, 0x3d, 0x08, 0x89, 0x00, + 0x36, 0x0e, 0x69, 0x74, 0xef, 0x02, 0x09, 0x81, 0x43, 0x48, 0x23, 0x32, 0x5a, 0x46, 0x26, 0x63, + 0x41, 0x63, 0xaf, 0x20, 0xff, 0x86, 0xf3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf2, 0xf6, 0x9d, + 0x7e, 0x7d, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params returns all rollup module parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // L1BlockInfo returns the block info derived from L1. + L1BlockInfo(ctx context.Context, in *QueryL1BlockInfoRequest, opts ...grpc.CallOption) (*QueryL1BlockInfoResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/rollup.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) L1BlockInfo(ctx context.Context, in *QueryL1BlockInfoRequest, opts ...grpc.CallOption) (*QueryL1BlockInfoResponse, error) { + out := new(QueryL1BlockInfoResponse) + err := c.cc.Invoke(ctx, "/rollup.v1.Query/L1BlockInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns all rollup module parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // L1BlockInfo returns the block info derived from L1. + L1BlockInfo(context.Context, *QueryL1BlockInfoRequest) (*QueryL1BlockInfoResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) L1BlockInfo(ctx context.Context, req *QueryL1BlockInfoRequest) (*QueryL1BlockInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method L1BlockInfo not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollup.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_L1BlockInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryL1BlockInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).L1BlockInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollup.v1.Query/L1BlockInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).L1BlockInfo(ctx, req.(*QueryL1BlockInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rollup.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "L1BlockInfo", + Handler: _Query_L1BlockInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rollup/v1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryL1BlockInfoRequest) 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 *QueryL1BlockInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryL1BlockInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryL1BlockInfoResponse) 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 *QueryL1BlockInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryL1BlockInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.L1BlockInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryL1BlockInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryL1BlockInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.L1BlockInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryL1BlockInfoRequest) 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: QueryL1BlockInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryL1BlockInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryL1BlockInfoResponse) 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: QueryL1BlockInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryL1BlockInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field L1BlockInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.L1BlockInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +)