[stream] removed epoch state related experimental code.

pull/3583/head
Jacky Wang 4 years ago
parent 5eb1cf1d1e
commit 1158f5a263
No known key found for this signature in database
GPG Key ID: 1085CE5F4FF5842C
  1. 34
      p2p/stream/protocols/sync/chain.go
  2. 42
      p2p/stream/protocols/sync/chain_test.go
  3. 52
      p2p/stream/protocols/sync/client.go
  4. 71
      p2p/stream/protocols/sync/client_test.go
  5. 30
      p2p/stream/protocols/sync/message/compose.go
  6. 406
      p2p/stream/protocols/sync/message/msg.pb.go
  7. 11
      p2p/stream/protocols/sync/message/msg.proto
  8. 16
      p2p/stream/protocols/sync/message/parse.go
  9. 29
      p2p/stream/protocols/sync/stream.go
  10. 25
      p2p/stream/protocols/sync/stream_test.go
  11. 60
      p2p/stream/protocols/sync/utils.go

@ -1,9 +1,6 @@
package sync
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/consensus/engine"
@ -18,7 +15,6 @@ type chainHelper interface {
getBlockHashes(bns []uint64) []common.Hash
getBlocksByNumber(bns []uint64) ([]*types.Block, error)
getBlocksByHashes(hs []common.Hash) ([]*types.Block, error)
getEpochState(epoch uint64) (*EpochStateResult, error)
}
type chainHelperImpl struct {
@ -137,33 +133,3 @@ func (ch *chainHelperImpl) getBlockSigFromNextBlock(header *block.Header) []byte
func (ch *chainHelperImpl) getBlockSigFromDB(header *block.Header) ([]byte, error) {
return ch.chain.ReadCommitSig(header.Number().Uint64())
}
func (ch *chainHelperImpl) getEpochState(epoch uint64) (*EpochStateResult, error) {
if ch.chain.ShardID() != 0 {
return nil, errors.New("get epoch state currently unavailable on side chain")
}
if epoch == 0 {
return nil, errors.New("nil shard state for epoch 0")
}
res := &EpochStateResult{}
targetBN := ch.schedule.EpochLastBlock(epoch - 1)
res.Header = ch.chain.GetHeaderByNumber(targetBN)
if res.Header == nil {
// we still don't have the given epoch
return res, nil
}
epochBI := new(big.Int).SetUint64(epoch)
if ch.chain.Config().IsPreStaking(epochBI) {
// For epoch before preStaking, only hash is stored in header
ss, err := ch.chain.ReadShardState(epochBI)
if err != nil {
return nil, err
}
if ss == nil {
return nil, fmt.Errorf("missing shard state for [EPOCH-%v]", epoch)
}
res.State = ss
}
return res, nil
}

@ -13,7 +13,6 @@ import (
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core/types"
syncpb "github.com/harmony-one/harmony/p2p/stream/protocols/sync/message"
"github.com/harmony-one/harmony/shard"
)
type testChainHelper struct{}
@ -30,19 +29,6 @@ func (tch *testChainHelper) getBlocksByNumber(bns []uint64) ([]*types.Block, err
return blocks, nil
}
func (tch *testChainHelper) getEpochState(epoch uint64) (*EpochStateResult, error) {
header := &block.Header{Header: testHeader.Copy()}
header.SetEpoch(big.NewInt(int64(epoch - 1)))
state := testEpochState.DeepCopy()
state.Epoch = big.NewInt(int64(epoch))
return &EpochStateResult{
Header: header,
State: state,
}, nil
}
func (tch *testChainHelper) getBlockHashes(bns []uint64) []common.Hash {
hs := make([]common.Hash, 0, len(bns))
for _, bn := range bns {
@ -117,34 +103,6 @@ func decodeBlocksBytes(bbs [][]byte) ([]*types.Block, error) {
return blocks, nil
}
func checkEpochStateResult(epoch uint64, b []byte) error {
var msg = &syncpb.Message{}
if err := protobuf.Unmarshal(b, msg); err != nil {
return err
}
geResp, err := msg.GetEpochStateResponse()
if err != nil {
return err
}
var (
header *block.Header
epochState *shard.State
)
if err := rlp.DecodeBytes(geResp.HeaderBytes, &header); err != nil {
return err
}
if err := rlp.DecodeBytes(geResp.ShardState, &epochState); err != nil {
return err
}
if header.Epoch().Uint64() != epoch-1 {
return fmt.Errorf("unexpected epoch of header %v / %v", header.Epoch(), epoch-1)
}
if epochState.Epoch.Uint64() != epoch {
return fmt.Errorf("unexpected epoch of shard state %v / %v", epochState.Epoch.Uint64(), epoch)
}
return nil
}
func checkBlockNumberResult(b []byte) error {
var msg = &syncpb.Message{}
if err := protobuf.Unmarshal(b, msg); err != nil {

@ -38,24 +38,6 @@ func (p *Protocol) GetBlocksByNumber(ctx context.Context, bns []uint64, opts ...
return blocks, stid, nil
}
// GetEpochState get the epoch block from querying the remote node running sync stream protocol.
// Currently, this method is only supported by beacon syncer.
// Note: use this after epoch chain is implemented.
func (p *Protocol) GetEpochState(ctx context.Context, epoch uint64, opts ...Option) (*EpochStateResult, sttypes.StreamID, error) {
req := newGetEpochBlockRequest(epoch)
resp, stid, err := p.rm.DoRequest(ctx, req, opts...)
if err != nil {
return nil, stid, err
}
res, err := epochStateResultFromResponse(resp)
if err != nil {
return nil, stid, err
}
return res, stid, nil
}
// GetCurrentBlockNumber get the current block number from remote node
func (p *Protocol) GetCurrentBlockNumber(ctx context.Context, opts ...Option) (uint64, sttypes.StreamID, error) {
req := newGetBlockNumberRequest()
@ -187,40 +169,6 @@ func (req *getBlocksByNumberRequest) parseBlockBytesAndSigs(resp *syncResponse)
return gbResp.BlocksBytes, gbResp.CommitSig, nil
}
type getEpochBlockRequest struct {
epoch uint64
pbReq *syncpb.Request
}
func newGetEpochBlockRequest(epoch uint64) *getEpochBlockRequest {
pbReq := syncpb.MakeGetEpochStateRequest(epoch)
return &getEpochBlockRequest{
epoch: epoch,
pbReq: pbReq,
}
}
func (req *getEpochBlockRequest) ReqID() uint64 {
return req.pbReq.GetReqId()
}
func (req *getEpochBlockRequest) SetReqID(val uint64) {
req.pbReq.ReqId = val
}
func (req *getEpochBlockRequest) String() string {
return fmt.Sprintf("REQUEST [GetEpochBlock: %v]", req.epoch)
}
func (req *getEpochBlockRequest) IsSupportedByProto(target sttypes.ProtoSpec) bool {
return target.Version.GreaterThanOrEqual(MinVersion)
}
func (req *getEpochBlockRequest) Encode() ([]byte, error) {
msg := syncpb.MakeMessageFromRequest(req.pbReq)
return protobuf.Marshal(msg)
}
type getBlockNumberRequest struct {
pbReq *syncpb.Request
}

@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"math/big"
"strings"
"testing"
@ -18,12 +17,10 @@ import (
"github.com/harmony-one/harmony/p2p/stream/common/streammanager"
syncpb "github.com/harmony-one/harmony/p2p/stream/protocols/sync/message"
sttypes "github.com/harmony-one/harmony/p2p/stream/types"
"github.com/harmony-one/harmony/shard"
)
var (
_ sttypes.Request = &getBlocksByNumberRequest{}
_ sttypes.Request = &getEpochBlockRequest{}
_ sttypes.Request = &getBlockNumberRequest{}
_ sttypes.Response = &syncResponse{&syncpb.Response{}}
)
@ -44,13 +41,6 @@ var (
testBlockBytes, _ = rlp.EncodeToBytes(testBlock)
testBlockResponse = syncpb.MakeGetBlocksByNumResponse(0, [][]byte{testBlockBytes}, make([][]byte, 1))
testEpochState = &shard.State{
Epoch: new(big.Int).SetInt64(1),
Shards: []shard.Committee{},
}
testEpochStateBytes, _ = rlp.EncodeToBytes(testEpochState)
testEpochStateResponse = syncpb.MakeGetEpochStateResponse(0, testHeaderBytes, testEpochStateBytes)
testCurBlockNumber uint64 = 100
testBlockNumberResponse = syncpb.MakeGetBlockNumberResponse(0, testCurBlockNumber)
@ -80,7 +70,7 @@ func TestProtocol_GetBlocksByNumber(t *testing.T) {
{
getResponse: func(request sttypes.Request) (sttypes.Response, sttypes.StreamID) {
return &syncResponse{
pb: testEpochStateResponse,
pb: testBlockNumberResponse,
}, makeTestStreamID(0)
},
expErr: errors.New("not GetBlockByNumber"),
@ -119,65 +109,6 @@ func TestProtocol_GetBlocksByNumber(t *testing.T) {
}
}
func TestProtocol_GetEpochState(t *testing.T) {
tests := []struct {
getResponse getResponseFn
expErr error
expStID sttypes.StreamID
}{
{
getResponse: func(request sttypes.Request) (sttypes.Response, sttypes.StreamID) {
return &syncResponse{
pb: testEpochStateResponse,
}, makeTestStreamID(0)
},
expErr: nil,
expStID: makeTestStreamID(0),
},
{
getResponse: func(request sttypes.Request) (sttypes.Response, sttypes.StreamID) {
return &syncResponse{
pb: testBlockResponse,
}, makeTestStreamID(0)
},
expErr: errors.New("not GetEpochStateResponse"),
expStID: makeTestStreamID(0),
},
{
getResponse: nil,
expErr: errors.New("get response error"),
expStID: "",
},
{
getResponse: func(request sttypes.Request) (sttypes.Response, sttypes.StreamID) {
return &syncResponse{
pb: testErrorResponse,
}, makeTestStreamID(0)
},
expErr: errors.New("test error"),
expStID: makeTestStreamID(0),
},
}
for i, test := range tests {
protocol := makeTestProtocol(test.getResponse)
res, stid, err := protocol.GetEpochState(context.Background(), 0)
if assErr := assertError(err, test.expErr); assErr != nil {
t.Errorf("Test %v: %v", i, assErr)
continue
}
if stid != test.expStID {
t.Errorf("Test %v: unexpected st id: %v / %v", i, stid, test.expStID)
}
if test.expErr == nil {
if gotEpoch := res.State.Epoch; gotEpoch.Cmp(new(big.Int).SetUint64(1)) != 0 {
t.Errorf("Test %v: unexpected epoch delivered: %v / %v", i, gotEpoch.String(), 1)
}
}
}
}
func TestProtocol_GetCurrentBlockNumber(t *testing.T) {
tests := []struct {
getResponse getResponseFn

@ -46,17 +46,6 @@ func MakeGetBlocksByHashesRequest(hashes []common.Hash) *Request {
}
}
// MakeGetEpochStateRequest make GetEpochBlock request
func MakeGetEpochStateRequest(epoch uint64) *Request {
return &Request{
Request: &Request_GetEpochStateRequest{
GetEpochStateRequest: &GetEpochStateRequest{
Epoch: epoch,
},
},
}
}
// MakeErrorResponse makes the error response
func MakeErrorResponseMessage(rid uint64, err error) *Message {
resp := MakeErrorResponse(rid, err)
@ -149,25 +138,6 @@ func MakeGetBlocksByHashesResponse(rid uint64, blocksBytes [][]byte, sigs [][]by
}
}
// MakeGetEpochStateResponse makes GetEpochStateResponse as message
func MakeGetEpochStateResponseMessage(rid uint64, headerBytes []byte, ssBytes []byte) *Message {
resp := MakeGetEpochStateResponse(rid, headerBytes, ssBytes)
return makeMessageFromResponse(resp)
}
// MakeEpochStateResponse makes GetEpochStateResponse as response
func MakeGetEpochStateResponse(rid uint64, headerBytes []byte, ssBytes []byte) *Response {
return &Response{
ReqId: rid,
Response: &Response_GetEpochStateResponse{
GetEpochStateResponse: &GetEpochStateResponse{
HeaderBytes: headerBytes,
ShardState: ssBytes,
},
},
}
}
// MakeMessageFromRequest makes a message from the request
func MakeMessageFromRequest(req *Request) *Message {
return &Message{

@ -116,7 +116,6 @@ type Request struct {
// *Request_GetBlockHashesRequest
// *Request_GetBlocksByNumRequest
// *Request_GetBlocksByHashesRequest
// *Request_GetEpochStateRequest
Request isRequest_Request `protobuf_oneof:"request"`
}
@ -194,13 +193,6 @@ func (x *Request) GetGetBlocksByHashesRequest() *GetBlocksByHashesRequest {
return nil
}
func (x *Request) GetGetEpochStateRequest() *GetEpochStateRequest {
if x, ok := x.GetRequest().(*Request_GetEpochStateRequest); ok {
return x.GetEpochStateRequest
}
return nil
}
type isRequest_Request interface {
isRequest_Request()
}
@ -221,10 +213,6 @@ type Request_GetBlocksByHashesRequest struct {
GetBlocksByHashesRequest *GetBlocksByHashesRequest `protobuf:"bytes,5,opt,name=get_blocks_by_hashes_request,json=getBlocksByHashesRequest,proto3,oneof"`
}
type Request_GetEpochStateRequest struct {
GetEpochStateRequest *GetEpochStateRequest `protobuf:"bytes,6,opt,name=get_epoch_state_request,json=getEpochStateRequest,proto3,oneof"`
}
func (*Request_GetBlockNumberRequest) isRequest_Request() {}
func (*Request_GetBlockHashesRequest) isRequest_Request() {}
@ -233,8 +221,6 @@ func (*Request_GetBlocksByNumRequest) isRequest_Request() {}
func (*Request_GetBlocksByHashesRequest) isRequest_Request() {}
func (*Request_GetEpochStateRequest) isRequest_Request() {}
type GetBlockNumberRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -414,53 +400,6 @@ func (x *GetBlocksByHashesRequest) GetBlockHashes() [][]byte {
return nil
}
type GetEpochStateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"`
}
func (x *GetEpochStateRequest) Reset() {
*x = GetEpochStateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEpochStateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEpochStateRequest) ProtoMessage() {}
func (x *GetEpochStateRequest) ProtoReflect() protoreflect.Message {
mi := &file_msg_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)
}
// Deprecated: Use GetEpochStateRequest.ProtoReflect.Descriptor instead.
func (*GetEpochStateRequest) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{6}
}
func (x *GetEpochStateRequest) GetEpoch() uint64 {
if x != nil {
return x.Epoch
}
return 0
}
type Response struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -473,14 +412,13 @@ type Response struct {
// *Response_GetBlockHashesResponse
// *Response_GetBlocksByNumResponse
// *Response_GetBlocksByHashesResponse
// *Response_GetEpochStateResponse
Response isResponse_Response `protobuf_oneof:"response"`
}
func (x *Response) Reset() {
*x = Response{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[7]
mi := &file_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -493,7 +431,7 @@ func (x *Response) String() string {
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[7]
mi := &file_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -506,7 +444,7 @@ func (x *Response) ProtoReflect() protoreflect.Message {
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{7}
return file_msg_proto_rawDescGZIP(), []int{6}
}
func (x *Response) GetReqId() uint64 {
@ -558,13 +496,6 @@ func (x *Response) GetGetBlocksByHashesResponse() *GetBlocksByHashesResponse {
return nil
}
func (x *Response) GetGetEpochStateResponse() *GetEpochStateResponse {
if x, ok := x.GetResponse().(*Response_GetEpochStateResponse); ok {
return x.GetEpochStateResponse
}
return nil
}
type isResponse_Response interface {
isResponse_Response()
}
@ -589,10 +520,6 @@ type Response_GetBlocksByHashesResponse struct {
GetBlocksByHashesResponse *GetBlocksByHashesResponse `protobuf:"bytes,6,opt,name=get_blocks_by_hashes_response,json=getBlocksByHashesResponse,proto3,oneof"`
}
type Response_GetEpochStateResponse struct {
GetEpochStateResponse *GetEpochStateResponse `protobuf:"bytes,7,opt,name=get_epoch_state_response,json=getEpochStateResponse,proto3,oneof"`
}
func (*Response_ErrorResponse) isResponse_Response() {}
func (*Response_GetBlockNumberResponse) isResponse_Response() {}
@ -603,8 +530,6 @@ func (*Response_GetBlocksByNumResponse) isResponse_Response() {}
func (*Response_GetBlocksByHashesResponse) isResponse_Response() {}
func (*Response_GetEpochStateResponse) isResponse_Response() {}
type ErrorResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -616,7 +541,7 @@ type ErrorResponse struct {
func (x *ErrorResponse) Reset() {
*x = ErrorResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[8]
mi := &file_msg_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -629,7 +554,7 @@ func (x *ErrorResponse) String() string {
func (*ErrorResponse) ProtoMessage() {}
func (x *ErrorResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[8]
mi := &file_msg_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -642,7 +567,7 @@ func (x *ErrorResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead.
func (*ErrorResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{8}
return file_msg_proto_rawDescGZIP(), []int{7}
}
func (x *ErrorResponse) GetError() string {
@ -663,7 +588,7 @@ type GetBlockNumberResponse struct {
func (x *GetBlockNumberResponse) Reset() {
*x = GetBlockNumberResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[9]
mi := &file_msg_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -676,7 +601,7 @@ func (x *GetBlockNumberResponse) String() string {
func (*GetBlockNumberResponse) ProtoMessage() {}
func (x *GetBlockNumberResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[9]
mi := &file_msg_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -689,7 +614,7 @@ func (x *GetBlockNumberResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBlockNumberResponse.ProtoReflect.Descriptor instead.
func (*GetBlockNumberResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{9}
return file_msg_proto_rawDescGZIP(), []int{8}
}
func (x *GetBlockNumberResponse) GetNumber() uint64 {
@ -710,7 +635,7 @@ type GetBlockHashesResponse struct {
func (x *GetBlockHashesResponse) Reset() {
*x = GetBlockHashesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[10]
mi := &file_msg_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -723,7 +648,7 @@ func (x *GetBlockHashesResponse) String() string {
func (*GetBlockHashesResponse) ProtoMessage() {}
func (x *GetBlockHashesResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[10]
mi := &file_msg_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -736,7 +661,7 @@ func (x *GetBlockHashesResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBlockHashesResponse.ProtoReflect.Descriptor instead.
func (*GetBlockHashesResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{10}
return file_msg_proto_rawDescGZIP(), []int{9}
}
func (x *GetBlockHashesResponse) GetHashes() [][]byte {
@ -758,7 +683,7 @@ type GetBlocksByNumResponse struct {
func (x *GetBlocksByNumResponse) Reset() {
*x = GetBlocksByNumResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[11]
mi := &file_msg_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -771,7 +696,7 @@ func (x *GetBlocksByNumResponse) String() string {
func (*GetBlocksByNumResponse) ProtoMessage() {}
func (x *GetBlocksByNumResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[11]
mi := &file_msg_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -784,7 +709,7 @@ func (x *GetBlocksByNumResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBlocksByNumResponse.ProtoReflect.Descriptor instead.
func (*GetBlocksByNumResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{11}
return file_msg_proto_rawDescGZIP(), []int{10}
}
func (x *GetBlocksByNumResponse) GetBlocksBytes() [][]byte {
@ -813,7 +738,7 @@ type GetBlocksByHashesResponse struct {
func (x *GetBlocksByHashesResponse) Reset() {
*x = GetBlocksByHashesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[12]
mi := &file_msg_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -826,7 +751,7 @@ func (x *GetBlocksByHashesResponse) String() string {
func (*GetBlocksByHashesResponse) ProtoMessage() {}
func (x *GetBlocksByHashesResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[12]
mi := &file_msg_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -839,7 +764,7 @@ func (x *GetBlocksByHashesResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBlocksByHashesResponse.ProtoReflect.Descriptor instead.
func (*GetBlocksByHashesResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{12}
return file_msg_proto_rawDescGZIP(), []int{11}
}
func (x *GetBlocksByHashesResponse) GetBlocksBytes() [][]byte {
@ -856,61 +781,6 @@ func (x *GetBlocksByHashesResponse) GetCommitSig() [][]byte {
return nil
}
type GetEpochStateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
HeaderBytes []byte `protobuf:"bytes,1,opt,name=header_bytes,json=headerBytes,proto3" json:"header_bytes,omitempty"`
ShardState []byte `protobuf:"bytes,2,opt,name=shard_state,json=shardState,proto3" json:"shard_state,omitempty"`
}
func (x *GetEpochStateResponse) Reset() {
*x = GetEpochStateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEpochStateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEpochStateResponse) ProtoMessage() {}
func (x *GetEpochStateResponse) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetEpochStateResponse.ProtoReflect.Descriptor instead.
func (*GetEpochStateResponse) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{13}
}
func (x *GetEpochStateResponse) GetHeaderBytes() []byte {
if x != nil {
return x.HeaderBytes
}
return nil
}
func (x *GetEpochStateResponse) GetShardState() []byte {
if x != nil {
return x.ShardState
}
return nil
}
var File_msg_proto protoreflect.FileDescriptor
var file_msg_proto_rawDesc = []byte{
@ -925,7 +795,7 @@ var file_msg_proto_rawDesc = []byte{
0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79,
0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x04, 0x72, 0x65, 0x73, 0x70, 0x42, 0x0d, 0x0a, 0x0b, 0x72,
0x65, 0x71, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x22, 0xde, 0x04, 0x0a, 0x07, 0x52,
0x65, 0x71, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x22, 0xf2, 0x03, 0x0a, 0x07, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x71, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x72, 0x65, 0x71, 0x49, 0x64, 0x12, 0x6d, 0x0a,
0x18, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65,
@ -956,100 +826,78 @@ var file_msg_proto_rawDesc = []byte{
0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x18, 0x67, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x6a, 0x0a, 0x17, 0x67, 0x65, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63,
0x68, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18,
0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e,
0x75, 0x65, 0x73, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22,
0x17, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65,
0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x16, 0x0a, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x42,
0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x16, 0x0a, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04,
0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x3d, 0x0a, 0x18, 0x47, 0x65,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f,
0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0xd5, 0x04, 0x0a, 0x08, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x71, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x72, 0x65, 0x71, 0x49, 0x64, 0x12, 0x53, 0x0a,
0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e,
0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x14, 0x67, 0x65, 0x74, 0x45,
0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x42, 0x09, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x17, 0x0a, 0x15, 0x47,
0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a,
0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52,
0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16,
0x0a, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01,
0x52, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x3d, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68,
0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48,
0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63,
0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a,
0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70,
0x6f, 0x63, 0x68, 0x22, 0xc4, 0x05, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x71, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
0x52, 0x05, 0x72, 0x65, 0x71, 0x49, 0x64, 0x12, 0x53, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x2a, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70, 0x0a, 0x19,
0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72,
0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65,
0x61, 0x67, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x70, 0x0a, 0x19, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f,
0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e,
0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70,
0x0a, 0x19, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68,
0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e,
0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x71, 0x0a, 0x1a, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62,
0x79, 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73,
0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75,
0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x7a, 0x0a, 0x1d, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x73, 0x5f, 0x62, 0x79, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x68, 0x61, 0x72,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70, 0x0a, 0x19, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e,
0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61,
0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16,
0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x1a, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72,
0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63,
0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x48, 0x00, 0x52, 0x19, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42,
0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x6d, 0x0a, 0x18, 0x67, 0x65, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x74, 0x61,
0x74, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x32, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e,
0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63,
0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a,
0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0d, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f,
0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e,
0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48,
0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a,
0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x06, 0x68,
0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x5a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74,
0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x69, 0x67,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69,
0x67, 0x22, 0x5d, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79,
0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21,
0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65,
0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69, 0x67,
0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x68, 0x65, 0x61,
0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x0b, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x0b,
0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, 0x09, 0x5a,
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48,
0x00, 0x52, 0x16, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75,
0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7a, 0x0a, 0x1d, 0x67, 0x65, 0x74,
0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65,
0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x36, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61,
0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47,
0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x19, 0x67, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x25, 0x0a, 0x0d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01,
0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0c, 0x52, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x5a, 0x0a, 0x16,
0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73,
0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d,
0x6d, 0x69, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69, 0x67, 0x22, 0x5d, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f,
0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
0x69, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69, 0x67, 0x42, 0x09, 0x5a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1064,7 +912,7 @@ func file_msg_proto_rawDescGZIP() []byte {
return file_msg_proto_rawDescData
}
var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_msg_proto_goTypes = []interface{}{
(*Message)(nil), // 0: harmony.stream.sync.message.Message
(*Request)(nil), // 1: harmony.stream.sync.message.Request
@ -1072,34 +920,30 @@ var file_msg_proto_goTypes = []interface{}{
(*GetBlockHashesRequest)(nil), // 3: harmony.stream.sync.message.GetBlockHashesRequest
(*GetBlocksByNumRequest)(nil), // 4: harmony.stream.sync.message.GetBlocksByNumRequest
(*GetBlocksByHashesRequest)(nil), // 5: harmony.stream.sync.message.GetBlocksByHashesRequest
(*GetEpochStateRequest)(nil), // 6: harmony.stream.sync.message.GetEpochStateRequest
(*Response)(nil), // 7: harmony.stream.sync.message.Response
(*ErrorResponse)(nil), // 8: harmony.stream.sync.message.ErrorResponse
(*GetBlockNumberResponse)(nil), // 9: harmony.stream.sync.message.GetBlockNumberResponse
(*GetBlockHashesResponse)(nil), // 10: harmony.stream.sync.message.GetBlockHashesResponse
(*GetBlocksByNumResponse)(nil), // 11: harmony.stream.sync.message.GetBlocksByNumResponse
(*GetBlocksByHashesResponse)(nil), // 12: harmony.stream.sync.message.GetBlocksByHashesResponse
(*GetEpochStateResponse)(nil), // 13: harmony.stream.sync.message.GetEpochStateResponse
(*Response)(nil), // 6: harmony.stream.sync.message.Response
(*ErrorResponse)(nil), // 7: harmony.stream.sync.message.ErrorResponse
(*GetBlockNumberResponse)(nil), // 8: harmony.stream.sync.message.GetBlockNumberResponse
(*GetBlockHashesResponse)(nil), // 9: harmony.stream.sync.message.GetBlockHashesResponse
(*GetBlocksByNumResponse)(nil), // 10: harmony.stream.sync.message.GetBlocksByNumResponse
(*GetBlocksByHashesResponse)(nil), // 11: harmony.stream.sync.message.GetBlocksByHashesResponse
}
var file_msg_proto_depIdxs = []int32{
1, // 0: harmony.stream.sync.message.Message.req:type_name -> harmony.stream.sync.message.Request
7, // 1: harmony.stream.sync.message.Message.resp:type_name -> harmony.stream.sync.message.Response
6, // 1: harmony.stream.sync.message.Message.resp:type_name -> harmony.stream.sync.message.Response
2, // 2: harmony.stream.sync.message.Request.get_block_number_request:type_name -> harmony.stream.sync.message.GetBlockNumberRequest
3, // 3: harmony.stream.sync.message.Request.get_block_hashes_request:type_name -> harmony.stream.sync.message.GetBlockHashesRequest
4, // 4: harmony.stream.sync.message.Request.get_blocks_by_num_request:type_name -> harmony.stream.sync.message.GetBlocksByNumRequest
5, // 5: harmony.stream.sync.message.Request.get_blocks_by_hashes_request:type_name -> harmony.stream.sync.message.GetBlocksByHashesRequest
6, // 6: harmony.stream.sync.message.Request.get_epoch_state_request:type_name -> harmony.stream.sync.message.GetEpochStateRequest
8, // 7: harmony.stream.sync.message.Response.error_response:type_name -> harmony.stream.sync.message.ErrorResponse
9, // 8: harmony.stream.sync.message.Response.get_block_number_response:type_name -> harmony.stream.sync.message.GetBlockNumberResponse
10, // 9: harmony.stream.sync.message.Response.get_block_hashes_response:type_name -> harmony.stream.sync.message.GetBlockHashesResponse
11, // 10: harmony.stream.sync.message.Response.get_blocks_by_num_response:type_name -> harmony.stream.sync.message.GetBlocksByNumResponse
12, // 11: harmony.stream.sync.message.Response.get_blocks_by_hashes_response:type_name -> harmony.stream.sync.message.GetBlocksByHashesResponse
13, // 12: harmony.stream.sync.message.Response.get_epoch_state_response:type_name -> harmony.stream.sync.message.GetEpochStateResponse
13, // [13:13] is the sub-list for method output_type
13, // [13:13] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name
13, // [13:13] is the sub-list for extension extendee
0, // [0:13] is the sub-list for field type_name
7, // 6: harmony.stream.sync.message.Response.error_response:type_name -> harmony.stream.sync.message.ErrorResponse
8, // 7: harmony.stream.sync.message.Response.get_block_number_response:type_name -> harmony.stream.sync.message.GetBlockNumberResponse
9, // 8: harmony.stream.sync.message.Response.get_block_hashes_response:type_name -> harmony.stream.sync.message.GetBlockHashesResponse
10, // 9: harmony.stream.sync.message.Response.get_blocks_by_num_response:type_name -> harmony.stream.sync.message.GetBlocksByNumResponse
11, // 10: harmony.stream.sync.message.Response.get_blocks_by_hashes_response:type_name -> harmony.stream.sync.message.GetBlocksByHashesResponse
11, // [11:11] is the sub-list for method output_type
11, // [11:11] 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_msg_proto_init() }
@ -1181,18 +1025,6 @@ func file_msg_proto_init() {
}
}
file_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEpochStateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
@ -1204,7 +1036,7 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
file_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ErrorResponse); i {
case 0:
return &v.state
@ -1216,7 +1048,7 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
file_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetBlockNumberResponse); i {
case 0:
return &v.state
@ -1228,7 +1060,7 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
file_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetBlockHashesResponse); i {
case 0:
return &v.state
@ -1240,7 +1072,7 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
file_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetBlocksByNumResponse); i {
case 0:
return &v.state
@ -1252,7 +1084,7 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
file_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetBlocksByHashesResponse); i {
case 0:
return &v.state
@ -1264,18 +1096,6 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEpochStateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_msg_proto_msgTypes[0].OneofWrappers = []interface{}{
(*Message_Req)(nil),
@ -1286,15 +1106,13 @@ func file_msg_proto_init() {
(*Request_GetBlockHashesRequest)(nil),
(*Request_GetBlocksByNumRequest)(nil),
(*Request_GetBlocksByHashesRequest)(nil),
(*Request_GetEpochStateRequest)(nil),
}
file_msg_proto_msgTypes[7].OneofWrappers = []interface{}{
file_msg_proto_msgTypes[6].OneofWrappers = []interface{}{
(*Response_ErrorResponse)(nil),
(*Response_GetBlockNumberResponse)(nil),
(*Response_GetBlockHashesResponse)(nil),
(*Response_GetBlocksByNumResponse)(nil),
(*Response_GetBlocksByHashesResponse)(nil),
(*Response_GetEpochStateResponse)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1302,7 +1120,7 @@ func file_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 14,
NumMessages: 12,
NumExtensions: 0,
NumServices: 0,
},

@ -17,7 +17,6 @@ message Request {
GetBlockHashesRequest get_block_hashes_request = 3;
GetBlocksByNumRequest get_blocks_by_num_request = 4;
GetBlocksByHashesRequest get_blocks_by_hashes_request = 5;
GetEpochStateRequest get_epoch_state_request = 6;
}
}
@ -35,10 +34,6 @@ message GetBlocksByHashesRequest {
repeated bytes block_hashes = 1;
}
message GetEpochStateRequest {
uint64 epoch = 1;
}
message Response {
uint64 req_id = 1;
oneof response {
@ -47,7 +42,6 @@ message Response {
GetBlockHashesResponse get_block_hashes_response = 4;
GetBlocksByNumResponse get_blocks_by_num_response = 5;
GetBlocksByHashesResponse get_blocks_by_hashes_response = 6;
GetEpochStateResponse get_epoch_state_response = 7;
}
}
@ -73,10 +67,5 @@ message GetBlocksByHashesResponse {
repeated bytes commit_sig = 2;
}
message GetEpochStateResponse {
bytes header_bytes = 1;
bytes shard_state = 2;
}

@ -79,19 +79,3 @@ func (msg *Message) GetBlocksByHashesResponse() (*GetBlocksByHashesResponse, err
}
return gbResp, nil
}
// GetEpochStateResponse parse the message to GetEpochStateResponse
func (msg *Message) GetEpochStateResponse() (*GetEpochStateResponse, error) {
resp := msg.GetResp()
if resp == nil {
return nil, errors.New("not response message")
}
if errResp := resp.GetErrorResponse(); errResp != nil {
return nil, &ResponseError{errResp.Error}
}
gesResp := resp.GetGetEpochStateResponse()
if gesResp == nil {
return nil, errors.New("not GetEpochStateResponse")
}
return gesResp, nil
}

@ -180,9 +180,6 @@ func (st *syncStream) handleReq(req *syncpb.Request) error {
if bhReq := req.GetGetBlocksByHashesRequest(); bhReq != nil {
return st.handleGetBlocksByHashesRequest(req.ReqId, bhReq)
}
if esReq := req.GetGetEpochStateRequest(); esReq != nil {
return st.handleEpochStateRequest(req.ReqId, esReq)
}
// unsupported request type
resp := syncpb.MakeErrorResponseMessage(req.ReqId, errUnknownReqType)
return st.writeMsg(resp)
@ -242,21 +239,6 @@ func (st *syncStream) handleGetBlocksByHashesRequest(rid uint64, req *syncpb.Get
return errors.Wrap(err, "[GetBlocksByHashes]")
}
func (st *syncStream) handleEpochStateRequest(rid uint64, req *syncpb.GetEpochStateRequest) error {
resp, err := st.computeEpochStateResp(rid, req.Epoch)
if err != nil {
resp = syncpb.MakeErrorResponseMessage(rid, err)
}
if writeErr := st.writeMsg(resp); writeErr != nil {
if err == nil {
err = writeErr
} else {
err = fmt.Errorf("%v; [writeMsg] %v", err.Error(), writeErr)
}
}
return errors.Wrap(err, "[GetEpochState]")
}
func (st *syncStream) handleResp(resp *syncpb.Response) {
st.protocol.rm.DeliverResponse(st.ID(), &syncResponse{resp})
}
@ -355,17 +337,6 @@ func (st *syncStream) computeRespFromBlockHashes(rid uint64, hs []common.Hash) (
return syncpb.MakeGetBlocksByHashesResponseMessage(rid, blocksBytes, sigs), nil
}
func (st *syncStream) computeEpochStateResp(rid uint64, epoch uint64) (*syncpb.Message, error) {
if epoch == 0 {
return nil, errors.New("Epoch 0 does not have shard state")
}
esRes, err := st.chain.getEpochState(epoch)
if err != nil {
return nil, err
}
return esRes.toMessage(rid)
}
func bytesToHashes(bs [][]byte) []common.Hash {
hs := make([]common.Hash, 0, len(bs))
for _, b := range bs {

@ -24,10 +24,6 @@ var (
testGetBlockRequest = syncpb.MakeGetBlocksByNumRequest(testGetBlockNumbers)
testGetBlockRequestMsg = syncpb.MakeMessageFromRequest(testGetBlockRequest)
testEpoch uint64 = 20
testEpochStateRequest = syncpb.MakeGetEpochStateRequest(testEpoch)
testEpochStateRequestMsg = syncpb.MakeMessageFromRequest(testEpochStateRequest)
testCurrentNumberRequest = syncpb.MakeGetBlockNumberRequest()
testCurrentNumberRequestMsg = syncpb.MakeMessageFromRequest(testCurrentNumberRequest)
@ -67,27 +63,6 @@ func TestSyncStream_HandleGetBlocksByRequest(t *testing.T) {
}
}
func TestSyncStream_HandleEpochStateRequest(t *testing.T) {
st, remoteSt := makeTestSyncStream()
go st.run()
defer close(st.closeC)
req := testEpochStateRequestMsg
b, _ := protobuf.Marshal(req)
err := remoteSt.WriteBytes(b)
if err != nil {
t.Fatal(err)
}
time.Sleep(200 * time.Millisecond)
receivedBytes, _ := remoteSt.ReadBytes()
if err := checkEpochStateResult(testEpoch, receivedBytes); err != nil {
t.Fatal(err)
}
}
func TestSyncStream_HandleCurrentBlockNumber(t *testing.T) {
st, remoteSt := makeTestSyncStream()

@ -3,13 +3,9 @@ package sync
import (
"fmt"
"github.com/ethereum/go-ethereum/rlp"
protobuf "github.com/golang/protobuf/proto"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/p2p/stream/common/requestmanager"
syncpb "github.com/harmony-one/harmony/p2p/stream/protocols/sync/message"
sttypes "github.com/harmony-one/harmony/p2p/stream/types"
"github.com/harmony-one/harmony/shard"
"github.com/pkg/errors"
)
@ -36,62 +32,6 @@ func (resp *syncResponse) String() string {
return fmt.Sprintf("[SyncResponse %v]", resp.pb.String())
}
// EpochStateResult is the result for GetEpochStateQuery
type EpochStateResult struct {
Header *block.Header
State *shard.State
}
func epochStateResultFromResponse(resp sttypes.Response) (*EpochStateResult, error) {
sResp, ok := resp.(*syncResponse)
if !ok || sResp == nil {
return nil, errors.New("not sync response")
}
if errResp := sResp.pb.GetErrorResponse(); errResp != nil {
return nil, errors.New(errResp.Error)
}
gesResp := sResp.pb.GetGetEpochStateResponse()
if gesResp == nil {
return nil, errors.New("not GetEpochStateResponse")
}
var (
headerBytes = gesResp.HeaderBytes
ssBytes = gesResp.ShardState
header *block.Header
ss *shard.State
)
if len(headerBytes) > 0 {
if err := rlp.DecodeBytes(headerBytes, &header); err != nil {
return nil, err
}
}
if len(ssBytes) > 0 {
// here shard state is not encoded with legacy rules
if err := rlp.DecodeBytes(ssBytes, &ss); err != nil {
return nil, err
}
}
return &EpochStateResult{
Header: header,
State: ss,
}, nil
}
func (res *EpochStateResult) toMessage(rid uint64) (*syncpb.Message, error) {
headerBytes, err := rlp.EncodeToBytes(res.Header)
if err != nil {
return nil, err
}
// Shard state is not wrapped here, means no legacy shard state encoding rule as
// in shard.EncodeWrapper.
ssBytes, err := rlp.EncodeToBytes(res.State)
if err != nil {
return nil, err
}
return syncpb.MakeGetEpochStateResponseMessage(rid, headerBytes, ssBytes), nil
}
// Option is the additional option to do requests.
// Currently, two options are supported:
// 1. WithHighPriority - do the request in high priority.

Loading…
Cancel
Save