diff --git a/release/proto/go/rpc/api/v1/api.pb.go b/release/proto/go/rpc/api/v1/api.pb.go index a306a413..0cc389e9 100644 --- a/release/proto/go/rpc/api/v1/api.pb.go +++ b/release/proto/go/rpc/api/v1/api.pb.go @@ -558,9 +558,8 @@ type PoetProof struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Proof *MerkleProof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` - Members [][]byte `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` - Leaves uint64 `protobuf:"varint,3,opt,name=leaves,proto3" json:"leaves,omitempty"` + Proof *MerkleProof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + Leaves uint64 `protobuf:"varint,2,opt,name=leaves,proto3" json:"leaves,omitempty"` } func (x *PoetProof) Reset() { @@ -602,13 +601,6 @@ func (x *PoetProof) GetProof() *MerkleProof { return nil } -func (x *PoetProof) GetMembers() [][]byte { - if x != nil { - return x.Members - } - return nil -} - func (x *PoetProof) GetLeaves() uint64 { if x != nil { return x.Leaves @@ -718,6 +710,100 @@ func (x *GetProofResponse) GetPubkey() []byte { return nil } +type GetRoundRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RoundId string `protobuf:"bytes,1,opt,name=round_id,json=roundId,proto3" json:"round_id,omitempty"` +} + +func (x *GetRoundRequest) Reset() { + *x = GetRoundRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_api_v1_api_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRoundRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoundRequest) ProtoMessage() {} + +func (x *GetRoundRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_api_v1_api_proto_msgTypes[13] + 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 GetRoundRequest.ProtoReflect.Descriptor instead. +func (*GetRoundRequest) Descriptor() ([]byte, []int) { + return file_rpc_api_v1_api_proto_rawDescGZIP(), []int{13} +} + +func (x *GetRoundRequest) GetRoundId() string { + if x != nil { + return x.RoundId + } + return "" +} + +type GetRoundResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Members [][]byte `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"` +} + +func (x *GetRoundResponse) Reset() { + *x = GetRoundResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_api_v1_api_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRoundResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoundResponse) ProtoMessage() {} + +func (x *GetRoundResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_api_v1_api_proto_msgTypes[14] + 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 GetRoundResponse.ProtoReflect.Descriptor instead. +func (*GetRoundResponse) Descriptor() ([]byte, []int) { + return file_rpc_api_v1_api_proto_rawDescGZIP(), []int{14} +} + +func (x *GetRoundResponse) GetMembers() [][]byte { + if x != nil { + return x.Members + } + return nil +} + var File_rpc_api_v1_api_proto protoreflect.FileDescriptor var file_rpc_api_v1_api_proto_rawDesc = []byte{ @@ -778,63 +864,74 @@ var file_rpc_api_v1_api_proto_rawDesc = []byte{ 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x6e, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x4e, 0x6f, 0x64, 0x65, - 0x73, 0x22, 0x6c, 0x0a, 0x09, 0x50, 0x6f, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2d, + 0x73, 0x22, 0x52, 0x0a, 0x09, 0x50, 0x6f, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2d, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x72, 0x6b, 0x6c, - 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, - 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x61, 0x76, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x73, 0x22, - 0x2c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x57, 0x0a, - 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, - 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x16, - 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, - 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x32, 0xe9, 0x03, 0x0a, 0x0b, 0x50, 0x6f, 0x65, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, - 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, - 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x76, - 0x31, 0x2f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3a, 0x01, 0x2a, 0x12, 0x72, 0x0a, 0x0d, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x20, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, + 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x16, 0x0a, + 0x06, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, + 0x65, 0x61, 0x76, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, + 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x6e, + 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x6f, 0x75, 0x6e, + 0x64, 0x49, 0x64, 0x22, 0x57, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, + 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x22, 0x2c, 0x0a, 0x0f, + 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x10, 0x47, 0x65, + 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x32, 0xcf, 0x04, 0x0a, 0x0b, 0x50, 0x6f, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, + 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3a, 0x01, 0x2a, 0x12, 0x72, 0x0a, 0x0d, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x3a, 0x01, 0x2a, 0x12, 0x56, - 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x22, 0x0a, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, - 0x6d, 0x69, 0x74, 0x3a, 0x01, 0x2a, 0x12, 0x54, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, - 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x64, 0x0a, 0x08, - 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x12, 0x15, 0x2f, 0x76, 0x31, - 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x2f, 0x7b, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, - 0x64, 0x7d, 0x42, 0xa3, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, 0x73, 0x2f, 0x70, 0x6f, 0x65, 0x74, 0x2f, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, - 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, - 0xa2, 0x02, 0x03, 0x52, 0x41, 0x58, 0xaa, 0x02, 0x0a, 0x52, 0x70, 0x63, 0x2e, 0x41, 0x70, 0x69, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x52, 0x70, 0x63, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x16, 0x52, 0x70, 0x63, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x52, 0x70, 0x63, 0x3a, - 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x3a, 0x01, 0x2a, + 0x12, 0x56, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x22, 0x0a, 0x2f, 0x76, 0x31, 0x2f, 0x73, + 0x75, 0x62, 0x6d, 0x69, 0x74, 0x3a, 0x01, 0x2a, 0x12, 0x54, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x64, + 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x1b, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x12, 0x15, 0x2f, + 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x2f, 0x7b, 0x72, 0x6f, 0x75, 0x6e, 0x64, + 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x64, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, + 0x12, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, + 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f, + 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x17, 0x12, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x2f, + 0x7b, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x42, 0xa3, 0x01, 0x0a, 0x0e, 0x63, + 0x6f, 0x6d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x41, + 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x73, 0x68, 0x6f, + 0x73, 0x2f, 0x70, 0x6f, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x52, 0x41, 0x58, 0xaa, 0x02, + 0x0a, 0x52, 0x70, 0x63, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x52, 0x70, + 0x63, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, 0x52, 0x70, 0x63, 0x5c, 0x41, + 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x0c, 0x52, 0x70, 0x63, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -849,7 +946,7 @@ func file_rpc_api_v1_api_proto_rawDescGZIP() []byte { return file_rpc_api_v1_api_proto_rawDescData } -var file_rpc_api_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_rpc_api_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_rpc_api_v1_api_proto_goTypes = []interface{}{ (*StartRequest)(nil), // 0: rpc.api.v1.StartRequest (*StartResponse)(nil), // 1: rpc.api.v1.StartResponse @@ -864,10 +961,12 @@ var file_rpc_api_v1_api_proto_goTypes = []interface{}{ (*PoetProof)(nil), // 10: rpc.api.v1.PoetProof (*GetProofRequest)(nil), // 11: rpc.api.v1.GetProofRequest (*GetProofResponse)(nil), // 12: rpc.api.v1.GetProofResponse - (*durationpb.Duration)(nil), // 13: google.protobuf.Duration + (*GetRoundRequest)(nil), // 13: rpc.api.v1.GetRoundRequest + (*GetRoundResponse)(nil), // 14: rpc.api.v1.GetRoundResponse + (*durationpb.Duration)(nil), // 15: google.protobuf.Duration } var file_rpc_api_v1_api_proto_depIdxs = []int32{ - 13, // 0: rpc.api.v1.SubmitResponse.round_end:type_name -> google.protobuf.Duration + 15, // 0: rpc.api.v1.SubmitResponse.round_end:type_name -> google.protobuf.Duration 9, // 1: rpc.api.v1.PoetProof.proof:type_name -> rpc.api.v1.MerkleProof 10, // 2: rpc.api.v1.GetProofResponse.proof:type_name -> rpc.api.v1.PoetProof 0, // 3: rpc.api.v1.PoetService.Start:input_type -> rpc.api.v1.StartRequest @@ -875,13 +974,15 @@ var file_rpc_api_v1_api_proto_depIdxs = []int32{ 4, // 5: rpc.api.v1.PoetService.Submit:input_type -> rpc.api.v1.SubmitRequest 6, // 6: rpc.api.v1.PoetService.GetInfo:input_type -> rpc.api.v1.GetInfoRequest 11, // 7: rpc.api.v1.PoetService.GetProof:input_type -> rpc.api.v1.GetProofRequest - 1, // 8: rpc.api.v1.PoetService.Start:output_type -> rpc.api.v1.StartResponse - 3, // 9: rpc.api.v1.PoetService.UpdateGateway:output_type -> rpc.api.v1.UpdateGatewayResponse - 5, // 10: rpc.api.v1.PoetService.Submit:output_type -> rpc.api.v1.SubmitResponse - 7, // 11: rpc.api.v1.PoetService.GetInfo:output_type -> rpc.api.v1.GetInfoResponse - 12, // 12: rpc.api.v1.PoetService.GetProof:output_type -> rpc.api.v1.GetProofResponse - 8, // [8:13] is the sub-list for method output_type - 3, // [3:8] is the sub-list for method input_type + 13, // 8: rpc.api.v1.PoetService.GetRound:input_type -> rpc.api.v1.GetRoundRequest + 1, // 9: rpc.api.v1.PoetService.Start:output_type -> rpc.api.v1.StartResponse + 3, // 10: rpc.api.v1.PoetService.UpdateGateway:output_type -> rpc.api.v1.UpdateGatewayResponse + 5, // 11: rpc.api.v1.PoetService.Submit:output_type -> rpc.api.v1.SubmitResponse + 7, // 12: rpc.api.v1.PoetService.GetInfo:output_type -> rpc.api.v1.GetInfoResponse + 12, // 13: rpc.api.v1.PoetService.GetProof:output_type -> rpc.api.v1.GetProofResponse + 14, // 14: rpc.api.v1.PoetService.GetRound:output_type -> rpc.api.v1.GetRoundResponse + 9, // [9:15] is the sub-list for method output_type + 3, // [3:9] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -1049,6 +1150,30 @@ func file_rpc_api_v1_api_proto_init() { return nil } } + file_rpc_api_v1_api_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRoundRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_api_v1_api_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRoundResponse); 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{ @@ -1056,7 +1181,7 @@ func file_rpc_api_v1_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rpc_api_v1_api_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/release/proto/go/rpc/api/v1/api.pb.gw.go b/release/proto/go/rpc/api/v1/api.pb.gw.go index 075e228d..67130559 100644 --- a/release/proto/go/rpc/api/v1/api.pb.gw.go +++ b/release/proto/go/rpc/api/v1/api.pb.gw.go @@ -203,6 +203,58 @@ func local_request_PoetService_GetProof_0(ctx context.Context, marshaler runtime } +func request_PoetService_GetRound_0(ctx context.Context, marshaler runtime.Marshaler, client PoetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRoundRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["round_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "round_id") + } + + protoReq.RoundId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "round_id", err) + } + + msg, err := client.GetRound(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PoetService_GetRound_0(ctx context.Context, marshaler runtime.Marshaler, server PoetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRoundRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["round_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "round_id") + } + + protoReq.RoundId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "round_id", err) + } + + msg, err := server.GetRound(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterPoetServiceHandlerServer registers the http handlers for service PoetService to "mux". // UnaryRPC :call PoetServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -334,6 +386,31 @@ func RegisterPoetServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("GET", pattern_PoetService_GetRound_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, "/rpc.api.v1.PoetService/GetRound", runtime.WithHTTPPathPattern("/v1/rounds/{round_id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PoetService_GetRound_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_PoetService_GetRound_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -485,6 +562,28 @@ func RegisterPoetServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("GET", pattern_PoetService_GetRound_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, "/rpc.api.v1.PoetService/GetRound", runtime.WithHTTPPathPattern("/v1/rounds/{round_id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PoetService_GetRound_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_PoetService_GetRound_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -498,6 +597,8 @@ var ( pattern_PoetService_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "info"}, "")) pattern_PoetService_GetProof_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "proofs", "round_id"}, "")) + + pattern_PoetService_GetRound_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "rounds", "round_id"}, "")) ) var ( @@ -510,4 +611,6 @@ var ( forward_PoetService_GetInfo_0 = runtime.ForwardResponseMessage forward_PoetService_GetProof_0 = runtime.ForwardResponseMessage + + forward_PoetService_GetRound_0 = runtime.ForwardResponseMessage ) diff --git a/release/proto/go/rpc/api/v1/api_grpc.pb.go b/release/proto/go/rpc/api/v1/api_grpc.pb.go index 7944ed54..eb91e413 100644 --- a/release/proto/go/rpc/api/v1/api_grpc.pb.go +++ b/release/proto/go/rpc/api/v1/api_grpc.pb.go @@ -35,6 +35,8 @@ type PoetServiceClient interface { GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) // GetProof returns the generated proof for given round id. GetProof(ctx context.Context, in *GetProofRequest, opts ...grpc.CallOption) (*GetProofResponse, error) + // GetRound returns details about the given round + GetRound(ctx context.Context, in *GetRoundRequest, opts ...grpc.CallOption) (*GetRoundResponse, error) } type poetServiceClient struct { @@ -90,6 +92,15 @@ func (c *poetServiceClient) GetProof(ctx context.Context, in *GetProofRequest, o return out, nil } +func (c *poetServiceClient) GetRound(ctx context.Context, in *GetRoundRequest, opts ...grpc.CallOption) (*GetRoundResponse, error) { + out := new(GetRoundResponse) + err := c.cc.Invoke(ctx, "/rpc.api.v1.PoetService/GetRound", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // PoetServiceServer is the server API for PoetService service. // All implementations should embed UnimplementedPoetServiceServer // for forward compatibility @@ -107,6 +118,8 @@ type PoetServiceServer interface { GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) // GetProof returns the generated proof for given round id. GetProof(context.Context, *GetProofRequest) (*GetProofResponse, error) + // GetRound returns details about the given round + GetRound(context.Context, *GetRoundRequest) (*GetRoundResponse, error) } // UnimplementedPoetServiceServer should be embedded to have forward compatible implementations. @@ -128,6 +141,9 @@ func (UnimplementedPoetServiceServer) GetInfo(context.Context, *GetInfoRequest) func (UnimplementedPoetServiceServer) GetProof(context.Context, *GetProofRequest) (*GetProofResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetProof not implemented") } +func (UnimplementedPoetServiceServer) GetRound(context.Context, *GetRoundRequest) (*GetRoundResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRound not implemented") +} // UnsafePoetServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to PoetServiceServer will @@ -230,6 +246,24 @@ func _PoetService_GetProof_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _PoetService_GetRound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRoundRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PoetServiceServer).GetRound(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.api.v1.PoetService/GetRound", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PoetServiceServer).GetRound(ctx, req.(*GetRoundRequest)) + } + return interceptor(ctx, in, info, handler) +} + // PoetService_ServiceDesc is the grpc.ServiceDesc for PoetService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -257,6 +291,10 @@ var PoetService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetProof", Handler: _PoetService_GetProof_Handler, }, + { + MethodName: "GetRound", + Handler: _PoetService_GetRound_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rpc/api/v1/api.proto", diff --git a/release/proto/openapiv2/rpc/api/v1/api.swagger.json b/release/proto/openapiv2/rpc/api/v1/api.swagger.json index 0520a5c6..28e1760e 100644 --- a/release/proto/openapiv2/rpc/api/v1/api.swagger.json +++ b/release/proto/openapiv2/rpc/api/v1/api.swagger.json @@ -70,6 +70,37 @@ ] } }, + "/v1/rounds/{roundId}": { + "get": { + "summary": "GetRound returns details about the given round", + "operationId": "PoetService_GetRound", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1GetRoundResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "roundId", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "PoetService" + ] + } + }, "/v1/start": { "post": { "summary": "Start is used to start the service.", @@ -228,6 +259,18 @@ } } }, + "v1GetRoundResponse": { + "type": "object", + "properties": { + "members": { + "type": "array", + "items": { + "type": "string", + "format": "byte" + } + } + } + }, "v1MerkleProof": { "type": "object", "properties": { @@ -257,13 +300,6 @@ "proof": { "$ref": "#/definitions/v1MerkleProof" }, - "members": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, "leaves": { "type": "string", "format": "uint64" diff --git a/rpc/api/v1/api.proto b/rpc/api/v1/api.proto index ef3d3181..608cf58e 100644 --- a/rpc/api/v1/api.proto +++ b/rpc/api/v1/api.proto @@ -56,6 +56,15 @@ service PoetService { get: "/v1/proofs/{round_id}" }; } + + /** + GetRound returns details about the given round + */ + rpc GetRound(GetRoundRequest) returns (GetRoundResponse) { + option (google.api.http) = { + get: "/v1/rounds/{round_id}" + }; + } } message StartRequest { @@ -108,8 +117,7 @@ message MerkleProof { message PoetProof { MerkleProof proof = 1; - repeated bytes members = 2; - uint64 leaves = 3; + uint64 leaves = 2; } message GetProofRequest { @@ -120,3 +128,11 @@ message GetProofResponse { PoetProof proof = 1; bytes pubkey = 2; } + +message GetRoundRequest { + string round_id = 1; +} + +message GetRoundResponse { + repeated bytes members = 1; +} diff --git a/rpc/rpcserver.go b/rpc/rpcserver.go index ccc8db61..c012bc2d 100644 --- a/rpc/rpcserver.go +++ b/rpc/rpcserver.go @@ -22,7 +22,7 @@ import ( // rpcServer is a gRPC, RPC front end to poet. type rpcServer struct { - proofsDb *service.ProofsDatabase + serviceDB *service.ServiceDatabase s *service.Service gtwManager *gateway.Manager cfg config.Config @@ -36,12 +36,12 @@ var _ api.PoetServiceServer = (*rpcServer)(nil) // NewServer creates and returns a new instance of the rpcServer. func NewServer( svc *service.Service, - proofsDb *service.ProofsDatabase, + proofsDb *service.ServiceDatabase, gtwManager *gateway.Manager, cfg config.Config, ) *rpcServer { return &rpcServer{ - proofsDb: proofsDb, + serviceDB: proofsDb, s: svc, cfg: cfg, gtwManager: gtwManager, @@ -180,7 +180,7 @@ func (r *rpcServer) GetProof(ctx context.Context, in *api.GetProofRequest) (*api } } - proof, err := r.proofsDb.Get(ctx, in.RoundId) + proof, err := r.serviceDB.GetProof(ctx, in.RoundId) switch { case errors.Is(err, service.ErrNotFound): return nil, status.Error(codes.NotFound, "proof not found") @@ -192,8 +192,7 @@ func (r *rpcServer) GetProof(ctx context.Context, in *api.GetProofRequest) (*api ProvenLeaves: proof.ProvenLeaves, ProofNodes: proof.ProofNodes, }, - Members: proof.Members, - Leaves: proof.NumLeaves, + Leaves: proof.NumLeaves, }, Pubkey: proof.ServicePubKey, } @@ -203,3 +202,18 @@ func (r *rpcServer) GetProof(ctx context.Context, in *api.GetProofRequest) (*api return nil, status.Error(codes.Internal, err.Error()) } } + +// GetRound implements apiv1.PoetServiceServer. +func (r *rpcServer) GetRound(ctx context.Context, in *api.GetRoundRequest) (*api.GetRoundResponse, error) { + members, err := r.serviceDB.GetRoundMembers(ctx, in.RoundId) + switch { + case errors.Is(err, service.ErrNotFound): + return nil, status.Error(codes.NotFound, "round not found") + case err == nil: + out := api.GetRoundResponse{Members: members} + + return &out, nil + default: + return nil, status.Error(codes.Internal, err.Error()) + } +} diff --git a/server/server.go b/server/server.go index 4da0d5b2..4a513cb4 100644 --- a/server/server.go +++ b/server/server.go @@ -101,7 +101,7 @@ func (s *Server) Start(ctx context.Context) error { } proofsDbPath := filepath.Join(s.cfg.DataDir, "proofs") - proofsDb, err := service.NewProofsDatabase(proofsDbPath, s.svc.ProofsChan()) + proofsDb, err := service.NewServiceDatabase(proofsDbPath, s.svc.ProofsChan(), s.svc.RoundsDataChan()) if err != nil { return fmt.Errorf("failed to create proofs DB: %w", err) } diff --git a/server/server_test.go b/server/server_test.go index f7c4eb13..ee6a483e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -137,6 +137,15 @@ func TestSubmitAndGetProof(t *testing.T) { roundEnd := resp.RoundEnd.AsDuration() req.NotZero(roundEnd) + // Query for round details + var round *api.GetRoundResponse + req.Eventually(func() bool { + round, err = client.GetRound(context.Background(), &api.GetRoundRequest{RoundId: resp.RoundId}) + return err == nil + }, time.Second*2, time.Millisecond*100) + + req.Equal(round.Members, [][]byte{[]byte("hash")}) + // Wait for round to end <-time.After(roundEnd) @@ -148,8 +157,6 @@ func TestSubmitAndGetProof(t *testing.T) { }, time.Second, time.Millisecond*100) req.NotZero(proof.Proof.Leaves) - req.Len(proof.Proof.Members, 1) - req.Contains(proof.Proof.Members, []byte("hash")) cancel() merkleProof := shared.MerkleProof{ @@ -158,7 +165,7 @@ func TestSubmitAndGetProof(t *testing.T) { ProofNodes: proof.Proof.Proof.ProofNodes, } - root, err := prover.CalcTreeRoot(proof.Proof.Members) + root, err := prover.CalcTreeRoot(round.Members) req.NoError(err) labelHashFunc := hash.GenLabelHashFunc(root) diff --git a/service/db.go b/service/db.go index d27e1239..925a2bf4 100644 --- a/service/db.go +++ b/service/db.go @@ -14,52 +14,93 @@ import ( "github.com/spacemeshos/poet/shared" ) +type dataType byte + +const ( + typeProof dataType = iota + typeRound +) + var ErrNotFound = leveldb.ErrNotFound -type ProofsDatabase struct { +type ServiceDatabase struct { db *leveldb.DB proofs <-chan shared.ProofMessage + rounds <-chan RoundData +} + +func makeKey(t dataType, k []byte) []byte { + key := make([]byte, len(k)+1) + key = append(key, byte(t)) + return append(key, k...) } -func (db *ProofsDatabase) Get(ctx context.Context, roundID string) (*shared.ProofMessage, error) { - data, err := db.db.Get([]byte(roundID), nil) +func (db *ServiceDatabase) GetProof(ctx context.Context, roundID string) (*shared.ProofMessage, error) { + data, err := db.db.Get(makeKey(typeProof, []byte(roundID)), nil) if err != nil { - return nil, fmt.Errorf("get proof for %s from DB: %w", roundID, err) + return nil, fmt.Errorf("getting proof for round %s from DB: %w", roundID, err) } proof := &shared.ProofMessage{} if _, err := proof.DecodeScale(scale.NewDecoder(bytes.NewReader(data))); err != nil { - return nil, fmt.Errorf("failed to get deserialize proof: %w", err) + return nil, fmt.Errorf("deserializing proof for round %s: %w", roundID, err) } return proof, nil } -func NewProofsDatabase(dbPath string, proofs <-chan shared.ProofMessage) (*ProofsDatabase, error) { +func (db *ServiceDatabase) GetRoundMembers(ctx context.Context, roundID string) ([][]byte, error) { + data, err := db.db.Get(makeKey(typeRound, []byte(roundID)), nil) + if err != nil { + return nil, fmt.Errorf("getting members for round %s from DB: %w", roundID, err) + } + + if members, _, err := scale.DecodeSliceOfByteSlice(scale.NewDecoder(bytes.NewReader(data))); err != nil { + return nil, fmt.Errorf("deserializing round %s members: %w", roundID, err) + } else { + return members, nil + } +} + +func NewServiceDatabase( + dbPath string, + proofs <-chan shared.ProofMessage, + rounds <-chan RoundData, +) (*ServiceDatabase, error) { db, err := leveldb.OpenFile(dbPath, nil) if err != nil { - return nil, fmt.Errorf("failed to open database @ %s: %w", dbPath, err) + return nil, fmt.Errorf("opening database @ %s: %w", dbPath, err) } - return &ProofsDatabase{db, proofs}, nil + return &ServiceDatabase{db, proofs, rounds}, nil } -func (db *ProofsDatabase) Run(ctx context.Context) error { +func (db *ServiceDatabase) Run(ctx context.Context) error { logger := logging.FromContext(ctx).Named("proofs-db") for { select { case proof := <-db.proofs: serialized, err := serializeProofMsg(proof) if err != nil { - return fmt.Errorf("failed serializing proof: %w", err) + return fmt.Errorf("serializing proof: %w", err) } - if err := db.db.Put([]byte(proof.RoundID), serialized, &opt.WriteOptions{Sync: true}); err != nil { - logger.Error("failed storing proof in DB", zap.Error(err)) + if err := db.db.Put(makeKey(typeProof, []byte(proof.RoundID)), serialized, &opt.WriteOptions{Sync: true}); err != nil { + logger.Error("failed storing proof in DB", zap.String("round", proof.RoundID), zap.Error(err)) } else { - logger.Info("Proof saved in DB", + logger.Info("proof saved in DB", zap.String("round", proof.RoundID), - zap.Int("members", len(proof.Members)), zap.Uint64("leaves", proof.NumLeaves)) } + case round := <-db.rounds: + var dataBuf bytes.Buffer + if _, err := scale.EncodeSliceOfByteSlice(scale.NewEncoder(&dataBuf), round.Members); err != nil { + return fmt.Errorf("serializing proof: %w", err) + } + + if err := db.db.Put(makeKey(typeRound, []byte(round.ID)), dataBuf.Bytes(), &opt.WriteOptions{Sync: true}); err != nil { + logger.Error("failed storing round members in DB", zap.String("round", round.ID), zap.Error(err)) + } else { + logger.Info("round members saved in DB", zap.String("round", round.ID)) + } case <-ctx.Done(): logger.Info("shutting down proofs db") return db.db.Close() @@ -70,7 +111,7 @@ func (db *ProofsDatabase) Run(ctx context.Context) error { func serializeProofMsg(proof shared.ProofMessage) ([]byte, error) { var dataBuf bytes.Buffer if _, err := proof.EncodeScale(scale.NewEncoder(&dataBuf)); err != nil { - return nil, fmt.Errorf("failed to marshal proof message for round %v: %v", proof.RoundID, err) + return nil, fmt.Errorf("marshaling proof message for round %v: %v", proof.RoundID, err) } return dataBuf.Bytes(), nil diff --git a/service/db_test.go b/service/db_test.go new file mode 100644 index 00000000..0aa5c834 --- /dev/null +++ b/service/db_test.go @@ -0,0 +1,85 @@ +package service_test + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + "golang.org/x/sync/errgroup" + + "github.com/spacemeshos/poet/service" + "github.com/spacemeshos/poet/shared" +) + +func TestServiceDb_GetRoundMembers(t *testing.T) { + t.Parallel() + req := require.New(t) + rounds := make(chan service.RoundData, 1) + t.Cleanup(func() { close(rounds) }) + db, err := service.NewServiceDatabase(t.TempDir(), nil, rounds) + req.NoError(err) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + var eg errgroup.Group + eg.Go(func() error { return db.Run(ctx) }) + + _, err = db.GetRoundMembers(context.Background(), "") + req.ErrorIs(err, service.ErrNotFound) + + rounds <- service.RoundData{ + Members: [][]byte{{0, 1, 2}}, + } + + var members [][]byte + req.Eventually(func() bool { + members, err = db.GetRoundMembers(context.Background(), "") + return err == nil + }, time.Second, time.Millisecond*10) + req.Equal([][]byte{{0, 1, 2}}, members) + + _, err = db.GetProof(context.Background(), "") + req.ErrorIs(err, service.ErrNotFound) + + cancel() + req.NoError(eg.Wait()) +} + +func TestServiceDb_GetProof(t *testing.T) { + t.Parallel() + req := require.New(t) + proofs := make(chan shared.ProofMessage, 1) + t.Cleanup(func() { close(proofs) }) + db, err := service.NewServiceDatabase(t.TempDir(), proofs, nil) + req.NoError(err) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + var eg errgroup.Group + eg.Go(func() error { return db.Run(ctx) }) + + _, err = db.GetProof(context.Background(), "") + req.ErrorIs(err, service.ErrNotFound) + + proof := shared.ProofMessage{ + Proof: shared.Proof{ + NumLeaves: 123, + }, + ServicePubKey: []byte("service pub key"), + } + proofs <- proof + + var gotProof *shared.ProofMessage + req.Eventually(func() bool { + gotProof, err = db.GetProof(context.Background(), "") + return err == nil + }, time.Second, time.Millisecond*10) + req.Equal(proof, *gotProof) + + _, err = db.GetRoundMembers(context.Background(), "") + req.ErrorIs(err, service.ErrNotFound) + + cancel() + req.NoError(eg.Wait()) +} diff --git a/service/round.go b/service/round.go index 51090094..1f6cc150 100644 --- a/service/round.go +++ b/service/round.go @@ -230,12 +230,7 @@ func (r *round) saveState() error { }) } -func (r *round) calcMembersAndStatement() ([][]byte, []byte, error) { - mtree, err := merkle.NewTree() - if err != nil { - return nil, nil, fmt.Errorf("failed to initialize merkle tree: %v", err) - } - +func (r *round) Members() [][]byte { members := make([][]byte, 0) iter := r.challengesDb.NewIterator(nil, nil) defer iter.Release() @@ -243,9 +238,20 @@ func (r *round) calcMembersAndStatement() ([][]byte, []byte, error) { challenge := iter.Value() challengeCopy := make([]byte, len(challenge)) copy(challengeCopy, challenge) - members = append(members, challengeCopy) - if err := mtree.AddLeaf(challengeCopy); err != nil { + } + + return members +} + +func (r *round) calcMembersAndStatement() ([][]byte, []byte, error) { + mtree, err := merkle.NewTree() + if err != nil { + return nil, nil, fmt.Errorf("failed to initialize merkle tree: %v", err) + } + members := r.Members() + for _, challenge := range members { + if err := mtree.AddLeaf(challenge); err != nil { return nil, nil, err } } diff --git a/service/service.go b/service/service.go index 19aed6e8..8a79bcdc 100644 --- a/service/service.go +++ b/service/service.go @@ -25,6 +25,13 @@ import ( "github.com/spacemeshos/poet/shared" ) +type RoundData struct { + ID string + // Members is the ordered list of miners challenges which are included + // in the proof (by using the list hash digest as the proof generation input (the statement)). + Members [][]byte +} + type Config struct { Genesis string `long:"genesis-time" description:"Genesis timestamp"` EpochDuration time.Duration `long:"epoch-duration" description:"Epoch duration"` @@ -50,8 +57,12 @@ const ChallengeVerifierCacheSize = 1024 // It is stopped by canceling the context provided to `Service::Run`. // It mustn't be restarted. A new instance of `Service` must be created. type Service struct { - started atomic.Bool - proofs chan shared.ProofMessage + started atomic.Bool + // a proof is pushed into `proofs` channel when it's generated + proofs chan shared.ProofMessage + // a round's info is pushed into `rounds`` channel when it starts + rounds chan RoundData + // commands to execute on the actor's main goroutine are pushed into `commands` channel commands chan Command timer <-chan time.Time @@ -144,6 +155,7 @@ func NewService(ctx context.Context, cfg *Config, datadir string) (*Service, err s := &Service{ proofs: make(chan shared.ProofMessage, 1), + rounds: make(chan RoundData, 1), commands: cmds, cfg: cfg, minMemoryLayer: minMemoryLayer, @@ -168,6 +180,10 @@ func (s *Service) ProofsChan() <-chan shared.ProofMessage { return s.proofs } +func (s *Service) RoundsDataChan() <-chan RoundData { + return s.rounds +} + func (s *Service) loop(ctx context.Context, roundToResume *round) error { logger := logging.FromContext(ctx).Named("worker") ctx = logging.NewContext(ctx, logger) @@ -232,6 +248,16 @@ func (s *Service) loop(ctx context.Context, roundToResume *round) error { s.executingRounds[round.ID] = struct{}{} end := s.roundEndTime(round) + + select { + case s.rounds <- RoundData{ + ID: round.ID, + Members: round.Members(), + }: + default: + logger.Debug("could not push round data, the receiving end might've hang") + } + minMemoryLayer := s.minMemoryLayer eg.Go(func() error { unlock := lockOSThread(ctx, roundTidFile) @@ -487,7 +513,6 @@ func (s *Service) reportNewProof(round string, execution *executionState) { s.proofs <- shared.ProofMessage{ Proof: shared.Proof{ MerkleProof: *execution.NIP, - Members: execution.Members, NumLeaves: execution.NumLeaves, }, ServicePubKey: s.PubKey, diff --git a/service/service_test.go b/service/service_test.go index e23f2eed..9ed1bab4 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -12,7 +12,6 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" "golang.org/x/sync/errgroup" "github.com/spacemeshos/poet/gateway/challenge_verifier" @@ -41,6 +40,8 @@ func TestService_Recovery(t *testing.T) { challengeVerifier := mocks.NewMockVerifier(ctrl) tempdir := t.TempDir() + var rounds []service.RoundData + // Generate groups of random challenges. challengeGroupSize := 5 challengeGroups := make([][]challenge, 3) @@ -81,12 +82,15 @@ func TestService_Recovery(t *testing.T) { // Submit challenges to open round (0). submitChallenges("0", challengeGroups[0]) - // Wait for round 0 to start executing. - req.Eventually(func() bool { - info, err := s.Info(context.Background()) - req.NoError(err) - return slices.Contains(info.ExecutingRoundsIds, "0") - }, cfg.EpochDuration*2, time.Millisecond*100) + // Wait for round0 0 to start executing. + // Receive the next round when it is started + roundData := <-s.RoundsDataChan() + req.Equal("0", roundData.ID) + rounds = append(rounds, roundData) + + info, err := s.Info(context.Background()) + req.NoError(err) + req.Contains(info.ExecutingRoundsIds, "0") // Submit challenges to open round (1). submitChallenges("1", challengeGroups[1]) @@ -104,7 +108,7 @@ func TestService_Recovery(t *testing.T) { eg.Go(func() error { return s.Run(ctx) }) // Service instance should recover 2 rounds: round 0 in executing state, and round 1 in open state. - info, err := s.Info(context.Background()) + info, err = s.Info(context.Background()) req.NoError(err) req.Equal("1", info.OpenRoundID) req.Len(info.ExecutingRoundsIds, 1) @@ -112,25 +116,26 @@ func TestService_Recovery(t *testing.T) { req.Equal([]string{"0"}, info.ExecutingRoundsIds) req.NoError(s.Start(context.Background(), challengeVerifier)) - // Wait for round 2 to open - req.Eventually(func() bool { - info, err := s.Info(context.Background()) - req.NoError(err) - return info.OpenRoundID == "2" - }, cfg.EpochDuration*2, time.Millisecond*100) + + // Receive the next round when it is started + roundData = <-s.RoundsDataChan() + req.Equal("1", roundData.ID) + rounds = append(rounds, roundData) + + info, err = s.Info(context.Background()) + req.NoError(err) + req.Equal("2", info.OpenRoundID) submitChallenges("2", challengeGroups[2]) + roundData = <-s.RoundsDataChan() + req.Equal("2", roundData.ID) + rounds = append(rounds, roundData) for i := 0; i < len(challengeGroups); i++ { proof := <-s.ProofsChan() req.Equal(strconv.Itoa(i), proof.RoundID) - // Verify the submitted challenges. - req.Len(proof.Members, len(challengeGroups[i]), "round: %v i: %d", proof.RoundID, i) - for _, ch := range challengeGroups[i] { - req.Contains(proof.Members, ch.data, "round: %v, i: %d", proof.RoundID, i) - } - challenge, err := prover.CalcTreeRoot(proof.Members) + challenge, err := prover.CalcTreeRoot(rounds[i].Members) req.NoError(err) err = verifier.Validate( @@ -211,6 +216,15 @@ func TestNewService(t *testing.T) { return false }, cfg.EpochDuration*2, time.Millisecond*100) + // Receive the round data + round := <-s.RoundsDataChan() + req.Equal(currentRound, round.ID) + // Verify the submitted challenges. + req.Len(round.Members, len(challenges)) + for _, ch := range challenges { + req.Contains(round.Members, ch.data) + } + // Wait for end of execution. req.Eventually(func() bool { info, err := s.Info(context.Background()) @@ -224,15 +238,9 @@ func TestNewService(t *testing.T) { // Wait for proof message. proof := <-s.ProofsChan() - req.Equal(currentRound, proof.RoundID) - // Verify the submitted challenges. - req.Len(proof.Members, len(challenges)) - for _, ch := range challenges { - req.Contains(proof.Members, ch.data) - } - challenge, err := prover.CalcTreeRoot(proof.Members) + challenge, err := prover.CalcTreeRoot(round.Members) req.NoError(err) err = verifier.Validate( @@ -458,11 +466,8 @@ func TestService_Recovery_MissingOpenRound(t *testing.T) { req.NoError(s.Start(context.Background(), challengeVerifier)) // Wait for round 0 to start executing. - req.Eventually(func() bool { - info, err := s.Info(context.Background()) - req.NoError(err) - return slices.Contains(info.ExecutingRoundsIds, "0") - }, cfg.EpochDuration*2, time.Millisecond*100) + round := <-s.RoundsDataChan() + req.Equal("0", round.ID) cancel() req.NoError(eg.Wait()) @@ -529,11 +534,8 @@ func TestService_Recovery_Reset(t *testing.T) { req.NoError(s.Start(context.Background(), challengeVerifier)) // Wait for round 0 to start executing. - req.Eventually(func() bool { - info, err := s.Info(context.Background()) - req.NoError(err) - return slices.Contains(info.ExecutingRoundsIds, "0") - }, cfg.EpochDuration*2, time.Millisecond*100) + round := <-s.RoundsDataChan() + req.Equal("0", round.ID) cancel() req.NoError(eg.Wait()) diff --git a/shared/shared.go b/shared/shared.go index 35fa22ca..1b961454 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -76,13 +76,8 @@ func MakeLabelFunc() func(hash LabelHash, labelID uint64, leftSiblings [][]byte) } type Proof struct { - // The actual proof. + // The actual proof of sequential work. MerkleProof - - // Members is the ordered list of miners challenges which are included - // in the proof (by using the list hash digest as the proof generation input (the statement)). - Members [][]byte - // NumLeaves is the width of the proof-generation tree. NumLeaves uint64 } diff --git a/shared/shared_scale.go b/shared/shared_scale.go index 0b6fb1c7..ba70bfd8 100644 --- a/shared/shared_scale.go +++ b/shared/shared_scale.go @@ -120,13 +120,6 @@ func (t *Proof) EncodeScale(enc *scale.Encoder) (total int, err error) { } total += n } - { - n, err := scale.EncodeSliceOfByteSlice(enc, t.Members) - if err != nil { - return total, err - } - total += n - } { n, err := scale.EncodeCompact64(enc, uint64(t.NumLeaves)) if err != nil { @@ -145,14 +138,6 @@ func (t *Proof) DecodeScale(dec *scale.Decoder) (total int, err error) { } total += n } - { - field, n, err := scale.DecodeSliceOfByteSlice(dec) - if err != nil { - return total, err - } - total += n - t.Members = field - } { field, n, err := scale.DecodeCompact64(dec) if err != nil {