From 4521f9aeae8a900c4aac79a85049c4ea1a2da15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Tue, 10 Sep 2024 14:24:30 +0200 Subject: [PATCH] feat: pass Options in grpc proxy --- proto/da/da.proto | 2 +- proxy/grpc/client.go | 1 + proxy/grpc/server.go | 2 +- types/pb/da/da.pb.go | 167 ++++++++++++++----------------------------- 4 files changed, 58 insertions(+), 114 deletions(-) diff --git a/proto/da/da.proto b/proto/da/da.proto index 1f23b6e..3380cc8 100644 --- a/proto/da/da.proto +++ b/proto/da/da.proto @@ -108,7 +108,7 @@ message SubmitRequest { repeated Blob blobs = 1; double gas_price = 2; Namespace namespace = 3; - optional bytes options = 4; + bytes options = 4; } // SubmitResponse is the response type for the Submit rpc method. diff --git a/proxy/grpc/client.go b/proxy/grpc/client.go index ff45f6d..5f10681 100644 --- a/proxy/grpc/client.go +++ b/proxy/grpc/client.go @@ -131,6 +131,7 @@ func (c *Client) SubmitWithOptions(ctx context.Context, blobs []da.Blob, gasPric Blobs: blobsDA2PB(blobs), GasPrice: gasPrice, Namespace: &pbda.Namespace{Value: namespace}, + Options: options, } resp, err := c.client.Submit(ctx, req) diff --git a/proxy/grpc/server.go b/proxy/grpc/server.go index f6c59f5..8408535 100644 --- a/proxy/grpc/server.go +++ b/proxy/grpc/server.go @@ -69,7 +69,7 @@ func (p *proxySrv) GetProofs(ctx context.Context, request *pbda.GetProofsRequest func (p *proxySrv) Submit(ctx context.Context, request *pbda.SubmitRequest) (*pbda.SubmitResponse, error) { blobs := blobsPB2DA(request.Blobs) - ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue()) + ids, err := p.target.SubmitWithOptions(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), request.Options) if err != nil { return nil, err } diff --git a/types/pb/da/da.pb.go b/types/pb/da/da.pb.go index 1e03451..3ec2520 100644 --- a/types/pb/da/da.pb.go +++ b/types/pb/da/da.pb.go @@ -731,9 +731,7 @@ type SubmitRequest struct { Blobs []*Blob `protobuf:"bytes,1,rep,name=blobs,proto3" json:"blobs,omitempty"` GasPrice float64 `protobuf:"fixed64,2,opt,name=gas_price,json=gasPrice,proto3" json:"gas_price,omitempty"` Namespace *Namespace `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` - // Types that are valid to be assigned to XOptions: - // *SubmitRequest_Options - XOptions isSubmitRequest_XOptions `protobuf_oneof:"_options"` + Options []byte `protobuf:"bytes,4,opt,name=options,proto3" json:"options,omitempty"` } func (m *SubmitRequest) Reset() { *m = SubmitRequest{} } @@ -769,25 +767,6 @@ func (m *SubmitRequest) XXX_DiscardUnknown() { var xxx_messageInfo_SubmitRequest proto.InternalMessageInfo -type isSubmitRequest_XOptions interface { - isSubmitRequest_XOptions() - MarshalTo([]byte) (int, error) - Size() int -} - -type SubmitRequest_Options struct { - Options []byte `protobuf:"bytes,4,opt,name=options,proto3,oneof" json:"options,omitempty"` -} - -func (*SubmitRequest_Options) isSubmitRequest_XOptions() {} - -func (m *SubmitRequest) GetXOptions() isSubmitRequest_XOptions { - if m != nil { - return m.XOptions - } - return nil -} - func (m *SubmitRequest) GetBlobs() []*Blob { if m != nil { return m.Blobs @@ -810,19 +789,12 @@ func (m *SubmitRequest) GetNamespace() *Namespace { } func (m *SubmitRequest) GetOptions() []byte { - if x, ok := m.GetXOptions().(*SubmitRequest_Options); ok { - return x.Options + if m != nil { + return m.Options } return nil } -// XXX_OneofWrappers is for the internal use of the proto package. -func (*SubmitRequest) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*SubmitRequest_Options)(nil), - } -} - // SubmitResponse is the response type for the Submit rpc method. type SubmitResponse struct { Ids []*ID `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` @@ -999,46 +971,45 @@ func init() { func init() { proto.RegisterFile("da/da.proto", fileDescriptor_feb508392bc12c0f) } var fileDescriptor_feb508392bc12c0f = []byte{ - // 613 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xb6, 0x93, 0x36, 0x8d, 0xc7, 0xa4, 0x3f, 0xdb, 0x50, 0x2c, 0x43, 0xad, 0x76, 0x4f, 0x11, - 0x3f, 0x05, 0x82, 0x04, 0x82, 0x13, 0x84, 0x48, 0x21, 0x07, 0x50, 0xe5, 0x20, 0x24, 0x24, 0xa4, - 0x68, 0x53, 0x2f, 0xa9, 0xa5, 0x38, 0x36, 0x59, 0xa7, 0xaa, 0xca, 0x19, 0x89, 0x23, 0x0f, 0xc1, - 0xc3, 0x70, 0xec, 0x91, 0x23, 0x4a, 0x5e, 0x04, 0xad, 0x77, 0xd7, 0x8e, 0x5b, 0x99, 0x28, 0x12, - 0xc7, 0xf9, 0xfb, 0xe6, 0xf3, 0xcc, 0x37, 0x6b, 0x30, 0x3d, 0xf2, 0xd0, 0x23, 0x47, 0xd1, 0x24, - 0x8c, 0x43, 0x54, 0xf2, 0x08, 0x3e, 0x04, 0xe3, 0x1d, 0x09, 0x28, 0x8b, 0xc8, 0x09, 0x45, 0x75, - 0x58, 0x3f, 0x23, 0xa3, 0x29, 0xb5, 0xf4, 0x03, 0xbd, 0x71, 0xc3, 0x15, 0x06, 0xbe, 0x03, 0x6b, - 0xad, 0x51, 0x38, 0x28, 0x88, 0xda, 0x50, 0xea, 0xb6, 0x0b, 0x62, 0x18, 0xe0, 0x75, 0x18, 0x04, - 0x7e, 0x1c, 0xd0, 0x71, 0x5c, 0x90, 0xb3, 0x0f, 0xeb, 0xc7, 0x93, 0x30, 0xfc, 0x5c, 0x10, 0xae, - 0x03, 0x7a, 0x4b, 0xce, 0x79, 0xff, 0x9e, 0x7f, 0x41, 0x5d, 0xfa, 0x65, 0x4a, 0x59, 0x8c, 0x9f, - 0xc3, 0x6e, 0xce, 0xcb, 0xa2, 0x70, 0xcc, 0x28, 0xc2, 0x50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x24, 0xaf, 0x08, 0xac, 0xa1, 0x67, 0x50, 0x55, 0xc3, - 0x47, 0xbb, 0x3c, 0xe3, 0x8a, 0x0e, 0xec, 0x7a, 0xde, 0xa9, 0x0a, 0x5b, 0xd6, 0xaf, 0x99, 0xa3, - 0x5f, 0xce, 0x1c, 0xfd, 0xcf, 0xcc, 0xd1, 0x7f, 0xcc, 0x1d, 0xed, 0x72, 0xee, 0x68, 0xbf, 0xe7, - 0x8e, 0x36, 0xa8, 0x24, 0xbf, 0x95, 0x27, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x7e, 0xe1, - 0xb8, 0x65, 0x06, 0x00, 0x00, + // 601 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x6f, 0xd3, 0x4c, + 0x10, 0x8e, 0x93, 0x26, 0x8d, 0xc7, 0x6f, 0xd2, 0x76, 0x9b, 0xb7, 0x58, 0x06, 0xac, 0x74, 0x4f, + 0x11, 0x1f, 0x01, 0x82, 0x04, 0x82, 0x13, 0x84, 0x48, 0x51, 0x0e, 0xa0, 0xca, 0x41, 0x48, 0x48, + 0x48, 0xd1, 0xa6, 0x5e, 0x52, 0x4b, 0x71, 0x6c, 0xb2, 0x4e, 0x55, 0x95, 0x33, 0x77, 0x24, 0xfe, + 0x14, 0xc7, 0x1e, 0x39, 0xa2, 0xe4, 0x8f, 0xa0, 0xf5, 0xee, 0xda, 0x71, 0x2b, 0x13, 0x45, 0xe2, + 0x38, 0x5f, 0xcf, 0x3c, 0x9e, 0x79, 0x66, 0x0d, 0x86, 0x4b, 0x1e, 0xb9, 0xa4, 0x1d, 0xce, 0x83, + 0x28, 0x40, 0x45, 0x97, 0xe0, 0x63, 0xd0, 0xdf, 0x11, 0x9f, 0xb2, 0x90, 0x9c, 0x52, 0xd4, 0x80, + 0xf2, 0x39, 0x99, 0x2e, 0xa8, 0xa9, 0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x3e, 0x00, 0xd6, 0x5e, 0x62, 0x27, 0x99, 0x4f, 0xa0, 0x22, 0xee, 0x08, 0x1d, 0xc8, + 0x60, 0x7a, 0xa9, 0x16, 0x5a, 0x77, 0x25, 0x25, 0x2f, 0x41, 0x4f, 0x34, 0x8f, 0x1a, 0x32, 0x25, + 0x73, 0x5d, 0xd6, 0xff, 0xd7, 0xbc, 0xeb, 0xed, 0x84, 0xe0, 0x44, 0xbb, 0xcc, 0x0d, 0x88, 0x76, + 0x59, 0xe1, 0x8a, 0x12, 0xb1, 0x72, 0x51, 0x92, 0xd1, 0xa4, 0x28, 0xc9, 0x2a, 0x02, 0x17, 0xd0, + 0x73, 0xa8, 0xaa, 0xe1, 0xa3, 0x43, 0x9e, 0x71, 0x4d, 0x07, 0x56, 0x23, 0xeb, 0x54, 0x85, 0x5d, + 0xf3, 0xe7, 0xd2, 0xd6, 0xae, 0x96, 0xb6, 0xf6, 0x7b, 0x69, 0x6b, 0xdf, 0x57, 0x76, 0xe1, 0x6a, + 0x65, 0x17, 0x7e, 0xad, 0xec, 0xc2, 0xb8, 0x12, 0xff, 0x45, 0x9e, 0xfe, 0x09, 0x00, 0x00, 0xff, + 0xff, 0xed, 0xc8, 0xba, 0x02, 0x54, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1907,14 +1878,12 @@ func (m *SubmitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.XOptions != nil { - { - size := m.XOptions.Size() - i -= size - if _, err := m.XOptions.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } + if len(m.Options) > 0 { + i -= len(m.Options) + copy(dAtA[i:], m.Options) + i = encodeVarintDa(dAtA, i, uint64(len(m.Options))) + i-- + dAtA[i] = 0x22 } if m.Namespace != nil { { @@ -1951,22 +1920,6 @@ func (m *SubmitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SubmitRequest_Options) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SubmitRequest_Options) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Options != nil { - i -= len(m.Options) - copy(dAtA[i:], m.Options) - i = encodeVarintDa(dAtA, i, uint64(len(m.Options))) - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} func (m *SubmitResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2352,24 +2305,13 @@ func (m *SubmitRequest) Size() (n int) { l = m.Namespace.Size() n += 1 + l + sovDa(uint64(l)) } - if m.XOptions != nil { - n += m.XOptions.Size() - } - return n -} - -func (m *SubmitRequest_Options) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Options != nil { - l = len(m.Options) + l = len(m.Options) + if l > 0 { n += 1 + l + sovDa(uint64(l)) } return n } + func (m *SubmitResponse) Size() (n int) { if m == nil { return 0 @@ -3907,9 +3849,10 @@ func (m *SubmitRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.XOptions = &SubmitRequest_Options{v} + m.Options = append(m.Options[:0], dAtA[iNdEx:postIndex]...) + if m.Options == nil { + m.Options = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex