From ba163b2ee96242320697db433a9b397fcf5879db Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Mon, 17 Mar 2025 23:03:38 +0200 Subject: [PATCH] Update RPC --- .../rpc_get_pruning_window_roots.go | 6 +- cmd/archiveexport/main.go | 10 +- domain/consensus/model/externalapi/hash.go | 12 ++ .../grpcserver/protowire/messages.pb.go | 16 +- .../grpcserver/protowire/messages_grpc.pb.go | 176 +++++++----------- .../server/grpcserver/protowire/p2p.pb.go | 16 +- .../server/grpcserver/protowire/rpc.pb.go | 111 +++++------ .../server/grpcserver/protowire/rpc.proto | 6 +- .../protowire/rpc_get_pruning_window_roots.go | 12 +- 9 files changed, 168 insertions(+), 197 deletions(-) diff --git a/app/appmessage/rpc_get_pruning_window_roots.go b/app/appmessage/rpc_get_pruning_window_roots.go index 0b590e775..472286284 100644 --- a/app/appmessage/rpc_get_pruning_window_roots.go +++ b/app/appmessage/rpc_get_pruning_window_roots.go @@ -11,8 +11,8 @@ func (msg *GetPruningWindowRootsRequestMessage) Command() MessageCommand { return CmdGetPruningWindowRootsRequestMessage } -type PruningWindowRoot struct { - Root string +type PruningWindowRoots struct { + PPRoots []string PPIndex uint64 } @@ -20,7 +20,7 @@ type PruningWindowRoot struct { // its respective RPC message type GetPruningWindowRootsResponseMessage struct { baseMessage - Roots []*PruningWindowRoot + Roots []*PruningWindowRoots Error *RPCError } diff --git a/cmd/archiveexport/main.go b/cmd/archiveexport/main.go index 61969d4c0..ff975ed71 100644 --- a/cmd/archiveexport/main.go +++ b/cmd/archiveexport/main.go @@ -75,18 +75,18 @@ func mainImpl(cfg *configFlags) error { } for _, root := range rootsResp.Roots { - log.Infof("Got root %s", root.Root) + log.Infof("Got root %s", root.PPRoots) } counterStart := time.Now() counter := 0 for _, root := range rootsResp.Roots { - rootHash, err := externalapi.NewDomainHashFromString(root.Root) + ppRoots, err := externalapi.NewDomainHashesFromStrings(root.PPRoots) if err != nil { return err } - log.Infof("Adding past of %s", rootHash) + log.Infof("Adding past of %s", ppRoots) if err != nil { return err @@ -98,7 +98,9 @@ func mainImpl(cfg *configFlags) error { // TODO: Since GD data is not always available, we should extract the blue work from the header and use that for topological traversal heap := tc.DAGTraversalManager().NewDownHeap(model.NewStagingArea()) - heap.Push(rootHash) + for _, ppRoot := range ppRoots { + heap.Push(ppRoot) + } visited := make(map[externalapi.DomainHash]struct{}) chunk := make([]*appmessage.ArchivalBlock, 0, 1000) diff --git a/domain/consensus/model/externalapi/hash.go b/domain/consensus/model/externalapi/hash.go index 1ea8a9007..2261c0ab4 100644 --- a/domain/consensus/model/externalapi/hash.go +++ b/domain/consensus/model/externalapi/hash.go @@ -59,6 +59,18 @@ func NewDomainHashFromString(hashString string) (*DomainHash, error) { return NewDomainHashFromByteSlice(hashBytes) } +func NewDomainHashesFromStrings(hashStrings []string) ([]*DomainHash, error) { + hashes := make([]*DomainHash, len(hashStrings)) + for i, hashString := range hashStrings { + hash, err := NewDomainHashFromString(hashString) + if err != nil { + return nil, err + } + hashes[i] = hash + } + return hashes, nil +} + // String returns the Hash as the hexadecimal string of the hash. func (hash DomainHash) String() string { return hex.EncodeToString(hash.hashArray[:]) diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go index 45a1f44da..14a39a614 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.2 -// protoc v3.12.3 +// protoc-gen-go v1.36.5 +// protoc v3.12.4 // source: messages.proto package protowire @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -2568,7 +2569,7 @@ func (*KaspadMessage_AddArchivalBlocksResponse) isKaspadMessage_Payload() {} var File_messages_proto protoreflect.FileDescriptor -var file_messages_proto_rawDesc = []byte{ +var file_messages_proto_rawDesc = string([]byte{ 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, @@ -3639,16 +3640,16 @@ var file_messages_proto_rawDesc = []byte{ 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_messages_proto_rawDescOnce sync.Once - file_messages_proto_rawDescData = file_messages_proto_rawDesc + file_messages_proto_rawDescData []byte ) func file_messages_proto_rawDescGZIP() []byte { file_messages_proto_rawDescOnce.Do(func() { - file_messages_proto_rawDescData = protoimpl.X.CompressGZIP(file_messages_proto_rawDescData) + file_messages_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc))) }) return file_messages_proto_rawDescData } @@ -4149,7 +4150,7 @@ func file_messages_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_messages_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -4160,7 +4161,6 @@ func file_messages_proto_init() { MessageInfos: file_messages_proto_msgTypes, }.Build() File_messages_proto = out.File - file_messages_proto_rawDesc = nil file_messages_proto_goTypes = nil file_messages_proto_depIdxs = nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/messages_grpc.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/messages_grpc.pb.go index 9db8b8501..89dd56b1a 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/messages_grpc.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/messages_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.12.3 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.12.4 // source: messages.proto package protowire @@ -15,14 +15,18 @@ import ( // 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 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + P2P_MessageStream_FullMethodName = "/protowire.P2P/MessageStream" +) // P2PClient is the client API for P2P 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 P2PClient interface { - MessageStream(ctx context.Context, opts ...grpc.CallOption) (P2P_MessageStreamClient, error) + MessageStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[KaspadMessage, KaspadMessage], error) } type p2PClient struct { @@ -33,53 +37,39 @@ func NewP2PClient(cc grpc.ClientConnInterface) P2PClient { return &p2PClient{cc} } -func (c *p2PClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (P2P_MessageStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &P2P_ServiceDesc.Streams[0], "/protowire.P2P/MessageStream", opts...) +func (c *p2PClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[KaspadMessage, KaspadMessage], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &P2P_ServiceDesc.Streams[0], P2P_MessageStream_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &p2PMessageStreamClient{stream} + x := &grpc.GenericClientStream[KaspadMessage, KaspadMessage]{ClientStream: stream} return x, nil } -type P2P_MessageStreamClient interface { - Send(*KaspadMessage) error - Recv() (*KaspadMessage, error) - grpc.ClientStream -} - -type p2PMessageStreamClient struct { - grpc.ClientStream -} - -func (x *p2PMessageStreamClient) Send(m *KaspadMessage) error { - return x.ClientStream.SendMsg(m) -} - -func (x *p2PMessageStreamClient) Recv() (*KaspadMessage, error) { - m := new(KaspadMessage) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type P2P_MessageStreamClient = grpc.BidiStreamingClient[KaspadMessage, KaspadMessage] // P2PServer is the server API for P2P service. // All implementations must embed UnimplementedP2PServer -// for forward compatibility +// for forward compatibility. type P2PServer interface { - MessageStream(P2P_MessageStreamServer) error + MessageStream(grpc.BidiStreamingServer[KaspadMessage, KaspadMessage]) error mustEmbedUnimplementedP2PServer() } -// UnimplementedP2PServer must be embedded to have forward compatible implementations. -type UnimplementedP2PServer struct { -} +// UnimplementedP2PServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedP2PServer struct{} -func (UnimplementedP2PServer) MessageStream(P2P_MessageStreamServer) error { +func (UnimplementedP2PServer) MessageStream(grpc.BidiStreamingServer[KaspadMessage, KaspadMessage]) error { return status.Errorf(codes.Unimplemented, "method MessageStream not implemented") } func (UnimplementedP2PServer) mustEmbedUnimplementedP2PServer() {} +func (UnimplementedP2PServer) testEmbeddedByValue() {} // UnsafeP2PServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to P2PServer will @@ -89,34 +79,22 @@ type UnsafeP2PServer interface { } func RegisterP2PServer(s grpc.ServiceRegistrar, srv P2PServer) { + // If the following call pancis, it indicates UnimplementedP2PServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&P2P_ServiceDesc, srv) } func _P2P_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(P2PServer).MessageStream(&p2PMessageStreamServer{stream}) + return srv.(P2PServer).MessageStream(&grpc.GenericServerStream[KaspadMessage, KaspadMessage]{ServerStream: stream}) } -type P2P_MessageStreamServer interface { - Send(*KaspadMessage) error - Recv() (*KaspadMessage, error) - grpc.ServerStream -} - -type p2PMessageStreamServer struct { - grpc.ServerStream -} - -func (x *p2PMessageStreamServer) Send(m *KaspadMessage) error { - return x.ServerStream.SendMsg(m) -} - -func (x *p2PMessageStreamServer) Recv() (*KaspadMessage, error) { - m := new(KaspadMessage) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type P2P_MessageStreamServer = grpc.BidiStreamingServer[KaspadMessage, KaspadMessage] // P2P_ServiceDesc is the grpc.ServiceDesc for P2P service. // It's only intended for direct use with grpc.RegisterService, @@ -136,11 +114,15 @@ var P2P_ServiceDesc = grpc.ServiceDesc{ Metadata: "messages.proto", } +const ( + RPC_MessageStream_FullMethodName = "/protowire.RPC/MessageStream" +) + // RPCClient is the client API for RPC 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 RPCClient interface { - MessageStream(ctx context.Context, opts ...grpc.CallOption) (RPC_MessageStreamClient, error) + MessageStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[KaspadMessage, KaspadMessage], error) } type rPCClient struct { @@ -151,53 +133,39 @@ func NewRPCClient(cc grpc.ClientConnInterface) RPCClient { return &rPCClient{cc} } -func (c *rPCClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (RPC_MessageStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &RPC_ServiceDesc.Streams[0], "/protowire.RPC/MessageStream", opts...) +func (c *rPCClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[KaspadMessage, KaspadMessage], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &RPC_ServiceDesc.Streams[0], RPC_MessageStream_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &rPCMessageStreamClient{stream} + x := &grpc.GenericClientStream[KaspadMessage, KaspadMessage]{ClientStream: stream} return x, nil } -type RPC_MessageStreamClient interface { - Send(*KaspadMessage) error - Recv() (*KaspadMessage, error) - grpc.ClientStream -} - -type rPCMessageStreamClient struct { - grpc.ClientStream -} - -func (x *rPCMessageStreamClient) Send(m *KaspadMessage) error { - return x.ClientStream.SendMsg(m) -} - -func (x *rPCMessageStreamClient) Recv() (*KaspadMessage, error) { - m := new(KaspadMessage) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type RPC_MessageStreamClient = grpc.BidiStreamingClient[KaspadMessage, KaspadMessage] // RPCServer is the server API for RPC service. // All implementations must embed UnimplementedRPCServer -// for forward compatibility +// for forward compatibility. type RPCServer interface { - MessageStream(RPC_MessageStreamServer) error + MessageStream(grpc.BidiStreamingServer[KaspadMessage, KaspadMessage]) error mustEmbedUnimplementedRPCServer() } -// UnimplementedRPCServer must be embedded to have forward compatible implementations. -type UnimplementedRPCServer struct { -} +// UnimplementedRPCServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRPCServer struct{} -func (UnimplementedRPCServer) MessageStream(RPC_MessageStreamServer) error { +func (UnimplementedRPCServer) MessageStream(grpc.BidiStreamingServer[KaspadMessage, KaspadMessage]) error { return status.Errorf(codes.Unimplemented, "method MessageStream not implemented") } func (UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {} +func (UnimplementedRPCServer) testEmbeddedByValue() {} // UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RPCServer will @@ -207,34 +175,22 @@ type UnsafeRPCServer interface { } func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer) { + // If the following call pancis, it indicates UnimplementedRPCServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&RPC_ServiceDesc, srv) } func _RPC_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(RPCServer).MessageStream(&rPCMessageStreamServer{stream}) + return srv.(RPCServer).MessageStream(&grpc.GenericServerStream[KaspadMessage, KaspadMessage]{ServerStream: stream}) } -type RPC_MessageStreamServer interface { - Send(*KaspadMessage) error - Recv() (*KaspadMessage, error) - grpc.ServerStream -} - -type rPCMessageStreamServer struct { - grpc.ServerStream -} - -func (x *rPCMessageStreamServer) Send(m *KaspadMessage) error { - return x.ServerStream.SendMsg(m) -} - -func (x *rPCMessageStreamServer) Recv() (*KaspadMessage, error) { - m := new(KaspadMessage) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type RPC_MessageStreamServer = grpc.BidiStreamingServer[KaspadMessage, KaspadMessage] // RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. // It's only intended for direct use with grpc.RegisterService, diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/p2p.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/p2p.pb.go index 730c26b83..43910f787 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/p2p.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/p2p.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.2 -// protoc v3.12.3 +// protoc-gen-go v1.36.5 +// protoc v3.12.4 // source: p2p.proto package protowire @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -3046,7 +3047,7 @@ func (x *TrustedDataMessage) GetGhostdagData() []*BlockGhostdagDataHashPair { var File_p2p_proto protoreflect.FileDescriptor -var file_p2p_proto_rawDesc = []byte{ +var file_p2p_proto_rawDesc = string([]byte{ 0x0a, 0x09, 0x70, 0x32, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x22, 0x8c, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, @@ -3442,16 +3443,16 @@ var file_p2p_proto_rawDesc = []byte{ 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_p2p_proto_rawDescOnce sync.Once - file_p2p_proto_rawDescData = file_p2p_proto_rawDesc + file_p2p_proto_rawDescData []byte ) func file_p2p_proto_rawDescGZIP() []byte { file_p2p_proto_rawDescOnce.Do(func() { - file_p2p_proto_rawDescData = protoimpl.X.CompressGZIP(file_p2p_proto_rawDescData) + file_p2p_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_p2p_proto_rawDesc), len(file_p2p_proto_rawDesc))) }) return file_p2p_proto_rawDescData } @@ -3598,7 +3599,7 @@ func file_p2p_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_p2p_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_p2p_proto_rawDesc), len(file_p2p_proto_rawDesc)), NumEnums: 0, NumMessages: 60, NumExtensions: 0, @@ -3609,7 +3610,6 @@ func file_p2p_proto_init() { MessageInfos: file_p2p_proto_msgTypes, }.Build() File_p2p_proto = out.File - file_p2p_proto_rawDesc = nil file_p2p_proto_goTypes = nil file_p2p_proto_depIdxs = nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go index be84686e7..4bf22a262 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go @@ -13,8 +13,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.2 -// protoc v3.12.3 +// protoc-gen-go v1.36.5 +// protoc v3.12.4 // source: rpc.proto package protowire @@ -24,6 +24,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -7847,28 +7848,28 @@ func (*GetPruningWindowRootsRequestMessage) Descriptor() ([]byte, []int) { return file_rpc_proto_rawDescGZIP(), []int{139} } -type PruningWindowRoot struct { +type PruningWindowRoots struct { state protoimpl.MessageState `protogen:"open.v1"` - Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` + PpRoots []string `protobuf:"bytes,1,rep,name=pp_roots,json=ppRoots,proto3" json:"pp_roots,omitempty"` PpIndex uint64 `protobuf:"varint,2,opt,name=pp_index,json=ppIndex,proto3" json:"pp_index,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *PruningWindowRoot) Reset() { - *x = PruningWindowRoot{} +func (x *PruningWindowRoots) Reset() { + *x = PruningWindowRoots{} mi := &file_rpc_proto_msgTypes[140] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *PruningWindowRoot) String() string { +func (x *PruningWindowRoots) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PruningWindowRoot) ProtoMessage() {} +func (*PruningWindowRoots) ProtoMessage() {} -func (x *PruningWindowRoot) ProtoReflect() protoreflect.Message { +func (x *PruningWindowRoots) ProtoReflect() protoreflect.Message { mi := &file_rpc_proto_msgTypes[140] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -7880,19 +7881,19 @@ func (x *PruningWindowRoot) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PruningWindowRoot.ProtoReflect.Descriptor instead. -func (*PruningWindowRoot) Descriptor() ([]byte, []int) { +// Deprecated: Use PruningWindowRoots.ProtoReflect.Descriptor instead. +func (*PruningWindowRoots) Descriptor() ([]byte, []int) { return file_rpc_proto_rawDescGZIP(), []int{140} } -func (x *PruningWindowRoot) GetRoot() string { +func (x *PruningWindowRoots) GetPpRoots() []string { if x != nil { - return x.Root + return x.PpRoots } - return "" + return nil } -func (x *PruningWindowRoot) GetPpIndex() uint64 { +func (x *PruningWindowRoots) GetPpIndex() uint64 { if x != nil { return x.PpIndex } @@ -7901,7 +7902,7 @@ func (x *PruningWindowRoot) GetPpIndex() uint64 { type GetPruningWindowRootsResponseMessage struct { state protoimpl.MessageState `protogen:"open.v1"` - Roots []*PruningWindowRoot `protobuf:"bytes,1,rep,name=roots,proto3" json:"roots,omitempty"` + Roots []*PruningWindowRoots `protobuf:"bytes,1,rep,name=roots,proto3" json:"roots,omitempty"` Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -7937,7 +7938,7 @@ func (*GetPruningWindowRootsResponseMessage) Descriptor() ([]byte, []int) { return file_rpc_proto_rawDescGZIP(), []int{141} } -func (x *GetPruningWindowRootsResponseMessage) GetRoots() []*PruningWindowRoot { +func (x *GetPruningWindowRootsResponseMessage) GetRoots() []*PruningWindowRoots { if x != nil { return x.Roots } @@ -8093,7 +8094,7 @@ func (x *AddArchivalBlocksResponseMessage) GetError() *RPCError { var File_rpc_proto protoreflect.FileDescriptor -var file_rpc_proto_rawDesc = []byte{ +var file_rpc_proto_rawDesc = string([]byte{ 0x0a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x22, 0x24, 0x0a, 0x08, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, @@ -9245,48 +9246,49 @@ var file_rpc_proto_rawDesc = []byte{ 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x25, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x42, 0x0a, 0x11, 0x50, 0x72, 0x75, 0x6e, - 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6f, - 0x74, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x70, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x07, 0x70, 0x70, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x86, 0x01, 0x0a, - 0x24, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, - 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, - 0x2e, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, - 0x6f, 0x74, 0x52, 0x05, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, + 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4a, 0x0a, 0x12, 0x50, 0x72, 0x75, 0x6e, + 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x19, + 0x0a, 0x08, 0x70, 0x70, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x07, 0x70, 0x70, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x70, 0x5f, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x70, 0x70, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x22, 0x87, 0x01, 0x0a, 0x24, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, + 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x33, 0x0a, + 0x05, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, + 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x05, 0x72, 0x6f, 0x6f, + 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, + 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x50, + 0x0a, 0x0d, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, + 0x14, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, + 0x2e, 0x52, 0x70, 0x63, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x22, 0x53, 0x0a, 0x1f, 0x41, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, + 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x06, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x22, 0x4e, 0x0a, 0x20, 0x41, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, + 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, - 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x12, 0x29, 0x0a, 0x05, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x53, 0x0a, 0x1f, 0x41, 0x64, 0x64, 0x41, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x22, 0x4e, 0x0a, 0x20, - 0x41, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x26, 0x5a, 0x24, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, - 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, + 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +}) var ( file_rpc_proto_rawDescOnce sync.Once - file_rpc_proto_rawDescData = file_rpc_proto_rawDesc + file_rpc_proto_rawDescData []byte ) func file_rpc_proto_rawDescGZIP() []byte { file_rpc_proto_rawDescOnce.Do(func() { - file_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_proto_rawDescData) + file_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_rpc_proto_rawDesc), len(file_rpc_proto_rawDesc))) }) return file_rpc_proto_rawDescData } @@ -9435,7 +9437,7 @@ var file_rpc_proto_goTypes = []any{ (*SubmitTransactionReplacementRequestMessage)(nil), // 138: protowire.SubmitTransactionReplacementRequestMessage (*SubmitTransactionReplacementResponseMessage)(nil), // 139: protowire.SubmitTransactionReplacementResponseMessage (*GetPruningWindowRootsRequestMessage)(nil), // 140: protowire.GetPruningWindowRootsRequestMessage - (*PruningWindowRoot)(nil), // 141: protowire.PruningWindowRoot + (*PruningWindowRoots)(nil), // 141: protowire.PruningWindowRoots (*GetPruningWindowRootsResponseMessage)(nil), // 142: protowire.GetPruningWindowRootsResponseMessage (*ArchivalBlock)(nil), // 143: protowire.ArchivalBlock (*AddArchivalBlocksRequestMessage)(nil), // 144: protowire.AddArchivalBlocksRequestMessage @@ -9543,7 +9545,7 @@ var file_rpc_proto_depIdxs = []int32{ 6, // 98: protowire.SubmitTransactionReplacementRequestMessage.transaction:type_name -> protowire.RpcTransaction 6, // 99: protowire.SubmitTransactionReplacementResponseMessage.replacedTransaction:type_name -> protowire.RpcTransaction 1, // 100: protowire.SubmitTransactionReplacementResponseMessage.error:type_name -> protowire.RPCError - 141, // 101: protowire.GetPruningWindowRootsResponseMessage.roots:type_name -> protowire.PruningWindowRoot + 141, // 101: protowire.GetPruningWindowRootsResponseMessage.roots:type_name -> protowire.PruningWindowRoots 1, // 102: protowire.GetPruningWindowRootsResponseMessage.error:type_name -> protowire.RPCError 2, // 103: protowire.ArchivalBlock.block:type_name -> protowire.RpcBlock 143, // 104: protowire.AddArchivalBlocksRequestMessage.blocks:type_name -> protowire.ArchivalBlock @@ -9564,7 +9566,7 @@ func file_rpc_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_rpc_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_rpc_proto_rawDesc), len(file_rpc_proto_rawDesc)), NumEnums: 1, NumMessages: 145, NumExtensions: 0, @@ -9576,7 +9578,6 @@ func file_rpc_proto_init() { MessageInfos: file_rpc_proto_msgTypes, }.Build() File_rpc_proto = out.File - file_rpc_proto_rawDesc = nil file_rpc_proto_goTypes = nil file_rpc_proto_depIdxs = nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto index e29e86331..4cf527520 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto @@ -892,13 +892,13 @@ message SubmitTransactionReplacementResponseMessage { message GetPruningWindowRootsRequestMessage {} -message PruningWindowRoot { - string root = 1; +message PruningWindowRoots { + repeated string pp_roots = 1; uint64 pp_index = 2; } message GetPruningWindowRootsResponseMessage { - repeated PruningWindowRoot roots = 1; + repeated PruningWindowRoots roots = 1; RPCError error = 1000; } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go index 975849812..c69c0dfe1 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go @@ -29,10 +29,10 @@ func (x *KaspadMessage_GetPruningWindowRootsResponse) fromAppMessage(message *ap err = &RPCError{Message: message.Error.Message} } - roots := make([]*PruningWindowRoot, len(message.Roots)) + roots := make([]*PruningWindowRoots, len(message.Roots)) for i, root := range message.Roots { - roots[i] = &PruningWindowRoot{ - Root: root.Root, + roots[i] = &PruningWindowRoots{ + PpRoots: root.PPRoots, PpIndex: root.PPIndex, } } @@ -55,10 +55,10 @@ func (x *GetPruningWindowRootsResponseMessage) toAppMessage() (appmessage.Messag return nil, err } - roots := make([]*appmessage.PruningWindowRoot, len(x.Roots)) + roots := make([]*appmessage.PruningWindowRoots, len(x.Roots)) for i, root := range x.Roots { - roots[i] = &appmessage.PruningWindowRoot{ - Root: root.Root, + roots[i] = &appmessage.PruningWindowRoots{ + PPRoots: root.PpRoots, PPIndex: root.PpIndex, } }