From 7256c5d3a4d32c07e59be7967f351f362192d306 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 29 May 2020 06:38:37 +0000 Subject: [PATCH] [libp2p/consensus] p2p spamming defense This is a big PR merged many small commits together. We add the message validation function in libp2p layer. In the validation function, we check the following conditions 1) the p2p message is a valid consensus message 2) the p2p message sender has a valid public key 3) the sender's public key is in the current committee 4) log the number of invalid/valid messages After the validation, the valid messages will be forward to the network, while the invalid messages will be filtered out. The messages intended for the validator will be handled in the consensus layer. Signed-off-by: Leo Chen --- api/client/service/proto/client.pb.go | 438 +++-- api/proto/common.go | 4 +- api/proto/message/message.pb.go | 1478 +++++++++++------ .../syncing/downloader/proto/downloader.pb.go | 491 ++++-- consensus/checks.go | 137 +- consensus/consensus.go | 3 - consensus/consensus_service.go | 44 - consensus/consensus_v2.go | 127 +- consensus/validator.go | 4 +- go.mod | 15 +- node/node.go | 395 ++++- node/node_explorer.go | 45 +- node/node_handler.go | 169 +- p2p/host.go | 121 +- test/deploy.sh | 2 +- 15 files changed, 2149 insertions(+), 1324 deletions(-) diff --git a/api/client/service/proto/client.pb.go b/api/client/service/proto/client.pb.go index 50b34330a0..c9e3ce5a79 100644 --- a/api/client/service/proto/client.pb.go +++ b/api/client/service/proto/client.pb.go @@ -1,230 +1,376 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0 +// protoc v3.6.1 // source: client.proto package client import ( context "context" - fmt "fmt" proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 // FetchAccountStateRequest is the request to fetch an account's balance and nonce. type FetchAccountStateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // The account address - Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } -func (m *FetchAccountStateRequest) Reset() { *m = FetchAccountStateRequest{} } -func (m *FetchAccountStateRequest) String() string { return proto.CompactTextString(m) } -func (*FetchAccountStateRequest) ProtoMessage() {} -func (*FetchAccountStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{0} +func (x *FetchAccountStateRequest) Reset() { + *x = FetchAccountStateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_client_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *FetchAccountStateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_FetchAccountStateRequest.Unmarshal(m, b) -} -func (m *FetchAccountStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_FetchAccountStateRequest.Marshal(b, m, deterministic) +func (x *FetchAccountStateRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *FetchAccountStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_FetchAccountStateRequest.Merge(m, src) -} -func (m *FetchAccountStateRequest) XXX_Size() int { - return xxx_messageInfo_FetchAccountStateRequest.Size(m) -} -func (m *FetchAccountStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_FetchAccountStateRequest.DiscardUnknown(m) + +func (*FetchAccountStateRequest) ProtoMessage() {} + +func (x *FetchAccountStateRequest) ProtoReflect() protoreflect.Message { + mi := &file_client_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) } -var xxx_messageInfo_FetchAccountStateRequest proto.InternalMessageInfo +// Deprecated: Use FetchAccountStateRequest.ProtoReflect.Descriptor instead. +func (*FetchAccountStateRequest) Descriptor() ([]byte, []int) { + return file_client_proto_rawDescGZIP(), []int{0} +} -func (m *FetchAccountStateRequest) GetAddress() []byte { - if m != nil { - return m.Address +func (x *FetchAccountStateRequest) GetAddress() []byte { + if x != nil { + return x.Address } return nil } // FetchAccountStateResponse is the response of FetchAccountStateRequest. type FetchAccountStateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // The balance of the account (big.Int) Balance []byte `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"` // The nonce of the account - Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` } -func (m *FetchAccountStateResponse) Reset() { *m = FetchAccountStateResponse{} } -func (m *FetchAccountStateResponse) String() string { return proto.CompactTextString(m) } -func (*FetchAccountStateResponse) ProtoMessage() {} -func (*FetchAccountStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{1} +func (x *FetchAccountStateResponse) Reset() { + *x = FetchAccountStateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_client_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *FetchAccountStateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_FetchAccountStateResponse.Unmarshal(m, b) -} -func (m *FetchAccountStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_FetchAccountStateResponse.Marshal(b, m, deterministic) -} -func (m *FetchAccountStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_FetchAccountStateResponse.Merge(m, src) -} -func (m *FetchAccountStateResponse) XXX_Size() int { - return xxx_messageInfo_FetchAccountStateResponse.Size(m) +func (x *FetchAccountStateResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *FetchAccountStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_FetchAccountStateResponse.DiscardUnknown(m) + +func (*FetchAccountStateResponse) ProtoMessage() {} + +func (x *FetchAccountStateResponse) ProtoReflect() protoreflect.Message { + mi := &file_client_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) } -var xxx_messageInfo_FetchAccountStateResponse proto.InternalMessageInfo +// Deprecated: Use FetchAccountStateResponse.ProtoReflect.Descriptor instead. +func (*FetchAccountStateResponse) Descriptor() ([]byte, []int) { + return file_client_proto_rawDescGZIP(), []int{1} +} -func (m *FetchAccountStateResponse) GetBalance() []byte { - if m != nil { - return m.Balance +func (x *FetchAccountStateResponse) GetBalance() []byte { + if x != nil { + return x.Balance } return nil } -func (m *FetchAccountStateResponse) GetNonce() uint64 { - if m != nil { - return m.Nonce +func (x *FetchAccountStateResponse) GetNonce() uint64 { + if x != nil { + return x.Nonce } return 0 } // GetFreeTokenRequest is the request to get free token from the faucet smart contract. type GetFreeTokenRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // The account address to receive the free token - Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } -func (m *GetFreeTokenRequest) Reset() { *m = GetFreeTokenRequest{} } -func (m *GetFreeTokenRequest) String() string { return proto.CompactTextString(m) } -func (*GetFreeTokenRequest) ProtoMessage() {} -func (*GetFreeTokenRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{2} +func (x *GetFreeTokenRequest) Reset() { + *x = GetFreeTokenRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_client_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetFreeTokenRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFreeTokenRequest.Unmarshal(m, b) -} -func (m *GetFreeTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFreeTokenRequest.Marshal(b, m, deterministic) -} -func (m *GetFreeTokenRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFreeTokenRequest.Merge(m, src) +func (x *GetFreeTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetFreeTokenRequest) XXX_Size() int { - return xxx_messageInfo_GetFreeTokenRequest.Size(m) -} -func (m *GetFreeTokenRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetFreeTokenRequest.DiscardUnknown(m) + +func (*GetFreeTokenRequest) ProtoMessage() {} + +func (x *GetFreeTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_client_proto_msgTypes[2] + 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) } -var xxx_messageInfo_GetFreeTokenRequest proto.InternalMessageInfo +// Deprecated: Use GetFreeTokenRequest.ProtoReflect.Descriptor instead. +func (*GetFreeTokenRequest) Descriptor() ([]byte, []int) { + return file_client_proto_rawDescGZIP(), []int{2} +} -func (m *GetFreeTokenRequest) GetAddress() []byte { - if m != nil { - return m.Address +func (x *GetFreeTokenRequest) GetAddress() []byte { + if x != nil { + return x.Address } return nil } // GetFreeTokenResponse is the response of GetFreeTokenRequest. type GetFreeTokenResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // The transaction Id that requests free token from the faucet. - TxId []byte `protobuf:"bytes,1,opt,name=txId,proto3" json:"txId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + TxId []byte `protobuf:"bytes,1,opt,name=txId,proto3" json:"txId,omitempty"` } -func (m *GetFreeTokenResponse) Reset() { *m = GetFreeTokenResponse{} } -func (m *GetFreeTokenResponse) String() string { return proto.CompactTextString(m) } -func (*GetFreeTokenResponse) ProtoMessage() {} -func (*GetFreeTokenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{3} +func (x *GetFreeTokenResponse) Reset() { + *x = GetFreeTokenResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_client_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetFreeTokenResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFreeTokenResponse.Unmarshal(m, b) -} -func (m *GetFreeTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFreeTokenResponse.Marshal(b, m, deterministic) -} -func (m *GetFreeTokenResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFreeTokenResponse.Merge(m, src) -} -func (m *GetFreeTokenResponse) XXX_Size() int { - return xxx_messageInfo_GetFreeTokenResponse.Size(m) -} -func (m *GetFreeTokenResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetFreeTokenResponse.DiscardUnknown(m) +func (x *GetFreeTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_GetFreeTokenResponse proto.InternalMessageInfo +func (*GetFreeTokenResponse) ProtoMessage() {} -func (m *GetFreeTokenResponse) GetTxId() []byte { - if m != nil { - return m.TxId +func (x *GetFreeTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_client_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return nil + return mi.MessageOf(x) } -func init() { - proto.RegisterType((*FetchAccountStateRequest)(nil), "client.FetchAccountStateRequest") - proto.RegisterType((*FetchAccountStateResponse)(nil), "client.FetchAccountStateResponse") - proto.RegisterType((*GetFreeTokenRequest)(nil), "client.GetFreeTokenRequest") - proto.RegisterType((*GetFreeTokenResponse)(nil), "client.GetFreeTokenResponse") +// Deprecated: Use GetFreeTokenResponse.ProtoReflect.Descriptor instead. +func (*GetFreeTokenResponse) Descriptor() ([]byte, []int) { + return file_client_proto_rawDescGZIP(), []int{3} } -func init() { - proto.RegisterFile("client.proto", fileDescriptor_014de31d7ac8c57c) +func (x *GetFreeTokenResponse) GetTxId() []byte { + if x != nil { + return x.TxId + } + return nil } -var fileDescriptor_014de31d7ac8c57c = []byte{ - // 229 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x83, 0xf0, 0x94, 0x4c, 0xb8, 0x24, - 0xdc, 0x52, 0x4b, 0x92, 0x33, 0x1c, 0x93, 0x93, 0xf3, 0x4b, 0xf3, 0x4a, 0x82, 0x4b, 0x12, 0x4b, - 0x52, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0x24, 0xb8, 0xd8, 0x13, 0x53, 0x52, 0x8a, - 0x52, 0x8b, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x60, 0x5c, 0x25, 0x6f, 0x2e, 0x49, - 0x2c, 0xba, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x41, 0xda, 0x92, 0x12, 0x73, 0x12, 0xf3, 0x92, - 0x53, 0x61, 0xda, 0xa0, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0x7c, 0x90, 0x38, 0x93, 0x02, 0xa3, - 0x06, 0x4b, 0x10, 0x84, 0xa3, 0xa4, 0xcf, 0x25, 0xec, 0x9e, 0x5a, 0xe2, 0x56, 0x94, 0x9a, 0x1a, - 0x92, 0x9f, 0x9d, 0x9a, 0x47, 0xd8, 0x76, 0x2d, 0x2e, 0x11, 0x54, 0x0d, 0x50, 0x8b, 0x85, 0xb8, - 0x58, 0x4a, 0x2a, 0x3c, 0x53, 0xa0, 0xca, 0xc1, 0x6c, 0xa3, 0x1d, 0x8c, 0x5c, 0xbc, 0xce, 0x60, - 0xaf, 0x06, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x0a, 0x45, 0x71, 0x09, 0x62, 0xb8, 0x5d, 0x48, - 0x41, 0x0f, 0x1a, 0x3a, 0xb8, 0x02, 0x43, 0x4a, 0x11, 0x8f, 0x0a, 0x88, 0xfd, 0x4a, 0x0c, 0x42, - 0xde, 0x5c, 0x3c, 0xc8, 0x2e, 0x13, 0x92, 0x86, 0x69, 0xc2, 0xe2, 0x41, 0x29, 0x19, 0xec, 0x92, - 0x30, 0xc3, 0x92, 0xd8, 0xc0, 0x31, 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc6, 0xd9, 0x35, - 0x0c, 0xb9, 0x01, 0x00, 0x00, +var File_client_proto protoreflect.FileDescriptor + +var file_client_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x22, 0x34, 0x0a, 0x18, 0x46, 0x65, 0x74, 0x63, 0x68, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x4b, 0x0a, 0x19, + 0x46, 0x65, 0x74, 0x63, 0x68, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, + 0x6e, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x22, 0x2f, 0x0a, 0x13, 0x47, 0x65, 0x74, + 0x46, 0x72, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x2a, 0x0a, 0x14, 0x47, 0x65, + 0x74, 0x46, 0x72, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x74, 0x78, 0x49, 0x64, 0x32, 0xb8, 0x01, 0x0a, 0x0d, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x11, 0x46, 0x65, 0x74, 0x63, + 0x68, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x20, 0x2e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x21, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x46, 0x72, 0x65, 0x65, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1b, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, + 0x74, 0x46, 0x72, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1c, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x72, + 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_client_proto_rawDescOnce sync.Once + file_client_proto_rawDescData = file_client_proto_rawDesc +) + +func file_client_proto_rawDescGZIP() []byte { + file_client_proto_rawDescOnce.Do(func() { + file_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_proto_rawDescData) + }) + return file_client_proto_rawDescData +} + +var file_client_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_client_proto_goTypes = []interface{}{ + (*FetchAccountStateRequest)(nil), // 0: client.FetchAccountStateRequest + (*FetchAccountStateResponse)(nil), // 1: client.FetchAccountStateResponse + (*GetFreeTokenRequest)(nil), // 2: client.GetFreeTokenRequest + (*GetFreeTokenResponse)(nil), // 3: client.GetFreeTokenResponse +} +var file_client_proto_depIdxs = []int32{ + 0, // 0: client.ClientService.FetchAccountState:input_type -> client.FetchAccountStateRequest + 2, // 1: client.ClientService.GetFreeToken:input_type -> client.GetFreeTokenRequest + 1, // 2: client.ClientService.FetchAccountState:output_type -> client.FetchAccountStateResponse + 3, // 3: client.ClientService.GetFreeToken:output_type -> client.GetFreeTokenResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] 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_client_proto_init() } +func file_client_proto_init() { + if File_client_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FetchAccountStateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_client_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FetchAccountStateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_client_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetFreeTokenRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_client_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetFreeTokenResponse); 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_client_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_client_proto_goTypes, + DependencyIndexes: file_client_proto_depIdxs, + MessageInfos: file_client_proto_msgTypes, + }.Build() + File_client_proto = out.File + file_client_proto_rawDesc = nil + file_client_proto_goTypes = nil + file_client_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -279,10 +425,10 @@ type ClientServiceServer interface { type UnimplementedClientServiceServer struct { } -func (*UnimplementedClientServiceServer) FetchAccountState(ctx context.Context, req *FetchAccountStateRequest) (*FetchAccountStateResponse, error) { +func (*UnimplementedClientServiceServer) FetchAccountState(context.Context, *FetchAccountStateRequest) (*FetchAccountStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FetchAccountState not implemented") } -func (*UnimplementedClientServiceServer) GetFreeToken(ctx context.Context, req *GetFreeTokenRequest) (*GetFreeTokenResponse, error) { +func (*UnimplementedClientServiceServer) GetFreeToken(context.Context, *GetFreeTokenRequest) (*GetFreeTokenResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetFreeToken not implemented") } diff --git a/api/proto/common.go b/api/proto/common.go index a0651a5c50..6c60466e21 100644 --- a/api/proto/common.go +++ b/api/proto/common.go @@ -29,8 +29,8 @@ type MessageCategory byte const ( Consensus MessageCategory = iota Node - Client - DRand + Client // deprecated + DRand // not used ) const ( diff --git a/api/proto/message/message.pb.go b/api/proto/message/message.pb.go index a3bcb80a0f..4e01f75b99 100644 --- a/api/proto/message/message.pb.go +++ b/api/proto/message/message.pb.go @@ -1,66 +1,95 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0 +// protoc v3.6.1 // source: message.proto package message import ( context "context" - fmt "fmt" proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 // ServiceType indicates which service used to generate this message. type ServiceType int32 const ( - ServiceType_CONSENSUS ServiceType = 0 - ServiceType_STAKING ServiceType = 1 // Deprecated: Do not use. - ServiceType_DRAND ServiceType = 2 // Deprecated: Do not use. + ServiceType_CONSENSUS ServiceType = 0 + // Deprecated: Do not use. + ServiceType_STAKING ServiceType = 1 + // Deprecated: Do not use. + ServiceType_DRAND ServiceType = 2 ServiceType_CLIENT_SUPPORT ServiceType = 3 ) -var ServiceType_name = map[int32]string{ - 0: "CONSENSUS", - 1: "STAKING", - 2: "DRAND", - 3: "CLIENT_SUPPORT", -} +// Enum value maps for ServiceType. +var ( + ServiceType_name = map[int32]string{ + 0: "CONSENSUS", + 1: "STAKING", + 2: "DRAND", + 3: "CLIENT_SUPPORT", + } + ServiceType_value = map[string]int32{ + "CONSENSUS": 0, + "STAKING": 1, + "DRAND": 2, + "CLIENT_SUPPORT": 3, + } +) -var ServiceType_value = map[string]int32{ - "CONSENSUS": 0, - "STAKING": 1, - "DRAND": 2, - "CLIENT_SUPPORT": 3, +func (x ServiceType) Enum() *ServiceType { + p := new(ServiceType) + *p = x + return p } func (x ServiceType) String() string { - return proto.EnumName(ServiceType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } +func (ServiceType) Descriptor() protoreflect.EnumDescriptor { + return file_message_proto_enumTypes[0].Descriptor() +} + +func (ServiceType) Type() protoreflect.EnumType { + return &file_message_proto_enumTypes[0] +} + +func (x ServiceType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ServiceType.Descriptor instead. func (ServiceType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0} + return file_message_proto_rawDescGZIP(), []int{0} } // MessageType indicates what is the type of this message. type MessageType int32 const ( - MessageType_NEWNODE_BEACON_STAKING MessageType = 0 // Deprecated: Do not use. + // Deprecated: Do not use. + MessageType_NEWNODE_BEACON_STAKING MessageType = 0 MessageType_ANNOUNCE MessageType = 1 MessageType_PREPARE MessageType = 2 MessageType_PREPARED MessageType = 3 @@ -68,73 +97,121 @@ const ( MessageType_COMMITTED MessageType = 5 MessageType_VIEWCHANGE MessageType = 6 MessageType_NEWVIEW MessageType = 7 - MessageType_DRAND_INIT MessageType = 10 // Deprecated: Do not use. - MessageType_DRAND_COMMIT MessageType = 11 // Deprecated: Do not use. - MessageType_LOTTERY_REQUEST MessageType = 12 // Deprecated: Do not use. + // Deprecated: Do not use. + MessageType_DRAND_INIT MessageType = 10 + // Deprecated: Do not use. + MessageType_DRAND_COMMIT MessageType = 11 + // Deprecated: Do not use. + MessageType_LOTTERY_REQUEST MessageType = 12 // it should be either ENTER or GETPLAYERS but it will be removed later. +) + +// Enum value maps for MessageType. +var ( + MessageType_name = map[int32]string{ + 0: "NEWNODE_BEACON_STAKING", + 1: "ANNOUNCE", + 2: "PREPARE", + 3: "PREPARED", + 4: "COMMIT", + 5: "COMMITTED", + 6: "VIEWCHANGE", + 7: "NEWVIEW", + 10: "DRAND_INIT", + 11: "DRAND_COMMIT", + 12: "LOTTERY_REQUEST", + } + MessageType_value = map[string]int32{ + "NEWNODE_BEACON_STAKING": 0, + "ANNOUNCE": 1, + "PREPARE": 2, + "PREPARED": 3, + "COMMIT": 4, + "COMMITTED": 5, + "VIEWCHANGE": 6, + "NEWVIEW": 7, + "DRAND_INIT": 10, + "DRAND_COMMIT": 11, + "LOTTERY_REQUEST": 12, + } ) -var MessageType_name = map[int32]string{ - 0: "NEWNODE_BEACON_STAKING", - 1: "ANNOUNCE", - 2: "PREPARE", - 3: "PREPARED", - 4: "COMMIT", - 5: "COMMITTED", - 6: "VIEWCHANGE", - 7: "NEWVIEW", - 10: "DRAND_INIT", - 11: "DRAND_COMMIT", - 12: "LOTTERY_REQUEST", -} - -var MessageType_value = map[string]int32{ - "NEWNODE_BEACON_STAKING": 0, - "ANNOUNCE": 1, - "PREPARE": 2, - "PREPARED": 3, - "COMMIT": 4, - "COMMITTED": 5, - "VIEWCHANGE": 6, - "NEWVIEW": 7, - "DRAND_INIT": 10, - "DRAND_COMMIT": 11, - "LOTTERY_REQUEST": 12, +func (x MessageType) Enum() *MessageType { + p := new(MessageType) + *p = x + return p } func (x MessageType) String() string { - return proto.EnumName(MessageType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (MessageType) Descriptor() protoreflect.EnumDescriptor { + return file_message_proto_enumTypes[1].Descriptor() +} + +func (MessageType) Type() protoreflect.EnumType { + return &file_message_proto_enumTypes[1] +} + +func (x MessageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } +// Deprecated: Use MessageType.Descriptor instead. func (MessageType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{1} + return file_message_proto_rawDescGZIP(), []int{1} } type LotteryRequest_Type int32 const ( - LotteryRequest_ENTER LotteryRequest_Type = 0 // Deprecated: Do not use. - LotteryRequest_RESULT LotteryRequest_Type = 1 // Deprecated: Do not use. - LotteryRequest_PICK_WINNER LotteryRequest_Type = 2 // Deprecated: Do not use. + // Deprecated: Do not use. + LotteryRequest_ENTER LotteryRequest_Type = 0 + // Deprecated: Do not use. + LotteryRequest_RESULT LotteryRequest_Type = 1 + // Deprecated: Do not use. + LotteryRequest_PICK_WINNER LotteryRequest_Type = 2 ) -var LotteryRequest_Type_name = map[int32]string{ - 0: "ENTER", - 1: "RESULT", - 2: "PICK_WINNER", -} +// Enum value maps for LotteryRequest_Type. +var ( + LotteryRequest_Type_name = map[int32]string{ + 0: "ENTER", + 1: "RESULT", + 2: "PICK_WINNER", + } + LotteryRequest_Type_value = map[string]int32{ + "ENTER": 0, + "RESULT": 1, + "PICK_WINNER": 2, + } +) -var LotteryRequest_Type_value = map[string]int32{ - "ENTER": 0, - "RESULT": 1, - "PICK_WINNER": 2, +func (x LotteryRequest_Type) Enum() *LotteryRequest_Type { + p := new(LotteryRequest_Type) + *p = x + return p } func (x LotteryRequest_Type) String() string { - return proto.EnumName(LotteryRequest_Type_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (LotteryRequest_Type) Descriptor() protoreflect.EnumDescriptor { + return file_message_proto_enumTypes[2].Descriptor() +} + +func (LotteryRequest_Type) Type() protoreflect.EnumType { + return &file_message_proto_enumTypes[2] } +func (x LotteryRequest_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use LotteryRequest_Type.Descriptor instead. func (LotteryRequest_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{3, 0} + return file_message_proto_rawDescGZIP(), []int{3, 0} } // This is universal message for all communication protocols. @@ -143,63 +220,116 @@ func (LotteryRequest_Type) EnumDescriptor() ([]byte, []int) { // // The request field will be either one of the structure corresponding to the MessageType type. type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + ServiceType ServiceType `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=message.ServiceType" json:"service_type,omitempty"` Type MessageType `protobuf:"varint,2,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"` Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` - // Types that are valid to be assigned to Request: + // Types that are assignable to Request: // *Message_Staking // *Message_Consensus // *Message_Drand // *Message_Viewchange // *Message_LotteryRequest - Request isMessage_Request `protobuf_oneof:"request"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Request isMessage_Request `protobuf_oneof:"request"` } -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0} +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Message) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Message.Unmarshal(m, b) +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_message_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) } -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{0} } -func (m *Message) XXX_Size() int { - return xxx_messageInfo_Message.Size(m) + +func (x *Message) GetServiceType() ServiceType { + if x != nil { + return x.ServiceType + } + return ServiceType_CONSENSUS } -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) + +func (x *Message) GetType() MessageType { + if x != nil { + return x.Type + } + return MessageType_NEWNODE_BEACON_STAKING } -var xxx_messageInfo_Message proto.InternalMessageInfo +func (x *Message) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} -func (m *Message) GetServiceType() ServiceType { +func (m *Message) GetRequest() isMessage_Request { if m != nil { - return m.ServiceType + return m.Request } - return ServiceType_CONSENSUS + return nil } -func (m *Message) GetType() MessageType { - if m != nil { - return m.Type +// Deprecated: Do not use. +func (x *Message) GetStaking() *StakingRequest { + if x, ok := x.GetRequest().(*Message_Staking); ok { + return x.Staking } - return MessageType_NEWNODE_BEACON_STAKING + return nil } -func (m *Message) GetSignature() []byte { - if m != nil { - return m.Signature +func (x *Message) GetConsensus() *ConsensusRequest { + if x, ok := x.GetRequest().(*Message_Consensus); ok { + return x.Consensus + } + return nil +} + +// Deprecated: Do not use. +func (x *Message) GetDrand() *DrandRequest { + if x, ok := x.GetRequest().(*Message_Drand); ok { + return x.Drand + } + return nil +} + +func (x *Message) GetViewchange() *ViewChangeRequest { + if x, ok := x.GetRequest().(*Message_Viewchange); ok { + return x.Viewchange + } + return nil +} + +// Deprecated: Do not use. +func (x *Message) GetLotteryRequest() *LotteryRequest { + if x, ok := x.GetRequest().(*Message_LotteryRequest); ok { + return x.LotteryRequest } return nil } @@ -209,6 +339,7 @@ type isMessage_Request interface { } type Message_Staking struct { + // Deprecated: Do not use. Staking *StakingRequest `protobuf:"bytes,4,opt,name=staking,proto3,oneof"` } @@ -217,6 +348,7 @@ type Message_Consensus struct { } type Message_Drand struct { + // Deprecated: Do not use. Drand *DrandRequest `protobuf:"bytes,6,opt,name=drand,proto3,oneof"` } @@ -225,6 +357,9 @@ type Message_Viewchange struct { } type Message_LotteryRequest struct { + // Refactor this later after demo. + // + // Deprecated: Do not use. LotteryRequest *LotteryRequest `protobuf:"bytes,8,opt,name=lottery_request,json=lotteryRequest,proto3,oneof"` } @@ -238,122 +373,64 @@ func (*Message_Viewchange) isMessage_Request() {} func (*Message_LotteryRequest) isMessage_Request() {} -func (m *Message) GetRequest() isMessage_Request { - if m != nil { - return m.Request - } - return nil -} - -// Deprecated: Do not use. -func (m *Message) GetStaking() *StakingRequest { - if x, ok := m.GetRequest().(*Message_Staking); ok { - return x.Staking - } - return nil -} +type Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Message) GetConsensus() *ConsensusRequest { - if x, ok := m.GetRequest().(*Message_Consensus); ok { - return x.Consensus - } - return nil + ServiceType ServiceType `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=message.ServiceType" json:"service_type,omitempty"` + Type MessageType `protobuf:"varint,2,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"` + // Types that are assignable to Response: + // *Response_LotteryResponse + Response isResponse_Response `protobuf_oneof:"response"` } -// Deprecated: Do not use. -func (m *Message) GetDrand() *DrandRequest { - if x, ok := m.GetRequest().(*Message_Drand); ok { - return x.Drand +func (x *Response) Reset() { + *x = Response{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -func (m *Message) GetViewchange() *ViewChangeRequest { - if x, ok := m.GetRequest().(*Message_Viewchange); ok { - return x.Viewchange - } - return nil +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) } -// Deprecated: Do not use. -func (m *Message) GetLotteryRequest() *LotteryRequest { - if x, ok := m.GetRequest().(*Message_LotteryRequest); ok { - return x.LotteryRequest - } - return nil -} +func (*Response) ProtoMessage() {} -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Message) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Message_Staking)(nil), - (*Message_Consensus)(nil), - (*Message_Drand)(nil), - (*Message_Viewchange)(nil), - (*Message_LotteryRequest)(nil), +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_message_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) } -type Response struct { - ServiceType ServiceType `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=message.ServiceType" json:"service_type,omitempty"` - Type MessageType `protobuf:"varint,2,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"` - // Types that are valid to be assigned to Response: - // *Response_LotteryResponse - Response isResponse_Response `protobuf_oneof:"response"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} +// Deprecated: Use Response.ProtoReflect.Descriptor instead. func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{1} + return file_message_proto_rawDescGZIP(), []int{1} } -func (m *Response) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Response.Unmarshal(m, b) -} -func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Response.Marshal(b, m, deterministic) -} -func (m *Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Response.Merge(m, src) -} -func (m *Response) XXX_Size() int { - return xxx_messageInfo_Response.Size(m) -} -func (m *Response) XXX_DiscardUnknown() { - xxx_messageInfo_Response.DiscardUnknown(m) -} - -var xxx_messageInfo_Response proto.InternalMessageInfo - -func (m *Response) GetServiceType() ServiceType { - if m != nil { - return m.ServiceType +func (x *Response) GetServiceType() ServiceType { + if x != nil { + return x.ServiceType } return ServiceType_CONSENSUS } -func (m *Response) GetType() MessageType { - if m != nil { - return m.Type +func (x *Response) GetType() MessageType { + if x != nil { + return x.Type } return MessageType_NEWNODE_BEACON_STAKING } -type isResponse_Response interface { - isResponse_Response() -} - -type Response_LotteryResponse struct { - LotteryResponse *LotteryResponse `protobuf:"bytes,3,opt,name=lottery_response,json=lotteryResponse,proto3,oneof"` -} - -func (*Response_LotteryResponse) isResponse_Response() {} - func (m *Response) GetResponse() isResponse_Response { if m != nil { return m.Response @@ -362,552 +439,855 @@ func (m *Response) GetResponse() isResponse_Response { } // Deprecated: Do not use. -func (m *Response) GetLotteryResponse() *LotteryResponse { - if x, ok := m.GetResponse().(*Response_LotteryResponse); ok { +func (x *Response) GetLotteryResponse() *LotteryResponse { + if x, ok := x.GetResponse().(*Response_LotteryResponse); ok { return x.LotteryResponse } return nil } -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Response) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Response_LotteryResponse)(nil), - } +type isResponse_Response interface { + isResponse_Response() } -type LotteryResponse struct { - Players []string `protobuf:"bytes,2,rep,name=players,proto3" json:"players,omitempty"` // Deprecated: Do not use. - Balances []string `protobuf:"bytes,3,rep,name=balances,proto3" json:"balances,omitempty"` // Deprecated: Do not use. - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type Response_LotteryResponse struct { + // Deprecated: Do not use. + LotteryResponse *LotteryResponse `protobuf:"bytes,3,opt,name=lottery_response,json=lotteryResponse,proto3,oneof"` } -func (m *LotteryResponse) Reset() { *m = LotteryResponse{} } -func (m *LotteryResponse) String() string { return proto.CompactTextString(m) } -func (*LotteryResponse) ProtoMessage() {} -func (*LotteryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{2} -} +func (*Response_LotteryResponse) isResponse_Response() {} -func (m *LotteryResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LotteryResponse.Unmarshal(m, b) -} -func (m *LotteryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LotteryResponse.Marshal(b, m, deterministic) -} -func (m *LotteryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_LotteryResponse.Merge(m, src) +type LotteryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Deprecated: Do not use. + Players []string `protobuf:"bytes,2,rep,name=players,proto3" json:"players,omitempty"` + // Deprecated: Do not use. + Balances []string `protobuf:"bytes,3,rep,name=balances,proto3" json:"balances,omitempty"` +} + +func (x *LotteryResponse) Reset() { + *x = LotteryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *LotteryResponse) XXX_Size() int { - return xxx_messageInfo_LotteryResponse.Size(m) + +func (x *LotteryResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *LotteryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_LotteryResponse.DiscardUnknown(m) + +func (*LotteryResponse) ProtoMessage() {} + +func (x *LotteryResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[2] + 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) } -var xxx_messageInfo_LotteryResponse proto.InternalMessageInfo +// Deprecated: Use LotteryResponse.ProtoReflect.Descriptor instead. +func (*LotteryResponse) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{2} +} // Deprecated: Do not use. -func (m *LotteryResponse) GetPlayers() []string { - if m != nil { - return m.Players +func (x *LotteryResponse) GetPlayers() []string { + if x != nil { + return x.Players } return nil } // Deprecated: Do not use. -func (m *LotteryResponse) GetBalances() []string { - if m != nil { - return m.Balances +func (x *LotteryResponse) GetBalances() []string { + if x != nil { + return x.Balances } return nil } type LotteryRequest struct { - Type LotteryRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=message.LotteryRequest_Type" json:"type,omitempty"` // Deprecated: Do not use. - PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` // Deprecated: Do not use. - Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` // Deprecated: Do not use. - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Deprecated: Do not use. + Type LotteryRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=message.LotteryRequest_Type" json:"type,omitempty"` + // Deprecated: Do not use. + PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + // Deprecated: Do not use. + Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *LotteryRequest) Reset() { + *x = LotteryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *LotteryRequest) Reset() { *m = LotteryRequest{} } -func (m *LotteryRequest) String() string { return proto.CompactTextString(m) } -func (*LotteryRequest) ProtoMessage() {} -func (*LotteryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{3} +func (x *LotteryRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *LotteryRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LotteryRequest.Unmarshal(m, b) -} -func (m *LotteryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LotteryRequest.Marshal(b, m, deterministic) -} -func (m *LotteryRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_LotteryRequest.Merge(m, src) -} -func (m *LotteryRequest) XXX_Size() int { - return xxx_messageInfo_LotteryRequest.Size(m) -} -func (m *LotteryRequest) XXX_DiscardUnknown() { - xxx_messageInfo_LotteryRequest.DiscardUnknown(m) +func (*LotteryRequest) ProtoMessage() {} + +func (x *LotteryRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[3] + 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) } -var xxx_messageInfo_LotteryRequest proto.InternalMessageInfo +// Deprecated: Use LotteryRequest.ProtoReflect.Descriptor instead. +func (*LotteryRequest) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{3} +} // Deprecated: Do not use. -func (m *LotteryRequest) GetType() LotteryRequest_Type { - if m != nil { - return m.Type +func (x *LotteryRequest) GetType() LotteryRequest_Type { + if x != nil { + return x.Type } return LotteryRequest_ENTER } // Deprecated: Do not use. -func (m *LotteryRequest) GetPrivateKey() string { - if m != nil { - return m.PrivateKey +func (x *LotteryRequest) GetPrivateKey() string { + if x != nil { + return x.PrivateKey } return "" } // Deprecated: Do not use. -func (m *LotteryRequest) GetAmount() int64 { - if m != nil { - return m.Amount +func (x *LotteryRequest) GetAmount() int64 { + if x != nil { + return x.Amount } return 0 } // Staking Request from new node to beacon node. type StakingRequest struct { - Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` // Deprecated: Do not use. - NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` // Deprecated: Do not use. - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Deprecated: Do not use. + Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` + // Deprecated: Do not use. + NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *StakingRequest) Reset() { + *x = StakingRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *StakingRequest) Reset() { *m = StakingRequest{} } -func (m *StakingRequest) String() string { return proto.CompactTextString(m) } -func (*StakingRequest) ProtoMessage() {} -func (*StakingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{4} +func (x *StakingRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *StakingRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StakingRequest.Unmarshal(m, b) -} -func (m *StakingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StakingRequest.Marshal(b, m, deterministic) -} -func (m *StakingRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakingRequest.Merge(m, src) -} -func (m *StakingRequest) XXX_Size() int { - return xxx_messageInfo_StakingRequest.Size(m) -} -func (m *StakingRequest) XXX_DiscardUnknown() { - xxx_messageInfo_StakingRequest.DiscardUnknown(m) +func (*StakingRequest) ProtoMessage() {} + +func (x *StakingRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[4] + 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) } -var xxx_messageInfo_StakingRequest proto.InternalMessageInfo +// Deprecated: Use StakingRequest.ProtoReflect.Descriptor instead. +func (*StakingRequest) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{4} +} // Deprecated: Do not use. -func (m *StakingRequest) GetTransaction() []byte { - if m != nil { - return m.Transaction +func (x *StakingRequest) GetTransaction() []byte { + if x != nil { + return x.Transaction } return nil } // Deprecated: Do not use. -func (m *StakingRequest) GetNodeId() string { - if m != nil { - return m.NodeId +func (x *StakingRequest) GetNodeId() string { + if x != nil { + return x.NodeId } return "" } type ConsensusRequest struct { - ViewId uint64 `protobuf:"varint,1,opt,name=view_id,json=viewId,proto3" json:"view_id,omitempty"` - BlockNum uint64 `protobuf:"varint,2,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` - ShardId uint32 `protobuf:"varint,3,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` - BlockHash []byte `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` - Block []byte `protobuf:"bytes,5,opt,name=block,proto3" json:"block,omitempty"` - SenderPubkey []byte `protobuf:"bytes,6,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` - Payload []byte `protobuf:"bytes,7,opt,name=payload,proto3" json:"payload,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ConsensusRequest) Reset() { *m = ConsensusRequest{} } -func (m *ConsensusRequest) String() string { return proto.CompactTextString(m) } -func (*ConsensusRequest) ProtoMessage() {} -func (*ConsensusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{5} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ViewId uint64 `protobuf:"varint,1,opt,name=view_id,json=viewId,proto3" json:"view_id,omitempty"` + BlockNum uint64 `protobuf:"varint,2,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` + ShardId uint32 `protobuf:"varint,3,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` + BlockHash []byte `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + Block []byte `protobuf:"bytes,5,opt,name=block,proto3" json:"block,omitempty"` + SenderPubkey []byte `protobuf:"bytes,6,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` + Payload []byte `protobuf:"bytes,7,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *ConsensusRequest) Reset() { + *x = ConsensusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ConsensusRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ConsensusRequest.Unmarshal(m, b) -} -func (m *ConsensusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ConsensusRequest.Marshal(b, m, deterministic) -} -func (m *ConsensusRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConsensusRequest.Merge(m, src) -} -func (m *ConsensusRequest) XXX_Size() int { - return xxx_messageInfo_ConsensusRequest.Size(m) +func (x *ConsensusRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ConsensusRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ConsensusRequest.DiscardUnknown(m) + +func (*ConsensusRequest) ProtoMessage() {} + +func (x *ConsensusRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[5] + 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) } -var xxx_messageInfo_ConsensusRequest proto.InternalMessageInfo +// Deprecated: Use ConsensusRequest.ProtoReflect.Descriptor instead. +func (*ConsensusRequest) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{5} +} -func (m *ConsensusRequest) GetViewId() uint64 { - if m != nil { - return m.ViewId +func (x *ConsensusRequest) GetViewId() uint64 { + if x != nil { + return x.ViewId } return 0 } -func (m *ConsensusRequest) GetBlockNum() uint64 { - if m != nil { - return m.BlockNum +func (x *ConsensusRequest) GetBlockNum() uint64 { + if x != nil { + return x.BlockNum } return 0 } -func (m *ConsensusRequest) GetShardId() uint32 { - if m != nil { - return m.ShardId +func (x *ConsensusRequest) GetShardId() uint32 { + if x != nil { + return x.ShardId } return 0 } -func (m *ConsensusRequest) GetBlockHash() []byte { - if m != nil { - return m.BlockHash +func (x *ConsensusRequest) GetBlockHash() []byte { + if x != nil { + return x.BlockHash } return nil } -func (m *ConsensusRequest) GetBlock() []byte { - if m != nil { - return m.Block +func (x *ConsensusRequest) GetBlock() []byte { + if x != nil { + return x.Block } return nil } -func (m *ConsensusRequest) GetSenderPubkey() []byte { - if m != nil { - return m.SenderPubkey +func (x *ConsensusRequest) GetSenderPubkey() []byte { + if x != nil { + return x.SenderPubkey } return nil } -func (m *ConsensusRequest) GetPayload() []byte { - if m != nil { - return m.Payload +func (x *ConsensusRequest) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } type DrandRequest struct { - ShardId uint32 `protobuf:"varint,1,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` // Deprecated: Do not use. - SenderPubkey []byte `protobuf:"bytes,2,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` // Deprecated: Do not use. - BlockHash []byte `protobuf:"bytes,3,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` // Deprecated: Do not use. - Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` // Deprecated: Do not use. - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DrandRequest) Reset() { *m = DrandRequest{} } -func (m *DrandRequest) String() string { return proto.CompactTextString(m) } -func (*DrandRequest) ProtoMessage() {} -func (*DrandRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{6} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Deprecated: Do not use. + ShardId uint32 `protobuf:"varint,1,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` + // Deprecated: Do not use. + SenderPubkey []byte `protobuf:"bytes,2,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` + // Deprecated: Do not use. + BlockHash []byte `protobuf:"bytes,3,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + // Deprecated: Do not use. + Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *DrandRequest) Reset() { + *x = DrandRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *DrandRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DrandRequest.Unmarshal(m, b) -} -func (m *DrandRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DrandRequest.Marshal(b, m, deterministic) -} -func (m *DrandRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DrandRequest.Merge(m, src) +func (x *DrandRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *DrandRequest) XXX_Size() int { - return xxx_messageInfo_DrandRequest.Size(m) -} -func (m *DrandRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DrandRequest.DiscardUnknown(m) + +func (*DrandRequest) ProtoMessage() {} + +func (x *DrandRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[6] + 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) } -var xxx_messageInfo_DrandRequest proto.InternalMessageInfo +// Deprecated: Use DrandRequest.ProtoReflect.Descriptor instead. +func (*DrandRequest) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{6} +} // Deprecated: Do not use. -func (m *DrandRequest) GetShardId() uint32 { - if m != nil { - return m.ShardId +func (x *DrandRequest) GetShardId() uint32 { + if x != nil { + return x.ShardId } return 0 } // Deprecated: Do not use. -func (m *DrandRequest) GetSenderPubkey() []byte { - if m != nil { - return m.SenderPubkey +func (x *DrandRequest) GetSenderPubkey() []byte { + if x != nil { + return x.SenderPubkey } return nil } // Deprecated: Do not use. -func (m *DrandRequest) GetBlockHash() []byte { - if m != nil { - return m.BlockHash +func (x *DrandRequest) GetBlockHash() []byte { + if x != nil { + return x.BlockHash } return nil } // Deprecated: Do not use. -func (m *DrandRequest) GetPayload() []byte { - if m != nil { - return m.Payload +func (x *DrandRequest) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } type ViewChangeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + ViewId uint64 `protobuf:"varint,1,opt,name=view_id,json=viewId,proto3" json:"view_id,omitempty"` BlockNum uint64 `protobuf:"varint,2,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` ShardId uint32 `protobuf:"varint,3,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` SenderPubkey []byte `protobuf:"bytes,4,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` LeaderPubkey []byte `protobuf:"bytes,5,opt,name=leader_pubkey,json=leaderPubkey,proto3" json:"leader_pubkey,omitempty"` - Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` - ViewchangeSig []byte `protobuf:"bytes,7,opt,name=viewchange_sig,json=viewchangeSig,proto3" json:"viewchange_sig,omitempty"` - ViewidSig []byte `protobuf:"bytes,8,opt,name=viewid_sig,json=viewidSig,proto3" json:"viewid_sig,omitempty"` + Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` // message payload: either m1 type or m2 type + ViewchangeSig []byte `protobuf:"bytes,7,opt,name=viewchange_sig,json=viewchangeSig,proto3" json:"viewchange_sig,omitempty"` // signature on payload + ViewidSig []byte `protobuf:"bytes,8,opt,name=viewid_sig,json=viewidSig,proto3" json:"viewid_sig,omitempty"` // signature on view_id // below is for newview message only // only need 1 valid m1 type message which is in payload - M2Aggsigs []byte `protobuf:"bytes,9,opt,name=m2_aggsigs,json=m2Aggsigs,proto3" json:"m2_aggsigs,omitempty"` - M2Bitmap []byte `protobuf:"bytes,10,opt,name=m2_bitmap,json=m2Bitmap,proto3" json:"m2_bitmap,omitempty"` - M3Aggsigs []byte `protobuf:"bytes,11,opt,name=m3_aggsigs,json=m3Aggsigs,proto3" json:"m3_aggsigs,omitempty"` - M3Bitmap []byte `protobuf:"bytes,12,opt,name=m3_bitmap,json=m3Bitmap,proto3" json:"m3_bitmap,omitempty"` - PreparedBlock []byte `protobuf:"bytes,13,opt,name=prepared_block,json=preparedBlock,proto3" json:"prepared_block,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ViewChangeRequest) Reset() { *m = ViewChangeRequest{} } -func (m *ViewChangeRequest) String() string { return proto.CompactTextString(m) } -func (*ViewChangeRequest) ProtoMessage() {} -func (*ViewChangeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{7} + M2Aggsigs []byte `protobuf:"bytes,9,opt,name=m2_aggsigs,json=m2Aggsigs,proto3" json:"m2_aggsigs,omitempty"` // m2: |nil| + M2Bitmap []byte `protobuf:"bytes,10,opt,name=m2_bitmap,json=m2Bitmap,proto3" json:"m2_bitmap,omitempty"` + M3Aggsigs []byte `protobuf:"bytes,11,opt,name=m3_aggsigs,json=m3Aggsigs,proto3" json:"m3_aggsigs,omitempty"` // m3: |viewID| + M3Bitmap []byte `protobuf:"bytes,12,opt,name=m3_bitmap,json=m3Bitmap,proto3" json:"m3_bitmap,omitempty"` + PreparedBlock []byte `protobuf:"bytes,13,opt,name=prepared_block,json=preparedBlock,proto3" json:"prepared_block,omitempty"` +} + +func (x *ViewChangeRequest) Reset() { + *x = ViewChangeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ViewChangeRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ViewChangeRequest.Unmarshal(m, b) -} -func (m *ViewChangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ViewChangeRequest.Marshal(b, m, deterministic) -} -func (m *ViewChangeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ViewChangeRequest.Merge(m, src) -} -func (m *ViewChangeRequest) XXX_Size() int { - return xxx_messageInfo_ViewChangeRequest.Size(m) +func (x *ViewChangeRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ViewChangeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ViewChangeRequest.DiscardUnknown(m) + +func (*ViewChangeRequest) ProtoMessage() {} + +func (x *ViewChangeRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[7] + 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) } -var xxx_messageInfo_ViewChangeRequest proto.InternalMessageInfo +// Deprecated: Use ViewChangeRequest.ProtoReflect.Descriptor instead. +func (*ViewChangeRequest) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{7} +} -func (m *ViewChangeRequest) GetViewId() uint64 { - if m != nil { - return m.ViewId +func (x *ViewChangeRequest) GetViewId() uint64 { + if x != nil { + return x.ViewId } return 0 } -func (m *ViewChangeRequest) GetBlockNum() uint64 { - if m != nil { - return m.BlockNum +func (x *ViewChangeRequest) GetBlockNum() uint64 { + if x != nil { + return x.BlockNum } return 0 } -func (m *ViewChangeRequest) GetShardId() uint32 { - if m != nil { - return m.ShardId +func (x *ViewChangeRequest) GetShardId() uint32 { + if x != nil { + return x.ShardId } return 0 } -func (m *ViewChangeRequest) GetSenderPubkey() []byte { - if m != nil { - return m.SenderPubkey +func (x *ViewChangeRequest) GetSenderPubkey() []byte { + if x != nil { + return x.SenderPubkey } return nil } -func (m *ViewChangeRequest) GetLeaderPubkey() []byte { - if m != nil { - return m.LeaderPubkey +func (x *ViewChangeRequest) GetLeaderPubkey() []byte { + if x != nil { + return x.LeaderPubkey } return nil } -func (m *ViewChangeRequest) GetPayload() []byte { - if m != nil { - return m.Payload +func (x *ViewChangeRequest) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } -func (m *ViewChangeRequest) GetViewchangeSig() []byte { - if m != nil { - return m.ViewchangeSig +func (x *ViewChangeRequest) GetViewchangeSig() []byte { + if x != nil { + return x.ViewchangeSig } return nil } -func (m *ViewChangeRequest) GetViewidSig() []byte { - if m != nil { - return m.ViewidSig +func (x *ViewChangeRequest) GetViewidSig() []byte { + if x != nil { + return x.ViewidSig } return nil } -func (m *ViewChangeRequest) GetM2Aggsigs() []byte { - if m != nil { - return m.M2Aggsigs +func (x *ViewChangeRequest) GetM2Aggsigs() []byte { + if x != nil { + return x.M2Aggsigs } return nil } -func (m *ViewChangeRequest) GetM2Bitmap() []byte { - if m != nil { - return m.M2Bitmap +func (x *ViewChangeRequest) GetM2Bitmap() []byte { + if x != nil { + return x.M2Bitmap } return nil } -func (m *ViewChangeRequest) GetM3Aggsigs() []byte { - if m != nil { - return m.M3Aggsigs +func (x *ViewChangeRequest) GetM3Aggsigs() []byte { + if x != nil { + return x.M3Aggsigs } return nil } -func (m *ViewChangeRequest) GetM3Bitmap() []byte { - if m != nil { - return m.M3Bitmap +func (x *ViewChangeRequest) GetM3Bitmap() []byte { + if x != nil { + return x.M3Bitmap } return nil } -func (m *ViewChangeRequest) GetPreparedBlock() []byte { - if m != nil { - return m.PreparedBlock +func (x *ViewChangeRequest) GetPreparedBlock() []byte { + if x != nil { + return x.PreparedBlock } return nil } -func init() { - proto.RegisterEnum("message.ServiceType", ServiceType_name, ServiceType_value) - proto.RegisterEnum("message.MessageType", MessageType_name, MessageType_value) - proto.RegisterEnum("message.LotteryRequest_Type", LotteryRequest_Type_name, LotteryRequest_Type_value) - proto.RegisterType((*Message)(nil), "message.Message") - proto.RegisterType((*Response)(nil), "message.Response") - proto.RegisterType((*LotteryResponse)(nil), "message.LotteryResponse") - proto.RegisterType((*LotteryRequest)(nil), "message.LotteryRequest") - proto.RegisterType((*StakingRequest)(nil), "message.StakingRequest") - proto.RegisterType((*ConsensusRequest)(nil), "message.ConsensusRequest") - proto.RegisterType((*DrandRequest)(nil), "message.DrandRequest") - proto.RegisterType((*ViewChangeRequest)(nil), "message.ViewChangeRequest") -} - -func init() { - proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) -} - -var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 1014 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xdd, 0x6e, 0xe3, 0x44, - 0x14, 0xae, 0xf3, 0xe7, 0xe4, 0xd8, 0x4e, 0xbd, 0xc3, 0x42, 0xbd, 0xdd, 0xee, 0xaa, 0xa4, 0xac, - 0xa8, 0xf6, 0xa2, 0x82, 0x14, 0x69, 0x05, 0xe2, 0x26, 0x4d, 0xcc, 0xd6, 0x6a, 0xeb, 0x84, 0x89, - 0xbb, 0x15, 0x57, 0xd6, 0x34, 0x1e, 0x25, 0x56, 0x13, 0xc7, 0x78, 0x9c, 0xae, 0xf2, 0x24, 0x3c, - 0x05, 0x2f, 0x01, 0xbc, 0x00, 0x57, 0xbc, 0x0e, 0x9a, 0x19, 0xdb, 0x71, 0x52, 0xb8, 0x43, 0xdc, - 0xf9, 0x7c, 0xe7, 0x7c, 0xe7, 0xe7, 0x9b, 0x39, 0x93, 0x80, 0xb1, 0xa0, 0x8c, 0x91, 0x29, 0x3d, - 0x8b, 0x93, 0x65, 0xba, 0x44, 0x6a, 0x66, 0x76, 0x7e, 0xab, 0x82, 0x7a, 0x23, 0xbf, 0xd1, 0x3b, - 0xd0, 0x19, 0x4d, 0x1e, 0xc3, 0x09, 0xf5, 0xd3, 0x75, 0x4c, 0x2d, 0xe5, 0x58, 0x39, 0x6d, 0x77, - 0x9f, 0x9f, 0xe5, 0xd4, 0xb1, 0x74, 0x7a, 0xeb, 0x98, 0x62, 0x8d, 0x6d, 0x0c, 0x74, 0x0a, 0x35, - 0x41, 0xa8, 0xec, 0x10, 0xb2, 0xc4, 0x82, 0x20, 0x22, 0xd0, 0x11, 0xb4, 0x58, 0x38, 0x8d, 0x48, - 0xba, 0x4a, 0xa8, 0x55, 0x3d, 0x56, 0x4e, 0x75, 0xbc, 0x01, 0xd0, 0x3b, 0x50, 0x59, 0x4a, 0x1e, - 0xc2, 0x68, 0x6a, 0xd5, 0x8e, 0x95, 0x53, 0xad, 0x7b, 0xb0, 0xa9, 0x2d, 0x71, 0x4c, 0x7f, 0x5e, - 0x51, 0x96, 0x5e, 0x54, 0x2c, 0xe5, 0x72, 0x0f, 0xe7, 0xd1, 0xe8, 0x5b, 0x68, 0x4d, 0x96, 0x11, - 0xa3, 0x11, 0x5b, 0x31, 0xab, 0x2e, 0xa8, 0x2f, 0x0a, 0x6a, 0x3f, 0xf7, 0x64, 0xe4, 0xcb, 0x3d, - 0xbc, 0x89, 0x46, 0x5f, 0x43, 0x3d, 0x48, 0x48, 0x14, 0x58, 0x0d, 0x41, 0xfb, 0xb4, 0xa0, 0x0d, - 0x38, 0xba, 0x5d, 0x4f, 0x46, 0xa2, 0xef, 0x01, 0x1e, 0x43, 0xfa, 0x71, 0x32, 0x23, 0xd1, 0x94, - 0x5a, 0xaa, 0xe0, 0x1d, 0x16, 0xbc, 0x0f, 0x21, 0xfd, 0xd8, 0x17, 0xae, 0x4d, 0xbd, 0x52, 0x3c, - 0xfa, 0x01, 0xf6, 0xe7, 0xcb, 0x34, 0xa5, 0xc9, 0xda, 0x4f, 0x64, 0x80, 0xd5, 0xdc, 0x19, 0xf6, - 0x5a, 0xfa, 0xb7, 0x8b, 0xb7, 0xe7, 0xdb, 0x68, 0x0b, 0xd4, 0x8c, 0xdf, 0xf9, 0x43, 0x81, 0x26, - 0xa6, 0x2c, 0xe6, 0x43, 0xfd, 0x1f, 0xa7, 0xe8, 0x80, 0xb9, 0x19, 0x41, 0x96, 0x15, 0x87, 0xa9, - 0x75, 0xad, 0xa7, 0x33, 0x48, 0x7f, 0x36, 0xc4, 0xfe, 0x7c, 0x07, 0x06, 0x68, 0xe6, 0x29, 0x3a, - 0x43, 0xd8, 0xdf, 0x61, 0xa1, 0x23, 0x50, 0xe3, 0x39, 0x59, 0xd3, 0x84, 0x59, 0x95, 0xe3, 0xea, - 0x69, 0x8b, 0xa7, 0xc1, 0x39, 0x84, 0x5e, 0x43, 0xf3, 0x9e, 0xcc, 0x49, 0x34, 0xa1, 0xcc, 0xaa, - 0x16, 0xee, 0x02, 0xeb, 0xfc, 0xae, 0x40, 0x7b, 0x5b, 0x4b, 0xf4, 0x4d, 0x36, 0xa4, 0x54, 0xe5, - 0xe8, 0x5f, 0x24, 0x3f, 0xe3, 0xc3, 0x8a, 0x64, 0x72, 0xe0, 0x13, 0xd0, 0xe2, 0x24, 0x7c, 0x24, - 0x29, 0xf5, 0x1f, 0xe8, 0x5a, 0x28, 0x24, 0x6b, 0x41, 0x06, 0x5f, 0xd1, 0x35, 0x3a, 0x84, 0x06, - 0x59, 0x2c, 0x57, 0x51, 0x2a, 0xb4, 0xa8, 0x0a, 0x7f, 0x86, 0x74, 0xbe, 0x83, 0x9a, 0xd0, 0xd8, - 0x80, 0xba, 0xed, 0x7a, 0x36, 0x36, 0xf7, 0x0e, 0x2b, 0x4d, 0x05, 0xb5, 0xa1, 0x81, 0xed, 0xf1, - 0xed, 0xb5, 0x67, 0x2a, 0xc2, 0xfe, 0x04, 0xb4, 0x91, 0xd3, 0xbf, 0xf2, 0xef, 0x1c, 0xd7, 0xb5, - 0xb1, 0x59, 0xe1, 0x60, 0x67, 0x0c, 0xed, 0xed, 0xdb, 0x8f, 0xbe, 0x00, 0x2d, 0x4d, 0x48, 0xc4, - 0xc8, 0x24, 0x0d, 0x97, 0x91, 0x98, 0x45, 0x17, 0xe5, 0xca, 0x30, 0x7a, 0x09, 0x6a, 0xb4, 0x0c, - 0xa8, 0x1f, 0x06, 0xa5, 0x86, 0x1b, 0x1c, 0x72, 0x82, 0xce, 0x5f, 0x0a, 0x98, 0xbb, 0x8b, 0x81, - 0x0e, 0x40, 0xe5, 0x17, 0x95, 0x33, 0x78, 0xce, 0x1a, 0x6e, 0x70, 0xd3, 0x09, 0xd0, 0x4b, 0x68, - 0xdd, 0xcf, 0x97, 0x93, 0x07, 0x3f, 0x5a, 0x2d, 0x44, 0xb2, 0x1a, 0x6e, 0x0a, 0xc0, 0x5d, 0x2d, - 0xd0, 0x0b, 0x68, 0xb2, 0x19, 0x49, 0x02, 0x4e, 0xe3, 0x93, 0x1b, 0x58, 0x15, 0xb6, 0x13, 0xa0, - 0x57, 0x00, 0x92, 0x37, 0x23, 0x6c, 0x26, 0x76, 0x5a, 0xc7, 0x32, 0xd3, 0x25, 0x61, 0x33, 0xf4, - 0x1c, 0xea, 0xc2, 0x10, 0x2b, 0xab, 0x63, 0x69, 0xa0, 0x13, 0x30, 0x18, 0x8d, 0x02, 0x9a, 0xf8, - 0xf1, 0xea, 0x9e, 0xcb, 0xdd, 0x10, 0x5e, 0x5d, 0x82, 0x23, 0x81, 0x21, 0x0b, 0xd4, 0x98, 0xac, - 0xe7, 0x4b, 0x12, 0x88, 0x05, 0xd4, 0x71, 0x6e, 0x76, 0x7e, 0x51, 0x40, 0x2f, 0xef, 0x2e, 0x7a, - 0x55, 0xea, 0x8f, 0x8f, 0x65, 0xc8, 0x4b, 0x94, 0xf7, 0xf8, 0xe5, 0x6e, 0xb9, 0x4a, 0x21, 0xe7, - 0x76, 0xc9, 0xcf, 0xb7, 0x86, 0xa9, 0x16, 0x51, 0xa5, 0x81, 0x8e, 0x36, 0x5d, 0xd5, 0x0a, 0x7f, - 0xd1, 0xd9, 0xaf, 0x55, 0x78, 0xf6, 0xe4, 0x75, 0xf8, 0xef, 0x45, 0x7f, 0xa2, 0x5f, 0xed, 0x1f, - 0xf4, 0x3b, 0x01, 0x63, 0x4e, 0x49, 0x29, 0x48, 0x1e, 0x81, 0x2e, 0xc1, 0xa7, 0x22, 0x37, 0xb6, - 0x44, 0x46, 0x6f, 0xa0, 0xbd, 0x79, 0xd2, 0x7c, 0x16, 0x4e, 0xb3, 0x53, 0x30, 0x36, 0xe8, 0x38, - 0x9c, 0xf2, 0xf3, 0xe7, 0x40, 0x18, 0x88, 0x90, 0xa6, 0x3c, 0x7f, 0x89, 0x64, 0xee, 0x45, 0xd7, - 0x27, 0xd3, 0x29, 0x0b, 0xa7, 0xcc, 0x6a, 0x49, 0xf7, 0xa2, 0xdb, 0x93, 0x00, 0x17, 0x60, 0xd1, - 0xf5, 0xef, 0xc3, 0x74, 0x41, 0x62, 0x0b, 0x84, 0xb7, 0xb9, 0xe8, 0x5e, 0x08, 0x5b, 0x70, 0xcf, - 0x0b, 0xae, 0x96, 0x71, 0xcf, 0xcb, 0xdc, 0xf3, 0x9c, 0xab, 0x67, 0xdc, 0xf3, 0x8c, 0xfb, 0x06, - 0xda, 0x71, 0x42, 0x63, 0x92, 0xd0, 0xc0, 0x97, 0x17, 0xd0, 0x90, 0xdd, 0xe7, 0xe8, 0x05, 0x07, - 0xdf, 0x8e, 0x40, 0x2b, 0x3d, 0x96, 0xc8, 0x80, 0x56, 0x7f, 0xe8, 0x8e, 0x6d, 0x77, 0x7c, 0x3b, - 0x36, 0xf7, 0xd0, 0x3e, 0xa8, 0x63, 0xaf, 0x77, 0xe5, 0xb8, 0xef, 0xb3, 0xe5, 0x35, 0xa0, 0x3e, - 0xc0, 0x3d, 0x77, 0x20, 0xd7, 0x16, 0x21, 0x68, 0xf7, 0xaf, 0x1d, 0xdb, 0xf5, 0xfc, 0xf1, 0xed, - 0x68, 0x34, 0xc4, 0x9e, 0x59, 0x7d, 0xfb, 0xa7, 0x02, 0x5a, 0xe9, 0x39, 0x45, 0xaf, 0xe1, 0x33, - 0xd7, 0xbe, 0x73, 0x87, 0x03, 0xdb, 0xbf, 0xb0, 0x7b, 0xfd, 0xa1, 0xeb, 0xe7, 0x29, 0xe5, 0xfb, - 0xa0, 0x43, 0xb3, 0xe7, 0xba, 0xc3, 0x5b, 0xb7, 0x6f, 0x9b, 0x0a, 0xd2, 0x40, 0x1d, 0x61, 0x7b, - 0xd4, 0xc3, 0xb6, 0x59, 0xe1, 0xae, 0xcc, 0x18, 0x98, 0x55, 0x04, 0xd0, 0xe8, 0x0f, 0x6f, 0x6e, - 0x1c, 0xcf, 0xac, 0xc9, 0x3e, 0xf9, 0xb7, 0x67, 0x0f, 0xcc, 0x3a, 0x6a, 0x03, 0x7c, 0x70, 0xec, - 0xbb, 0xfe, 0x65, 0xcf, 0x7d, 0x6f, 0x9b, 0x0d, 0x9e, 0xc5, 0xb5, 0xef, 0x38, 0x64, 0xaa, 0x08, - 0x01, 0x88, 0x9e, 0x7d, 0xc7, 0x75, 0x3c, 0x13, 0x44, 0xd1, 0xe7, 0xa0, 0x4b, 0x2c, 0xcb, 0xa8, - 0x09, 0xf4, 0x00, 0xf6, 0xaf, 0x87, 0x9e, 0x67, 0xe3, 0x9f, 0x7c, 0x6c, 0xff, 0x78, 0x6b, 0x8f, - 0x3d, 0x53, 0xe7, 0x8e, 0x6e, 0x0f, 0x8c, 0xfe, 0x3c, 0xa4, 0x51, 0x9a, 0x69, 0x85, 0xbe, 0x02, - 0x75, 0x94, 0x2c, 0x27, 0x94, 0x31, 0x64, 0xee, 0xfe, 0x88, 0x1c, 0x3e, 0x2b, 0x90, 0xfc, 0x8d, - 0xef, 0xec, 0xdd, 0x37, 0xc4, 0x9f, 0x92, 0xf3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x76, 0xe0, - 0x82, 0x48, 0xa5, 0x08, 0x00, 0x00, +var File_message_proto protoreflect.FileDescriptor + +var file_message_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xc2, 0x03, 0x0a, 0x07, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, + 0x02, 0x18, 0x01, 0x48, 0x00, 0x52, 0x07, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x12, 0x39, + 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x09, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x12, 0x31, 0x0a, 0x05, 0x64, 0x72, 0x61, + 0x6e, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x44, 0x72, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, + 0x02, 0x18, 0x01, 0x48, 0x00, 0x52, 0x05, 0x64, 0x72, 0x61, 0x6e, 0x64, 0x12, 0x3c, 0x0a, 0x0a, + 0x76, 0x69, 0x65, 0x77, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0a, + 0x76, 0x69, 0x65, 0x77, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x46, 0x0a, 0x0f, 0x6c, 0x6f, + 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4c, 0x6f, + 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x02, 0x18, 0x01, + 0x48, 0x00, 0x52, 0x0e, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xc4, 0x01, + 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x14, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x14, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x49, 0x0a, + 0x10, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x02, 0x18, 0x01, 0x48, 0x00, 0x52, 0x0f, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4f, 0x0a, 0x0f, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x70, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x1e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x08, 0x62, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0xc3, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, + 0x54, 0x79, 0x70, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x23, + 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x3a, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x05, 0x45, 0x4e, 0x54, 0x45, 0x52, + 0x10, 0x00, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x0e, 0x0a, 0x06, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, + 0x10, 0x01, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x13, 0x0a, 0x0b, 0x50, 0x49, 0x43, 0x4b, 0x5f, 0x57, + 0x49, 0x4e, 0x4e, 0x45, 0x52, 0x10, 0x02, 0x1a, 0x02, 0x08, 0x01, 0x22, 0x53, 0x0a, 0x0e, 0x53, + 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, + 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, + 0x22, 0xd7, 0x01, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x49, 0x64, 0x12, 0x1b, + 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x73, + 0x68, 0x61, 0x72, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x73, + 0x68, 0x61, 0x72, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, + 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x73, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6b, 0x65, 0x79, + 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x97, 0x01, 0x0a, 0x0c, 0x44, + 0x72, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x08, 0x73, + 0x68, 0x61, 0x72, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, + 0x01, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0d, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x50, 0x75, 0x62, + 0x6b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, + 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xad, 0x03, 0x0a, 0x11, 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x69, + 0x65, 0x77, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x76, 0x69, 0x65, + 0x77, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, + 0x12, 0x19, 0x0a, 0x08, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x73, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6b, 0x65, 0x79, + 0x12, 0x23, 0x0a, 0x0d, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, + 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, + 0x75, 0x62, 0x6b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, + 0x25, 0x0a, 0x0e, 0x76, 0x69, 0x65, 0x77, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x73, 0x69, + 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x76, 0x69, 0x65, 0x77, 0x63, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x53, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x69, 0x65, 0x77, 0x69, 0x64, + 0x5f, 0x73, 0x69, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x76, 0x69, 0x65, 0x77, + 0x69, 0x64, 0x53, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x32, 0x5f, 0x61, 0x67, 0x67, 0x73, + 0x69, 0x67, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6d, 0x32, 0x41, 0x67, 0x67, + 0x73, 0x69, 0x67, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x32, 0x5f, 0x62, 0x69, 0x74, 0x6d, 0x61, + 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x32, 0x42, 0x69, 0x74, 0x6d, 0x61, + 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x33, 0x5f, 0x61, 0x67, 0x67, 0x73, 0x69, 0x67, 0x73, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6d, 0x33, 0x41, 0x67, 0x67, 0x73, 0x69, 0x67, 0x73, + 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x33, 0x5f, 0x62, 0x69, 0x74, 0x6d, 0x61, 0x70, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x33, 0x42, 0x69, 0x74, 0x6d, 0x61, 0x70, 0x12, 0x25, 0x0a, + 0x0e, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, + 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x2a, 0x50, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x53, 0x45, 0x4e, 0x53, 0x55, 0x53, + 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x07, 0x53, 0x54, 0x41, 0x4b, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x1a, + 0x02, 0x08, 0x01, 0x12, 0x0d, 0x0a, 0x05, 0x44, 0x52, 0x41, 0x4e, 0x44, 0x10, 0x02, 0x1a, 0x02, + 0x08, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x53, 0x55, 0x50, + 0x50, 0x4f, 0x52, 0x54, 0x10, 0x03, 0x2a, 0xd1, 0x01, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x16, 0x4e, 0x45, 0x57, 0x4e, 0x4f, 0x44, + 0x45, 0x5f, 0x42, 0x45, 0x41, 0x43, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x4b, 0x49, 0x4e, 0x47, + 0x10, 0x00, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x4e, 0x4e, 0x4f, 0x55, 0x4e, + 0x43, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, + 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x44, 0x10, 0x03, 0x12, + 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x43, + 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x54, 0x45, 0x44, 0x10, 0x05, 0x12, 0x0e, 0x0a, 0x0a, 0x56, 0x49, + 0x45, 0x57, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x45, + 0x57, 0x56, 0x49, 0x45, 0x57, 0x10, 0x07, 0x12, 0x12, 0x0a, 0x0a, 0x44, 0x52, 0x41, 0x4e, 0x44, + 0x5f, 0x49, 0x4e, 0x49, 0x54, 0x10, 0x0a, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x14, 0x0a, 0x0c, 0x44, + 0x52, 0x41, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x0b, 0x1a, 0x02, 0x08, + 0x01, 0x12, 0x17, 0x0a, 0x0f, 0x4c, 0x4f, 0x54, 0x54, 0x45, 0x52, 0x59, 0x5f, 0x52, 0x45, 0x51, + 0x55, 0x45, 0x53, 0x54, 0x10, 0x0c, 0x1a, 0x02, 0x08, 0x01, 0x32, 0x41, 0x0a, 0x0d, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x50, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x11, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_message_proto_rawDescOnce sync.Once + file_message_proto_rawDescData = file_message_proto_rawDesc +) + +func file_message_proto_rawDescGZIP() []byte { + file_message_proto_rawDescOnce.Do(func() { + file_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_message_proto_rawDescData) + }) + return file_message_proto_rawDescData +} + +var file_message_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_message_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_message_proto_goTypes = []interface{}{ + (ServiceType)(0), // 0: message.ServiceType + (MessageType)(0), // 1: message.MessageType + (LotteryRequest_Type)(0), // 2: message.LotteryRequest.Type + (*Message)(nil), // 3: message.Message + (*Response)(nil), // 4: message.Response + (*LotteryResponse)(nil), // 5: message.LotteryResponse + (*LotteryRequest)(nil), // 6: message.LotteryRequest + (*StakingRequest)(nil), // 7: message.StakingRequest + (*ConsensusRequest)(nil), // 8: message.ConsensusRequest + (*DrandRequest)(nil), // 9: message.DrandRequest + (*ViewChangeRequest)(nil), // 10: message.ViewChangeRequest +} +var file_message_proto_depIdxs = []int32{ + 0, // 0: message.Message.service_type:type_name -> message.ServiceType + 1, // 1: message.Message.type:type_name -> message.MessageType + 7, // 2: message.Message.staking:type_name -> message.StakingRequest + 8, // 3: message.Message.consensus:type_name -> message.ConsensusRequest + 9, // 4: message.Message.drand:type_name -> message.DrandRequest + 10, // 5: message.Message.viewchange:type_name -> message.ViewChangeRequest + 6, // 6: message.Message.lottery_request:type_name -> message.LotteryRequest + 0, // 7: message.Response.service_type:type_name -> message.ServiceType + 1, // 8: message.Response.type:type_name -> message.MessageType + 5, // 9: message.Response.lottery_response:type_name -> message.LotteryResponse + 2, // 10: message.LotteryRequest.type:type_name -> message.LotteryRequest.Type + 3, // 11: message.ClientService.Process:input_type -> message.Message + 4, // 12: message.ClientService.Process:output_type -> message.Response + 12, // [12:13] is the sub-list for method output_type + 11, // [11:12] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name +} + +func init() { file_message_proto_init() } +func file_message_proto_init() { + if File_message_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LotteryResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LotteryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StakingRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConsensusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DrandRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ViewChangeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_message_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Message_Staking)(nil), + (*Message_Consensus)(nil), + (*Message_Drand)(nil), + (*Message_Viewchange)(nil), + (*Message_LotteryRequest)(nil), + } + file_message_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*Response_LotteryResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_message_proto_rawDesc, + NumEnums: 3, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_message_proto_goTypes, + DependencyIndexes: file_message_proto_depIdxs, + EnumInfos: file_message_proto_enumTypes, + MessageInfos: file_message_proto_msgTypes, + }.Build() + File_message_proto = out.File + file_message_proto_rawDesc = nil + file_message_proto_goTypes = nil + file_message_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -951,7 +1331,7 @@ type ClientServiceServer interface { type UnimplementedClientServiceServer struct { } -func (*UnimplementedClientServiceServer) Process(ctx context.Context, req *Message) (*Response, error) { +func (*UnimplementedClientServiceServer) Process(context.Context, *Message) (*Response, error) { return nil, status.Errorf(codes.Unimplemented, "method Process not implemented") } diff --git a/api/service/syncing/downloader/proto/downloader.pb.go b/api/service/syncing/downloader/proto/downloader.pb.go index 5025e6d7d4..108f70e33b 100644 --- a/api/service/syncing/downloader/proto/downloader.pb.go +++ b/api/service/syncing/downloader/proto/downloader.pb.go @@ -1,28 +1,33 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0 +// protoc v3.6.1 // source: downloader.proto package downloader import ( context "context" - fmt "fmt" proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 type DownloaderRequest_RequestType int32 @@ -37,34 +42,55 @@ const ( DownloaderRequest_BLOCKHEADER DownloaderRequest_RequestType = 7 ) -var DownloaderRequest_RequestType_name = map[int32]string{ - 0: "BLOCKHASH", - 1: "BLOCK", - 2: "NEWBLOCK", - 3: "BLOCKHEIGHT", - 4: "REGISTER", - 5: "REGISTERTIMEOUT", - 6: "UNKNOWN", - 7: "BLOCKHEADER", -} +// Enum value maps for DownloaderRequest_RequestType. +var ( + DownloaderRequest_RequestType_name = map[int32]string{ + 0: "BLOCKHASH", + 1: "BLOCK", + 2: "NEWBLOCK", + 3: "BLOCKHEIGHT", + 4: "REGISTER", + 5: "REGISTERTIMEOUT", + 6: "UNKNOWN", + 7: "BLOCKHEADER", + } + DownloaderRequest_RequestType_value = map[string]int32{ + "BLOCKHASH": 0, + "BLOCK": 1, + "NEWBLOCK": 2, + "BLOCKHEIGHT": 3, + "REGISTER": 4, + "REGISTERTIMEOUT": 5, + "UNKNOWN": 6, + "BLOCKHEADER": 7, + } +) -var DownloaderRequest_RequestType_value = map[string]int32{ - "BLOCKHASH": 0, - "BLOCK": 1, - "NEWBLOCK": 2, - "BLOCKHEIGHT": 3, - "REGISTER": 4, - "REGISTERTIMEOUT": 5, - "UNKNOWN": 6, - "BLOCKHEADER": 7, +func (x DownloaderRequest_RequestType) Enum() *DownloaderRequest_RequestType { + p := new(DownloaderRequest_RequestType) + *p = x + return p } func (x DownloaderRequest_RequestType) String() string { - return proto.EnumName(DownloaderRequest_RequestType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DownloaderRequest_RequestType) Descriptor() protoreflect.EnumDescriptor { + return file_downloader_proto_enumTypes[0].Descriptor() +} + +func (DownloaderRequest_RequestType) Type() protoreflect.EnumType { + return &file_downloader_proto_enumTypes[0] +} + +func (x DownloaderRequest_RequestType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } +// Deprecated: Use DownloaderRequest_RequestType.Descriptor instead. func (DownloaderRequest_RequestType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_6a99ec95c7ab1ff1, []int{0, 0} + return file_downloader_proto_rawDescGZIP(), []int{0, 0} } type DownloaderResponse_RegisterResponseType int32 @@ -72,216 +98,345 @@ type DownloaderResponse_RegisterResponseType int32 const ( DownloaderResponse_SUCCESS DownloaderResponse_RegisterResponseType = 0 DownloaderResponse_FAIL DownloaderResponse_RegisterResponseType = 1 - DownloaderResponse_INSYNC DownloaderResponse_RegisterResponseType = 2 + DownloaderResponse_INSYNC DownloaderResponse_RegisterResponseType = 2 // node is now in sync, remove it from the broadcast list ) -var DownloaderResponse_RegisterResponseType_name = map[int32]string{ - 0: "SUCCESS", - 1: "FAIL", - 2: "INSYNC", -} +// Enum value maps for DownloaderResponse_RegisterResponseType. +var ( + DownloaderResponse_RegisterResponseType_name = map[int32]string{ + 0: "SUCCESS", + 1: "FAIL", + 2: "INSYNC", + } + DownloaderResponse_RegisterResponseType_value = map[string]int32{ + "SUCCESS": 0, + "FAIL": 1, + "INSYNC": 2, + } +) -var DownloaderResponse_RegisterResponseType_value = map[string]int32{ - "SUCCESS": 0, - "FAIL": 1, - "INSYNC": 2, +func (x DownloaderResponse_RegisterResponseType) Enum() *DownloaderResponse_RegisterResponseType { + p := new(DownloaderResponse_RegisterResponseType) + *p = x + return p } func (x DownloaderResponse_RegisterResponseType) String() string { - return proto.EnumName(DownloaderResponse_RegisterResponseType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DownloaderResponse_RegisterResponseType) Descriptor() protoreflect.EnumDescriptor { + return file_downloader_proto_enumTypes[1].Descriptor() } +func (DownloaderResponse_RegisterResponseType) Type() protoreflect.EnumType { + return &file_downloader_proto_enumTypes[1] +} + +func (x DownloaderResponse_RegisterResponseType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DownloaderResponse_RegisterResponseType.Descriptor instead. func (DownloaderResponse_RegisterResponseType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_6a99ec95c7ab1ff1, []int{1, 0} + return file_downloader_proto_rawDescGZIP(), []int{1, 0} } // DownloaderRequest is the generic download request. type DownloaderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // Request type. Type DownloaderRequest_RequestType `protobuf:"varint,1,opt,name=type,proto3,enum=downloader.DownloaderRequest_RequestType" json:"type,omitempty"` // The hashes of the blocks we want to download. - Hashes [][]byte `protobuf:"bytes,2,rep,name=hashes,proto3" json:"hashes,omitempty"` - PeerHash []byte `protobuf:"bytes,3,opt,name=peerHash,proto3" json:"peerHash,omitempty"` - BlockHash []byte `protobuf:"bytes,4,opt,name=blockHash,proto3" json:"blockHash,omitempty"` - Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip,omitempty"` - Port string `protobuf:"bytes,6,opt,name=port,proto3" json:"port,omitempty"` - Size uint32 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DownloaderRequest) Reset() { *m = DownloaderRequest{} } -func (m *DownloaderRequest) String() string { return proto.CompactTextString(m) } -func (*DownloaderRequest) ProtoMessage() {} -func (*DownloaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_6a99ec95c7ab1ff1, []int{0} + Hashes [][]byte `protobuf:"bytes,2,rep,name=hashes,proto3" json:"hashes,omitempty"` + PeerHash []byte `protobuf:"bytes,3,opt,name=peerHash,proto3" json:"peerHash,omitempty"` + BlockHash []byte `protobuf:"bytes,4,opt,name=blockHash,proto3" json:"blockHash,omitempty"` + Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip,omitempty"` + Port string `protobuf:"bytes,6,opt,name=port,proto3" json:"port,omitempty"` + Size uint32 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` +} + +func (x *DownloaderRequest) Reset() { + *x = DownloaderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_downloader_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *DownloaderRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DownloaderRequest.Unmarshal(m, b) -} -func (m *DownloaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DownloaderRequest.Marshal(b, m, deterministic) -} -func (m *DownloaderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DownloaderRequest.Merge(m, src) -} -func (m *DownloaderRequest) XXX_Size() int { - return xxx_messageInfo_DownloaderRequest.Size(m) +func (x *DownloaderRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *DownloaderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DownloaderRequest.DiscardUnknown(m) + +func (*DownloaderRequest) ProtoMessage() {} + +func (x *DownloaderRequest) ProtoReflect() protoreflect.Message { + mi := &file_downloader_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) } -var xxx_messageInfo_DownloaderRequest proto.InternalMessageInfo +// Deprecated: Use DownloaderRequest.ProtoReflect.Descriptor instead. +func (*DownloaderRequest) Descriptor() ([]byte, []int) { + return file_downloader_proto_rawDescGZIP(), []int{0} +} -func (m *DownloaderRequest) GetType() DownloaderRequest_RequestType { - if m != nil { - return m.Type +func (x *DownloaderRequest) GetType() DownloaderRequest_RequestType { + if x != nil { + return x.Type } return DownloaderRequest_BLOCKHASH } -func (m *DownloaderRequest) GetHashes() [][]byte { - if m != nil { - return m.Hashes +func (x *DownloaderRequest) GetHashes() [][]byte { + if x != nil { + return x.Hashes } return nil } -func (m *DownloaderRequest) GetPeerHash() []byte { - if m != nil { - return m.PeerHash +func (x *DownloaderRequest) GetPeerHash() []byte { + if x != nil { + return x.PeerHash } return nil } -func (m *DownloaderRequest) GetBlockHash() []byte { - if m != nil { - return m.BlockHash +func (x *DownloaderRequest) GetBlockHash() []byte { + if x != nil { + return x.BlockHash } return nil } -func (m *DownloaderRequest) GetIp() string { - if m != nil { - return m.Ip +func (x *DownloaderRequest) GetIp() string { + if x != nil { + return x.Ip } return "" } -func (m *DownloaderRequest) GetPort() string { - if m != nil { - return m.Port +func (x *DownloaderRequest) GetPort() string { + if x != nil { + return x.Port } return "" } -func (m *DownloaderRequest) GetSize() uint32 { - if m != nil { - return m.Size +func (x *DownloaderRequest) GetSize() uint32 { + if x != nil { + return x.Size } return 0 } // DownloaderResponse is the generic response of DownloaderRequest. type DownloaderResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // payload of Block. Payload [][]byte `protobuf:"bytes,1,rep,name=payload,proto3" json:"payload,omitempty"` // response of registration request - Type DownloaderResponse_RegisterResponseType `protobuf:"varint,2,opt,name=type,proto3,enum=downloader.DownloaderResponse_RegisterResponseType" json:"type,omitempty"` - BlockHeight uint64 `protobuf:"varint,3,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Type DownloaderResponse_RegisterResponseType `protobuf:"varint,2,opt,name=type,proto3,enum=downloader.DownloaderResponse_RegisterResponseType" json:"type,omitempty"` + BlockHeight uint64 `protobuf:"varint,3,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` } -func (m *DownloaderResponse) Reset() { *m = DownloaderResponse{} } -func (m *DownloaderResponse) String() string { return proto.CompactTextString(m) } -func (*DownloaderResponse) ProtoMessage() {} -func (*DownloaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6a99ec95c7ab1ff1, []int{1} +func (x *DownloaderResponse) Reset() { + *x = DownloaderResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_downloader_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *DownloaderResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DownloaderResponse.Unmarshal(m, b) -} -func (m *DownloaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DownloaderResponse.Marshal(b, m, deterministic) +func (x *DownloaderResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *DownloaderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DownloaderResponse.Merge(m, src) -} -func (m *DownloaderResponse) XXX_Size() int { - return xxx_messageInfo_DownloaderResponse.Size(m) -} -func (m *DownloaderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DownloaderResponse.DiscardUnknown(m) + +func (*DownloaderResponse) ProtoMessage() {} + +func (x *DownloaderResponse) ProtoReflect() protoreflect.Message { + mi := &file_downloader_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) } -var xxx_messageInfo_DownloaderResponse proto.InternalMessageInfo +// Deprecated: Use DownloaderResponse.ProtoReflect.Descriptor instead. +func (*DownloaderResponse) Descriptor() ([]byte, []int) { + return file_downloader_proto_rawDescGZIP(), []int{1} +} -func (m *DownloaderResponse) GetPayload() [][]byte { - if m != nil { - return m.Payload +func (x *DownloaderResponse) GetPayload() [][]byte { + if x != nil { + return x.Payload } return nil } -func (m *DownloaderResponse) GetType() DownloaderResponse_RegisterResponseType { - if m != nil { - return m.Type +func (x *DownloaderResponse) GetType() DownloaderResponse_RegisterResponseType { + if x != nil { + return x.Type } return DownloaderResponse_SUCCESS } -func (m *DownloaderResponse) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight +func (x *DownloaderResponse) GetBlockHeight() uint64 { + if x != nil { + return x.BlockHeight } return 0 } -func init() { - proto.RegisterEnum("downloader.DownloaderRequest_RequestType", DownloaderRequest_RequestType_name, DownloaderRequest_RequestType_value) - proto.RegisterEnum("downloader.DownloaderResponse_RegisterResponseType", DownloaderResponse_RegisterResponseType_name, DownloaderResponse_RegisterResponseType_value) - proto.RegisterType((*DownloaderRequest)(nil), "downloader.DownloaderRequest") - proto.RegisterType((*DownloaderResponse)(nil), "downloader.DownloaderResponse") -} - -func init() { - proto.RegisterFile("downloader.proto", fileDescriptor_6a99ec95c7ab1ff1) -} - -var fileDescriptor_6a99ec95c7ab1ff1 = []byte{ - // 410 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xce, 0x3a, 0x8e, 0x93, 0x4c, 0xd2, 0x76, 0x19, 0x10, 0x5a, 0x55, 0x80, 0x2c, 0x9f, 0xcc, - 0xc5, 0x87, 0xf6, 0xc4, 0x81, 0x43, 0x70, 0x4d, 0x6c, 0xb5, 0x38, 0x62, 0xed, 0x50, 0x71, 0x74, - 0xe9, 0xaa, 0xb6, 0xa8, 0xea, 0xc5, 0xeb, 0x0a, 0x99, 0x17, 0xe0, 0x05, 0x79, 0x06, 0x9e, 0x03, - 0x79, 0x9d, 0xd6, 0x96, 0x80, 0x9c, 0x76, 0xbf, 0x6f, 0x7e, 0x34, 0xf3, 0x7d, 0x03, 0xf4, 0xba, - 0xfc, 0x7e, 0x77, 0x5b, 0x66, 0xd7, 0xa2, 0xf2, 0x64, 0x55, 0xd6, 0x25, 0x42, 0xcf, 0x38, 0xbf, - 0x0d, 0x78, 0x72, 0xf6, 0x08, 0xb9, 0xf8, 0x76, 0x2f, 0x54, 0x8d, 0x6f, 0xc1, 0xac, 0x1b, 0x29, - 0x18, 0xb1, 0x89, 0x7b, 0x78, 0xf2, 0xda, 0x1b, 0xb4, 0xf8, 0x2b, 0xd9, 0xdb, 0xbd, 0x69, 0x23, - 0x05, 0xd7, 0x65, 0xf8, 0x1c, 0xac, 0x3c, 0x53, 0xb9, 0x50, 0xcc, 0xb0, 0xc7, 0xee, 0x92, 0xef, - 0x10, 0x1e, 0xc3, 0x4c, 0x0a, 0x51, 0x85, 0x99, 0xca, 0xd9, 0xd8, 0x26, 0xee, 0x92, 0x3f, 0x62, - 0x7c, 0x01, 0xf3, 0xab, 0xdb, 0xf2, 0xcb, 0x57, 0x1d, 0x34, 0x75, 0xb0, 0x27, 0xf0, 0x10, 0x8c, - 0x42, 0xb2, 0x89, 0x4d, 0xdc, 0x39, 0x37, 0x0a, 0x89, 0x08, 0xa6, 0x2c, 0xab, 0x9a, 0x59, 0x9a, - 0xd1, 0xff, 0x96, 0x53, 0xc5, 0x0f, 0xc1, 0xa6, 0x36, 0x71, 0x0f, 0xb8, 0xfe, 0x3b, 0x3f, 0x09, - 0x2c, 0x06, 0xf3, 0xe1, 0x01, 0xcc, 0xdf, 0x5d, 0x6c, 0xfc, 0xf3, 0x70, 0x95, 0x84, 0x74, 0x84, - 0x73, 0x98, 0x68, 0x48, 0x09, 0x2e, 0x61, 0x16, 0x07, 0x97, 0x1d, 0x32, 0xf0, 0x08, 0x16, 0x5d, - 0x5e, 0x10, 0xad, 0xc3, 0x94, 0x8e, 0xdb, 0x30, 0x0f, 0xd6, 0x51, 0x92, 0x06, 0x9c, 0x9a, 0xf8, - 0x14, 0x8e, 0x1e, 0x50, 0x1a, 0x7d, 0x08, 0x36, 0xdb, 0x94, 0x4e, 0x70, 0x01, 0xd3, 0x6d, 0x7c, - 0x1e, 0x6f, 0x2e, 0x63, 0x6a, 0x0d, 0x1a, 0xac, 0xce, 0x02, 0x4e, 0xa7, 0xce, 0x2f, 0x02, 0x38, - 0xd4, 0x4e, 0xc9, 0xf2, 0x4e, 0x09, 0x64, 0x30, 0x95, 0x59, 0xd3, 0x92, 0x8c, 0x68, 0xad, 0x1e, - 0x20, 0xae, 0x77, 0x1e, 0x18, 0xda, 0x83, 0xd3, 0xff, 0x79, 0xd0, 0xf5, 0xf1, 0xb8, 0xb8, 0x29, - 0x54, 0xdd, 0x13, 0x03, 0x37, 0x6c, 0x58, 0x74, 0x42, 0x8a, 0xe2, 0x26, 0xaf, 0xb5, 0xf0, 0x26, - 0x1f, 0x52, 0xce, 0x1b, 0x78, 0xf6, 0xaf, 0xfa, 0x76, 0xa3, 0x64, 0xeb, 0xfb, 0x41, 0x92, 0xd0, - 0x11, 0xce, 0xc0, 0x7c, 0xbf, 0x8a, 0x2e, 0x28, 0x41, 0x00, 0x2b, 0x8a, 0x93, 0xcf, 0xb1, 0x4f, - 0x8d, 0x93, 0x4f, 0x00, 0xfd, 0x34, 0x18, 0xc2, 0xe4, 0xe3, 0xbd, 0xa8, 0x1a, 0x7c, 0xb9, 0xf7, - 0x64, 0x8e, 0x5f, 0xed, 0xdf, 0xc6, 0x19, 0x5d, 0x59, 0xfa, 0x54, 0x4f, 0xff, 0x04, 0x00, 0x00, - 0xff, 0xff, 0x00, 0xaf, 0x33, 0x33, 0xbe, 0x02, 0x00, 0x00, +var File_downloader_proto protoreflect.FileDescriptor + +var file_downloader_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x22, 0xe6, + 0x02, 0x0a, 0x11, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, + 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0c, 0x52, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x65, 0x65, 0x72, 0x48, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, + 0x65, 0x65, 0x72, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x48, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x87, 0x01, + 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, + 0x09, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x48, 0x41, 0x53, 0x48, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, + 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x45, 0x57, 0x42, 0x4c, + 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x48, 0x45, + 0x49, 0x47, 0x48, 0x54, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, + 0x45, 0x52, 0x10, 0x04, 0x12, 0x13, 0x0a, 0x0f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, + 0x54, 0x49, 0x4d, 0x45, 0x4f, 0x55, 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x06, 0x12, 0x0f, 0x0a, 0x0b, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x48, + 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x07, 0x22, 0xd4, 0x01, 0x0a, 0x12, 0x44, 0x6f, 0x77, 0x6e, + 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x47, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x22, 0x39, 0x0a, 0x14, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, + 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, 0x49, 0x4c, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x4e, 0x53, 0x59, 0x4e, 0x43, 0x10, 0x02, 0x32, 0x56, + 0x0a, 0x0a, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x12, 0x48, 0x0a, 0x05, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, + 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, + 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_downloader_proto_rawDescOnce sync.Once + file_downloader_proto_rawDescData = file_downloader_proto_rawDesc +) + +func file_downloader_proto_rawDescGZIP() []byte { + file_downloader_proto_rawDescOnce.Do(func() { + file_downloader_proto_rawDescData = protoimpl.X.CompressGZIP(file_downloader_proto_rawDescData) + }) + return file_downloader_proto_rawDescData +} + +var file_downloader_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_downloader_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_downloader_proto_goTypes = []interface{}{ + (DownloaderRequest_RequestType)(0), // 0: downloader.DownloaderRequest.RequestType + (DownloaderResponse_RegisterResponseType)(0), // 1: downloader.DownloaderResponse.RegisterResponseType + (*DownloaderRequest)(nil), // 2: downloader.DownloaderRequest + (*DownloaderResponse)(nil), // 3: downloader.DownloaderResponse +} +var file_downloader_proto_depIdxs = []int32{ + 0, // 0: downloader.DownloaderRequest.type:type_name -> downloader.DownloaderRequest.RequestType + 1, // 1: downloader.DownloaderResponse.type:type_name -> downloader.DownloaderResponse.RegisterResponseType + 2, // 2: downloader.Downloader.Query:input_type -> downloader.DownloaderRequest + 3, // 3: downloader.Downloader.Query:output_type -> downloader.DownloaderResponse + 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_downloader_proto_init() } +func file_downloader_proto_init() { + if File_downloader_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_downloader_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DownloaderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_downloader_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DownloaderResponse); 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_downloader_proto_rawDesc, + NumEnums: 2, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_downloader_proto_goTypes, + DependencyIndexes: file_downloader_proto_depIdxs, + EnumInfos: file_downloader_proto_enumTypes, + MessageInfos: file_downloader_proto_msgTypes, + }.Build() + File_downloader_proto = out.File + file_downloader_proto_rawDesc = nil + file_downloader_proto_goTypes = nil + file_downloader_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -325,7 +480,7 @@ type DownloaderServer interface { type UnimplementedDownloaderServer struct { } -func (*UnimplementedDownloaderServer) Query(ctx context.Context, req *DownloaderRequest) (*DownloaderResponse, error) { +func (*UnimplementedDownloaderServer) Query(context.Context, *DownloaderRequest) (*DownloaderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Query not implemented") } diff --git a/consensus/checks.go b/consensus/checks.go index 12203513f3..d56912c868 100644 --- a/consensus/checks.go +++ b/consensus/checks.go @@ -3,92 +3,52 @@ package consensus import ( "bytes" + protobuf "github.com/golang/protobuf/proto" + libbls "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto/bls" + "github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/internal/chain" - "github.com/harmony-one/harmony/internal/utils" - "github.com/harmony-one/harmony/shard" + "github.com/pkg/errors" ) // MaxBlockNumDiff limits the received block number to only 100 further from the current block number const MaxBlockNumDiff = 100 -func (consensus *Consensus) validatorSanityChecks(msg *msg_pb.Message) bool { - if msg.GetConsensus() == nil { - consensus.getLogger().Warn().Msg("[validatorSanityChecks] malformed message") - return false - } - consensus.getLogger().Debug(). - Uint64("blockNum", msg.GetConsensus().BlockNum). - Uint64("viewID", msg.GetConsensus().ViewId). - Str("msgType", msg.Type.String()). - Msg("[validatorSanityChecks] Checking new message") - err := consensus.verifySenderKey(msg) +var ( + errBytesToBLSPubKey = errors.New("bytes to bls pubkey failed") +) + +// verifyMessageSig verify the signature of the message are valid from the signer's public key. +func verifyMessageSig(signerPubKey *libbls.PublicKey, message *msg_pb.Message) error { + signature := message.Signature + message.Signature = nil + messageBytes, err := protobuf.Marshal(message) if err != nil { - if err == shard.ErrValidNotInCommittee { - utils.SampledLogger().Info(). - Hex("senderKey", msg.GetConsensus().SenderPubkey). - Msg("sender key not in this slot's subcommittee") - } else { - consensus.getLogger().Error().Err(err).Msg("VerifySenderKey failed") - } - return false + return err } - senderKey, err := bls.BytesToBLSPublicKey(msg.GetConsensus().SenderPubkey) + + msgSig := libbls.Sign{} + err = msgSig.Deserialize(signature) if err != nil { - return false + return err } - if !senderKey.IsEqual(consensus.LeaderPubKey.Object) && - consensus.current.Mode() == Normal && !consensus.IgnoreViewIDCheck.IsSet() { - consensus.getLogger().Warn().Msgf( - "[%s] SenderKey not match leader PubKey", - msg.GetType().String(), - ) - return false + msgHash := hash.Keccak256(messageBytes) + if !msgSig.VerifyHash(signerPubKey, msgHash[:]) { + return errors.New("failed to verify the signature") } - - if err := verifyMessageSig(senderKey, msg); err != nil { - consensus.getLogger().Error().Err(err).Msg( - "Failed to verify sender's signature", - ) - return false - } - - return true + message.Signature = signature + return nil } -func (consensus *Consensus) leaderSanityChecks(msg *msg_pb.Message) bool { - if msg.GetConsensus() == nil { - consensus.getLogger().Warn().Msg("[leaderSanityChecks] malformed message") - return false - } - consensus.getLogger().Debug(). - Uint64("blockNum", msg.GetConsensus().BlockNum). - Uint64("viewID", msg.GetConsensus().ViewId). - Str("msgType", msg.Type.String()). - Msg("[leaderSanityChecks] Checking new message") - err := consensus.verifySenderKey(msg) +func (consensus *Consensus) senderKeySanityChecks(msg *msg_pb.Message, senderKey *bls.SerializedPublicKey) bool { + pubkey, err := bls.BytesToBLSPublicKey(senderKey[:]) if err != nil { - if err == shard.ErrValidNotInCommittee { - consensus.getLogger().Info(). - Hex("senderKey", msg.GetConsensus().SenderPubkey).Msgf( - "[%s] sender key not in this slot's subcommittee", - msg.GetType().String(), - ) - } else { - consensus.getLogger().Error().Err(err).Msgf( - "[%s] verifySenderKey failed", - msg.GetType().String(), - ) - } return false } - senderKey, err := bls.BytesToBLSPublicKey(msg.GetConsensus().SenderPubkey) - if err != nil { - return false - } - if err = verifyMessageSig(senderKey, msg); err != nil { + + if err := verifyMessageSig(pubkey, msg); err != nil { consensus.getLogger().Error().Err(err).Msgf( "[%s] Failed to verify sender's signature", msg.GetType().String(), @@ -129,7 +89,7 @@ func (consensus *Consensus) onAnnounceSanityChecks(recvMsg *FBFTMessage) bool { Str("recvMsgBlockHash", recvMsg.BlockHash.Hex()). Str("LeaderKey", consensus.LeaderPubKey.Bytes.Hex()). Msg("[OnAnnounce] Leader is malicious") - if consensus.current.Mode() == ViewChanging { + if consensus.IsViewChangingMode() { consensus.getLogger().Debug().Msg( "[OnAnnounce] Already in ViewChanging mode, conflicing announce, doing noop", ) @@ -200,43 +160,6 @@ func (consensus *Consensus) onPreparedSanityChecks( return true } -func (consensus *Consensus) viewChangeSanityCheck(msg *msg_pb.Message) bool { - if msg.GetViewchange() == nil { - consensus.getLogger().Warn().Msg("[viewChangeSanityCheck] malformed message") - return false - } - consensus.getLogger().Debug(). - Msg("[viewChangeSanityCheck] Checking new message") - err := consensus.verifyViewChangeSenderKey(msg) - if err != nil { - if err == shard.ErrValidNotInCommittee { - consensus.getLogger().Info(). - Hex("senderKey", msg.GetViewchange().SenderPubkey).Msgf( - "[%s] sender key not in this slot's subcommittee", - msg.GetType().String(), - ) - } else { - consensus.getLogger().Error().Err(err).Msgf( - "[%s] VerifySenderKey Failed", - msg.GetType().String(), - ) - } - return false - } - senderKey, err := bls.BytesToBLSPublicKey(msg.GetViewchange().SenderPubkey) - if err != nil { - return false - } - if err := verifyMessageSig(senderKey, msg); err != nil { - consensus.getLogger().Error().Err(err).Msgf( - "[%s] Failed To Verify Sender's Signature", - msg.GetType().String(), - ) - return false - } - return true -} - func (consensus *Consensus) onViewChangeSanityCheck(recvMsg *FBFTMessage) bool { // TODO: if difference is only one, new leader can still propose the same committed block to avoid another view change // TODO: new leader catchup without ignore view change message @@ -252,7 +175,7 @@ func (consensus *Consensus) onViewChangeSanityCheck(recvMsg *FBFTMessage) bool { Msg("[onViewChange] New Leader Has Lower Blocknum") return false } - if consensus.current.Mode() == ViewChanging && + if consensus.IsViewChangingMode() && consensus.current.ViewID() > recvMsg.ViewID { consensus.getLogger().Warn(). Uint64("MyViewChangingID", consensus.current.ViewID()). @@ -278,7 +201,7 @@ func (consensus *Consensus) onNewViewSanityCheck(recvMsg *FBFTMessage) bool { Msg("[onNewView] ViewID should be larger than the viewID of the last successful consensus") return false } - if consensus.current.Mode() != ViewChanging { + if !consensus.IsViewChangingMode() { consensus.getLogger().Warn(). Msg("[onNewView] Not in ViewChanging mode, ignoring the new view message") return false diff --git a/consensus/consensus.go b/consensus/consensus.go index b9f8f8658b..dcd60eea67 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -39,8 +39,6 @@ type Consensus struct { // blockNum: the next blockNumber that FBFT is going to agree on, // should be equal to the blockNumber of next block blockNum uint64 - // channel to receive consensus message - MsgChan chan []byte // How long to delay sending commit messages. delayCommit time.Duration // Consensus rounds whose commit phase finished @@ -207,7 +205,6 @@ func New( // displayed on explorer as Height right now consensus.viewID = 0 consensus.ShardID = shard - consensus.MsgChan = make(chan []byte) consensus.syncReadyChan = make(chan struct{}) consensus.syncNotReadyChan = make(chan struct{}) consensus.SlashChan = make(chan slash.Record) diff --git a/consensus/consensus_service.go b/consensus/consensus_service.go index 27eba0a2e3..57836dd5cd 100644 --- a/consensus/consensus_service.go +++ b/consensus/consensus_service.go @@ -197,50 +197,6 @@ func (consensus *Consensus) IsValidatorInCommitteeBytes(pubKey bls.SerializedPub return consensus.Decider.IndexOf(pubKey) != -1 } -// Verify the signature of the message are valid from the signer's public key. -func verifyMessageSig(signerPubKey *bls_core.PublicKey, message *msg_pb.Message) error { - signature := message.Signature - message.Signature = nil - messageBytes, err := protobuf.Marshal(message) - if err != nil { - return err - } - - msgSig := bls_core.Sign{} - err = msgSig.Deserialize(signature) - if err != nil { - return err - } - msgHash := hash.Keccak256(messageBytes) - if !msgSig.VerifyHash(signerPubKey, msgHash[:]) { - return errors.New("failed to verify the signature") - } - message.Signature = signature - return nil -} - -// verifySenderKey verifys the message senderKey is properly signed and senderAddr is valid -func (consensus *Consensus) verifySenderKey(msg *msg_pb.Message) error { - senderKey := bls.SerializedPublicKey{} - - copy(senderKey[:], msg.GetConsensus().SenderPubkey[:]) - if !consensus.IsValidatorInCommitteeBytes(senderKey) { - return shard.ErrValidNotInCommittee - } - return nil -} - -func (consensus *Consensus) verifyViewChangeSenderKey(msg *msg_pb.Message) error { - vcMsg := msg.GetViewchange() - senderKey := bls.SerializedPublicKey{} - copy(senderKey[:], vcMsg.SenderPubkey) - - if !consensus.IsValidatorInCommittee(senderKey) { - return shard.ErrValidNotInCommittee - } - return nil -} - // SetViewID set the viewID to the height of the blockchain func (consensus *Consensus) SetViewID(height uint64) { consensus.viewID = height diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 20d3c5842d..de90d81860 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -2,13 +2,13 @@ package consensus import ( "bytes" + "context" "encoding/hex" "sync/atomic" "time" "github.com/harmony-one/harmony/crypto/bls" - protobuf "github.com/golang/protobuf/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/block" "github.com/harmony-one/harmony/consensus/quorum" @@ -21,45 +21,26 @@ import ( "github.com/pkg/errors" ) -// handlemessageupdate will update the consensus state according to received message -func (consensus *Consensus) handleMessageUpdate(payload []byte) { - if len(payload) == 0 { - return - } - msg := &msg_pb.Message{} - if err := protobuf.Unmarshal(payload, msg); err != nil { - consensus.getLogger().Error().Err(err).Msg("Failed to unmarshal message payload.") - return - } +var ( + errSenderPubKeyNotLeader = errors.New("sender pubkey doesn't match leader") + errVerifyMessageSignature = errors.New("verify message signature failed") +) + +// IsViewChangingMode return true if curernt mode is viewchanging +func (consensus *Consensus) IsViewChangingMode() bool { + return consensus.current.Mode() == ViewChanging +} +// HandleMessageUpdate will update the consensus state according to received message +func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb.Message, senderKey *bls.SerializedPublicKey) error { // when node is in ViewChanging mode, it still accepts normal messages into FBFTLog // in order to avoid possible trap forever but drop PREPARE and COMMIT // which are message types specifically for a node acting as leader - if (consensus.current.Mode() == ViewChanging) && + // so we just ignore those messages + if consensus.IsViewChangingMode() && (msg.Type == msg_pb.MessageType_PREPARE || msg.Type == msg_pb.MessageType_COMMIT) { - return - } - - if msg.Type == msg_pb.MessageType_VIEWCHANGE || - msg.Type == msg_pb.MessageType_NEWVIEW { - if msg.GetViewchange() != nil && - msg.GetViewchange().ShardId != consensus.ShardID { - consensus.getLogger().Warn(). - Uint32("myShardId", consensus.ShardID). - Uint32("receivedShardId", msg.GetViewchange().ShardId). - Msg("Received view change message from different shard") - return - } - } else { - if msg.GetConsensus() != nil && - msg.GetConsensus().ShardId != consensus.ShardID { - consensus.getLogger().Warn(). - Uint32("myShardId", consensus.ShardID). - Uint32("receivedShardId", msg.GetConsensus().ShardId). - Msg("Received consensus message from different shard") - return - } + return nil } intendedForValidator, intendedForLeader := @@ -68,34 +49,60 @@ func (consensus *Consensus) handleMessageUpdate(payload []byte) { switch t := msg.Type; true { // Handle validator intended messages first - case t == msg_pb.MessageType_ANNOUNCE && - intendedForValidator && - consensus.validatorSanityChecks(msg): + case t == msg_pb.MessageType_ANNOUNCE && intendedForValidator: + if !bytes.Equal(senderKey[:], consensus.LeaderPubKey.Bytes[:]) && + consensus.current.Mode() == Normal && !consensus.IgnoreViewIDCheck.IsSet() { + return errSenderPubKeyNotLeader + } + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onAnnounce(msg) - case t == msg_pb.MessageType_PREPARED && - intendedForValidator && - consensus.validatorSanityChecks(msg): + case t == msg_pb.MessageType_PREPARED && intendedForValidator: + if !bytes.Equal(senderKey[:], consensus.LeaderPubKey.Bytes[:]) && + consensus.current.Mode() == Normal && !consensus.IgnoreViewIDCheck.IsSet() { + return errSenderPubKeyNotLeader + } + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onPrepared(msg) - case t == msg_pb.MessageType_COMMITTED && - intendedForValidator && - consensus.validatorSanityChecks(msg): + case t == msg_pb.MessageType_COMMITTED && intendedForValidator: + if !bytes.Equal(senderKey[:], consensus.LeaderPubKey.Bytes[:]) && + consensus.current.Mode() == Normal && !consensus.IgnoreViewIDCheck.IsSet() { + return errSenderPubKeyNotLeader + } + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onCommitted(msg) + // Handle leader intended messages now - case t == msg_pb.MessageType_PREPARE && - intendedForLeader && - consensus.leaderSanityChecks(msg): + case t == msg_pb.MessageType_PREPARE && intendedForLeader: + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onPrepare(msg) - case t == msg_pb.MessageType_COMMIT && - intendedForLeader && - consensus.leaderSanityChecks(msg): + case t == msg_pb.MessageType_COMMIT && intendedForLeader: + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onCommit(msg) - case t == msg_pb.MessageType_VIEWCHANGE && - consensus.viewChangeSanityCheck(msg): + + // Handle view change messages + case t == msg_pb.MessageType_VIEWCHANGE: + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onViewChange(msg) - case t == msg_pb.MessageType_NEWVIEW && - consensus.viewChangeSanityCheck(msg): + case t == msg_pb.MessageType_NEWVIEW: + if !consensus.senderKeySanityChecks(msg, senderKey) { + return errVerifyMessageSignature + } consensus.onNewView(msg) } + + return nil } func (consensus *Consensus) finalizeCommits() { @@ -177,11 +184,10 @@ func (consensus *Consensus) finalizeCommits() { Int("numStakingTxns", len(block.StakingTransactions())). Msg("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!") - if n := time.Now(); n.Before(consensus.NextBlockDue) { - // Sleep to wait for the full block time - consensus.getLogger().Debug().Msg("[finalizeCommits] Waiting for Block Time") - time.Sleep(consensus.NextBlockDue.Sub(n)) - } + // Sleep to wait for the full block time + consensus.getLogger().Debug().Msg("[finalizeCommits] Waiting for Block Time") + <-time.After(time.Until(consensus.NextBlockDue)) + // Send signal to Node to propose the new block for consensus consensus.ReadySignal <- struct{}{} @@ -316,7 +322,7 @@ func (consensus *Consensus) tryCatchup() { } // catup up and skip from view change trap if currentBlockNum < consensus.blockNum && - consensus.current.Mode() == ViewChanging { + consensus.IsViewChangingMode() { consensus.current.SetMode(Normal) consensus.consensusTimeout[timeoutViewChange].Stop() } @@ -488,9 +494,6 @@ func (consensus *Consensus) Start( Msg("[ConsensusMainLoop] STARTING CONSENSUS") consensus.announce(newBlock) - case msg := <-consensus.MsgChan: - consensus.handleMessageUpdate(msg) - case viewID := <-consensus.commitFinishChan: consensus.getLogger().Debug().Msg("[ConsensusMainLoop] commitFinishChan") diff --git a/consensus/validator.go b/consensus/validator.go index 6457a7a028..a42e0fd911 100644 --- a/consensus/validator.go +++ b/consensus/validator.go @@ -39,7 +39,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { consensus.blockHash = recvMsg.BlockHash // we have already added message and block, skip check viewID // and send prepare message if is in ViewChanging mode - if consensus.current.Mode() == ViewChanging { + if consensus.IsViewChangingMode() { consensus.getLogger().Debug(). Msg("[OnAnnounce] Still in ViewChanging Mode, Exiting !!") return @@ -308,7 +308,7 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { } consensus.tryCatchup() - if consensus.current.Mode() == ViewChanging { + if consensus.IsViewChangingMode() { consensus.getLogger().Info().Msg("[OnCommitted] Still in ViewChanging mode, Exiting!!") return } diff --git a/go.mod b/go.mod index 2e99c58026..4c34ba3738 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/ethereum/go-ethereum v1.8.27 github.com/fjl/memsize v0.0.0-20180929194037-2a09253e352a // indirect github.com/garslo/gogen v0.0.0-20170307003452-d6ebae628c7c // indirect - github.com/golang/mock v1.3.1 - github.com/golang/protobuf v1.3.5 + github.com/golang/mock v1.4.0 + github.com/golang/protobuf v1.4.0 github.com/golangci/golangci-lint v1.22.2 github.com/gorilla/handlers v1.4.0 // indirect github.com/gorilla/mux v1.7.2 @@ -36,16 +36,16 @@ require ( github.com/karalabe/hid v1.0.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/libp2p/go-addr-util v0.0.2 // indirect - github.com/libp2p/go-libp2p v0.9.2 - github.com/libp2p/go-libp2p-core v0.5.6 + github.com/libp2p/go-libp2p v0.10.0 + github.com/libp2p/go-libp2p-core v0.6.0 github.com/libp2p/go-libp2p-crypto v0.1.0 github.com/libp2p/go-libp2p-discovery v0.4.0 github.com/libp2p/go-libp2p-host v0.1.0 github.com/libp2p/go-libp2p-kad-dht v0.8.0 github.com/libp2p/go-libp2p-net v0.1.0 github.com/libp2p/go-libp2p-peer v0.2.0 - github.com/libp2p/go-libp2p-peerstore v0.2.4 - github.com/libp2p/go-libp2p-pubsub v0.3.1 + github.com/libp2p/go-libp2p-peerstore v0.2.6 + github.com/libp2p/go-libp2p-pubsub v0.3.2 github.com/multiformats/go-multiaddr v0.2.2 github.com/multiformats/go-multiaddr-net v0.1.5 github.com/natefinch/lumberjack v2.0.0+incompatible @@ -58,7 +58,7 @@ require ( github.com/rs/zerolog v1.18.0 github.com/shirou/gopsutil v2.18.12+incompatible // indirect github.com/spf13/viper v1.6.1 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect github.com/uber/jaeger-lib v2.2.0+incompatible // indirect @@ -67,6 +67,7 @@ require ( golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/tools v0.0.0-20200408032209-46bd65c8538f google.golang.org/grpc v1.28.1 + google.golang.org/protobuf v1.23.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect diff --git a/node/node.go b/node/node.go index 19bfcaef14..1ff25b1d1f 100644 --- a/node/node.go +++ b/node/node.go @@ -8,14 +8,17 @@ import ( "os" "strings" "sync" + "sync/atomic" "time" "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" + protobuf "github.com/golang/protobuf/proto" "github.com/harmony-one/abool" bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/client" + "github.com/harmony-one/harmony/api/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" proto_node "github.com/harmony-one/harmony/api/proto/node" "github.com/harmony-one/harmony/api/service" @@ -38,6 +41,7 @@ import ( "github.com/harmony-one/harmony/staking/slash" staking "github.com/harmony-one/harmony/staking/types" "github.com/harmony-one/harmony/webhooks" + libp2p_peer "github.com/libp2p/go-libp2p-core/peer" libp2p_pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/pkg/errors" "golang.org/x/sync/semaphore" @@ -58,6 +62,8 @@ const ( ShardRxWorkers = 32 // GlobalRxWorkers is the number of concurrent global message handlers. GlobalRxWorkers = 32 + // MsgChanBuffer is the buffer of consensus message handlers. + MsgChanBuffer = 512 ) const ( @@ -126,6 +132,14 @@ type Node struct { BroadcastInvalidTx bool // InSync flag indicates the node is in-sync or not IsInSync *abool.AtomicBool + + // metrics of p2p messages + NumP2PMessages uint32 + NumTotalMessages uint32 + NumValidMessages uint32 + NumInvalidMessages uint32 + NumSlotMessages uint32 + NumIgnoredMessages uint32 } // Blockchain returns the blockchain for the node's current shard. @@ -333,66 +347,356 @@ func (node *Node) AddPendingReceipts(receipts *types.CXReceiptsProof) { Msg("Got ONE more receipt message") } +type withError struct { + err error + payload interface{} +} + +var ( + errNotRightKeySize = errors.New("key received over wire is wrong size") + errNoSenderPubKey = errors.New("no sender public BLS key in message") + errWrongShardID = errors.New("wrong shard id") +) + +// validateShardBoundMessage validate consensus message +// validate shardID +// validate public key size +// verify message signature +func (node *Node) validateShardBoundMessage( + ctx context.Context, payload []byte, +) (*msg_pb.Message, *bls.SerializedPublicKey, bool, error) { + var ( + m msg_pb.Message + ) + atomic.AddUint32(&node.NumTotalMessages, 1) + + if err := protobuf.Unmarshal(payload, &m); err != nil { + atomic.AddUint32(&node.NumInvalidMessages, 1) + return nil, nil, true, errors.WithStack(err) + } + + // when node is in ViewChanging mode, it still accepts normal messages into FBFTLog + // in order to avoid possible trap forever but drop PREPARE and COMMIT + // which are message types specifically for a node acting as leader + // so we just ignore those messages + if node.Consensus.IsViewChangingMode() { + switch m.Type { + case msg_pb.MessageType_PREPARE, msg_pb.MessageType_COMMIT: + return nil, nil, true, nil + } + } + + // ignore message not intended for leader, but still forward them to the network + if node.Consensus.IsLeader() { + switch m.Type { + case msg_pb.MessageType_ANNOUNCE, msg_pb.MessageType_PREPARED, msg_pb.MessageType_COMMITTED: + atomic.AddUint32(&node.NumIgnoredMessages, 1) + return nil, nil, true, nil + } + } + + maybeCon, maybeVC := m.GetConsensus(), m.GetViewchange() + senderKey := bls.SerializedPublicKey{} + + if maybeCon != nil { + if maybeCon.ShardId != node.Consensus.ShardID { + atomic.AddUint32(&node.NumInvalidMessages, 1) + return nil, nil, true, errors.WithStack(errWrongShardID) + } + copy(senderKey[:], maybeCon.SenderPubkey[:]) + } else if maybeVC != nil { + if maybeVC.ShardId != node.Consensus.ShardID { + atomic.AddUint32(&node.NumInvalidMessages, 1) + return nil, nil, true, errors.WithStack(errWrongShardID) + } + copy(senderKey[:], maybeVC.SenderPubkey) + } else { + atomic.AddUint32(&node.NumInvalidMessages, 1) + return nil, nil, true, errors.WithStack(errNoSenderPubKey) + } + + if len(senderKey) != bls.PublicKeySizeInBytes { + atomic.AddUint32(&node.NumInvalidMessages, 1) + return nil, nil, true, errors.WithStack(errNotRightKeySize) + } + + if !node.Consensus.IsValidatorInCommittee(senderKey) { + atomic.AddUint32(&node.NumSlotMessages, 1) + return nil, nil, true, errors.WithStack(shard.ErrValidNotInCommittee) + } + + // ignore mesage not intended for validator + // but still forward them to the network + if !node.Consensus.IsLeader() { + switch m.Type { + case msg_pb.MessageType_PREPARE, msg_pb.MessageType_COMMIT: + atomic.AddUint32(&node.NumIgnoredMessages, 1) + return nil, nil, true, nil + } + } + + atomic.AddUint32(&node.NumValidMessages, 1) + return &m, &senderKey, false, nil +} + +var ( + errMsgHadNoHMYPayLoadAssumption = errors.New("did not have sufficient size for hmy msg") + errConsensusMessageOnUnexpectedTopic = errors.New("received consensus on wrong topic") +) + // Start kicks off the node message handling func (node *Node) Start() error { - allTopics := node.host.AllTopics() - if len(allTopics) == 0 { - return errors.New("have no topics to listen to") + // groupID and whether this topic is used for consensus + type t struct { + tp nodeconfig.GroupID + isCon bool } - weighted := make([]*semaphore.Weighted, len(allTopics)) - const maxMessageHandlers = 4096 - ctx := context.Background() + groups := map[nodeconfig.GroupID]bool{} + + // three topic subscribed by each validator + for _, t := range []t{ + {node.NodeConfig.GetShardGroupID(), true}, + {nodeconfig.NewClientGroupIDByShardID(shard.BeaconChainShardID), false}, + {node.NodeConfig.GetClientGroupID(), false}, + } { + if _, ok := groups[t.tp]; !ok { + groups[t.tp] = t.isCon + } + } + + type u struct { + p2p.NamedTopic + consensusBound bool + } + + var allTopics []u + + utils.Logger().Debug(). + Interface("topics-ended-up-with", groups). + Uint32("shard-id", node.Consensus.ShardID). + Msg("starting with these topics") + + // init the pubsub topics + for key, isCon := range groups { + topicHandle, err := node.host.GetOrJoin(string(key)) + if err != nil { + return err + } + allTopics = append( + allTopics, u{ + NamedTopic: p2p.NamedTopic{string(key), topicHandle}, + consensusBound: isCon, + }, + ) + } + pubsub := node.host.PubSub() ownID := node.host.GetID() - errChan := make(chan error) + errChan := make(chan withError, 100) + + // p2p consensus message handler function + type p2pHandlerConsensus func( + ctx context.Context, + msg *msg_pb.Message, + key *bls.SerializedPublicKey, + ) error + + // other p2p message handler function + type p2pHandlerElse func( + ctx context.Context, + rlpPayload []byte, + ) error + + // interface pass to p2p message validator + type validated struct { + consensusBound bool + handleC p2pHandlerConsensus + handleCArg *msg_pb.Message + handleE p2pHandlerElse + handleEArg []byte + senderPubKey *bls.SerializedPublicKey + } + + isThisNodeAnExplorerNode := node.NodeConfig.Role() == nodeconfig.ExplorerNode - for i, topic := range allTopics { - sub, err := topic.Subscribe() + for i := range allTopics { + sub, err := allTopics[i].Topic.Subscribe() if err != nil { return err } - weighted[i] = semaphore.NewWeighted(maxMessageHandlers) - msgChan := make(chan *libp2p_pubsub.Message) - go func(msgChan chan *libp2p_pubsub.Message, sem *semaphore.Weighted) { - for msg := range msgChan { - payload := msg.GetData() - if len(payload) < p2pMsgPrefixSize { - continue + topicNamed := allTopics[i].Name + isConsensusBound := allTopics[i].consensusBound + + utils.Logger().Info(). + Str("topic", topicNamed). + Msg("enabled topic validation pubsub messages") + + // register topic validator for each topic + if err := pubsub.RegisterTopicValidator( + topicNamed, + // this is the validation function called to quickly validate every p2p message + func(ctx context.Context, peer libp2p_peer.ID, msg *libp2p_pubsub.Message) libp2p_pubsub.ValidationResult { + atomic.AddUint32(&node.NumP2PMessages, 1) + hmyMsg := msg.GetData() + + // first to validate the size of the p2p message + if len(hmyMsg) < p2pMsgPrefixSize { + return libp2p_pubsub.ValidationAccept } - if sem.TryAcquire(1) { - go func() { - node.HandleMessage( - payload[p2pMsgPrefixSize:], msg.GetFrom(), - ) - sem.Release(1) - }() - } else { - utils.Logger().Warn(). - Msg("could not acquire semaphore to process incoming message") + + openBox := hmyMsg[p2pMsgPrefixSize:] + + // validate message category + switch proto.MessageCategory(openBox[proto.MessageCategoryBytes-1]) { + case proto.Consensus: + + // received consensus message in non-consensus bound topic + if !isConsensusBound { + errChan <- withError{ + errors.WithStack(errConsensusMessageOnUnexpectedTopic), msg, + } + return libp2p_pubsub.ValidationReject + } + + // validate consensus message + validMsg, senderPubKey, ignore, err := node.validateShardBoundMessage( + context.TODO(), openBox[proto.MessageCategoryBytes:], + ) + + if err != nil { + errChan <- withError{err, msg.GetFrom()} + return libp2p_pubsub.ValidationReject + } + + // ignore the further processing of the p2p messages as it is not intended for this node + if ignore { + return libp2p_pubsub.ValidationAccept + } + + msg.ValidatorData = validated{ + consensusBound: true, + handleC: node.Consensus.HandleMessageUpdate, + handleCArg: validMsg, + senderPubKey: senderPubKey, + } + return libp2p_pubsub.ValidationAccept + + case proto.Node: + // TODO push the message parsing here, so can ban + msg.ValidatorData = validated{ + consensusBound: false, + handleE: node.HandleNodeMessage, + handleEArg: openBox, + } + default: + return libp2p_pubsub.ValidationIgnore + } + + select { + case <-ctx.Done(): + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + utils.Logger().Warn(). + Str("topic", topicNamed).Msg("[context] exceeded validation deadline") + } + errChan <- withError{errors.WithStack(ctx.Err()), nil} + default: + return libp2p_pubsub.ValidationAccept } + + return libp2p_pubsub.ValidationReject + }, + // WithValidatorTimeout is an option that sets a timeout for an (asynchronous) topic validator. By default there is no timeout in asynchronous validators. + libp2p_pubsub.WithValidatorTimeout(250*time.Millisecond), + // WithValidatorConcurrency set the concurernt validator, default is 1024 + libp2p_pubsub.WithValidatorConcurrency(p2p.SetAsideForConsensus), + // WithValidatorInline is an option that sets the validation disposition to synchronous: + // it will be executed inline in validation front-end, without spawning a new goroutine. + // This is suitable for simple or cpu-bound validators that do not block. + libp2p_pubsub.WithValidatorInline(true), + ); err != nil { + return err + } + + sem := semaphore.NewWeighted(p2p.MaxMessageHandlers) + msgChan := make(chan validated, MsgChanBuffer) + + go func() { + for m := range msgChan { + // should not take more than 10 seconds to process one message + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + msg := m + go func() { + defer cancel() + + if sem.TryAcquire(1) { + defer sem.Release(1) + + if msg.consensusBound { + if isThisNodeAnExplorerNode { + if err := node.explorerMessageHandler( + ctx, msg.handleCArg, + ); err != nil { + errChan <- withError{err, nil} + } + } else { + if err := msg.handleC(ctx, msg.handleCArg, msg.senderPubKey); err != nil { + errChan <- withError{err, nil} + } + } + } else { + if err := msg.handleE(ctx, msg.handleEArg); err != nil { + errChan <- withError{err, nil} + } + } + + select { + case <-ctx.Done(): + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + utils.Logger().Warn(). + Str("topic", topicNamed).Msg("[context] exceeded handler deadline") + } + errChan <- withError{errors.WithStack(ctx.Err()), nil} + default: + return + } + } + }() } - }(msgChan, weighted[i]) + }() + + go func() { - go func(msgChan chan *libp2p_pubsub.Message) { for { - nextMsg, err := sub.Next(ctx) + nextMsg, err := sub.Next(context.Background()) if err != nil { - errChan <- err + errChan <- withError{errors.WithStack(err), nil} continue } + if nextMsg.GetFrom() == ownID { continue } - msgChan <- nextMsg + + if validatedMessage, ok := nextMsg.ValidatorData.(validated); ok { + msgChan <- validatedMessage + } else { + // continue if ValidatorData is nil + if nextMsg.ValidatorData == nil { + continue + } + } } - }(msgChan) + }() } - for err := range errChan { - utils.Logger().Info().Err(err).Msg("issue while handling incoming p2p message") + for e := range errChan { + utils.SampledLogger().Info(). + Interface("item", e.payload). + Msgf("[p2p]: issue while handling incoming p2p message: %v", e.err) } // NOTE never gets here return nil + } // GetSyncID returns the syncID of this node @@ -527,6 +831,29 @@ func New( } }() } + go func() { + ticker := time.NewTicker(time.Minute) + defer ticker.Stop() + for { + select { + case <-ticker.C: + utils.Logger().Info(). + Uint32("P2PMessage", node.NumP2PMessages). + Uint32("TotalMessage", node.NumTotalMessages). + Uint32("ValidMessage", node.NumValidMessages). + Uint32("InvalidMessage", node.NumInvalidMessages). + Uint32("SlotMessage", node.NumSlotMessages). + Uint32("IgnoredMessage", node.NumIgnoredMessages). + Msg("MsgValidator") + atomic.StoreUint32(&node.NumInvalidMessages, 0) + atomic.StoreUint32(&node.NumSlotMessages, 0) + atomic.StoreUint32(&node.NumIgnoredMessages, 0) + atomic.StoreUint32(&node.NumValidMessages, 0) + atomic.StoreUint32(&node.NumTotalMessages, 0) + atomic.StoreUint32(&node.NumP2PMessages, 0) + } + } + }() return &node } diff --git a/node/node_explorer.go b/node/node_explorer.go index 6fe6f53acf..c0c42b2edc 100644 --- a/node/node_explorer.go +++ b/node/node_explorer.go @@ -1,41 +1,43 @@ package node import ( + "context" "sort" "sync" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - protobuf "github.com/golang/protobuf/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/api/service/explorer" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus/signature" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/internal/utils" + "github.com/pkg/errors" ) var once sync.Once -// ExplorerMessageHandler passes received message in node_handler to explorer service -func (node *Node) ExplorerMessageHandler(payload []byte) { - if len(payload) == 0 { - utils.Logger().Error().Msg("Payload is empty") - return - } - msg := &msg_pb.Message{} - err := protobuf.Unmarshal(payload, msg) - if err != nil { - utils.Logger().Error().Err(err).Msg("Failed to unmarshal message payload.") - return - } +var ( + errBlockBeforeCommit = errors.New( + "explorer hasnt received the block before the committed msg", + ) + errFailVerifyMultiSign = errors.New( + "explorer failed to verify the multi signature for commit phase", + ) + errFailFindingValidCommit = errors.New( + "explorer failed finding a valid committed message", + ) +) +// explorerMessageHandler passes received message in node_handler to explorer service +func (node *Node) explorerMessageHandler(ctx context.Context, msg *msg_pb.Message) error { if msg.Type == msg_pb.MessageType_COMMITTED { recvMsg, err := consensus.ParseFBFTMessage(msg) if err != nil { utils.Logger().Error().Err(err). Msg("[Explorer] onCommitted unable to parse msg") - return + return err } aggSig, mask, err := node.Consensus.ReadSignatureBitmapPayload( @@ -44,12 +46,12 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { if err != nil { utils.Logger().Error().Err(err). Msg("[Explorer] readSignatureBitmapPayload failed") - return + return err } if !node.Consensus.Decider.IsQuorumAchievedByMask(mask) { utils.Logger().Error().Msg("[Explorer] not have enough signature power") - return + return nil } block := node.Consensus.FBFTLog.GetBlockByHash(recvMsg.BlockHash) @@ -59,7 +61,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { Uint64("msgBlock", recvMsg.BlockNum). Msg("[Explorer] Haven't received the block before the committed msg") node.Consensus.FBFTLog.AddMessage(recvMsg) - return + return errBlockBeforeCommit } commitPayload := signature.ConstructCommitPayload(node.Blockchain(), @@ -69,7 +71,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { Error().Err(err). Uint64("msgBlock", recvMsg.BlockNum). Msg("[Explorer] Failed to verify the multi signature for commit phase") - return + return errFailVerifyMultiSign } block.SetCurrentCommitSig(recvMsg.Payload) @@ -80,12 +82,12 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { recvMsg, err := consensus.ParseFBFTMessage(msg) if err != nil { utils.Logger().Error().Err(err).Msg("[Explorer] Unable to parse Prepared msg") - return + return err } block, blockObj := recvMsg.Block, &types.Block{} if err := rlp.DecodeBytes(block, blockObj); err != nil { utils.Logger().Error().Err(err).Msg("explorer could not rlp decode block") - return + return err } // Add the block into FBFT log. node.Consensus.FBFTLog.AddBlock(blockObj) @@ -107,13 +109,14 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { } if committedMsg == nil { utils.Logger().Error().Err(err).Msg("[Explorer] Failed finding a valid committed message.") - return + return errFailFindingValidCommit } blockObj.SetCurrentCommitSig(committedMsg.Payload) node.AddNewBlockForExplorer(blockObj) node.commitBlockForExplorer(blockObj) } } + return nil } // AddNewBlockForExplorer add new block for explorer. diff --git a/node/node_handler.go b/node/node_handler.go index 08795ad75a..00e1500339 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -24,7 +24,6 @@ import ( "github.com/harmony-one/harmony/staking/slash" staking "github.com/harmony-one/harmony/staking/types" "github.com/harmony-one/harmony/webhooks" - libp2p_peer "github.com/libp2p/go-libp2p-core/peer" "github.com/pkg/errors" ) @@ -58,101 +57,75 @@ func (node *Node) processSkippedMsgTypeByteValue( } } -// HandleMessage parses the message and dispatch the actions. -func (node *Node) HandleMessage(content []byte, sender libp2p_peer.ID) { - // log in-coming metrics - node.host.LogRecvMessage(content) - utils.Logger().Debug(). - Int64("TotalIn", node.host.GetBandwidthTotals().TotalIn). - Float64("RateIn", node.host.GetBandwidthTotals().RateIn). - Msg("[metrics][p2p] traffic in in bytes") - - msgCategory, err := proto.GetMessageCategory(content) - if err != nil { - utils.Logger().Error(). - Err(err). - Msg("HandleMessage get message category failed") - return - } - msgType, err := proto.GetMessageType(content) - if err != nil { - utils.Logger().Error(). - Err(err). - Msg("HandleMessage get message type failed") - return - } - - msgPayload, err := proto.GetMessagePayload(content) - if err != nil { - utils.Logger().Error(). - Err(err). - Msg("HandleMessage get message payload failed") - return - } +var ( + errInvalidPayloadSize = errors.New("invalid payload size") + errWrongBlockMsgSize = errors.New("invalid block message size") +) - switch msgCategory { - case proto.Consensus: - msgPayload, _ := proto.GetConsensusMessagePayload(content) - if node.NodeConfig.Role() == nodeconfig.ExplorerNode { - node.ExplorerMessageHandler(msgPayload) - } else { - node.ConsensusMessageHandler(msgPayload) +// HandleNodeMessage parses the message and dispatch the actions. +func (node *Node) HandleNodeMessage( + ctx context.Context, + payload []byte, +) error { + + // Prevent OOB crash + if len(payload) < (proto.MessageTypeBytes + proto.MessageCategoryBytes) { + return errors.WithStack(errInvalidPayloadSize) + } + msgPayload := payload[proto.MessageCategoryBytes+proto.MessageTypeBytes:] + msgType := byte(payload[proto.MessageCategoryBytes+proto.MessageTypeBytes-1]) + actionType := proto_node.MessageType(msgType) + + switch actionType { + case proto_node.Transaction: + utils.Logger().Debug().Msg("NET: received message: Node/Transaction") + node.transactionMessageHandler(msgPayload) + case proto_node.Staking: + utils.Logger().Debug().Msg("NET: received message: Node/Staking") + node.stakingMessageHandler(msgPayload) + case proto_node.Block: + utils.Logger().Debug().Msg("NET: received message: Node/Block") + if len(msgPayload) < 1 { + utils.Logger().Debug().Msgf("Invalid block message size") + return errors.WithStack(errWrongBlockMsgSize) } - case proto.Node: - actionType := proto_node.MessageType(msgType) - switch actionType { - case proto_node.Transaction: - utils.Logger().Debug().Msg("NET: received message: Node/Transaction") - node.transactionMessageHandler(msgPayload) - case proto_node.Staking: - utils.Logger().Debug().Msg("NET: received message: Node/Staking") - node.stakingMessageHandler(msgPayload) - case proto_node.Block: - utils.Logger().Debug().Msg("NET: received message: Node/Block") - if len(msgPayload) < 1 { - utils.Logger().Debug().Msgf("Invalid block message size") - return - } - switch blockMsgType := proto_node.BlockMessageType(msgPayload[0]); blockMsgType { - case proto_node.Sync: - utils.Logger().Debug().Msg("NET: received message: Node/Sync") - blocks := []*types.Block{} - if err := rlp.DecodeBytes(msgPayload[1:], &blocks); err != nil { - utils.Logger().Error(). - Err(err). - Msg("block sync") - } else { - // for non-beaconchain node, subscribe to beacon block broadcast - if node.Blockchain().ShardID() != shard.BeaconChainShardID && - node.NodeConfig.Role() != nodeconfig.ExplorerNode { - for _, block := range blocks { - if block.ShardID() == 0 { - utils.Logger().Info(). - Msgf("Beacon block being handled by block channel: %d", block.NumberU64()) - go func(blk *types.Block) { - node.BeaconBlockChannel <- blk - }(block) - } - } - } - if node.Client != nil && node.Client.UpdateBlocks != nil && blocks != nil { - utils.Logger().Info().Msg("Block being handled by client") - node.Client.UpdateBlocks(blocks) + switch blockMsgType := proto_node.BlockMessageType(msgPayload[0]); blockMsgType { + case proto_node.Sync: + utils.Logger().Debug().Msg("NET: received message: Node/Sync") + blocks := []*types.Block{} + if err := rlp.DecodeBytes(msgPayload[1:], &blocks); err != nil { + return err + } + // for non-beaconchain node, subscribe to beacon block broadcast + if node.Blockchain().ShardID() != shard.BeaconChainShardID && + node.NodeConfig.Role() != nodeconfig.ExplorerNode { + for _, block := range blocks { + if block.ShardID() == 0 { + utils.Logger().Info(). + Uint64("block", blocks[0].NumberU64()). + Msgf("Beacon block being handled by block channel: %d", block.NumberU64()) + go func(blk *types.Block) { + node.BeaconBlockChannel <- blk + }(block) } } - case - proto_node.SlashCandidate, - proto_node.Receipt, - proto_node.CrossLink: - // skip first byte which is blockMsgType - node.processSkippedMsgTypeByteValue(blockMsgType, msgPayload[1:]) } + if node.Client != nil && node.Client.UpdateBlocks != nil && blocks != nil { + utils.Logger().Info().Msg("Block being handled by client") + node.Client.UpdateBlocks(blocks) + } + + case + proto_node.SlashCandidate, + proto_node.Receipt, + proto_node.CrossLink: + // skip first byte which is blockMsgType + node.processSkippedMsgTypeByteValue(blockMsgType, msgPayload[1:]) } - default: - utils.Logger().Error(). - Str("Unknown MsgCateogry", string(msgCategory)) } + + return nil } func (node *Node) transactionMessageHandler(msgPayload []byte) { @@ -320,6 +293,9 @@ func (node *Node) BroadcastCrossLink() { // VerifyNewBlock is called by consensus participants to verify the block (account model) they are // running consensus on func (node *Node) VerifyNewBlock(newBlock *types.Block) error { + if newBlock == nil || newBlock.Header() == nil { + return errors.New("nil header or block asked to verify") + } if err := node.Blockchain().Validator().ValidateHeader(newBlock, true); err != nil { utils.Logger().Error(). Str("blockHash", newBlock.Hash().Hex()). @@ -442,9 +418,6 @@ func (node *Node) PostConsensusProcessing( Str("hash", newBlock.Header().Hash().Hex()). Msg("Added New Block to Blockchain!!!") - // Update last consensus time for metrics - // TODO: randomly selected a few validators to broadcast messages instead of only leader broadcast - // TODO: refactor the asynchronous calls to separate go routine. if node.Consensus.IsLeader() { if node.NodeConfig.ShardID == shard.BeaconChainShardID { node.BroadcastNewBlock(newBlock) @@ -477,10 +450,6 @@ func (node *Node) PostConsensusProcessing( // Broadcast client requested missing cross shard receipts if there is any node.BroadcastMissingCXReceipts() - // Clear metrics after one consensus cycle - node.host.ResetMetrics() - utils.Logger().Debug().Msg("[metrics][p2p] Reset after 1 consensus cycle") - // Update consensus keys at last so the change of leader status doesn't mess up normal flow if len(newBlock.Header().ShardState()) > 0 { node.Consensus.SetMode(node.Consensus.UpdateConsensusInformation()) @@ -499,8 +468,9 @@ func (node *Node) PostConsensusProcessing( computed := availability.ComputeCurrentSigning( snapshot.Validator, wrapper, ) - beaconChainBlocks := uint64(node.Beaconchain().CurrentBlock().Header().Number().Int64()) % - shard.Schedule.BlocksPerEpoch() + beaconChainBlocks := uint64( + node.Beaconchain().CurrentBlock().Header().Number().Int64(), + ) % shard.Schedule.BlocksPerEpoch() computed.BlocksLeftInEpoch = shard.Schedule.BlocksPerEpoch() - beaconChainBlocks if err != nil && computed.IsBelowThreshold { @@ -548,8 +518,3 @@ func (node *Node) BootstrapConsensus() error { return nil } } - -// ConsensusMessageHandler passes received message in node_handler to consensus -func (node *Node) ConsensusMessageHandler(msgPayload []byte) { - node.Consensus.MsgChan <- msgPayload -} diff --git a/p2p/host.go b/p2p/host.go index cda34509b0..6e82d4f592 100644 --- a/p2p/host.go +++ b/p2p/host.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "os" + "runtime" "strings" "sync" @@ -15,7 +16,6 @@ import ( libp2p "github.com/libp2p/go-libp2p" libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto" libp2p_host "github.com/libp2p/go-libp2p-core/host" - libp2p_metrics "github.com/libp2p/go-libp2p-core/metrics" libp2p_network "github.com/libp2p/go-libp2p-core/network" libp2p_peer "github.com/libp2p/go-libp2p-core/peer" libp2p_peerstore "github.com/libp2p/go-libp2p-core/peerstore" @@ -35,12 +35,9 @@ type Host interface { ConnectHostPeer(Peer) error // SendMessageToGroups sends a message to one or more multicast groups. SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) error - AllTopics() []*libp2p_pubsub.Topic + PubSub() *libp2p_pubsub.PubSub C() (int, int, int) - // libp2p.metrics related - GetBandwidthTotals() libp2p_metrics.Stats - LogRecvMessage(msg []byte) - ResetMetrics() + GetOrJoin(topic string) (*libp2p_pubsub.Topic, error) } // Peer is the object for a p2p peer (node) @@ -52,19 +49,14 @@ type Peer struct { PeerID libp2p_peer.ID // PeerID, the pubkey for communication } -func (p Peer) String() string { - BLSPubKey := "nil" - if p.ConsensusPubKey != nil { - BLSPubKey = p.ConsensusPubKey.SerializeToHexStr() - } - return fmt.Sprintf( - "BLSPubKey:%s-%s/%s[%d]", BLSPubKey, - net.JoinHostPort(p.IP, p.Port), p.PeerID, len(p.Addrs), - ) -} - const ( - // MaxMessageSize is the 2048Kb + // SetAsideForConsensus set the number of active validation goroutines for the consensus topic + SetAsideForConsensus = 1 << 13 + // SetAsideOtherwise set the number of active validation goroutines for other topic + SetAsideOtherwise = 1 << 13 + // MaxMessageHandlers .. + MaxMessageHandlers = SetAsideForConsensus + SetAsideOtherwise + // MaxMessageSize is 2Mb MaxMessageSize = 1 << 21 ) @@ -75,6 +67,7 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { return nil, errors.Wrapf(err, "cannot create listen multiaddr from port %#v", self.Port) } + ctx := context.Background() p2pHost, err := libp2p.New(ctx, libp2p.ListenAddrs(listenAddr), @@ -87,7 +80,14 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { } options := []libp2p_pubsub.Option{ + // WithValidateQueueSize sets the buffer of validate queue. Defaults to 32. When queue is full, validation is throttled and new messages are dropped. + libp2p_pubsub.WithValidateQueueSize(512), + // WithPeerOutboundQueueSize is an option to set the buffer size for outbound messages to a peer. We start dropping messages to a peer if the outbound queue if full. libp2p_pubsub.WithPeerOutboundQueueSize(64), + // WithValidateWorkers sets the number of synchronous validation worker goroutines. Defaults to NumCPU. + libp2p_pubsub.WithValidateWorkers(runtime.NumCPU() * 2), + // WithValidateThrottle sets the upper bound on the number of active validation goroutines across all topics. The default is 8192. + libp2p_pubsub.WithValidateThrottle(MaxMessageHandlers), libp2p_pubsub.WithMaxMessageSize(MaxMessageSize), } @@ -120,22 +120,20 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { self.PeerID = p2pHost.ID() subLogger := utils.Logger().With().Str("hostID", p2pHost.ID().Pretty()).Logger() - newMetrics := libp2p_metrics.NewBandwidthCounter() - // has to save the private key for host h := &HostV2{ - h: p2pHost, - joiner: topicJoiner{pubsub}, - joined: map[string]*libp2p_pubsub.Topic{}, - self: *self, - priKey: key, - logger: &subLogger, - metrics: newMetrics, + h: p2pHost, + pubsub: pubsub, + joined: map[string]*libp2p_pubsub.Topic{}, + self: *self, + priKey: key, + logger: &subLogger, } if err != nil { return nil, err } + utils.Logger().Info(). Str("self", net.JoinHostPort(self.IP, self.Port)). Interface("PeerID", self.PeerID). @@ -144,30 +142,20 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { return h, nil } -type topicJoiner struct { - pubsub *libp2p_pubsub.PubSub -} - -func (tj topicJoiner) JoinTopic(topic string) (*libp2p_pubsub.Topic, error) { - th, err := tj.pubsub.Join(topic) - if err != nil { - return nil, err - } - return th, nil -} - // HostV2 is the version 2 p2p host type HostV2 struct { h libp2p_host.Host - joiner topicJoiner + pubsub *libp2p_pubsub.PubSub joined map[string]*libp2p_pubsub.Topic self Peer priKey libp2p_crypto.PrivKey lock sync.Mutex - // logger logger *zerolog.Logger - // metrics - metrics *libp2p_metrics.BandwidthCounter +} + +// PubSub .. +func (host *HostV2) PubSub() *libp2p_pubsub.PubSub { + return host.pubsub } // C .. -> (total known peers, connected, not connected) @@ -185,12 +173,13 @@ func (host *HostV2) C() (int, int, int) { return len(peers), connected, not } -func (host *HostV2) getTopic(topic string) (*libp2p_pubsub.Topic, error) { +// GetOrJoin .. +func (host *HostV2) GetOrJoin(topic string) (*libp2p_pubsub.Topic, error) { host.lock.Lock() defer host.lock.Unlock() if t, ok := host.joined[topic]; ok { return t, nil - } else if t, err := host.joiner.JoinTopic(topic); err != nil { + } else if t, err := host.pubsub.Join(topic); err != nil { return nil, errors.Wrapf(err, "cannot join pubsub topic %x", topic) } else { host.joined[topic] = t @@ -203,24 +192,23 @@ func (host *HostV2) getTopic(topic string) (*libp2p_pubsub.Topic, error) { // message for sending. func (host *HostV2) SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) (err error) { + if len(msg) == 0 { + return errors.New("cannot send out empty message") + } + for _, group := range groups { - t, e := host.getTopic(string(group)) + t, e := host.GetOrJoin(string(group)) if e != nil { err = e continue } + e = t.Publish(context.Background(), msg) if e != nil { err = e continue } - // log out-going metrics - host.metrics.LogSentMessage(int64(len(msg))) } - host.logger.Debug(). - Int64("TotalOut", host.GetBandwidthTotals().TotalOut). - Float64("RateOut", host.GetBandwidthTotals().RateOut). - Msg("[metrics][p2p] traffic out in bytes") return err } @@ -277,21 +265,6 @@ func (host *HostV2) GetPeerCount() int { return host.h.Peerstore().Peers().Len() } -// GetBandwidthTotals returns total bandwidth of a node -func (host *HostV2) GetBandwidthTotals() libp2p_metrics.Stats { - return host.metrics.GetBandwidthTotals() -} - -// LogRecvMessage logs received message on node -func (host *HostV2) LogRecvMessage(msg []byte) { - host.metrics.LogRecvMessage(int64(len(msg))) -} - -// ResetMetrics resets metrics counters -func (host *HostV2) ResetMetrics() { - host.metrics.Reset() -} - // ConnectHostPeer connects to peer host func (host *HostV2) ConnectHostPeer(peer Peer) error { ctx := context.Background() @@ -314,15 +287,11 @@ func (host *HostV2) ConnectHostPeer(peer Peer) error { return nil } -// AllTopics .. -func (host *HostV2) AllTopics() []*libp2p_pubsub.Topic { - host.lock.Lock() - defer host.lock.Unlock() - topics := []*libp2p_pubsub.Topic{} - for _, g := range host.joined { - topics = append(topics, g) - } - return topics +// NamedTopic represents pubsub topic +// Name is the human readable topic, groupID +type NamedTopic struct { + Name string + Topic *libp2p_pubsub.Topic } // ConstructMessage constructs the p2p message as [messageType, contentSize, content] diff --git a/test/deploy.sh b/test/deploy.sh index 1770f4115b..3aee75aa44 100755 --- a/test/deploy.sh +++ b/test/deploy.sh @@ -99,7 +99,7 @@ SYNC=true NETWORK=localnet VERBOSE=false -while getopts "hD:m:s:nBN:" option; do +while getopts "hD:m:s:nBN:v" option; do case $option in h) usage ;; D) DURATION=$OPTARG ;;