Implement GetBlockV2 in the beacon API (#9433)

* Implement `GetBlockV2` in the beacon API

* fix gateway config test

* Revert "fix gateway config test"

This reverts commit 8179400b2a.

* unregister v2

* review feedback

* improve comment

* reduce duplication

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Radosław Kapka
2021-08-26 17:22:06 +02:00
committed by GitHub
parent 74df479bd3
commit 89941d4be2
9 changed files with 578 additions and 362 deletions

View File

@@ -3,8 +3,7 @@ package gateway
import (
gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/gateway"
"google.golang.org/protobuf/encoding/protojson"
)
@@ -19,10 +18,10 @@ type MuxConfig struct {
// DefaultConfig returns a fully configured MuxConfig with standard gateway behavior.
func DefaultConfig(enableDebugRPCEndpoints bool) MuxConfig {
v1Alpha1Registrations := []gateway.PbHandlerRegistration{
ethpb.RegisterNodeHandler,
ethpb.RegisterBeaconChainHandler,
ethpb.RegisterBeaconNodeValidatorHandler,
pbrpc.RegisterHealthHandler,
ethpbalpha.RegisterNodeHandler,
ethpbalpha.RegisterBeaconChainHandler,
ethpbalpha.RegisterBeaconNodeValidatorHandler,
ethpbalpha.RegisterHealthHandler,
}
v1Registrations := []gateway.PbHandlerRegistration{
ethpbservice.RegisterBeaconNodeHandler,
@@ -31,7 +30,7 @@ func DefaultConfig(enableDebugRPCEndpoints bool) MuxConfig {
ethpbservice.RegisterEventsHandler,
}
if enableDebugRPCEndpoints {
v1Alpha1Registrations = append(v1Alpha1Registrations, pbrpc.RegisterDebugHandler)
v1Alpha1Registrations = append(v1Alpha1Registrations, ethpbalpha.RegisterDebugHandler)
v1Registrations = append(v1Registrations, ethpbservice.RegisterBeaconDebugHandler)
}

View File

@@ -13,6 +13,7 @@ import (
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpbv2 "github.com/prysmaticlabs/prysm/proto/eth/v2"
"github.com/prysmaticlabs/prysm/proto/migration"
ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
@@ -199,14 +200,12 @@ func (bs *Server) GetBlock(ctx context.Context, req *ethpbv1.BlockRequest) (*eth
ctx, span := trace.StartSpan(ctx, "beaconv1.GetBlock")
defer span.End()
block, err := bs.blockFromBlockID(ctx, req.BlockId)
if invalidBlockIdErr, ok := err.(*blockIdParseError); ok {
return nil, status.Errorf(codes.InvalidArgument, "Invalid block ID: %v", invalidBlockIdErr)
}
blk, err := bs.blockFromBlockID(ctx, req.BlockId)
err = handleGetBlock(blk, err)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get block from block ID: %v", err)
return nil, err
}
signedBeaconBlock, err := migration.SignedBeaconBlock(block)
signedBeaconBlock, err := migration.SignedBeaconBlock(blk)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
@@ -224,14 +223,12 @@ func (bs *Server) GetBlockSSZ(ctx context.Context, req *ethpbv1.BlockRequest) (*
ctx, span := trace.StartSpan(ctx, "beaconv1.GetBlockSSZ")
defer span.End()
block, err := bs.blockFromBlockID(ctx, req.BlockId)
if invalidBlockIdErr, ok := err.(*blockIdParseError); ok {
return nil, status.Errorf(codes.InvalidArgument, "Invalid block ID: %v", invalidBlockIdErr)
}
blk, err := bs.blockFromBlockID(ctx, req.BlockId)
err = handleGetBlock(blk, err)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get block from block ID: %v", err)
return nil, err
}
signedBeaconBlock, err := migration.SignedBeaconBlock(block)
signedBeaconBlock, err := migration.SignedBeaconBlock(blk)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
@@ -243,12 +240,80 @@ func (bs *Server) GetBlockSSZ(ctx context.Context, req *ethpbv1.BlockRequest) (*
return &ethpbv1.BlockSSZResponse{Data: sszBlock}, nil
}
func (bs *Server) GetBlockV2(ctx context.Context, request *ethpbv2.BlockRequestV2) (*ethpbv2.BlockResponseV2, error) {
panic("implement me")
// GetBlockV2 retrieves block details for given block ID.
func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (*ethpbv2.BlockResponseV2, error) {
ctx, span := trace.StartSpan(ctx, "beacon.GetBlockAltair")
defer span.End()
blk, phase0Blk, err := bs.blocksFromId(ctx, req.BlockId)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get block: %v", err)
}
if phase0Blk != nil {
v1Blk, err := migration.SignedBeaconBlock(blk)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
return &ethpbv2.BlockResponseV2{
Data: &ethpbv2.BeaconBlockContainerV2{
Block: &ethpbv2.BeaconBlockContainerV2_Phase0Block{Phase0Block: v1Blk.Block},
Signature: v1Blk.Signature,
},
}, nil
}
altairBlk, err := blk.PbAltairBlock()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not check for Altair block")
}
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
return &ethpbv2.BlockResponseV2{
Data: &ethpbv2.BeaconBlockContainerV2{
Block: &ethpbv2.BeaconBlockContainerV2_AltairBlock{AltairBlock: v2Blk},
Signature: blk.Signature(),
},
}, nil
}
func (bs *Server) GetBlockSSZV2(ctx context.Context, request *ethpbv2.BlockRequestV2) (*ethpbv2.BlockSSZResponseV2, error) {
panic("implement me")
// GetBlockSSZV2 returns the SSZ-serialized version of the beacon block for given block ID.
func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (*ethpbv2.BlockSSZResponseV2, error) {
ctx, span := trace.StartSpan(ctx, "beacon.GetBlockSSZV2")
defer span.End()
blk, phase0Blk, err := bs.blocksFromId(ctx, req.BlockId)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get block: %v", err)
}
if phase0Blk != nil {
signedBeaconBlock, err := migration.SignedBeaconBlock(blk)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
sszBlock, err := signedBeaconBlock.MarshalSSZ()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
}
return &ethpbv2.BlockSSZResponseV2{Data: sszBlock}, nil
}
altairBlk, err := blk.PbAltairBlock()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not check for Altair block")
}
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
}
data := &ethpbv2.SignedBeaconBlockAltair{
Message: v2Blk,
Signature: blk.Signature(),
}
sszData, err := data.MarshalSSZ()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
}
return &ethpbv2.BlockSSZResponseV2{Data: sszData}, nil
}
// GetBlockRoot retrieves hashTreeRoot of BeaconBlock/BeaconBlockHeader.
@@ -361,6 +426,25 @@ func (bs *Server) ListBlockAttestations(ctx context.Context, req *ethpbv1.BlockR
}, nil
}
func (bs *Server) blocksFromId(ctx context.Context, blockId []byte) (
signedBlock block.SignedBeaconBlock,
phase0Block *ethpbalpha.SignedBeaconBlock,
err error,
) {
blk, err := bs.blockFromBlockID(ctx, blockId)
err = handleGetBlock(blk, err)
if err != nil {
return nil, nil, err
}
phase0Blk, err := blk.PbPhase0Block()
// Assume we have an Altair block when Phase 0 block is unsupported.
// In such case we continue with the rest of the function.
if err != nil && !errors.Is(err, wrapper.ErrUnsupportedPhase0Block) {
return nil, nil, errors.New("Could not check for phase 0 block")
}
return blk, phase0Blk, nil
}
func (bs *Server) blockFromBlockID(ctx context.Context, blockId []byte) (block.SignedBeaconBlock, error) {
var err error
var blk block.SignedBeaconBlock
@@ -425,3 +509,16 @@ func (bs *Server) blockFromBlockID(ctx context.Context, blockId []byte) (block.S
}
return blk, nil
}
func handleGetBlock(blk block.SignedBeaconBlock, err error) error {
if invalidBlockIdErr, ok := err.(*blockIdParseError); ok {
return status.Errorf(codes.InvalidArgument, "Invalid block ID: %v", invalidBlockIdErr)
}
if err != nil {
return status.Errorf(codes.Internal, "Could not get block from block ID: %v", err)
}
if blk == nil || blk.IsNil() {
return status.Errorf(codes.Internal, "Could not find requested block")
}
return nil
}

View File

@@ -35,7 +35,7 @@ ssz_gen_marshal(
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
],
objs = [
"BeaconBlockContainerV2",
"SignedBeaconBlockAltair",
],
)

View File

@@ -175,9 +175,11 @@ type BeaconBlockContainerV2 struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Phase0Block *v1.BeaconBlock `protobuf:"bytes,1,opt,name=phase0Block,proto3" json:"phase0Block,omitempty"`
AltairBlock *BeaconBlockAltair `protobuf:"bytes,2,opt,name=altairBlock,proto3" json:"altairBlock,omitempty"`
Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"`
// Types that are assignable to Block:
// *BeaconBlockContainerV2_Phase0Block
// *BeaconBlockContainerV2_AltairBlock
Block isBeaconBlockContainerV2_Block `protobuf_oneof:"block"`
Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"`
}
func (x *BeaconBlockContainerV2) Reset() {
@@ -212,15 +214,22 @@ func (*BeaconBlockContainerV2) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{3}
}
func (m *BeaconBlockContainerV2) GetBlock() isBeaconBlockContainerV2_Block {
if m != nil {
return m.Block
}
return nil
}
func (x *BeaconBlockContainerV2) GetPhase0Block() *v1.BeaconBlock {
if x != nil {
if x, ok := x.GetBlock().(*BeaconBlockContainerV2_Phase0Block); ok {
return x.Phase0Block
}
return nil
}
func (x *BeaconBlockContainerV2) GetAltairBlock() *BeaconBlockAltair {
if x != nil {
if x, ok := x.GetBlock().(*BeaconBlockContainerV2_AltairBlock); ok {
return x.AltairBlock
}
return nil
@@ -233,6 +242,77 @@ func (x *BeaconBlockContainerV2) GetSignature() []byte {
return nil
}
type isBeaconBlockContainerV2_Block interface {
isBeaconBlockContainerV2_Block()
}
type BeaconBlockContainerV2_Phase0Block struct {
Phase0Block *v1.BeaconBlock `protobuf:"bytes,1,opt,name=phase0Block,proto3,oneof"`
}
type BeaconBlockContainerV2_AltairBlock struct {
AltairBlock *BeaconBlockAltair `protobuf:"bytes,2,opt,name=altairBlock,proto3,oneof"`
}
func (*BeaconBlockContainerV2_Phase0Block) isBeaconBlockContainerV2_Block() {}
func (*BeaconBlockContainerV2_AltairBlock) isBeaconBlockContainerV2_Block() {}
type SignedBeaconBlockAltair struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message *BeaconBlockAltair `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"`
}
func (x *SignedBeaconBlockAltair) Reset() {
*x = SignedBeaconBlockAltair{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SignedBeaconBlockAltair) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SignedBeaconBlockAltair) ProtoMessage() {}
func (x *SignedBeaconBlockAltair) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v2_beacon_block_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)
}
// Deprecated: Use SignedBeaconBlockAltair.ProtoReflect.Descriptor instead.
func (*SignedBeaconBlockAltair) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{4}
}
func (x *SignedBeaconBlockAltair) GetMessage() *BeaconBlockAltair {
if x != nil {
return x.Message
}
return nil
}
func (x *SignedBeaconBlockAltair) GetSignature() []byte {
if x != nil {
return x.Signature
}
return nil
}
type BeaconBlockAltair struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -248,7 +328,7 @@ type BeaconBlockAltair struct {
func (x *BeaconBlockAltair) Reset() {
*x = BeaconBlockAltair{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[4]
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -261,7 +341,7 @@ func (x *BeaconBlockAltair) String() string {
func (*BeaconBlockAltair) ProtoMessage() {}
func (x *BeaconBlockAltair) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[4]
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -274,7 +354,7 @@ func (x *BeaconBlockAltair) ProtoReflect() protoreflect.Message {
// Deprecated: Use BeaconBlockAltair.ProtoReflect.Descriptor instead.
func (*BeaconBlockAltair) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{4}
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{5}
}
func (x *BeaconBlockAltair) GetSlot() github_com_prysmaticlabs_eth2_types.Slot {
@@ -331,7 +411,7 @@ type BeaconBlockBodyAltair struct {
func (x *BeaconBlockBodyAltair) Reset() {
*x = BeaconBlockBodyAltair{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[5]
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -344,7 +424,7 @@ func (x *BeaconBlockBodyAltair) String() string {
func (*BeaconBlockBodyAltair) ProtoMessage() {}
func (x *BeaconBlockBodyAltair) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[5]
mi := &file_proto_eth_v2_beacon_block_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -357,7 +437,7 @@ func (x *BeaconBlockBodyAltair) ProtoReflect() protoreflect.Message {
// Deprecated: Use BeaconBlockBodyAltair.ProtoReflect.Descriptor instead.
func (*BeaconBlockBodyAltair) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{5}
return file_proto_eth_v2_beacon_block_proto_rawDescGZIP(), []int{6}
}
func (x *BeaconBlockBodyAltair) GetRandaoReveal() []byte {
@@ -445,88 +525,97 @@ var file_proto_eth_v2_beacon_block_proto_rawDesc = []byte{
0x61, 0x69, 0x6e, 0x65, 0x72, 0x56, 0x32, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x28, 0x0a,
0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x53, 0x5a, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x56, 0x32, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xc4, 0x01, 0x0a, 0x16, 0x42, 0x65, 0x61, 0x63,
0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd1, 0x01, 0x0a, 0x16, 0x42, 0x65, 0x61, 0x63,
0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72,
0x56, 0x32, 0x12, 0x3e, 0x0a, 0x0b, 0x70, 0x68, 0x61, 0x73, 0x65, 0x30, 0x42, 0x6c, 0x6f, 0x63,
0x56, 0x32, 0x12, 0x40, 0x0a, 0x0b, 0x70, 0x68, 0x61, 0x73, 0x65, 0x30, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x0b, 0x70, 0x68, 0x61, 0x73, 0x65, 0x30, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x12, 0x44, 0x0a, 0x0b, 0x61, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x68, 0x61, 0x73, 0x65, 0x30, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x46, 0x0a, 0x0b, 0x61, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x42, 0x6c,
0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x65, 0x61, 0x63,
0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x48, 0x00, 0x52,
0x0b, 0x61, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x24, 0x0a, 0x09,
0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42,
0x06, 0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75,
0x72, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x7d, 0x0a, 0x17, 0x53,
0x69, 0x67, 0x6e, 0x65, 0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x3c, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x52, 0x0b, 0x61, 0x6c, 0x74,
0x61, 0x69, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x24, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e,
0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18,
0x02, 0x39, 0x36, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xc0,
0x02, 0x0a, 0x11, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6c,
0x74, 0x61, 0x69, 0x72, 0x12, 0x40, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x04, 0x42, 0x2c, 0x82, 0xb5, 0x18, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73,
0x2f, 0x65, 0x74, 0x68, 0x32, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74,
0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x5d, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73,
0x65, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x36,
0x82, 0xb5, 0x18, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52,
0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xc0, 0x02, 0x0a, 0x11, 0x42,
0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72,
0x12, 0x40, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x2c,
0x82, 0xb5, 0x18, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70,
0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x65, 0x74, 0x68,
0x32, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f,
0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02,
0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x25,
0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74,
0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x3a, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x05, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x42, 0x6f, 0x64, 0x79, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x52, 0x04, 0x62, 0x6f, 0x64,
0x79, 0x22, 0xfa, 0x04, 0x0a, 0x15, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x42, 0x6f, 0x64, 0x79, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x2b, 0x0a, 0x0d, 0x72,
0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x72, 0x65, 0x76, 0x65, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x0c, 0x72, 0x61, 0x6e, 0x64,
0x61, 0x6f, 0x52, 0x65, 0x76, 0x65, 0x61, 0x6c, 0x12, 0x36, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31,
0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x74,
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74,
0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61,
0x12, 0x22, 0x0a, 0x08, 0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x08, 0x67, 0x72, 0x61, 0x66,
0x66, 0x69, 0x74, 0x69, 0x12, 0x58, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68,
0x69, 0x6e, 0x67, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x31, 0x36, 0x52, 0x11, 0x70, 0x72, 0x6f,
0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x57,
0x0a, 0x12, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68,
0x69, 0x6e, 0x67, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68,
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74,
0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x42, 0x05, 0x92,
0xb5, 0x18, 0x01, 0x32, 0x52, 0x11, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c,
0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x49, 0x0a, 0x0c, 0x61, 0x74, 0x74, 0x65, 0x73,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e,
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x92, 0xb5, 0x18,
0x03, 0x31, 0x32, 0x38, 0x52, 0x0c, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0x07,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x06,
0x92, 0xb5, 0x18, 0x02, 0x31, 0x36, 0x52, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73,
0x12, 0x55, 0x0a, 0x0f, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x5f, 0x65, 0x78,
0x69, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e,
0x65, 0x64, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x42,
0x06, 0x92, 0xb5, 0x18, 0x02, 0x31, 0x36, 0x52, 0x0e, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61,
0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x73, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f,
0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76,
0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52,
0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x42, 0x80,
0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d,
0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74,
0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f,
0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca,
0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76,
0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x32, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c,
0x6f, 0x74, 0x12, 0x5d, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x69,
0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x36, 0x82, 0xb5, 0x18, 0x32,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x65, 0x74, 0x68, 0x32, 0x2d, 0x74, 0x79,
0x70, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64,
0x65, 0x78, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x64, 0x65,
0x78, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a,
0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74,
0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f,
0x74, 0x12, 0x3a, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x26, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76,
0x32, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6f, 0x64,
0x79, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0xfa, 0x04,
0x0a, 0x15, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6f, 0x64,
0x79, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x2b, 0x0a, 0x0d, 0x72, 0x61, 0x6e, 0x64, 0x61,
0x6f, 0x5f, 0x72, 0x65, 0x76, 0x65, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x52, 0x65,
0x76, 0x65, 0x61, 0x6c, 0x12, 0x36, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74,
0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61,
0x74, 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x22, 0x0a, 0x08,
0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x08, 0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69,
0x12, 0x58, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61,
0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65,
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50,
0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x42,
0x06, 0x92, 0xb5, 0x18, 0x02, 0x31, 0x36, 0x52, 0x11, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65,
0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x57, 0x0a, 0x12, 0x61, 0x74,
0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73,
0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65,
0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x32,
0x52, 0x11, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69,
0x6e, 0x67, 0x73, 0x12, 0x49, 0x0a, 0x0c, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65,
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x92, 0xb5, 0x18, 0x03, 0x31, 0x32, 0x38,
0x52, 0x0c, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3c,
0x0a, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02,
0x31, 0x36, 0x52, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x12, 0x55, 0x0a, 0x0f,
0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x73, 0x18,
0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x56, 0x6f,
0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x42, 0x06, 0x92, 0xb5, 0x18,
0x02, 0x31, 0x36, 0x52, 0x0e, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78,
0x69, 0x74, 0x73, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72,
0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74,
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79,
0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e,
0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x42, 0x80, 0x01, 0x0a, 0x13, 0x6f,
0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65,
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61,
0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65,
0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74,
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -541,40 +630,42 @@ func file_proto_eth_v2_beacon_block_proto_rawDescGZIP() []byte {
return file_proto_eth_v2_beacon_block_proto_rawDescData
}
var file_proto_eth_v2_beacon_block_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_proto_eth_v2_beacon_block_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_proto_eth_v2_beacon_block_proto_goTypes = []interface{}{
(*BlockRequestV2)(nil), // 0: ethereum.eth.v2.BlockRequestV2
(*BlockResponseV2)(nil), // 1: ethereum.eth.v2.BlockResponseV2
(*BlockSSZResponseV2)(nil), // 2: ethereum.eth.v2.BlockSSZResponseV2
(*BeaconBlockContainerV2)(nil), // 3: ethereum.eth.v2.BeaconBlockContainerV2
(*BeaconBlockAltair)(nil), // 4: ethereum.eth.v2.BeaconBlockAltair
(*BeaconBlockBodyAltair)(nil), // 5: ethereum.eth.v2.BeaconBlockBodyAltair
(*v1.BeaconBlock)(nil), // 6: ethereum.eth.v1.BeaconBlock
(*v1.Eth1Data)(nil), // 7: ethereum.eth.v1.Eth1Data
(*v1.ProposerSlashing)(nil), // 8: ethereum.eth.v1.ProposerSlashing
(*v1.AttesterSlashing)(nil), // 9: ethereum.eth.v1.AttesterSlashing
(*v1.Attestation)(nil), // 10: ethereum.eth.v1.Attestation
(*v1.Deposit)(nil), // 11: ethereum.eth.v1.Deposit
(*v1.SignedVoluntaryExit)(nil), // 12: ethereum.eth.v1.SignedVoluntaryExit
(*v1.SyncAggregate)(nil), // 13: ethereum.eth.v1.SyncAggregate
(*BlockRequestV2)(nil), // 0: ethereum.eth.v2.BlockRequestV2
(*BlockResponseV2)(nil), // 1: ethereum.eth.v2.BlockResponseV2
(*BlockSSZResponseV2)(nil), // 2: ethereum.eth.v2.BlockSSZResponseV2
(*BeaconBlockContainerV2)(nil), // 3: ethereum.eth.v2.BeaconBlockContainerV2
(*SignedBeaconBlockAltair)(nil), // 4: ethereum.eth.v2.SignedBeaconBlockAltair
(*BeaconBlockAltair)(nil), // 5: ethereum.eth.v2.BeaconBlockAltair
(*BeaconBlockBodyAltair)(nil), // 6: ethereum.eth.v2.BeaconBlockBodyAltair
(*v1.BeaconBlock)(nil), // 7: ethereum.eth.v1.BeaconBlock
(*v1.Eth1Data)(nil), // 8: ethereum.eth.v1.Eth1Data
(*v1.ProposerSlashing)(nil), // 9: ethereum.eth.v1.ProposerSlashing
(*v1.AttesterSlashing)(nil), // 10: ethereum.eth.v1.AttesterSlashing
(*v1.Attestation)(nil), // 11: ethereum.eth.v1.Attestation
(*v1.Deposit)(nil), // 12: ethereum.eth.v1.Deposit
(*v1.SignedVoluntaryExit)(nil), // 13: ethereum.eth.v1.SignedVoluntaryExit
(*v1.SyncAggregate)(nil), // 14: ethereum.eth.v1.SyncAggregate
}
var file_proto_eth_v2_beacon_block_proto_depIdxs = []int32{
3, // 0: ethereum.eth.v2.BlockResponseV2.data:type_name -> ethereum.eth.v2.BeaconBlockContainerV2
6, // 1: ethereum.eth.v2.BeaconBlockContainerV2.phase0Block:type_name -> ethereum.eth.v1.BeaconBlock
4, // 2: ethereum.eth.v2.BeaconBlockContainerV2.altairBlock:type_name -> ethereum.eth.v2.BeaconBlockAltair
5, // 3: ethereum.eth.v2.BeaconBlockAltair.body:type_name -> ethereum.eth.v2.BeaconBlockBodyAltair
7, // 4: ethereum.eth.v2.BeaconBlockBodyAltair.eth1_data:type_name -> ethereum.eth.v1.Eth1Data
8, // 5: ethereum.eth.v2.BeaconBlockBodyAltair.proposer_slashings:type_name -> ethereum.eth.v1.ProposerSlashing
9, // 6: ethereum.eth.v2.BeaconBlockBodyAltair.attester_slashings:type_name -> ethereum.eth.v1.AttesterSlashing
10, // 7: ethereum.eth.v2.BeaconBlockBodyAltair.attestations:type_name -> ethereum.eth.v1.Attestation
11, // 8: ethereum.eth.v2.BeaconBlockBodyAltair.deposits:type_name -> ethereum.eth.v1.Deposit
12, // 9: ethereum.eth.v2.BeaconBlockBodyAltair.voluntary_exits:type_name -> ethereum.eth.v1.SignedVoluntaryExit
13, // 10: ethereum.eth.v2.BeaconBlockBodyAltair.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate
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
7, // 1: ethereum.eth.v2.BeaconBlockContainerV2.phase0Block:type_name -> ethereum.eth.v1.BeaconBlock
5, // 2: ethereum.eth.v2.BeaconBlockContainerV2.altairBlock:type_name -> ethereum.eth.v2.BeaconBlockAltair
5, // 3: ethereum.eth.v2.SignedBeaconBlockAltair.message:type_name -> ethereum.eth.v2.BeaconBlockAltair
6, // 4: ethereum.eth.v2.BeaconBlockAltair.body:type_name -> ethereum.eth.v2.BeaconBlockBodyAltair
8, // 5: ethereum.eth.v2.BeaconBlockBodyAltair.eth1_data:type_name -> ethereum.eth.v1.Eth1Data
9, // 6: ethereum.eth.v2.BeaconBlockBodyAltair.proposer_slashings:type_name -> ethereum.eth.v1.ProposerSlashing
10, // 7: ethereum.eth.v2.BeaconBlockBodyAltair.attester_slashings:type_name -> ethereum.eth.v1.AttesterSlashing
11, // 8: ethereum.eth.v2.BeaconBlockBodyAltair.attestations:type_name -> ethereum.eth.v1.Attestation
12, // 9: ethereum.eth.v2.BeaconBlockBodyAltair.deposits:type_name -> ethereum.eth.v1.Deposit
13, // 10: ethereum.eth.v2.BeaconBlockBodyAltair.voluntary_exits:type_name -> ethereum.eth.v1.SignedVoluntaryExit
14, // 11: ethereum.eth.v2.BeaconBlockBodyAltair.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate
12, // [12:12] is the sub-list for method output_type
12, // [12:12] is the sub-list for method input_type
12, // [12:12] is the sub-list for extension type_name
12, // [12:12] is the sub-list for extension extendee
0, // [0:12] is the sub-list for field type_name
}
func init() { file_proto_eth_v2_beacon_block_proto_init() }
@@ -632,7 +723,7 @@ func file_proto_eth_v2_beacon_block_proto_init() {
}
}
file_proto_eth_v2_beacon_block_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BeaconBlockAltair); i {
switch v := v.(*SignedBeaconBlockAltair); i {
case 0:
return &v.state
case 1:
@@ -644,6 +735,18 @@ func file_proto_eth_v2_beacon_block_proto_init() {
}
}
file_proto_eth_v2_beacon_block_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BeaconBlockAltair); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v2_beacon_block_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BeaconBlockBodyAltair); i {
case 0:
return &v.state
@@ -656,13 +759,17 @@ func file_proto_eth_v2_beacon_block_proto_init() {
}
}
}
file_proto_eth_v2_beacon_block_proto_msgTypes[3].OneofWrappers = []interface{}{
(*BeaconBlockContainerV2_Phase0Block)(nil),
(*BeaconBlockContainerV2_AltairBlock)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_eth_v2_beacon_block_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},

View File

@@ -41,13 +41,22 @@ message BlockSSZResponseV2 {
}
message BeaconBlockContainerV2 {
v1.BeaconBlock phase0Block = 1;
BeaconBlockAltair altairBlock = 2;
oneof block {
v1.BeaconBlock phase0Block = 1;
BeaconBlockAltair altairBlock = 2;
}
// 96 byte BLS signature from the validator that produced this block.
bytes signature = 3 [(ethereum.eth.ext.ssz_size) = "96"];
}
message SignedBeaconBlockAltair {
BeaconBlockAltair message = 1;
// 96 byte BLS signature from the validator that produced this block.
bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"];
}
// The Ethereum consensus beacon block. The message does not contain a validator signature.
message BeaconBlockAltair {
// Beacon chain slot that this block represents.

View File

@@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: e22f66e7ee2cd7da3b2e341ab1107f510d10a83a0dbcb9935ebbcaf014491f4e
// Hash: 1ecd73ba246c1c2aebe49304b4c866ef93e39b7b2c3d94f4a673932fbabde479
package eth
import (
@@ -8,149 +8,110 @@ import (
v1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
)
// MarshalSSZ ssz marshals the BeaconBlockContainerV2 object
func (b *BeaconBlockContainerV2) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
// MarshalSSZ ssz marshals the SignedBeaconBlockAltair object
func (s *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the BeaconBlockContainerV2 object to a target array
func (b *BeaconBlockContainerV2) MarshalSSZTo(buf []byte) (dst []byte, err error) {
// MarshalSSZTo ssz marshals the SignedBeaconBlockAltair object to a target array
func (s *SignedBeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(104)
offset := int(100)
// Offset (0) 'Phase0Block'
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if b.Phase0Block == nil {
b.Phase0Block = new(v1.BeaconBlock)
if s.Message == nil {
s.Message = new(BeaconBlockAltair)
}
offset += b.Phase0Block.SizeSSZ()
offset += s.Message.SizeSSZ()
// Offset (1) 'AltairBlock'
dst = ssz.WriteOffset(dst, offset)
if b.AltairBlock == nil {
b.AltairBlock = new(BeaconBlockAltair)
}
offset += b.AltairBlock.SizeSSZ()
// Field (2) 'Signature'
if len(b.Signature) != 96 {
// Field (1) 'Signature'
if len(s.Signature) != 96 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, b.Signature...)
dst = append(dst, s.Signature...)
// Field (0) 'Phase0Block'
if dst, err = b.Phase0Block.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'AltairBlock'
if dst, err = b.AltairBlock.MarshalSSZTo(dst); err != nil {
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the BeaconBlockContainerV2 object
func (b *BeaconBlockContainerV2) UnmarshalSSZ(buf []byte) error {
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockAltair object
func (s *SignedBeaconBlockAltair) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 104 {
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0, o1 uint64
var o0 uint64
// Offset (0) 'Phase0Block'
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 < 104 {
if o0 < 100 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'AltairBlock'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[4:100]))
}
s.Signature = append(s.Signature, buf[4:100]...)
// Field (2) 'Signature'
if cap(b.Signature) == 0 {
b.Signature = make([]byte, 0, len(buf[8:104]))
}
b.Signature = append(b.Signature, buf[8:104]...)
// Field (0) 'Phase0Block'
// Field (0) 'Message'
{
buf = tail[o0:o1]
if b.Phase0Block == nil {
b.Phase0Block = new(v1.BeaconBlock)
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BeaconBlockAltair)
}
if err = b.Phase0Block.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'AltairBlock'
{
buf = tail[o1:]
if b.AltairBlock == nil {
b.AltairBlock = new(BeaconBlockAltair)
}
if err = b.AltairBlock.UnmarshalSSZ(buf); err != nil {
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContainerV2 object
func (b *BeaconBlockContainerV2) SizeSSZ() (size int) {
size = 104
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockAltair object
func (s *SignedBeaconBlockAltair) SizeSSZ() (size int) {
size = 100
// Field (0) 'Phase0Block'
if b.Phase0Block == nil {
b.Phase0Block = new(v1.BeaconBlock)
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BeaconBlockAltair)
}
size += b.Phase0Block.SizeSSZ()
// Field (1) 'AltairBlock'
if b.AltairBlock == nil {
b.AltairBlock = new(BeaconBlockAltair)
}
size += b.AltairBlock.SizeSSZ()
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the BeaconBlockContainerV2 object
func (b *BeaconBlockContainerV2) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(b)
// HashTreeRoot ssz hashes the SignedBeaconBlockAltair object
func (s *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the BeaconBlockContainerV2 object with a hasher
func (b *BeaconBlockContainerV2) HashTreeRootWith(hh *ssz.Hasher) (err error) {
// HashTreeRootWith ssz hashes the SignedBeaconBlockAltair object with a hasher
func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Phase0Block'
if err = b.Phase0Block.HashTreeRootWith(hh); err != nil {
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'AltairBlock'
if err = b.AltairBlock.HashTreeRootWith(hh); err != nil {
return
}
// Field (2) 'Signature'
if len(b.Signature) != 96 {
// Field (1) 'Signature'
if len(s.Signature) != 96 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(b.Signature)
hh.PutBytes(s.Signature)
hh.Merkleize(indx)
return

View File

@@ -10,6 +10,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"@com_github_pkg_errors//:go_default_library",

View File

@@ -2,20 +2,21 @@ package migration
import (
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpbv2 "github.com/prysmaticlabs/prysm/proto/eth/v2"
ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"google.golang.org/protobuf/proto"
)
// BlockIfaceToV1BlockHeader converts a signed beacon block interface into a signed beacon block header.
func BlockIfaceToV1BlockHeader(block block.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) {
func BlockIfaceToV1BlockHeader(block block.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlockHeader, error) {
bodyRoot, err := block.Block().Body().HashTreeRoot()
if err != nil {
return nil, errors.Wrap(err, "failed to get body root of block")
}
return &ethpb.SignedBeaconBlockHeader{
Message: &ethpb.BeaconBlockHeader{
return &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: block.Block().Slot(),
ProposerIndex: block.Block().ProposerIndex(),
ParentRoot: block.Block().ParentRoot(),
@@ -27,13 +28,13 @@ func BlockIfaceToV1BlockHeader(block block.SignedBeaconBlock) (*ethpb.SignedBeac
}
// V1Alpha1BlockToV1BlockHeader converts a v1alpha1 SignedBeaconBlock proto to a v1 SignedBeaconBlockHeader proto.
func V1Alpha1BlockToV1BlockHeader(block *eth.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) {
func V1Alpha1BlockToV1BlockHeader(block *ethpbalpha.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlockHeader, error) {
bodyRoot, err := block.Block.Body.HashTreeRoot()
if err != nil {
return nil, errors.Wrap(err, "failed to get body root of block")
}
return &ethpb.SignedBeaconBlockHeader{
Message: &ethpb.BeaconBlockHeader{
return &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: block.Block.Slot,
ProposerIndex: block.Block.ProposerIndex,
ParentRoot: block.Block.ParentRoot,
@@ -45,12 +46,12 @@ func V1Alpha1BlockToV1BlockHeader(block *eth.SignedBeaconBlock) (*ethpb.SignedBe
}
// V1Alpha1ToV1SignedBlock converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
func V1Alpha1ToV1SignedBlock(alphaBlk *eth.SignedBeaconBlock) (*ethpb.SignedBeaconBlock, error) {
func V1Alpha1ToV1SignedBlock(alphaBlk *ethpbalpha.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
marshaledBlk, err := proto.Marshal(alphaBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1Block := &ethpb.SignedBeaconBlock{}
v1Block := &ethpbv1.SignedBeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
@@ -58,12 +59,12 @@ func V1Alpha1ToV1SignedBlock(alphaBlk *eth.SignedBeaconBlock) (*ethpb.SignedBeac
}
// V1ToV1Alpha1SignedBlock converts a v1 SignedBeaconBlock proto to a v1alpha1 proto.
func V1ToV1Alpha1SignedBlock(alphaBlk *ethpb.SignedBeaconBlock) (*eth.SignedBeaconBlock, error) {
func V1ToV1Alpha1SignedBlock(alphaBlk *ethpbv1.SignedBeaconBlock) (*ethpbalpha.SignedBeaconBlock, error) {
marshaledBlk, err := proto.Marshal(alphaBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &eth.SignedBeaconBlock{}
v1alpha1Block := &ethpbalpha.SignedBeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
@@ -71,12 +72,12 @@ func V1ToV1Alpha1SignedBlock(alphaBlk *ethpb.SignedBeaconBlock) (*eth.SignedBeac
}
// V1Alpha1ToV1Block converts a v1alpha1 BeaconBlock proto to a v1 proto.
func V1Alpha1ToV1Block(alphaBlk *eth.BeaconBlock) (*ethpb.BeaconBlock, error) {
func V1Alpha1ToV1Block(alphaBlk *ethpbalpha.BeaconBlock) (*ethpbv1.BeaconBlock, error) {
marshaledBlk, err := proto.Marshal(alphaBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1Block := &ethpb.BeaconBlock{}
v1Block := &ethpbv1.BeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
@@ -84,11 +85,11 @@ func V1Alpha1ToV1Block(alphaBlk *eth.BeaconBlock) (*ethpb.BeaconBlock, error) {
}
// V1Alpha1AggregateAttAndProofToV1 converts a v1alpha1 aggregate attestation and proof to v1.
func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *eth.AggregateAttestationAndProof) *ethpb.AggregateAttestationAndProof {
func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *ethpbalpha.AggregateAttestationAndProof) *ethpbv1.AggregateAttestationAndProof {
if v1alpha1Att == nil {
return &ethpb.AggregateAttestationAndProof{}
return &ethpbv1.AggregateAttestationAndProof{}
}
return &ethpb.AggregateAttestationAndProof{
return &ethpbv1.AggregateAttestationAndProof{
AggregatorIndex: v1alpha1Att.AggregatorIndex,
Aggregate: V1Alpha1AttestationToV1(v1alpha1Att.Aggregate),
SelectionProof: v1alpha1Att.SelectionProof,
@@ -96,12 +97,12 @@ func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *eth.AggregateAttestationAndPr
}
// V1SignedAggregateAttAndProofToV1Alpha1 converts a v1 signed aggregate attestation and proof to v1alpha1.
func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpb.SignedAggregateAttestationAndProof) *eth.SignedAggregateAttestationAndProof {
func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpbv1.SignedAggregateAttestationAndProof) *ethpbalpha.SignedAggregateAttestationAndProof {
if v1Att == nil {
return &eth.SignedAggregateAttestationAndProof{}
return &ethpbalpha.SignedAggregateAttestationAndProof{}
}
return &eth.SignedAggregateAttestationAndProof{
Message: &eth.AggregateAttestationAndProof{
return &ethpbalpha.SignedAggregateAttestationAndProof{
Message: &ethpbalpha.AggregateAttestationAndProof{
AggregatorIndex: v1Att.Message.AggregatorIndex,
Aggregate: V1AttestationToV1Alpha1(v1Att.Message.Aggregate),
SelectionProof: v1Att.Message.SelectionProof,
@@ -111,11 +112,11 @@ func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpb.SignedAggregateAttestat
}
// V1Alpha1IndexedAttToV1 converts a v1alpha1 indexed attestation to v1.
func V1Alpha1IndexedAttToV1(v1alpha1Att *eth.IndexedAttestation) *ethpb.IndexedAttestation {
func V1Alpha1IndexedAttToV1(v1alpha1Att *ethpbalpha.IndexedAttestation) *ethpbv1.IndexedAttestation {
if v1alpha1Att == nil {
return &ethpb.IndexedAttestation{}
return &ethpbv1.IndexedAttestation{}
}
return &ethpb.IndexedAttestation{
return &ethpbv1.IndexedAttestation{
AttestingIndices: v1alpha1Att.AttestingIndices,
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
Signature: v1alpha1Att.Signature,
@@ -123,11 +124,11 @@ func V1Alpha1IndexedAttToV1(v1alpha1Att *eth.IndexedAttestation) *ethpb.IndexedA
}
// V1Alpha1AttestationToV1 converts a v1alpha1 attestation to v1.
func V1Alpha1AttestationToV1(v1alpha1Att *eth.Attestation) *ethpb.Attestation {
func V1Alpha1AttestationToV1(v1alpha1Att *ethpbalpha.Attestation) *ethpbv1.Attestation {
if v1alpha1Att == nil {
return &ethpb.Attestation{}
return &ethpbv1.Attestation{}
}
return &ethpb.Attestation{
return &ethpbv1.Attestation{
AggregationBits: v1alpha1Att.AggregationBits,
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
Signature: v1alpha1Att.Signature,
@@ -135,11 +136,11 @@ func V1Alpha1AttestationToV1(v1alpha1Att *eth.Attestation) *ethpb.Attestation {
}
// V1AttestationToV1Alpha1 converts a v1 attestation to v1alpha1.
func V1AttestationToV1Alpha1(v1Att *ethpb.Attestation) *eth.Attestation {
func V1AttestationToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
if v1Att == nil {
return &eth.Attestation{}
return &ethpbalpha.Attestation{}
}
return &eth.Attestation{
return &ethpbalpha.Attestation{
AggregationBits: v1Att.AggregationBits,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
@@ -147,19 +148,19 @@ func V1AttestationToV1Alpha1(v1Att *ethpb.Attestation) *eth.Attestation {
}
// V1Alpha1AttDataToV1 converts a v1alpha1 attestation data to v1.
func V1Alpha1AttDataToV1(v1alpha1AttData *eth.AttestationData) *ethpb.AttestationData {
func V1Alpha1AttDataToV1(v1alpha1AttData *ethpbalpha.AttestationData) *ethpbv1.AttestationData {
if v1alpha1AttData == nil || v1alpha1AttData.Source == nil || v1alpha1AttData.Target == nil {
return &ethpb.AttestationData{}
return &ethpbv1.AttestationData{}
}
return &ethpb.AttestationData{
return &ethpbv1.AttestationData{
Slot: v1alpha1AttData.Slot,
Index: v1alpha1AttData.CommitteeIndex,
BeaconBlockRoot: v1alpha1AttData.BeaconBlockRoot,
Source: &ethpb.Checkpoint{
Source: &ethpbv1.Checkpoint{
Root: v1alpha1AttData.Source.Root,
Epoch: v1alpha1AttData.Source.Epoch,
},
Target: &ethpb.Checkpoint{
Target: &ethpbv1.Checkpoint{
Root: v1alpha1AttData.Target.Root,
Epoch: v1alpha1AttData.Target.Epoch,
},
@@ -167,23 +168,23 @@ func V1Alpha1AttDataToV1(v1alpha1AttData *eth.AttestationData) *ethpb.Attestatio
}
// V1Alpha1AttSlashingToV1 converts a v1alpha1 attester slashing to v1.
func V1Alpha1AttSlashingToV1(v1alpha1Slashing *eth.AttesterSlashing) *ethpb.AttesterSlashing {
func V1Alpha1AttSlashingToV1(v1alpha1Slashing *ethpbalpha.AttesterSlashing) *ethpbv1.AttesterSlashing {
if v1alpha1Slashing == nil {
return &ethpb.AttesterSlashing{}
return &ethpbv1.AttesterSlashing{}
}
return &ethpb.AttesterSlashing{
return &ethpbv1.AttesterSlashing{
Attestation_1: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_1),
Attestation_2: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_2),
}
}
// V1Alpha1SignedHeaderToV1 converts a v1alpha1 signed beacon block header to v1.
func V1Alpha1SignedHeaderToV1(v1alpha1Hdr *eth.SignedBeaconBlockHeader) *ethpb.SignedBeaconBlockHeader {
func V1Alpha1SignedHeaderToV1(v1alpha1Hdr *ethpbalpha.SignedBeaconBlockHeader) *ethpbv1.SignedBeaconBlockHeader {
if v1alpha1Hdr == nil || v1alpha1Hdr.Header == nil {
return &ethpb.SignedBeaconBlockHeader{}
return &ethpbv1.SignedBeaconBlockHeader{}
}
return &ethpb.SignedBeaconBlockHeader{
Message: &ethpb.BeaconBlockHeader{
return &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: v1alpha1Hdr.Header.Slot,
ProposerIndex: v1alpha1Hdr.Header.ProposerIndex,
ParentRoot: v1alpha1Hdr.Header.ParentRoot,
@@ -195,12 +196,12 @@ func V1Alpha1SignedHeaderToV1(v1alpha1Hdr *eth.SignedBeaconBlockHeader) *ethpb.S
}
// V1SignedHeaderToV1Alpha1 converts a v1 signed beacon block header to v1alpha1.
func V1SignedHeaderToV1Alpha1(v1Header *ethpb.SignedBeaconBlockHeader) *eth.SignedBeaconBlockHeader {
func V1SignedHeaderToV1Alpha1(v1Header *ethpbv1.SignedBeaconBlockHeader) *ethpbalpha.SignedBeaconBlockHeader {
if v1Header == nil || v1Header.Message == nil {
return &eth.SignedBeaconBlockHeader{}
return &ethpbalpha.SignedBeaconBlockHeader{}
}
return &eth.SignedBeaconBlockHeader{
Header: &eth.BeaconBlockHeader{
return &ethpbalpha.SignedBeaconBlockHeader{
Header: &ethpbalpha.BeaconBlockHeader{
Slot: v1Header.Message.Slot,
ProposerIndex: v1Header.Message.ProposerIndex,
ParentRoot: v1Header.Message.ParentRoot,
@@ -212,23 +213,23 @@ func V1SignedHeaderToV1Alpha1(v1Header *ethpb.SignedBeaconBlockHeader) *eth.Sign
}
// V1Alpha1ProposerSlashingToV1 converts a v1alpha1 proposer slashing to v1.
func V1Alpha1ProposerSlashingToV1(v1alpha1Slashing *eth.ProposerSlashing) *ethpb.ProposerSlashing {
func V1Alpha1ProposerSlashingToV1(v1alpha1Slashing *ethpbalpha.ProposerSlashing) *ethpbv1.ProposerSlashing {
if v1alpha1Slashing == nil {
return &ethpb.ProposerSlashing{}
return &ethpbv1.ProposerSlashing{}
}
return &ethpb.ProposerSlashing{
return &ethpbv1.ProposerSlashing{
SignedHeader_1: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_1),
SignedHeader_2: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_2),
}
}
// V1Alpha1ExitToV1 converts a v1alpha1 SignedVoluntaryExit to v1.
func V1Alpha1ExitToV1(v1alpha1Exit *eth.SignedVoluntaryExit) *ethpb.SignedVoluntaryExit {
func V1Alpha1ExitToV1(v1alpha1Exit *ethpbalpha.SignedVoluntaryExit) *ethpbv1.SignedVoluntaryExit {
if v1alpha1Exit == nil || v1alpha1Exit.Exit == nil {
return &ethpb.SignedVoluntaryExit{}
return &ethpbv1.SignedVoluntaryExit{}
}
return &ethpb.SignedVoluntaryExit{
Message: &ethpb.VoluntaryExit{
return &ethpbv1.SignedVoluntaryExit{
Message: &ethpbv1.VoluntaryExit{
Epoch: v1alpha1Exit.Exit.Epoch,
ValidatorIndex: v1alpha1Exit.Exit.ValidatorIndex,
},
@@ -237,12 +238,12 @@ func V1Alpha1ExitToV1(v1alpha1Exit *eth.SignedVoluntaryExit) *ethpb.SignedVolunt
}
// V1ExitToV1Alpha1 converts a v1 SignedVoluntaryExit to v1alpha1.
func V1ExitToV1Alpha1(v1Exit *ethpb.SignedVoluntaryExit) *eth.SignedVoluntaryExit {
func V1ExitToV1Alpha1(v1Exit *ethpbv1.SignedVoluntaryExit) *ethpbalpha.SignedVoluntaryExit {
if v1Exit == nil || v1Exit.Message == nil {
return &eth.SignedVoluntaryExit{}
return &ethpbalpha.SignedVoluntaryExit{}
}
return &eth.SignedVoluntaryExit{
Exit: &eth.VoluntaryExit{
return &ethpbalpha.SignedVoluntaryExit{
Exit: &ethpbalpha.VoluntaryExit{
Epoch: v1Exit.Message.Epoch,
ValidatorIndex: v1Exit.Message.ValidatorIndex,
},
@@ -251,11 +252,11 @@ func V1ExitToV1Alpha1(v1Exit *ethpb.SignedVoluntaryExit) *eth.SignedVoluntaryExi
}
// V1AttToV1Alpha1 converts a v1 attestation to v1alpha1.
func V1AttToV1Alpha1(v1Att *ethpb.Attestation) *eth.Attestation {
func V1AttToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
if v1Att == nil {
return &eth.Attestation{}
return &ethpbalpha.Attestation{}
}
return &eth.Attestation{
return &ethpbalpha.Attestation{
AggregationBits: v1Att.AggregationBits,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
@@ -263,11 +264,11 @@ func V1AttToV1Alpha1(v1Att *ethpb.Attestation) *eth.Attestation {
}
// V1IndexedAttToV1Alpha1 converts a v1 indexed attestation to v1alpha1.
func V1IndexedAttToV1Alpha1(v1Att *ethpb.IndexedAttestation) *eth.IndexedAttestation {
func V1IndexedAttToV1Alpha1(v1Att *ethpbv1.IndexedAttestation) *ethpbalpha.IndexedAttestation {
if v1Att == nil {
return &eth.IndexedAttestation{}
return &ethpbalpha.IndexedAttestation{}
}
return &eth.IndexedAttestation{
return &ethpbalpha.IndexedAttestation{
AttestingIndices: v1Att.AttestingIndices,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
@@ -275,19 +276,19 @@ func V1IndexedAttToV1Alpha1(v1Att *ethpb.IndexedAttestation) *eth.IndexedAttesta
}
// V1AttDataToV1Alpha1 converts a v1 attestation data to v1alpha1.
func V1AttDataToV1Alpha1(v1AttData *ethpb.AttestationData) *eth.AttestationData {
func V1AttDataToV1Alpha1(v1AttData *ethpbv1.AttestationData) *ethpbalpha.AttestationData {
if v1AttData == nil || v1AttData.Source == nil || v1AttData.Target == nil {
return &eth.AttestationData{}
return &ethpbalpha.AttestationData{}
}
return &eth.AttestationData{
return &ethpbalpha.AttestationData{
Slot: v1AttData.Slot,
CommitteeIndex: v1AttData.Index,
BeaconBlockRoot: v1AttData.BeaconBlockRoot,
Source: &eth.Checkpoint{
Source: &ethpbalpha.Checkpoint{
Root: v1AttData.Source.Root,
Epoch: v1AttData.Source.Epoch,
},
Target: &eth.Checkpoint{
Target: &ethpbalpha.Checkpoint{
Root: v1AttData.Target.Root,
Epoch: v1AttData.Target.Epoch,
},
@@ -295,33 +296,33 @@ func V1AttDataToV1Alpha1(v1AttData *ethpb.AttestationData) *eth.AttestationData
}
// V1AttSlashingToV1Alpha1 converts a v1 attester slashing to v1alpha1.
func V1AttSlashingToV1Alpha1(v1Slashing *ethpb.AttesterSlashing) *eth.AttesterSlashing {
func V1AttSlashingToV1Alpha1(v1Slashing *ethpbv1.AttesterSlashing) *ethpbalpha.AttesterSlashing {
if v1Slashing == nil {
return &eth.AttesterSlashing{}
return &ethpbalpha.AttesterSlashing{}
}
return &eth.AttesterSlashing{
return &ethpbalpha.AttesterSlashing{
Attestation_1: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_1),
Attestation_2: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_2),
}
}
// V1ProposerSlashingToV1Alpha1 converts a v1 proposer slashing to v1alpha1.
func V1ProposerSlashingToV1Alpha1(v1Slashing *ethpb.ProposerSlashing) *eth.ProposerSlashing {
func V1ProposerSlashingToV1Alpha1(v1Slashing *ethpbv1.ProposerSlashing) *ethpbalpha.ProposerSlashing {
if v1Slashing == nil {
return &eth.ProposerSlashing{}
return &ethpbalpha.ProposerSlashing{}
}
return &eth.ProposerSlashing{
return &ethpbalpha.ProposerSlashing{
Header_1: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_1),
Header_2: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_2),
}
}
// V1Alpha1ValidatorToV1 converts a v1alpha1 validator to v1.
func V1Alpha1ValidatorToV1(v1Alpha1Validator *eth.Validator) *ethpb.Validator {
func V1Alpha1ValidatorToV1(v1Alpha1Validator *ethpbalpha.Validator) *ethpbv1.Validator {
if v1Alpha1Validator == nil {
return &ethpb.Validator{}
return &ethpbv1.Validator{}
}
return &ethpb.Validator{
return &ethpbv1.Validator{
Pubkey: v1Alpha1Validator.PublicKey,
WithdrawalCredentials: v1Alpha1Validator.WithdrawalCredentials,
EffectiveBalance: v1Alpha1Validator.EffectiveBalance,
@@ -334,11 +335,11 @@ func V1Alpha1ValidatorToV1(v1Alpha1Validator *eth.Validator) *ethpb.Validator {
}
// V1ValidatorToV1Alpha1 converts a v1 validator to v1alpha1.
func V1ValidatorToV1Alpha1(v1Validator *ethpb.Validator) *eth.Validator {
func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator {
if v1Validator == nil {
return &eth.Validator{}
return &ethpbalpha.Validator{}
}
return &eth.Validator{
return &ethpbalpha.Validator{
PublicKey: v1Validator.Pubkey,
WithdrawalCredentials: v1Validator.WithdrawalCredentials,
EffectiveBalance: v1Validator.EffectiveBalance,
@@ -351,7 +352,7 @@ func V1ValidatorToV1Alpha1(v1Validator *ethpb.Validator) *eth.Validator {
}
// SignedBeaconBlock converts a signed beacon block interface to a v1alpha1 block.
func SignedBeaconBlock(block block.SignedBeaconBlock) (*ethpb.SignedBeaconBlock, error) {
func SignedBeaconBlock(block block.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
if block == nil || block.IsNil() {
return nil, errors.New("could not find requested block")
}
@@ -367,3 +368,16 @@ func SignedBeaconBlock(block block.SignedBeaconBlock) (*ethpb.SignedBeaconBlock,
return v1Block, nil
}
// V1Alpha1BeaconBlockAltairToV2 converts a v1alpha1 Altair beacon block to a v2 Altair block.
func V1Alpha1BeaconBlockAltairToV2(v1alpha1Block *ethpbalpha.BeaconBlockAltair) (*ethpbv2.BeaconBlockAltair, error) {
marshaledBlk, err := proto.Marshal(v1alpha1Block)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v2Block := &ethpbv2.BeaconBlockAltair{}
if err := proto.Unmarshal(marshaledBlk, v2Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v2Block, nil
}

View File

@@ -5,8 +5,8 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/go-bitfield"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -36,7 +36,7 @@ var (
)
func Test_BlockIfaceToV1BlockHeader(t *testing.T) {
alphaBlock := testutil.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{})
alphaBlock := testutil.HydrateSignedBeaconBlock(&ethpbalpha.SignedBeaconBlock{})
alphaBlock.Block.Slot = slot
alphaBlock.Block.ProposerIndex = validatorIndex
alphaBlock.Block.ParentRoot = parentRoot
@@ -57,12 +57,12 @@ func Test_BlockIfaceToV1BlockHeader(t *testing.T) {
func Test_V1Alpha1AggregateAttAndProofToV1(t *testing.T) {
proof := [32]byte{1}
att := testutil.HydrateAttestation(&eth.Attestation{
Data: &eth.AttestationData{
att := testutil.HydrateAttestation(&ethpbalpha.Attestation{
Data: &ethpbalpha.AttestationData{
Slot: 5,
},
})
alpha := &eth.AggregateAttestationAndProof{
alpha := &ethpbalpha.AggregateAttestationAndProof{
AggregatorIndex: 1,
Aggregate: att,
SelectionProof: proof[:],
@@ -74,7 +74,7 @@ func Test_V1Alpha1AggregateAttAndProofToV1(t *testing.T) {
}
func Test_V1Alpha1BlockToV1BlockHeader(t *testing.T) {
alphaBlock := testutil.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{})
alphaBlock := testutil.HydrateSignedBeaconBlock(&ethpbalpha.SignedBeaconBlock{})
alphaBlock.Block.Slot = slot
alphaBlock.Block.ProposerIndex = validatorIndex
alphaBlock.Block.ParentRoot = parentRoot
@@ -94,13 +94,13 @@ func Test_V1Alpha1BlockToV1BlockHeader(t *testing.T) {
}
func Test_V1Alpha1ToV1SignedBlock(t *testing.T) {
alphaBlock := testutil.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{})
alphaBlock := testutil.HydrateSignedBeaconBlock(&ethpbalpha.SignedBeaconBlock{})
alphaBlock.Block.Slot = slot
alphaBlock.Block.ProposerIndex = validatorIndex
alphaBlock.Block.ParentRoot = parentRoot
alphaBlock.Block.StateRoot = stateRoot
alphaBlock.Block.Body.RandaoReveal = randaoReveal
alphaBlock.Block.Body.Eth1Data = &eth.Eth1Data{
alphaBlock.Block.Body.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
@@ -117,13 +117,13 @@ func Test_V1Alpha1ToV1SignedBlock(t *testing.T) {
}
func Test_V1ToV1Alpha1SignedBlock(t *testing.T) {
v1Block := testutil.HydrateV1SignedBeaconBlock(&ethpb.SignedBeaconBlock{})
v1Block := testutil.HydrateV1SignedBeaconBlock(&ethpbv1.SignedBeaconBlock{})
v1Block.Block.Slot = slot
v1Block.Block.ProposerIndex = validatorIndex
v1Block.Block.ParentRoot = parentRoot
v1Block.Block.StateRoot = stateRoot
v1Block.Block.Body.RandaoReveal = randaoReveal
v1Block.Block.Body.Eth1Data = &ethpb.Eth1Data{
v1Block.Block.Body.Eth1Data = &ethpbv1.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
@@ -140,13 +140,13 @@ func Test_V1ToV1Alpha1SignedBlock(t *testing.T) {
}
func Test_V1ToV1Alpha1Block(t *testing.T) {
alphaBlock := testutil.HydrateBeaconBlock(&eth.BeaconBlock{})
alphaBlock := testutil.HydrateBeaconBlock(&ethpbalpha.BeaconBlock{})
alphaBlock.Slot = slot
alphaBlock.ProposerIndex = validatorIndex
alphaBlock.ParentRoot = parentRoot
alphaBlock.StateRoot = stateRoot
alphaBlock.Body.RandaoReveal = randaoReveal
alphaBlock.Body.Eth1Data = &eth.Eth1Data{
alphaBlock.Body.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
@@ -162,24 +162,24 @@ func Test_V1ToV1Alpha1Block(t *testing.T) {
}
func Test_V1Alpha1AttSlashingToV1(t *testing.T) {
alphaAttestation := &eth.IndexedAttestation{
alphaAttestation := &ethpbalpha.IndexedAttestation{
AttestingIndices: attestingIndices,
Data: &eth.AttestationData{
Data: &ethpbalpha.AttestationData{
Slot: slot,
CommitteeIndex: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &eth.Checkpoint{
Source: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &eth.Checkpoint{
Target: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
alphaSlashing := &eth.AttesterSlashing{
alphaSlashing := &ethpbalpha.AttesterSlashing{
Attestation_1: alphaAttestation,
Attestation_2: alphaAttestation,
}
@@ -193,14 +193,14 @@ func Test_V1Alpha1AttSlashingToV1(t *testing.T) {
}
func Test_V1Alpha1ProposerSlashingToV1(t *testing.T) {
alphaHeader := testutil.HydrateSignedBeaconHeader(&eth.SignedBeaconBlockHeader{})
alphaHeader := testutil.HydrateSignedBeaconHeader(&ethpbalpha.SignedBeaconBlockHeader{})
alphaHeader.Header.Slot = slot
alphaHeader.Header.ProposerIndex = validatorIndex
alphaHeader.Header.ParentRoot = parentRoot
alphaHeader.Header.StateRoot = stateRoot
alphaHeader.Header.BodyRoot = bodyRoot
alphaHeader.Signature = signature
alphaSlashing := &eth.ProposerSlashing{
alphaSlashing := &ethpbalpha.ProposerSlashing{
Header_1: alphaHeader,
Header_2: alphaHeader,
}
@@ -214,8 +214,8 @@ func Test_V1Alpha1ProposerSlashingToV1(t *testing.T) {
}
func Test_V1Alpha1ExitToV1(t *testing.T) {
alphaExit := &eth.SignedVoluntaryExit{
Exit: &eth.VoluntaryExit{
alphaExit := &ethpbalpha.SignedVoluntaryExit{
Exit: &ethpbalpha.VoluntaryExit{
Epoch: epoch,
ValidatorIndex: validatorIndex,
},
@@ -231,8 +231,8 @@ func Test_V1Alpha1ExitToV1(t *testing.T) {
}
func Test_V1ExitToV1Alpha1(t *testing.T) {
v1Exit := &ethpb.SignedVoluntaryExit{
Message: &ethpb.VoluntaryExit{
v1Exit := &ethpbv1.SignedVoluntaryExit{
Message: &ethpbv1.VoluntaryExit{
Epoch: epoch,
ValidatorIndex: validatorIndex,
},
@@ -248,24 +248,24 @@ func Test_V1ExitToV1Alpha1(t *testing.T) {
}
func Test_V1AttSlashingToV1Alpha1(t *testing.T) {
v1Attestation := &ethpb.IndexedAttestation{
v1Attestation := &ethpbv1.IndexedAttestation{
AttestingIndices: attestingIndices,
Data: &ethpb.AttestationData{
Data: &ethpbv1.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpb.Checkpoint{
Source: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpb.Checkpoint{
Target: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
v1Slashing := &ethpb.AttesterSlashing{
v1Slashing := &ethpbv1.AttesterSlashing{
Attestation_1: v1Attestation,
Attestation_2: v1Attestation,
}
@@ -279,8 +279,8 @@ func Test_V1AttSlashingToV1Alpha1(t *testing.T) {
}
func Test_V1ProposerSlashingToV1Alpha1(t *testing.T) {
v1Header := &ethpb.SignedBeaconBlockHeader{
Message: &ethpb.BeaconBlockHeader{
v1Header := &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: slot,
ProposerIndex: validatorIndex,
ParentRoot: parentRoot,
@@ -289,7 +289,7 @@ func Test_V1ProposerSlashingToV1Alpha1(t *testing.T) {
},
Signature: signature,
}
v1Slashing := &ethpb.ProposerSlashing{
v1Slashing := &ethpbv1.ProposerSlashing{
SignedHeader_1: v1Header,
SignedHeader_2: v1Header,
}
@@ -303,17 +303,17 @@ func Test_V1ProposerSlashingToV1Alpha1(t *testing.T) {
}
func Test_V1Alpha1AttToV1(t *testing.T) {
alphaAtt := &eth.Attestation{
alphaAtt := &ethpbalpha.Attestation{
AggregationBits: aggregationBits,
Data: &eth.AttestationData{
Data: &ethpbalpha.AttestationData{
Slot: slot,
CommitteeIndex: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &eth.Checkpoint{
Source: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &eth.Checkpoint{
Target: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
@@ -330,17 +330,17 @@ func Test_V1Alpha1AttToV1(t *testing.T) {
}
func Test_V1AttToV1Alpha1(t *testing.T) {
v1Att := &ethpb.Attestation{
v1Att := &ethpbv1.Attestation{
AggregationBits: aggregationBits,
Data: &ethpb.AttestationData{
Data: &ethpbv1.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpb.Checkpoint{
Source: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpb.Checkpoint{
Target: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
@@ -357,13 +357,13 @@ func Test_V1AttToV1Alpha1(t *testing.T) {
}
func Test_BlockInterfaceToV1Block(t *testing.T) {
v1Alpha1Block := testutil.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{})
v1Alpha1Block := testutil.HydrateSignedBeaconBlock(&ethpbalpha.SignedBeaconBlock{})
v1Alpha1Block.Block.Slot = slot
v1Alpha1Block.Block.ProposerIndex = validatorIndex
v1Alpha1Block.Block.ParentRoot = parentRoot
v1Alpha1Block.Block.StateRoot = stateRoot
v1Alpha1Block.Block.Body.RandaoReveal = randaoReveal
v1Alpha1Block.Block.Body.Eth1Data = &eth.Eth1Data{
v1Alpha1Block.Block.Body.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
@@ -380,7 +380,7 @@ func Test_BlockInterfaceToV1Block(t *testing.T) {
}
func Test_V1Alpha1ValidatorToV1(t *testing.T) {
v1Alpha1Validator := &eth.Validator{
v1Alpha1Validator := &ethpbalpha.Validator{
PublicKey: []byte("pubkey"),
WithdrawalCredentials: []byte("withdraw"),
EffectiveBalance: 99,
@@ -404,7 +404,7 @@ func Test_V1Alpha1ValidatorToV1(t *testing.T) {
}
func Test_V1ValidatorToV1Alpha1(t *testing.T) {
v1Validator := &ethpb.Validator{
v1Validator := &ethpbv1.Validator{
Pubkey: []byte("pubkey"),
WithdrawalCredentials: []byte("withdraw"),
EffectiveBalance: 99,
@@ -428,10 +428,10 @@ func Test_V1ValidatorToV1Alpha1(t *testing.T) {
}
func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
v1Att := &ethpb.SignedAggregateAttestationAndProof{
Message: &ethpb.AggregateAttestationAndProof{
v1Att := &ethpbv1.SignedAggregateAttestationAndProof{
Message: &ethpbv1.AggregateAttestationAndProof{
AggregatorIndex: 1,
Aggregate: testutil.HydrateV1Attestation(&ethpb.Attestation{}),
Aggregate: testutil.HydrateV1Attestation(&ethpbv1.Attestation{}),
SelectionProof: selectionProof,
},
Signature: signature,
@@ -446,7 +446,7 @@ func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
}
func Test_V1AttestationToV1Alpha1(t *testing.T) {
v1Att := testutil.HydrateV1Attestation(&ethpb.Attestation{})
v1Att := testutil.HydrateV1Attestation(&ethpbv1.Attestation{})
v1Alpha1Att := V1AttToV1Alpha1(v1Att)
v1Root, err := v1Att.HashTreeRoot()
@@ -455,3 +455,31 @@ func Test_V1AttestationToV1Alpha1(t *testing.T) {
require.NoError(t, err)
assert.DeepEqual(t, v1Root, v1Alpha1Root)
}
func Test_V1Alpha1BeaconBlockAltairToV2(t *testing.T) {
alphaBlock := testutil.HydrateBeaconBlockAltair(&ethpbalpha.BeaconBlockAltair{})
alphaBlock.Slot = slot
alphaBlock.ProposerIndex = validatorIndex
alphaBlock.ParentRoot = parentRoot
alphaBlock.StateRoot = stateRoot
alphaBlock.Body.RandaoReveal = randaoReveal
alphaBlock.Body.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
syncCommitteeBits := bitfield.NewBitvector512()
syncCommitteeBits.SetBitAt(100, true)
alphaBlock.Body.SyncAggregate = &ethpbalpha.SyncAggregate{
SyncCommitteeBits: syncCommitteeBits,
SyncCommitteeSignature: signature,
}
v2Block, err := V1Alpha1BeaconBlockAltairToV2(alphaBlock)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v2Root, err := v2Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v2Root)
}