From 3d6da01e53b28268dd57b3dc1458f7c1b673d838 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Fri, 15 Mar 2024 14:03:31 +0100 Subject: [PATCH 1/7] Add network service --- spacemesh/v2alpha1/network.proto | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spacemesh/v2alpha1/network.proto diff --git a/spacemesh/v2alpha1/network.proto b/spacemesh/v2alpha1/network.proto new file mode 100644 index 00000000..856c3ab1 --- /dev/null +++ b/spacemesh/v2alpha1/network.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package spacemesh.v2alpha1; + +message NetworkInfoRequest {} + +message NetworkInfoResponse { + uint64 genesis_time = 1; // network genesis time as unix epoch time + uint32 epoch_num_layers = 2; // number of layers per epoch + uint32 layer_duration = 3; // layer duration, in seconds + bytes genesis_id = 4; + string hrp = 5; + uint32 effective_genesis_layer = 6; // effective genesis layer, i.e., first layer after genesis initialization period + uint32 layers_per_epoch = 7; // number of layers per epoch +} + +service NetworkService { + rpc Info(NetworkInfoRequest) returns (NetworkInfoResponse); +} \ No newline at end of file From e3f27ef2821ffb09a6d6eb5adc64bcad3f10e183 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Fri, 15 Mar 2024 14:09:06 +0100 Subject: [PATCH 2/7] Build network service --- release/go/spacemesh/v2alpha1/network.pb.go | 281 ++++++++++++++++++ .../go/spacemesh/v2alpha1/network.pb.gw.go | 171 +++++++++++ .../go/spacemesh/v2alpha1/network_grpc.pb.go | 107 +++++++ 3 files changed, 559 insertions(+) create mode 100644 release/go/spacemesh/v2alpha1/network.pb.go create mode 100644 release/go/spacemesh/v2alpha1/network.pb.gw.go create mode 100644 release/go/spacemesh/v2alpha1/network_grpc.pb.go diff --git a/release/go/spacemesh/v2alpha1/network.pb.go b/release/go/spacemesh/v2alpha1/network.pb.go new file mode 100644 index 00000000..5f222062 --- /dev/null +++ b/release/go/spacemesh/v2alpha1/network.pb.go @@ -0,0 +1,281 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: spacemesh/v2alpha1/network.proto + +package spacemeshv2alpha1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type NetworkInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NetworkInfoRequest) Reset() { + *x = NetworkInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NetworkInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NetworkInfoRequest) ProtoMessage() {} + +func (x *NetworkInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NetworkInfoRequest.ProtoReflect.Descriptor instead. +func (*NetworkInfoRequest) Descriptor() ([]byte, []int) { + return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{0} +} + +type NetworkInfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GenesisTime uint64 `protobuf:"varint,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time + EpochNumLayers uint32 `protobuf:"varint,2,opt,name=epoch_num_layers,json=epochNumLayers,proto3" json:"epoch_num_layers,omitempty"` // number of layers per epoch + LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds + GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` + Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` + EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period + LayersPerEpoch uint32 `protobuf:"varint,7,opt,name=layers_per_epoch,json=layersPerEpoch,proto3" json:"layers_per_epoch,omitempty"` // number of layers per epoch +} + +func (x *NetworkInfoResponse) Reset() { + *x = NetworkInfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NetworkInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NetworkInfoResponse) ProtoMessage() {} + +func (x *NetworkInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NetworkInfoResponse.ProtoReflect.Descriptor instead. +func (*NetworkInfoResponse) Descriptor() ([]byte, []int) { + return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{1} +} + +func (x *NetworkInfoResponse) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *NetworkInfoResponse) GetEpochNumLayers() uint32 { + if x != nil { + return x.EpochNumLayers + } + return 0 +} + +func (x *NetworkInfoResponse) GetLayerDuration() uint32 { + if x != nil { + return x.LayerDuration + } + return 0 +} + +func (x *NetworkInfoResponse) GetGenesisId() []byte { + if x != nil { + return x.GenesisId + } + return nil +} + +func (x *NetworkInfoResponse) GetHrp() string { + if x != nil { + return x.Hrp + } + return "" +} + +func (x *NetworkInfoResponse) GetEffectiveGenesisLayer() uint32 { + if x != nil { + return x.EffectiveGenesisLayer + } + return 0 +} + +func (x *NetworkInfoResponse) GetLayersPerEpoch() uint32 { + if x != nil { + return x.LayersPerEpoch + } + return 0 +} + +var File_spacemesh_v2alpha1_network_proto protoreflect.FileDescriptor + +var file_spacemesh_v2alpha1_network_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x12, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x14, 0x0a, 0x12, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x9c, 0x02, 0x0a, + 0x13, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, + 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x65, 0x70, 0x6f, 0x63, 0x68, + 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x0e, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x4c, 0x61, 0x79, 0x65, 0x72, + 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, + 0x73, 0x69, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x67, 0x65, + 0x6e, 0x65, 0x73, 0x69, 0x73, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x72, 0x70, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x68, 0x72, 0x70, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x66, 0x66, + 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x65, 0x66, 0x66, 0x65, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, + 0x72, 0x12, 0x28, 0x0a, 0x10, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, + 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x73, 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x32, 0x69, 0x0a, 0x0e, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, + 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, + 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x42, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, + 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x6d, 0x65, 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, + 0x53, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, + 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, + 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, + 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x13, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_spacemesh_v2alpha1_network_proto_rawDescOnce sync.Once + file_spacemesh_v2alpha1_network_proto_rawDescData = file_spacemesh_v2alpha1_network_proto_rawDesc +) + +func file_spacemesh_v2alpha1_network_proto_rawDescGZIP() []byte { + file_spacemesh_v2alpha1_network_proto_rawDescOnce.Do(func() { + file_spacemesh_v2alpha1_network_proto_rawDescData = protoimpl.X.CompressGZIP(file_spacemesh_v2alpha1_network_proto_rawDescData) + }) + return file_spacemesh_v2alpha1_network_proto_rawDescData +} + +var file_spacemesh_v2alpha1_network_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_spacemesh_v2alpha1_network_proto_goTypes = []interface{}{ + (*NetworkInfoRequest)(nil), // 0: spacemesh.v2alpha1.NetworkInfoRequest + (*NetworkInfoResponse)(nil), // 1: spacemesh.v2alpha1.NetworkInfoResponse +} +var file_spacemesh_v2alpha1_network_proto_depIdxs = []int32{ + 0, // 0: spacemesh.v2alpha1.NetworkService.Info:input_type -> spacemesh.v2alpha1.NetworkInfoRequest + 1, // 1: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_spacemesh_v2alpha1_network_proto_init() } +func file_spacemesh_v2alpha1_network_proto_init() { + if File_spacemesh_v2alpha1_network_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_spacemesh_v2alpha1_network_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NetworkInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_spacemesh_v2alpha1_network_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NetworkInfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_spacemesh_v2alpha1_network_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_spacemesh_v2alpha1_network_proto_goTypes, + DependencyIndexes: file_spacemesh_v2alpha1_network_proto_depIdxs, + MessageInfos: file_spacemesh_v2alpha1_network_proto_msgTypes, + }.Build() + File_spacemesh_v2alpha1_network_proto = out.File + file_spacemesh_v2alpha1_network_proto_rawDesc = nil + file_spacemesh_v2alpha1_network_proto_goTypes = nil + file_spacemesh_v2alpha1_network_proto_depIdxs = nil +} diff --git a/release/go/spacemesh/v2alpha1/network.pb.gw.go b/release/go/spacemesh/v2alpha1/network.pb.gw.go new file mode 100644 index 00000000..758c3638 --- /dev/null +++ b/release/go/spacemesh/v2alpha1/network.pb.gw.go @@ -0,0 +1,171 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: spacemesh/v2alpha1/network.proto + +/* +Package spacemeshv2alpha1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package spacemeshv2alpha1 + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, client NetworkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq NetworkInfoRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Info(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, server NetworkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq NetworkInfoRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Info(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterNetworkServiceHandlerServer registers the http handlers for service NetworkService to "mux". +// UnaryRPC :call NetworkServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterNetworkServiceHandlerFromEndpoint instead. +func RegisterNetworkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NetworkServiceServer) error { + + mux.Handle("POST", pattern_NetworkService_Info_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/spacemesh.v2alpha1.NetworkService/Info", runtime.WithHTTPPathPattern("/spacemesh.v2alpha1.NetworkService/Info")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NetworkService_Info_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_NetworkService_Info_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterNetworkServiceHandlerFromEndpoint is same as RegisterNetworkServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterNetworkServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterNetworkServiceHandler(ctx, mux, conn) +} + +// RegisterNetworkServiceHandler registers the http handlers for service NetworkService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterNetworkServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterNetworkServiceHandlerClient(ctx, mux, NewNetworkServiceClient(conn)) +} + +// RegisterNetworkServiceHandlerClient registers the http handlers for service NetworkService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "NetworkServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "NetworkServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "NetworkServiceClient" to call the correct interceptors. +func RegisterNetworkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NetworkServiceClient) error { + + mux.Handle("POST", pattern_NetworkService_Info_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/spacemesh.v2alpha1.NetworkService/Info", runtime.WithHTTPPathPattern("/spacemesh.v2alpha1.NetworkService/Info")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NetworkService_Info_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_NetworkService_Info_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_NetworkService_Info_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"spacemesh.v2alpha1.NetworkService", "Info"}, "")) +) + +var ( + forward_NetworkService_Info_0 = runtime.ForwardResponseMessage +) diff --git a/release/go/spacemesh/v2alpha1/network_grpc.pb.go b/release/go/spacemesh/v2alpha1/network_grpc.pb.go new file mode 100644 index 00000000..9c9f32a5 --- /dev/null +++ b/release/go/spacemesh/v2alpha1/network_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: spacemesh/v2alpha1/network.proto + +package spacemeshv2alpha1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + NetworkService_Info_FullMethodName = "/spacemesh.v2alpha1.NetworkService/Info" +) + +// NetworkServiceClient is the client API for NetworkService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NetworkServiceClient interface { + Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) +} + +type networkServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewNetworkServiceClient(cc grpc.ClientConnInterface) NetworkServiceClient { + return &networkServiceClient{cc} +} + +func (c *networkServiceClient) Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) { + out := new(NetworkInfoResponse) + err := c.cc.Invoke(ctx, NetworkService_Info_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NetworkServiceServer is the server API for NetworkService service. +// All implementations should embed UnimplementedNetworkServiceServer +// for forward compatibility +type NetworkServiceServer interface { + Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) +} + +// UnimplementedNetworkServiceServer should be embedded to have forward compatible implementations. +type UnimplementedNetworkServiceServer struct { +} + +func (UnimplementedNetworkServiceServer) Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") +} + +// UnsafeNetworkServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NetworkServiceServer will +// result in compilation errors. +type UnsafeNetworkServiceServer interface { + mustEmbedUnimplementedNetworkServiceServer() +} + +func RegisterNetworkServiceServer(s grpc.ServiceRegistrar, srv NetworkServiceServer) { + s.RegisterService(&NetworkService_ServiceDesc, srv) +} + +func _NetworkService_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NetworkInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NetworkServiceServer).Info(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NetworkService_Info_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NetworkServiceServer).Info(ctx, req.(*NetworkInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// NetworkService_ServiceDesc is the grpc.ServiceDesc for NetworkService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NetworkService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "spacemesh.v2alpha1.NetworkService", + HandlerType: (*NetworkServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Info", + Handler: _NetworkService_Info_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "spacemesh/v2alpha1/network.proto", +} From 038f553c0a945da6181b111b22795fb98af5e4d7 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Fri, 15 Mar 2024 14:24:22 +0100 Subject: [PATCH 3/7] Remove epoch_num_layers --- release/go/spacemesh/v2alpha1/network.pb.go | 160 ++++++------------ .../go/spacemesh/v2alpha1/network.pb.gw.go | 5 +- .../go/spacemesh/v2alpha1/network_grpc.pb.go | 13 +- spacemesh/v2alpha1/network.proto | 7 +- 4 files changed, 63 insertions(+), 122 deletions(-) diff --git a/release/go/spacemesh/v2alpha1/network.pb.go b/release/go/spacemesh/v2alpha1/network.pb.go index 5f222062..f4d3df64 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.go +++ b/release/go/spacemesh/v2alpha1/network.pb.go @@ -9,6 +9,7 @@ package spacemeshv2alpha1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -20,52 +21,13 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type NetworkInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *NetworkInfoRequest) Reset() { - *x = NetworkInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NetworkInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NetworkInfoRequest) ProtoMessage() {} - -func (x *NetworkInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NetworkInfoRequest.ProtoReflect.Descriptor instead. -func (*NetworkInfoRequest) Descriptor() ([]byte, []int) { - return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{0} -} - type NetworkInfoResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GenesisTime uint64 `protobuf:"varint,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time - EpochNumLayers uint32 `protobuf:"varint,2,opt,name=epoch_num_layers,json=epochNumLayers,proto3" json:"epoch_num_layers,omitempty"` // number of layers per epoch - LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds + GenesisTime uint64 `protobuf:"varint,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time + LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period @@ -75,7 +37,7 @@ type NetworkInfoResponse struct { func (x *NetworkInfoResponse) Reset() { *x = NetworkInfoResponse{} if protoimpl.UnsafeEnabled { - mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -88,7 +50,7 @@ func (x *NetworkInfoResponse) String() string { func (*NetworkInfoResponse) ProtoMessage() {} func (x *NetworkInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -101,7 +63,7 @@ func (x *NetworkInfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use NetworkInfoResponse.ProtoReflect.Descriptor instead. func (*NetworkInfoResponse) Descriptor() ([]byte, []int) { - return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{1} + return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{0} } func (x *NetworkInfoResponse) GetGenesisTime() uint64 { @@ -111,13 +73,6 @@ func (x *NetworkInfoResponse) GetGenesisTime() uint64 { return 0 } -func (x *NetworkInfoResponse) GetEpochNumLayers() uint32 { - if x != nil { - return x.EpochNumLayers - } - return 0 -} - func (x *NetworkInfoResponse) GetLayerDuration() uint32 { if x != nil { return x.LayerDuration @@ -159,47 +114,44 @@ var file_spacemesh_v2alpha1_network_proto_rawDesc = []byte{ 0x0a, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x14, 0x0a, 0x12, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x9c, 0x02, 0x0a, - 0x13, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, - 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x65, 0x70, 0x6f, 0x63, 0x68, - 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x0e, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x4c, 0x61, 0x79, 0x65, 0x72, - 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, - 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, - 0x73, 0x69, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x67, 0x65, - 0x6e, 0x65, 0x73, 0x69, 0x73, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x72, 0x70, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x68, 0x72, 0x70, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x66, 0x66, - 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x6c, - 0x61, 0x79, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x65, 0x66, 0x66, 0x65, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, - 0x72, 0x12, 0x28, 0x0a, 0x10, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, - 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x73, 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x32, 0x69, 0x0a, 0x0e, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, - 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, - 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x42, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, - 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x6d, 0x65, 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, - 0x53, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, - 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, - 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, - 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x13, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xf2, 0x01, 0x0a, 0x13, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x67, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x72, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x68, 0x72, 0x70, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, + 0x76, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x28, + 0x0a, 0x10, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, + 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x32, 0x59, 0x0a, 0x0e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x27, 0x2e, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, + 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, + 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, + 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x56, 0x32, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, + 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, 0x53, 0x70, 0x61, + 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x53, 0x70, + 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -214,14 +166,14 @@ func file_spacemesh_v2alpha1_network_proto_rawDescGZIP() []byte { return file_spacemesh_v2alpha1_network_proto_rawDescData } -var file_spacemesh_v2alpha1_network_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_spacemesh_v2alpha1_network_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_spacemesh_v2alpha1_network_proto_goTypes = []interface{}{ - (*NetworkInfoRequest)(nil), // 0: spacemesh.v2alpha1.NetworkInfoRequest - (*NetworkInfoResponse)(nil), // 1: spacemesh.v2alpha1.NetworkInfoResponse + (*NetworkInfoResponse)(nil), // 0: spacemesh.v2alpha1.NetworkInfoResponse + (*emptypb.Empty)(nil), // 1: google.protobuf.Empty } var file_spacemesh_v2alpha1_network_proto_depIdxs = []int32{ - 0, // 0: spacemesh.v2alpha1.NetworkService.Info:input_type -> spacemesh.v2alpha1.NetworkInfoRequest - 1, // 1: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse + 1, // 0: spacemesh.v2alpha1.NetworkService.Info:input_type -> google.protobuf.Empty + 0, // 1: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -236,18 +188,6 @@ func file_spacemesh_v2alpha1_network_proto_init() { } if !protoimpl.UnsafeEnabled { file_spacemesh_v2alpha1_network_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NetworkInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_spacemesh_v2alpha1_network_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*NetworkInfoResponse); i { case 0: return &v.state @@ -266,7 +206,7 @@ func file_spacemesh_v2alpha1_network_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_spacemesh_v2alpha1_network_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 1, NumExtensions: 0, NumServices: 1, }, diff --git a/release/go/spacemesh/v2alpha1/network.pb.gw.go b/release/go/spacemesh/v2alpha1/network.pb.gw.go index 758c3638..3a671a57 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.gw.go +++ b/release/go/spacemesh/v2alpha1/network.pb.gw.go @@ -21,6 +21,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" ) // Suppress "imported and not used" errors @@ -32,7 +33,7 @@ var _ = utilities.NewDoubleArray var _ = metadata.Join func request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, client NetworkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq NetworkInfoRequest + var protoReq emptypb.Empty var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -49,7 +50,7 @@ func request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marsha } func local_request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, server NetworkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq NetworkInfoRequest + var protoReq emptypb.Empty var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) diff --git a/release/go/spacemesh/v2alpha1/network_grpc.pb.go b/release/go/spacemesh/v2alpha1/network_grpc.pb.go index 9c9f32a5..af36b893 100644 --- a/release/go/spacemesh/v2alpha1/network_grpc.pb.go +++ b/release/go/spacemesh/v2alpha1/network_grpc.pb.go @@ -11,6 +11,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -26,7 +27,7 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type NetworkServiceClient interface { - Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) + Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NetworkInfoResponse, error) } type networkServiceClient struct { @@ -37,7 +38,7 @@ func NewNetworkServiceClient(cc grpc.ClientConnInterface) NetworkServiceClient { return &networkServiceClient{cc} } -func (c *networkServiceClient) Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) { +func (c *networkServiceClient) Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NetworkInfoResponse, error) { out := new(NetworkInfoResponse) err := c.cc.Invoke(ctx, NetworkService_Info_FullMethodName, in, out, opts...) if err != nil { @@ -50,14 +51,14 @@ func (c *networkServiceClient) Info(ctx context.Context, in *NetworkInfoRequest, // All implementations should embed UnimplementedNetworkServiceServer // for forward compatibility type NetworkServiceServer interface { - Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) + Info(context.Context, *emptypb.Empty) (*NetworkInfoResponse, error) } // UnimplementedNetworkServiceServer should be embedded to have forward compatible implementations. type UnimplementedNetworkServiceServer struct { } -func (UnimplementedNetworkServiceServer) Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) { +func (UnimplementedNetworkServiceServer) Info(context.Context, *emptypb.Empty) (*NetworkInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") } @@ -73,7 +74,7 @@ func RegisterNetworkServiceServer(s grpc.ServiceRegistrar, srv NetworkServiceSer } func _NetworkService_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NetworkInfoRequest) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -85,7 +86,7 @@ func _NetworkService_Info_Handler(srv interface{}, ctx context.Context, dec func FullMethod: NetworkService_Info_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(NetworkServiceServer).Info(ctx, req.(*NetworkInfoRequest)) + return srv.(NetworkServiceServer).Info(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } diff --git a/spacemesh/v2alpha1/network.proto b/spacemesh/v2alpha1/network.proto index 856c3ab1..44bcbb9c 100644 --- a/spacemesh/v2alpha1/network.proto +++ b/spacemesh/v2alpha1/network.proto @@ -1,12 +1,11 @@ syntax = "proto3"; -package spacemesh.v2alpha1; +import "google/protobuf/empty.proto"; -message NetworkInfoRequest {} +package spacemesh.v2alpha1; message NetworkInfoResponse { uint64 genesis_time = 1; // network genesis time as unix epoch time - uint32 epoch_num_layers = 2; // number of layers per epoch uint32 layer_duration = 3; // layer duration, in seconds bytes genesis_id = 4; string hrp = 5; @@ -15,5 +14,5 @@ message NetworkInfoResponse { } service NetworkService { - rpc Info(NetworkInfoRequest) returns (NetworkInfoResponse); + rpc Info(google.protobuf.Empty) returns (NetworkInfoResponse); } \ No newline at end of file From 17959ce00d46abeefe565a4728aee6cc8264a9aa Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Wed, 20 Mar 2024 12:20:34 +0100 Subject: [PATCH 4/7] Use timestamp instead of int for genesis time and create empty request for network info --- release/go/spacemesh/v2alpha1/network.pb.go | 150 ++++++++++++------ .../go/spacemesh/v2alpha1/network.pb.gw.go | 5 +- .../go/spacemesh/v2alpha1/network_grpc.pb.go | 13 +- spacemesh/v2alpha1/network.proto | 8 +- 4 files changed, 116 insertions(+), 60 deletions(-) diff --git a/release/go/spacemesh/v2alpha1/network.pb.go b/release/go/spacemesh/v2alpha1/network.pb.go index f4d3df64..4077d7df 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.go +++ b/release/go/spacemesh/v2alpha1/network.pb.go @@ -9,7 +9,7 @@ package spacemeshv2alpha1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -26,12 +26,12 @@ type NetworkInfoResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GenesisTime uint64 `protobuf:"varint,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time - LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds - GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` - Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` - EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period - LayersPerEpoch uint32 `protobuf:"varint,7,opt,name=layers_per_epoch,json=layersPerEpoch,proto3" json:"layers_per_epoch,omitempty"` // number of layers per epoch + GenesisTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time + LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds + GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` + Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` + EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period + LayersPerEpoch uint32 `protobuf:"varint,7,opt,name=layers_per_epoch,json=layersPerEpoch,proto3" json:"layers_per_epoch,omitempty"` // number of layers per epoch } func (x *NetworkInfoResponse) Reset() { @@ -66,11 +66,11 @@ func (*NetworkInfoResponse) Descriptor() ([]byte, []int) { return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{0} } -func (x *NetworkInfoResponse) GetGenesisTime() uint64 { +func (x *NetworkInfoResponse) GetGenesisTime() *timestamppb.Timestamp { if x != nil { return x.GenesisTime } - return 0 + return nil } func (x *NetworkInfoResponse) GetLayerDuration() uint32 { @@ -108,18 +108,58 @@ func (x *NetworkInfoResponse) GetLayersPerEpoch() uint32 { return 0 } +type NetworkInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NetworkInfoRequest) Reset() { + *x = NetworkInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NetworkInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NetworkInfoRequest) ProtoMessage() {} + +func (x *NetworkInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_spacemesh_v2alpha1_network_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NetworkInfoRequest.ProtoReflect.Descriptor instead. +func (*NetworkInfoRequest) Descriptor() ([]byte, []int) { + return file_spacemesh_v2alpha1_network_proto_rawDescGZIP(), []int{1} +} + var File_spacemesh_v2alpha1_network_proto protoreflect.FileDescriptor var file_spacemesh_v2alpha1_network_proto_rawDesc = []byte{ 0x0a, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xf2, 0x01, 0x0a, 0x13, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, - 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x25, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x13, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3d, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, @@ -131,27 +171,29 @@ var file_spacemesh_v2alpha1_network_proto_rawDesc = []byte{ 0x76, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, - 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x32, 0x59, 0x0a, 0x0e, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x27, 0x2e, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, - 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, - 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, - 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x56, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, - 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, 0x53, 0x70, 0x61, - 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x53, 0x70, - 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x22, 0x14, 0x0a, 0x12, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0x69, + 0x0a, 0x0e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x57, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x27, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, + 0x73, 0x68, 0x2e, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, + 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xe2, 0x02, 0x1e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x13, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, + 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -166,19 +208,21 @@ func file_spacemesh_v2alpha1_network_proto_rawDescGZIP() []byte { return file_spacemesh_v2alpha1_network_proto_rawDescData } -var file_spacemesh_v2alpha1_network_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_spacemesh_v2alpha1_network_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_spacemesh_v2alpha1_network_proto_goTypes = []interface{}{ - (*NetworkInfoResponse)(nil), // 0: spacemesh.v2alpha1.NetworkInfoResponse - (*emptypb.Empty)(nil), // 1: google.protobuf.Empty + (*NetworkInfoResponse)(nil), // 0: spacemesh.v2alpha1.NetworkInfoResponse + (*NetworkInfoRequest)(nil), // 1: spacemesh.v2alpha1.NetworkInfoRequest + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp } var file_spacemesh_v2alpha1_network_proto_depIdxs = []int32{ - 1, // 0: spacemesh.v2alpha1.NetworkService.Info:input_type -> google.protobuf.Empty - 0, // 1: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 2, // 0: spacemesh.v2alpha1.NetworkInfoResponse.genesis_time:type_name -> google.protobuf.Timestamp + 1, // 1: spacemesh.v2alpha1.NetworkService.Info:input_type -> spacemesh.v2alpha1.NetworkInfoRequest + 0, // 2: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_spacemesh_v2alpha1_network_proto_init() } @@ -199,6 +243,18 @@ func file_spacemesh_v2alpha1_network_proto_init() { return nil } } + file_spacemesh_v2alpha1_network_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NetworkInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -206,7 +262,7 @@ func file_spacemesh_v2alpha1_network_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_spacemesh_v2alpha1_network_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, diff --git a/release/go/spacemesh/v2alpha1/network.pb.gw.go b/release/go/spacemesh/v2alpha1/network.pb.gw.go index 3a671a57..758c3638 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.gw.go +++ b/release/go/spacemesh/v2alpha1/network.pb.gw.go @@ -21,7 +21,6 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/emptypb" ) // Suppress "imported and not used" errors @@ -33,7 +32,7 @@ var _ = utilities.NewDoubleArray var _ = metadata.Join func request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, client NetworkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq emptypb.Empty + var protoReq NetworkInfoRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -50,7 +49,7 @@ func request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marsha } func local_request_NetworkService_Info_0(ctx context.Context, marshaler runtime.Marshaler, server NetworkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq emptypb.Empty + var protoReq NetworkInfoRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) diff --git a/release/go/spacemesh/v2alpha1/network_grpc.pb.go b/release/go/spacemesh/v2alpha1/network_grpc.pb.go index af36b893..9c9f32a5 100644 --- a/release/go/spacemesh/v2alpha1/network_grpc.pb.go +++ b/release/go/spacemesh/v2alpha1/network_grpc.pb.go @@ -11,7 +11,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -27,7 +26,7 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type NetworkServiceClient interface { - Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NetworkInfoResponse, error) + Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) } type networkServiceClient struct { @@ -38,7 +37,7 @@ func NewNetworkServiceClient(cc grpc.ClientConnInterface) NetworkServiceClient { return &networkServiceClient{cc} } -func (c *networkServiceClient) Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NetworkInfoResponse, error) { +func (c *networkServiceClient) Info(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) { out := new(NetworkInfoResponse) err := c.cc.Invoke(ctx, NetworkService_Info_FullMethodName, in, out, opts...) if err != nil { @@ -51,14 +50,14 @@ func (c *networkServiceClient) Info(ctx context.Context, in *emptypb.Empty, opts // All implementations should embed UnimplementedNetworkServiceServer // for forward compatibility type NetworkServiceServer interface { - Info(context.Context, *emptypb.Empty) (*NetworkInfoResponse, error) + Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) } // UnimplementedNetworkServiceServer should be embedded to have forward compatible implementations. type UnimplementedNetworkServiceServer struct { } -func (UnimplementedNetworkServiceServer) Info(context.Context, *emptypb.Empty) (*NetworkInfoResponse, error) { +func (UnimplementedNetworkServiceServer) Info(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") } @@ -74,7 +73,7 @@ func RegisterNetworkServiceServer(s grpc.ServiceRegistrar, srv NetworkServiceSer } func _NetworkService_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) + in := new(NetworkInfoRequest) if err := dec(in); err != nil { return nil, err } @@ -86,7 +85,7 @@ func _NetworkService_Info_Handler(srv interface{}, ctx context.Context, dec func FullMethod: NetworkService_Info_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(NetworkServiceServer).Info(ctx, req.(*emptypb.Empty)) + return srv.(NetworkServiceServer).Info(ctx, req.(*NetworkInfoRequest)) } return interceptor(ctx, in, info, handler) } diff --git a/spacemesh/v2alpha1/network.proto b/spacemesh/v2alpha1/network.proto index 44bcbb9c..79851cdb 100644 --- a/spacemesh/v2alpha1/network.proto +++ b/spacemesh/v2alpha1/network.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; package spacemesh.v2alpha1; message NetworkInfoResponse { - uint64 genesis_time = 1; // network genesis time as unix epoch time + google.protobuf.Timestamp genesis_time = 1; // network genesis time as unix epoch time uint32 layer_duration = 3; // layer duration, in seconds bytes genesis_id = 4; string hrp = 5; @@ -13,6 +13,8 @@ message NetworkInfoResponse { uint32 layers_per_epoch = 7; // number of layers per epoch } +message NetworkInfoRequest {} + service NetworkService { - rpc Info(google.protobuf.Empty) returns (NetworkInfoResponse); + rpc Info(NetworkInfoRequest) returns (NetworkInfoResponse); } \ No newline at end of file From d455693823cfce3c05360c3ef10e59e545bd385b Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Wed, 20 Mar 2024 12:21:39 +0100 Subject: [PATCH 5/7] Use google Duration for layer duration --- release/go/spacemesh/v2alpha1/network.pb.go | 97 +++++++++++---------- spacemesh/v2alpha1/network.proto | 3 +- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/release/go/spacemesh/v2alpha1/network.pb.go b/release/go/spacemesh/v2alpha1/network.pb.go index 4077d7df..59f93894 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.go +++ b/release/go/spacemesh/v2alpha1/network.pb.go @@ -9,6 +9,7 @@ package spacemeshv2alpha1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" @@ -26,8 +27,8 @@ type NetworkInfoResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GenesisTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time - LayerDuration uint32 `protobuf:"varint,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds + GenesisTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time + LayerDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period @@ -73,11 +74,11 @@ func (x *NetworkInfoResponse) GetGenesisTime() *timestamppb.Timestamp { return nil } -func (x *NetworkInfoResponse) GetLayerDuration() uint32 { +func (x *NetworkInfoResponse) GetLayerDuration() *durationpb.Duration { if x != nil { return x.LayerDuration } - return 0 + return nil } func (x *NetworkInfoResponse) GetGenesisId() []byte { @@ -154,46 +155,50 @@ var file_spacemesh_v2alpha1_network_proto_rawDesc = []byte{ 0x74, 0x6f, 0x12, 0x12, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x13, 0x4e, 0x65, 0x74, 0x77, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa9, 0x02, 0x0a, 0x13, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x25, + 0x70, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x75, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, - 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x67, 0x65, 0x6e, 0x65, 0x73, - 0x69, 0x73, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x72, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x68, 0x72, 0x70, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, - 0x69, 0x76, 0x65, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x28, - 0x0a, 0x10, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x65, 0x70, 0x6f, - 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, - 0x50, 0x65, 0x72, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x22, 0x14, 0x0a, 0x12, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0x69, - 0x0a, 0x0e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x57, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x27, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, - 0x6d, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, - 0x73, 0x68, 0x2e, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x0d, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x49, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x68, 0x72, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x68, 0x72, + 0x70, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x15, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x65, 0x6e, + 0x65, 0x73, 0x69, 0x73, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x50, 0x65, 0x72, 0x45, 0x70, + 0x6f, 0x63, 0x68, 0x22, 0x14, 0x0a, 0x12, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0x69, 0x0a, 0x0e, 0x4e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x04, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, + 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, + 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, + 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, + 0x65, 0x73, 0x68, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, + 0x58, 0xaa, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x56, 0x32, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, + 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xe2, 0x02, 0x1e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x56, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x13, 0x53, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, - 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x53, + 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x56, 0x32, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -213,16 +218,18 @@ var file_spacemesh_v2alpha1_network_proto_goTypes = []interface{}{ (*NetworkInfoResponse)(nil), // 0: spacemesh.v2alpha1.NetworkInfoResponse (*NetworkInfoRequest)(nil), // 1: spacemesh.v2alpha1.NetworkInfoRequest (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp + (*durationpb.Duration)(nil), // 3: google.protobuf.Duration } var file_spacemesh_v2alpha1_network_proto_depIdxs = []int32{ 2, // 0: spacemesh.v2alpha1.NetworkInfoResponse.genesis_time:type_name -> google.protobuf.Timestamp - 1, // 1: spacemesh.v2alpha1.NetworkService.Info:input_type -> spacemesh.v2alpha1.NetworkInfoRequest - 0, // 2: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 3, // 1: spacemesh.v2alpha1.NetworkInfoResponse.layer_duration:type_name -> google.protobuf.Duration + 1, // 2: spacemesh.v2alpha1.NetworkService.Info:input_type -> spacemesh.v2alpha1.NetworkInfoRequest + 0, // 3: spacemesh.v2alpha1.NetworkService.Info:output_type -> spacemesh.v2alpha1.NetworkInfoResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_spacemesh_v2alpha1_network_proto_init() } diff --git a/spacemesh/v2alpha1/network.proto b/spacemesh/v2alpha1/network.proto index 79851cdb..a24c6886 100644 --- a/spacemesh/v2alpha1/network.proto +++ b/spacemesh/v2alpha1/network.proto @@ -1,12 +1,13 @@ syntax = "proto3"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; package spacemesh.v2alpha1; message NetworkInfoResponse { google.protobuf.Timestamp genesis_time = 1; // network genesis time as unix epoch time - uint32 layer_duration = 3; // layer duration, in seconds + google.protobuf.Duration layer_duration = 3; // layer duration, in seconds bytes genesis_id = 4; string hrp = 5; uint32 effective_genesis_layer = 6; // effective genesis layer, i.e., first layer after genesis initialization period From ef47a94e852bac3a922622345ab1094a34db62f1 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Wed, 20 Mar 2024 12:39:17 +0100 Subject: [PATCH 6/7] Change comments --- spacemesh/v2alpha1/network.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spacemesh/v2alpha1/network.proto b/spacemesh/v2alpha1/network.proto index a24c6886..5e59ca77 100644 --- a/spacemesh/v2alpha1/network.proto +++ b/spacemesh/v2alpha1/network.proto @@ -6,8 +6,8 @@ import "google/protobuf/duration.proto"; package spacemesh.v2alpha1; message NetworkInfoResponse { - google.protobuf.Timestamp genesis_time = 1; // network genesis time as unix epoch time - google.protobuf.Duration layer_duration = 3; // layer duration, in seconds + google.protobuf.Timestamp genesis_time = 1; // genesis time of the network, represented as a timestamp + google.protobuf.Duration layer_duration = 3; // duration of each layer in the network, specified as a duration bytes genesis_id = 4; string hrp = 5; uint32 effective_genesis_layer = 6; // effective genesis layer, i.e., first layer after genesis initialization period From dbb3c5cbdfa7f5d0723dae1c76cc4fad47a82797 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Wed, 20 Mar 2024 12:39:38 +0100 Subject: [PATCH 7/7] make build --- release/go/spacemesh/v2alpha1/network.pb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/go/spacemesh/v2alpha1/network.pb.go b/release/go/spacemesh/v2alpha1/network.pb.go index 59f93894..fff60f96 100644 --- a/release/go/spacemesh/v2alpha1/network.pb.go +++ b/release/go/spacemesh/v2alpha1/network.pb.go @@ -27,8 +27,8 @@ type NetworkInfoResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GenesisTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // network genesis time as unix epoch time - LayerDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // layer duration, in seconds + GenesisTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` // genesis time of the network, represented as a timestamp + LayerDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=layer_duration,json=layerDuration,proto3" json:"layer_duration,omitempty"` // duration of each layer in the network, specified as a duration GenesisId []byte `protobuf:"bytes,4,opt,name=genesis_id,json=genesisId,proto3" json:"genesis_id,omitempty"` Hrp string `protobuf:"bytes,5,opt,name=hrp,proto3" json:"hrp,omitempty"` EffectiveGenesisLayer uint32 `protobuf:"varint,6,opt,name=effective_genesis_layer,json=effectiveGenesisLayer,proto3" json:"effective_genesis_layer,omitempty"` // effective genesis layer, i.e., first layer after genesis initialization period