Clean up some unused beacon state proto types and related code (#13735)

This commit is contained in:
Preston Van Loon 2024-03-12 22:20:36 -05:00 committed by GitHub
parent 4731304187
commit 9c5d16e161
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 1 additions and 6675 deletions

View File

@ -16,8 +16,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/runtime/version"
)
var errExecutionUnmarshal = errors.New("unable to unmarshal execution engine data")
// PayloadIDBytes defines a custom type for Payload IDs used by the engine API
// client with proper JSON Marshal and Unmarshal methods to hex.
type PayloadIDBytes [8]byte

View File

@ -113,7 +113,6 @@ ssz_proto_files(
name = "ssz_proto_files",
srcs = [
"beacon_block.proto",
"beacon_state.proto",
],
config = select({
"//conditions:default": "mainnet",

View File

@ -1,938 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v4.25.1
// source: proto/eth/v1/beacon_state.proto
package v1
import (
reflect "reflect"
sync "sync"
github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield"
github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
_ "github.com/prysmaticlabs/prysm/v5/proto/eth/ext"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/descriptorpb"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type BeaconState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"`
GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"`
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"`
LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"`
BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"8192,32"`
StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"8192,32"`
HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"`
Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"`
Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"2048"`
Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"`
Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"`
Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"`
RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"65536,32"`
Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"8192"`
PreviousEpochAttestations []*PendingAttestation `protobuf:"bytes,7001,rep,name=previous_epoch_attestations,json=previousEpochAttestations,proto3" json:"previous_epoch_attestations,omitempty" ssz-max:"4096"`
CurrentEpochAttestations []*PendingAttestation `protobuf:"bytes,7002,rep,name=current_epoch_attestations,json=currentEpochAttestations,proto3" json:"current_epoch_attestations,omitempty" ssz-max:"4096"`
JustificationBits github_com_prysmaticlabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitvector4" ssz-size:"1"`
PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"`
CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"`
FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"`
}
func (x *BeaconState) Reset() {
*x = BeaconState{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BeaconState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BeaconState) ProtoMessage() {}
func (x *BeaconState) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BeaconState.ProtoReflect.Descriptor instead.
func (*BeaconState) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{0}
}
func (x *BeaconState) GetGenesisTime() uint64 {
if x != nil {
return x.GenesisTime
}
return 0
}
func (x *BeaconState) GetGenesisValidatorsRoot() []byte {
if x != nil {
return x.GenesisValidatorsRoot
}
return nil
}
func (x *BeaconState) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
}
func (x *BeaconState) GetFork() *Fork {
if x != nil {
return x.Fork
}
return nil
}
func (x *BeaconState) GetLatestBlockHeader() *BeaconBlockHeader {
if x != nil {
return x.LatestBlockHeader
}
return nil
}
func (x *BeaconState) GetBlockRoots() [][]byte {
if x != nil {
return x.BlockRoots
}
return nil
}
func (x *BeaconState) GetStateRoots() [][]byte {
if x != nil {
return x.StateRoots
}
return nil
}
func (x *BeaconState) GetHistoricalRoots() [][]byte {
if x != nil {
return x.HistoricalRoots
}
return nil
}
func (x *BeaconState) GetEth1Data() *Eth1Data {
if x != nil {
return x.Eth1Data
}
return nil
}
func (x *BeaconState) GetEth1DataVotes() []*Eth1Data {
if x != nil {
return x.Eth1DataVotes
}
return nil
}
func (x *BeaconState) GetEth1DepositIndex() uint64 {
if x != nil {
return x.Eth1DepositIndex
}
return 0
}
func (x *BeaconState) GetValidators() []*Validator {
if x != nil {
return x.Validators
}
return nil
}
func (x *BeaconState) GetBalances() []uint64 {
if x != nil {
return x.Balances
}
return nil
}
func (x *BeaconState) GetRandaoMixes() [][]byte {
if x != nil {
return x.RandaoMixes
}
return nil
}
func (x *BeaconState) GetSlashings() []uint64 {
if x != nil {
return x.Slashings
}
return nil
}
func (x *BeaconState) GetPreviousEpochAttestations() []*PendingAttestation {
if x != nil {
return x.PreviousEpochAttestations
}
return nil
}
func (x *BeaconState) GetCurrentEpochAttestations() []*PendingAttestation {
if x != nil {
return x.CurrentEpochAttestations
}
return nil
}
func (x *BeaconState) GetJustificationBits() github_com_prysmaticlabs_go_bitfield.Bitvector4 {
if x != nil {
return x.JustificationBits
}
return github_com_prysmaticlabs_go_bitfield.Bitvector4(nil)
}
func (x *BeaconState) GetPreviousJustifiedCheckpoint() *Checkpoint {
if x != nil {
return x.PreviousJustifiedCheckpoint
}
return nil
}
func (x *BeaconState) GetCurrentJustifiedCheckpoint() *Checkpoint {
if x != nil {
return x.CurrentJustifiedCheckpoint
}
return nil
}
func (x *BeaconState) GetFinalizedCheckpoint() *Checkpoint {
if x != nil {
return x.FinalizedCheckpoint
}
return nil
}
type PendingAttestation struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3" json:"aggregation_bits,omitempty" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitlist" ssz-max:"2048"`
Data *AttestationData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
InclusionDelay github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=inclusion_delay,json=inclusionDelay,proto3" json:"inclusion_delay,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
ProposerIndex github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex `protobuf:"varint,4,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"`
}
func (x *PendingAttestation) Reset() {
*x = PendingAttestation{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PendingAttestation) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PendingAttestation) ProtoMessage() {}
func (x *PendingAttestation) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PendingAttestation.ProtoReflect.Descriptor instead.
func (*PendingAttestation) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{1}
}
func (x *PendingAttestation) GetAggregationBits() github_com_prysmaticlabs_go_bitfield.Bitlist {
if x != nil {
return x.AggregationBits
}
return github_com_prysmaticlabs_go_bitfield.Bitlist(nil)
}
func (x *PendingAttestation) GetData() *AttestationData {
if x != nil {
return x.Data
}
return nil
}
func (x *PendingAttestation) GetInclusionDelay() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
if x != nil {
return x.InclusionDelay
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
}
func (x *PendingAttestation) GetProposerIndex() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex {
if x != nil {
return x.ProposerIndex
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(0)
}
type Committee struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Index github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.CommitteeIndex"`
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
Validators []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex `protobuf:"varint,3,rep,packed,name=validators,proto3" json:"validators,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"`
}
func (x *Committee) Reset() {
*x = Committee{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Committee) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Committee) ProtoMessage() {}
func (x *Committee) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Committee.ProtoReflect.Descriptor instead.
func (*Committee) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{2}
}
func (x *Committee) GetIndex() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex {
if x != nil {
return x.Index
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex(0)
}
func (x *Committee) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
}
func (x *Committee) GetValidators() []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex {
if x != nil {
return x.Validators
}
return []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(nil)
}
type Fork struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PreviousVersion []byte `protobuf:"bytes,1,opt,name=previous_version,json=previousVersion,proto3" json:"previous_version,omitempty" ssz-size:"4"`
CurrentVersion []byte `protobuf:"bytes,2,opt,name=current_version,json=currentVersion,proto3" json:"current_version,omitempty" ssz-size:"4"`
Epoch github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"`
}
func (x *Fork) Reset() {
*x = Fork{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Fork) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Fork) ProtoMessage() {}
func (x *Fork) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Fork.ProtoReflect.Descriptor instead.
func (*Fork) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{3}
}
func (x *Fork) GetPreviousVersion() []byte {
if x != nil {
return x.PreviousVersion
}
return nil
}
func (x *Fork) GetCurrentVersion() []byte {
if x != nil {
return x.CurrentVersion
}
return nil
}
func (x *Fork) GetEpoch() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch {
if x != nil {
return x.Epoch
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(0)
}
type ForkChoiceHeadsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*ForkChoiceHead `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ForkChoiceHeadsResponse) Reset() {
*x = ForkChoiceHeadsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ForkChoiceHeadsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ForkChoiceHeadsResponse) ProtoMessage() {}
func (x *ForkChoiceHeadsResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_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 ForkChoiceHeadsResponse.ProtoReflect.Descriptor instead.
func (*ForkChoiceHeadsResponse) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{4}
}
func (x *ForkChoiceHeadsResponse) GetData() []*ForkChoiceHead {
if x != nil {
return x.Data
}
return nil
}
type ForkChoiceHead struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Root []byte `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty" ssz-size:"32"`
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
}
func (x *ForkChoiceHead) Reset() {
*x = ForkChoiceHead{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ForkChoiceHead) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ForkChoiceHead) ProtoMessage() {}
func (x *ForkChoiceHead) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ForkChoiceHead.ProtoReflect.Descriptor instead.
func (*ForkChoiceHead) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{5}
}
func (x *ForkChoiceHead) GetRoot() []byte {
if x != nil {
return x.Root
}
return nil
}
func (x *ForkChoiceHead) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
}
type BeaconStateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *BeaconState `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *BeaconStateResponse) Reset() {
*x = BeaconStateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BeaconStateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BeaconStateResponse) ProtoMessage() {}
func (x *BeaconStateResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_beacon_state_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 BeaconStateResponse.ProtoReflect.Descriptor instead.
func (*BeaconStateResponse) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{6}
}
func (x *BeaconStateResponse) GetData() *BeaconState {
if x != nil {
return x.Data
}
return nil
}
var File_proto_eth_v1_beacon_state_proto protoreflect.FileDescriptor
var file_proto_eth_v1_beacon_state_proto_rawDesc = []byte{
0x0a, 0x1f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62,
0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x0f, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x31, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f,
0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x1e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f,
0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x1f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f,
0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x1c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0xdb, 0x0b, 0x0a, 0x0b, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65,
0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65,
0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73,
0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f,
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18,
0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15,
0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x5a, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07,
0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 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, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73,
0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d,
0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f,
0x74, 0x12, 0x2a, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x15, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x53, 0x0a,
0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65,
0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 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, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52,
0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64,
0x65, 0x72, 0x12, 0x2d, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74,
0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x0b, 0x8a, 0xb5, 0x18, 0x07, 0x38, 0x31,
0x39, 0x32, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74,
0x73, 0x12, 0x2d, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73,
0x18, 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x0b, 0x8a, 0xb5, 0x18, 0x07, 0x38, 0x31, 0x39,
0x32, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73,
0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72,
0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18,
0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31,
0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f,
0x74, 0x73, 0x12, 0x37, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18,
0xb9, 0x17, 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, 0x4c, 0x0a, 0x0f, 0x65,
0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba,
0x17, 0x20, 0x03, 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,
0x42, 0x08, 0x92, 0xb5, 0x18, 0x04, 0x32, 0x30, 0x34, 0x38, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31,
0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68,
0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18,
0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f,
0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x4e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69,
0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e,
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31,
0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61,
0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61,
0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18,
0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08,
0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64,
0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42,
0x0c, 0x8a, 0xb5, 0x18, 0x08, 0x36, 0x35, 0x35, 0x33, 0x36, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72,
0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, 0x12, 0x27, 0x0a, 0x09, 0x73, 0x6c,
0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x08,
0x8a, 0xb5, 0x18, 0x04, 0x38, 0x31, 0x39, 0x32, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69,
0x6e, 0x67, 0x73, 0x12, 0x6e, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f,
0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x18, 0xd9, 0x36, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64,
0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08,
0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x19, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f,
0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x12, 0x6c, 0x0a, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65,
0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x18, 0xda, 0x36, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69,
0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0x92,
0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x18, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x12, 0x68, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x38,
0x82, 0xb5, 0x18, 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, 0x67, 0x6f, 0x2d,
0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74,
0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x60, 0x0a, 0x1d, 0x70,
0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65,
0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66,
0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x5e, 0x0a,
0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69,
0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e,
0x74, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66,
0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x4f, 0x0a,
0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65,
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, 0x6c,
0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x97,
0x03, 0x0a, 0x12, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x63, 0x0a, 0x10, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42,
0x38, 0x82, 0xb5, 0x18, 0x2c, 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, 0x67, 0x6f,
0x2d, 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x6c, 0x69, 0x73,
0x74, 0x92, 0xb5, 0x18, 0x04, 0x32, 0x30, 0x34, 0x38, 0x52, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65,
0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x34, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 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, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x12, 0x6e, 0x0a, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65,
0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 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, 0x76, 0x35,
0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73,
0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74,
0x52, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x6c, 0x61, 0x79,
0x12, 0x76, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x64,
0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5, 0x18, 0x4b, 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, 0x76, 0x35, 0x2f,
0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f,
0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 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, 0x22, 0xbe, 0x02, 0x0a, 0x09, 0x43, 0x6f, 0x6d,
0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x65, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18,
0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5, 0x18, 0x4b, 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, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e,
0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69,
0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65,
0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x59, 0x0a,
0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18,
0x41, 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,
0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70,
0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c,
0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x6f, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69,
0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5,
0x18, 0x4b, 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, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79,
0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0a, 0x76,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xc6, 0x01, 0x0a, 0x04, 0x46, 0x6f,
0x72, 0x6b, 0x12, 0x30, 0x0a, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x76,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x05, 0x8a, 0xb5,
0x18, 0x01, 0x34, 0x52, 0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x05, 0x8a,
0xb5, 0x18, 0x01, 0x34, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20,
0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 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, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65,
0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69,
0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x05, 0x65, 0x70, 0x6f,
0x63, 0x68, 0x22, 0x4e, 0x0a, 0x17, 0x46, 0x6f, 0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65,
0x48, 0x65, 0x61, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74,
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f,
0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x48, 0x65, 0x61, 0x64, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x22, 0x87, 0x01, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63,
0x65, 0x48, 0x65, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x04, 0x72, 0x6f, 0x6f,
0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42,
0x45, 0x82, 0xb5, 0x18, 0x41, 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, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73,
0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65,
0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x22, 0x47, 0x0a, 0x13,
0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 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, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x7d, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68,
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x42, 0x65,
0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
0x5a, 0x2e, 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, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e,
0x56, 0x31, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74,
0x68, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_eth_v1_beacon_state_proto_rawDescOnce sync.Once
file_proto_eth_v1_beacon_state_proto_rawDescData = file_proto_eth_v1_beacon_state_proto_rawDesc
)
func file_proto_eth_v1_beacon_state_proto_rawDescGZIP() []byte {
file_proto_eth_v1_beacon_state_proto_rawDescOnce.Do(func() {
file_proto_eth_v1_beacon_state_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_eth_v1_beacon_state_proto_rawDescData)
})
return file_proto_eth_v1_beacon_state_proto_rawDescData
}
var file_proto_eth_v1_beacon_state_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_proto_eth_v1_beacon_state_proto_goTypes = []interface{}{
(*BeaconState)(nil), // 0: ethereum.eth.v1.BeaconState
(*PendingAttestation)(nil), // 1: ethereum.eth.v1.PendingAttestation
(*Committee)(nil), // 2: ethereum.eth.v1.Committee
(*Fork)(nil), // 3: ethereum.eth.v1.Fork
(*ForkChoiceHeadsResponse)(nil), // 4: ethereum.eth.v1.ForkChoiceHeadsResponse
(*ForkChoiceHead)(nil), // 5: ethereum.eth.v1.ForkChoiceHead
(*BeaconStateResponse)(nil), // 6: ethereum.eth.v1.BeaconStateResponse
(*BeaconBlockHeader)(nil), // 7: ethereum.eth.v1.BeaconBlockHeader
(*Eth1Data)(nil), // 8: ethereum.eth.v1.Eth1Data
(*Validator)(nil), // 9: ethereum.eth.v1.Validator
(*Checkpoint)(nil), // 10: ethereum.eth.v1.Checkpoint
(*AttestationData)(nil), // 11: ethereum.eth.v1.AttestationData
}
var file_proto_eth_v1_beacon_state_proto_depIdxs = []int32{
3, // 0: ethereum.eth.v1.BeaconState.fork:type_name -> ethereum.eth.v1.Fork
7, // 1: ethereum.eth.v1.BeaconState.latest_block_header:type_name -> ethereum.eth.v1.BeaconBlockHeader
8, // 2: ethereum.eth.v1.BeaconState.eth1_data:type_name -> ethereum.eth.v1.Eth1Data
8, // 3: ethereum.eth.v1.BeaconState.eth1_data_votes:type_name -> ethereum.eth.v1.Eth1Data
9, // 4: ethereum.eth.v1.BeaconState.validators:type_name -> ethereum.eth.v1.Validator
1, // 5: ethereum.eth.v1.BeaconState.previous_epoch_attestations:type_name -> ethereum.eth.v1.PendingAttestation
1, // 6: ethereum.eth.v1.BeaconState.current_epoch_attestations:type_name -> ethereum.eth.v1.PendingAttestation
10, // 7: ethereum.eth.v1.BeaconState.previous_justified_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
10, // 8: ethereum.eth.v1.BeaconState.current_justified_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
10, // 9: ethereum.eth.v1.BeaconState.finalized_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
11, // 10: ethereum.eth.v1.PendingAttestation.data:type_name -> ethereum.eth.v1.AttestationData
5, // 11: ethereum.eth.v1.ForkChoiceHeadsResponse.data:type_name -> ethereum.eth.v1.ForkChoiceHead
0, // 12: ethereum.eth.v1.BeaconStateResponse.data:type_name -> ethereum.eth.v1.BeaconState
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
}
func init() { file_proto_eth_v1_beacon_state_proto_init() }
func file_proto_eth_v1_beacon_state_proto_init() {
if File_proto_eth_v1_beacon_state_proto != nil {
return
}
file_proto_eth_v1_attestation_proto_init()
file_proto_eth_v1_beacon_block_proto_init()
file_proto_eth_v1_validator_proto_init()
if !protoimpl.UnsafeEnabled {
file_proto_eth_v1_beacon_state_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BeaconState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PendingAttestation); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Committee); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Fork); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ForkChoiceHeadsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ForkChoiceHead); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_beacon_state_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BeaconStateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_eth_v1_beacon_state_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_proto_eth_v1_beacon_state_proto_goTypes,
DependencyIndexes: file_proto_eth_v1_beacon_state_proto_depIdxs,
MessageInfos: file_proto_eth_v1_beacon_state_proto_msgTypes,
}.Build()
File_proto_eth_v1_beacon_state_proto = out.File
file_proto_eth_v1_beacon_state_proto_rawDesc = nil
file_proto_eth_v1_beacon_state_proto_goTypes = nil
file_proto_eth_v1_beacon_state_proto_depIdxs = nil
}

View File

@ -1,4 +0,0 @@
//go:build ignore
// +build ignore
package ignore

View File

@ -1,107 +0,0 @@
// Copyright 2020 Prysmatic Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package ethereum.eth.v1;
import "google/protobuf/descriptor.proto";
import "proto/eth/ext/options.proto";
import "proto/eth/v1/attestation.proto";
import "proto/eth/v1/beacon_block.proto";
import "proto/eth/v1/validator.proto";
option csharp_namespace = "Ethereum.Eth.V1";
option go_package = "github.com/prysmaticlabs/prysm/v5/proto/eth/v1";
option java_multiple_files = true;
option java_outer_classname = "BeaconStateProto";
option java_package = "org.ethereum.eth.v1";
option php_namespace = "Ethereum\\Eth\\v1";
message BeaconState {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
Fork fork = 1004;
// History [2001-3000]
BeaconBlockHeader latest_block_header = 2001;
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
// Eth1 [3001-4000]
Eth1Data eth1_data = 3001;
repeated Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
uint64 eth1_deposit_index = 3003;
// Registry [4001-5000]
repeated Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Randomness [5001-6000]
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
// Slashings [6001-7000]
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
// Attestations [7001-8000]
repeated PendingAttestation previous_epoch_attestations = 7001 [(ethereum.eth.ext.ssz_max) = "previous_epoch_attestations.max"];
repeated PendingAttestation current_epoch_attestations = 7002 [(ethereum.eth.ext.ssz_max) = "current_epoch_attestations.max"];
// Finality [8001-9000]
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
Checkpoint previous_justified_checkpoint = 8002;
Checkpoint current_justified_checkpoint = 8003;
Checkpoint finalized_checkpoint = 8004;
}
message PendingAttestation {
// Bitfield representation of validator indices that have voted exactly
// the same vote and have been aggregated into this attestation.
bytes aggregation_bits = 1 [(ethereum.eth.ext.ssz_max) = "2048", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];
AttestationData data = 2;
// The difference of when attestation gets created and get included on chain.
uint64 inclusion_delay = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
// The proposer who included the attestation in the block.
uint64 proposer_index = 4 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"];
}
message Committee {
uint64 index = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.CommitteeIndex"];
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
repeated uint64 validators = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"];
}
// Fork structure used for indicating beacon chain versioning and forks.
message Fork {
bytes previous_version = 1 [(ethereum.eth.ext.ssz_size) = "4"];
bytes current_version = 2 [(ethereum.eth.ext.ssz_size) = "4"];
uint64 epoch = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"];
}
message ForkChoiceHeadsResponse {
repeated ForkChoiceHead data = 1;
}
message ForkChoiceHead {
bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
}
message BeaconStateResponse {
BeaconState data = 1;
}

View File

@ -99,7 +99,6 @@ ssz_proto_files(
srcs = [
"beacon_block.proto",
"beacon_lightclient.proto",
"beacon_state.proto",
"sync_committee.proto",
"validator.proto",
"withdrawals.proto",

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
//go:build ignore
// +build ignore
package ignore

View File

@ -1,243 +0,0 @@
// Copyright 2021 Prysmatic Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package ethereum.eth.v2;
import "proto/eth/ext/options.proto";
import "proto/eth/v1/attestation.proto";
import "proto/eth/v1/beacon_block.proto";
import "proto/eth/v1/beacon_state.proto";
import "proto/eth/v1/validator.proto";
import "proto/eth/v2/sync_committee.proto";
import "proto/eth/v2/version.proto";
import "proto/engine/v1/execution_engine.proto";
option csharp_namespace = "Ethereum.Eth.V2";
option go_package = "github.com/prysmaticlabs/prysm/v5/proto/eth/v2;eth";
option java_multiple_files = true;
option java_outer_classname = "SyncCommitteeProto";
option java_package = "org.ethereum.eth.v2";
option php_namespace = "Ethereum\\Eth\\v2";
message BeaconState {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
v1.Fork fork = 1004;
// History [2001-3000]
v1.BeaconBlockHeader latest_block_header = 2001;
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
// Eth1 [3001-4000]
v1.Eth1Data eth1_data = 3001;
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
uint64 eth1_deposit_index = 3003;
// Registry [4001-5000]
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Randomness [5001-6000]
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
// Slashings [6001-7000]
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
// Participation [7001-8000]
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair, replaced previous_epoch_attestations]
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair, replaced current_epoch_attestations]
// Finality [8001-9000]
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
v1.Checkpoint previous_justified_checkpoint = 8002;
v1.Checkpoint current_justified_checkpoint = 8003;
v1.Checkpoint finalized_checkpoint = 8004;
// New Altair fields [9001-10000]
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair]
SyncCommittee current_sync_committee = 9002; // [New in Altair]
SyncCommittee next_sync_committee = 9003; // [New in Altair]
}
message BeaconStateBellatrix {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
v1.Fork fork = 1004;
// History [2001-3000]
v1.BeaconBlockHeader latest_block_header = 2001;
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
// Eth1 [3001-4000]
v1.Eth1Data eth1_data = 3001;
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
uint64 eth1_deposit_index = 3003;
// Registry [4001-5000]
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Randomness [5001-6000]
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
// Slashings [6001-7000]
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
// Participation [7001-8000]
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Finality [8001-9000]
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
v1.Checkpoint previous_justified_checkpoint = 8002;
v1.Checkpoint current_justified_checkpoint = 8003;
v1.Checkpoint finalized_checkpoint = 8004;
// Altair fields [9001-10000]
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
SyncCommittee current_sync_committee = 9002; // [New in Altair]
SyncCommittee next_sync_committee = 9003; // [New in Altair]
// Bellatrix fields [10001-11000]
engine.v1.ExecutionPayloadHeader latest_execution_payload_header = 10001; // [New in Bellatrix]
}
message BeaconStateCapella {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
v1.Fork fork = 1004;
// History [2001-3000]
v1.BeaconBlockHeader latest_block_header = 2001;
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
// Eth1 [3001-4000]
v1.Eth1Data eth1_data = 3001;
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
uint64 eth1_deposit_index = 3003;
// Registry [4001-5000]
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Randomness [5001-6000]
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
// Slashings [6001-7000]
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
// Participation [7001-8000]
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Finality [8001-9000]
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
v1.Checkpoint previous_justified_checkpoint = 8002;
v1.Checkpoint current_justified_checkpoint = 8003;
v1.Checkpoint finalized_checkpoint = 8004;
// Altair fields [9001-10000]
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
SyncCommittee current_sync_committee = 9002; // [New in Altair]
SyncCommittee next_sync_committee = 9003; // [New in Altair]
// Bellatrix fields [10001-11000]
ethereum.engine.v1.ExecutionPayloadHeaderCapella latest_execution_payload_header = 10001; // [New in Bellatrix]
// Capella fields [11001-12000]
uint64 next_withdrawal_index = 11001; // [New in Capella]
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"]; // [New in Capella]
}
message BeaconStateDeneb {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
v1.Fork fork = 1004;
// History [2001-3000]
v1.BeaconBlockHeader latest_block_header = 2001;
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
// Eth1 [3001-4000]
v1.Eth1Data eth1_data = 3001;
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
uint64 eth1_deposit_index = 3003;
// Registry [4001-5000]
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Randomness [5001-6000]
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
// Slashings [6001-7000]
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
// Participation [7001-8000]
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
// Finality [8001-9000]
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
v1.Checkpoint previous_justified_checkpoint = 8002;
v1.Checkpoint current_justified_checkpoint = 8003;
v1.Checkpoint finalized_checkpoint = 8004;
// Altair fields [9001-10000]
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
SyncCommittee current_sync_committee = 9002; // [New in Altair]
SyncCommittee next_sync_committee = 9003; // [New in Altair]
// Bellatrix fields [10001-11000]
ethereum.engine.v1.ExecutionPayloadHeaderDeneb latest_execution_payload_header = 10001; // [Updated in Deneb]
// Capella fields [11001-12000]
uint64 next_withdrawal_index = 11001; // [New in Capella]
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"]; // [New in Capella]
}
message HistoricalSummary {
bytes block_summary_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
bytes state_summary_root = 2 [(ethereum.eth.ext.ssz_size) = "32"];
}
message BeaconStateSSZResponseV2 {
v2.Version version = 1;
bytes data = 2;
}
message ForkChoiceHeadsResponse {
repeated ForkChoiceHead data = 1;
}
message ForkChoiceHead {
bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
bool execution_optimistic = 3;
}

View File

@ -6,22 +6,15 @@ go_library(
"enums.go",
"v1alpha1_to_v1.go",
"v1alpha1_to_v2.go",
"v2_to_v1alpha1.go",
],
importpath = "github.com/prysmaticlabs/prysm/v5/proto/migration",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/state:go_default_library",
"//config/fieldparams:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//encoding/bytesutil:go_default_library",
"//encoding/ssz:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
],
)
@ -30,22 +23,13 @@ go_test(
srcs = [
"enums_test.go",
"v1alpha1_to_v1_test.go",
"v1alpha1_to_v2_test.go",
"v2_to_v1alpha1_test.go",
],
embed = [":go_default_library"],
deps = [
"//config/fieldparams:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"//testing/util:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
],
)

View File

@ -1,170 +1,10 @@
package migration
import (
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
)
// BlockIfaceToV1BlockHeader converts a signed beacon block interface into a signed beacon block header.
func BlockIfaceToV1BlockHeader(block interfaces.ReadOnlySignedBeaconBlock) (*ethpbv1.SignedBeaconBlockHeader, error) {
bodyRoot, err := block.Block().Body().HashTreeRoot()
if err != nil {
return nil, errors.Wrap(err, "failed to get body root of block")
}
parentRoot := block.Block().ParentRoot()
stateRoot := block.Block().StateRoot()
sig := block.Signature()
return &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: block.Block().Slot(),
ProposerIndex: block.Block().ProposerIndex(),
ParentRoot: parentRoot[:],
StateRoot: stateRoot[:],
BodyRoot: bodyRoot[:],
},
Signature: sig[:],
}, nil
}
// V1Alpha1ToV1SignedBlock converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
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 := &ethpbv1.SignedBeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1Block, nil
}
// V1ToV1Alpha1SignedBlock converts a v1 SignedBeaconBlock proto to a v1alpha1 proto.
func V1ToV1Alpha1SignedBlock(v1Blk *ethpbv1.SignedBeaconBlock) (*ethpbalpha.SignedBeaconBlock, error) {
marshaledBlk, err := proto.Marshal(v1Blk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// V1Alpha1ToV1Block converts a v1alpha1 ReadOnlyBeaconBlock proto to a v1 proto.
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 := &ethpbv1.BeaconBlock{}
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1Block, nil
}
// V1Alpha1AggregateAttAndProofToV1 converts a v1alpha1 aggregate attestation and proof to v1.
func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *ethpbalpha.AggregateAttestationAndProof) *ethpbv1.AggregateAttestationAndProof {
if v1alpha1Att == nil {
return &ethpbv1.AggregateAttestationAndProof{}
}
return &ethpbv1.AggregateAttestationAndProof{
AggregatorIndex: v1alpha1Att.AggregatorIndex,
Aggregate: V1Alpha1AttestationToV1(v1alpha1Att.Aggregate),
SelectionProof: v1alpha1Att.SelectionProof,
}
}
// V1SignedAggregateAttAndProofToV1Alpha1 converts a v1 signed aggregate attestation and proof to v1alpha1.
func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpbv1.SignedAggregateAttestationAndProof) *ethpbalpha.SignedAggregateAttestationAndProof {
if v1Att == nil {
return &ethpbalpha.SignedAggregateAttestationAndProof{}
}
return &ethpbalpha.SignedAggregateAttestationAndProof{
Message: &ethpbalpha.AggregateAttestationAndProof{
AggregatorIndex: v1Att.Message.AggregatorIndex,
Aggregate: V1AttestationToV1Alpha1(v1Att.Message.Aggregate),
SelectionProof: v1Att.Message.SelectionProof,
},
Signature: v1Att.Signature,
}
}
// V1Alpha1IndexedAttToV1 converts a v1alpha1 indexed attestation to v1.
func V1Alpha1IndexedAttToV1(v1alpha1Att *ethpbalpha.IndexedAttestation) *ethpbv1.IndexedAttestation {
if v1alpha1Att == nil {
return &ethpbv1.IndexedAttestation{}
}
return &ethpbv1.IndexedAttestation{
AttestingIndices: v1alpha1Att.AttestingIndices,
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
Signature: v1alpha1Att.Signature,
}
}
// V1Alpha1AttestationToV1 converts a v1alpha1 attestation to v1.
func V1Alpha1AttestationToV1(v1alpha1Att *ethpbalpha.Attestation) *ethpbv1.Attestation {
if v1alpha1Att == nil {
return &ethpbv1.Attestation{}
}
return &ethpbv1.Attestation{
AggregationBits: v1alpha1Att.AggregationBits,
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
Signature: v1alpha1Att.Signature,
}
}
// V1AttestationToV1Alpha1 converts a v1 attestation to v1alpha1.
func V1AttestationToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
if v1Att == nil {
return &ethpbalpha.Attestation{}
}
return &ethpbalpha.Attestation{
AggregationBits: v1Att.AggregationBits,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
}
}
// V1Alpha1AttDataToV1 converts a v1alpha1 attestation data to v1.
func V1Alpha1AttDataToV1(v1alpha1AttData *ethpbalpha.AttestationData) *ethpbv1.AttestationData {
if v1alpha1AttData == nil || v1alpha1AttData.Source == nil || v1alpha1AttData.Target == nil {
return &ethpbv1.AttestationData{}
}
return &ethpbv1.AttestationData{
Slot: v1alpha1AttData.Slot,
Index: v1alpha1AttData.CommitteeIndex,
BeaconBlockRoot: v1alpha1AttData.BeaconBlockRoot,
Source: &ethpbv1.Checkpoint{
Root: v1alpha1AttData.Source.Root,
Epoch: v1alpha1AttData.Source.Epoch,
},
Target: &ethpbv1.Checkpoint{
Root: v1alpha1AttData.Target.Root,
Epoch: v1alpha1AttData.Target.Epoch,
},
}
}
// V1Alpha1AttSlashingToV1 converts a v1alpha1 attester slashing to v1.
func V1Alpha1AttSlashingToV1(v1alpha1Slashing *ethpbalpha.AttesterSlashing) *ethpbv1.AttesterSlashing {
if v1alpha1Slashing == nil {
return &ethpbv1.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 *ethpbalpha.SignedBeaconBlockHeader) *ethpbv1.SignedBeaconBlockHeader {
if v1alpha1Hdr == nil || v1alpha1Hdr.Header == nil {
@ -191,23 +31,6 @@ func V1Alpha1HeaderToV1(v1alpha1Hdr *ethpbalpha.BeaconBlockHeader) *ethpbv1.Beac
}
}
// V1SignedHeaderToV1Alpha1 converts a v1 signed beacon block header to v1alpha1.
func V1SignedHeaderToV1Alpha1(v1Header *ethpbv1.SignedBeaconBlockHeader) *ethpbalpha.SignedBeaconBlockHeader {
if v1Header == nil || v1Header.Message == nil {
return &ethpbalpha.SignedBeaconBlockHeader{}
}
return &ethpbalpha.SignedBeaconBlockHeader{
Header: &ethpbalpha.BeaconBlockHeader{
Slot: v1Header.Message.Slot,
ProposerIndex: v1Header.Message.ProposerIndex,
ParentRoot: v1Header.Message.ParentRoot,
StateRoot: v1Header.Message.StateRoot,
BodyRoot: v1Header.Message.BodyRoot,
},
Signature: v1Header.Signature,
}
}
// V1HeaderToV1Alpha1 converts a v1 beacon block header to v1alpha1.
func V1HeaderToV1Alpha1(v1Header *ethpbv1.BeaconBlockHeader) *ethpbalpha.BeaconBlockHeader {
if v1Header == nil {
@ -222,128 +45,6 @@ func V1HeaderToV1Alpha1(v1Header *ethpbv1.BeaconBlockHeader) *ethpbalpha.BeaconB
}
}
// V1Alpha1ProposerSlashingToV1 converts a v1alpha1 proposer slashing to v1.
func V1Alpha1ProposerSlashingToV1(v1alpha1Slashing *ethpbalpha.ProposerSlashing) *ethpbv1.ProposerSlashing {
if v1alpha1Slashing == nil {
return &ethpbv1.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 *ethpbalpha.SignedVoluntaryExit) *ethpbv1.SignedVoluntaryExit {
if v1alpha1Exit == nil || v1alpha1Exit.Exit == nil {
return &ethpbv1.SignedVoluntaryExit{}
}
return &ethpbv1.SignedVoluntaryExit{
Message: &ethpbv1.VoluntaryExit{
Epoch: v1alpha1Exit.Exit.Epoch,
ValidatorIndex: v1alpha1Exit.Exit.ValidatorIndex,
},
Signature: v1alpha1Exit.Signature,
}
}
// V1ExitToV1Alpha1 converts a v1 SignedVoluntaryExit to v1alpha1.
func V1ExitToV1Alpha1(v1Exit *ethpbv1.SignedVoluntaryExit) *ethpbalpha.SignedVoluntaryExit {
if v1Exit == nil || v1Exit.Message == nil {
return &ethpbalpha.SignedVoluntaryExit{}
}
return &ethpbalpha.SignedVoluntaryExit{
Exit: &ethpbalpha.VoluntaryExit{
Epoch: v1Exit.Message.Epoch,
ValidatorIndex: v1Exit.Message.ValidatorIndex,
},
Signature: v1Exit.Signature,
}
}
// V1AttToV1Alpha1 converts a v1 attestation to v1alpha1.
func V1AttToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
if v1Att == nil {
return &ethpbalpha.Attestation{}
}
return &ethpbalpha.Attestation{
AggregationBits: v1Att.AggregationBits,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
}
}
// V1IndexedAttToV1Alpha1 converts a v1 indexed attestation to v1alpha1.
func V1IndexedAttToV1Alpha1(v1Att *ethpbv1.IndexedAttestation) *ethpbalpha.IndexedAttestation {
if v1Att == nil {
return &ethpbalpha.IndexedAttestation{}
}
return &ethpbalpha.IndexedAttestation{
AttestingIndices: v1Att.AttestingIndices,
Data: V1AttDataToV1Alpha1(v1Att.Data),
Signature: v1Att.Signature,
}
}
// V1AttDataToV1Alpha1 converts a v1 attestation data to v1alpha1.
func V1AttDataToV1Alpha1(v1AttData *ethpbv1.AttestationData) *ethpbalpha.AttestationData {
if v1AttData == nil || v1AttData.Source == nil || v1AttData.Target == nil {
return &ethpbalpha.AttestationData{}
}
return &ethpbalpha.AttestationData{
Slot: v1AttData.Slot,
CommitteeIndex: v1AttData.Index,
BeaconBlockRoot: v1AttData.BeaconBlockRoot,
Source: &ethpbalpha.Checkpoint{
Root: v1AttData.Source.Root,
Epoch: v1AttData.Source.Epoch,
},
Target: &ethpbalpha.Checkpoint{
Root: v1AttData.Target.Root,
Epoch: v1AttData.Target.Epoch,
},
}
}
// V1AttSlashingToV1Alpha1 converts a v1 attester slashing to v1alpha1.
func V1AttSlashingToV1Alpha1(v1Slashing *ethpbv1.AttesterSlashing) *ethpbalpha.AttesterSlashing {
if v1Slashing == nil {
return &ethpbalpha.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 *ethpbv1.ProposerSlashing) *ethpbalpha.ProposerSlashing {
if v1Slashing == nil {
return &ethpbalpha.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 *ethpbalpha.Validator) *ethpbv1.Validator {
if v1Alpha1Validator == nil {
return &ethpbv1.Validator{}
}
return &ethpbv1.Validator{
Pubkey: v1Alpha1Validator.PublicKey,
WithdrawalCredentials: v1Alpha1Validator.WithdrawalCredentials,
EffectiveBalance: v1Alpha1Validator.EffectiveBalance,
Slashed: v1Alpha1Validator.Slashed,
ActivationEligibilityEpoch: v1Alpha1Validator.ActivationEligibilityEpoch,
ActivationEpoch: v1Alpha1Validator.ActivationEpoch,
ExitEpoch: v1Alpha1Validator.ExitEpoch,
WithdrawableEpoch: v1Alpha1Validator.WithdrawableEpoch,
}
}
// V1ValidatorToV1Alpha1 converts a v1 validator to v1alpha1.
func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator {
if v1Validator == nil {
@ -360,161 +61,3 @@ func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator
WithdrawableEpoch: v1Validator.WithdrawableEpoch,
}
}
// SignedBeaconBlock converts a signed beacon block interface to a v1alpha1 block.
func SignedBeaconBlock(block interfaces.ReadOnlySignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
if block == nil || block.IsNil() {
return nil, errors.New("could not find requested block")
}
blk, err := block.PbPhase0Block()
if err != nil {
return nil, errors.Wrapf(err, "could not get raw block")
}
v1Block, err := V1Alpha1ToV1SignedBlock(blk)
if err != nil {
return nil, errors.New("could not convert block to v1 block")
}
return v1Block, nil
}
// BeaconStateToProto converts a state.BeaconState object to its protobuf equivalent.
func BeaconStateToProto(state state.BeaconState) (*ethpbv1.BeaconState, error) {
sourceFork := state.Fork()
sourceLatestBlockHeader := state.LatestBlockHeader()
sourceEth1Data := state.Eth1Data()
sourceEth1DataVotes := state.Eth1DataVotes()
sourceValidators := state.Validators()
sourcePrevEpochAtts, err := state.PreviousEpochAttestations()
if err != nil {
return nil, errors.Wrapf(err, "could not get previous epoch attestations from state")
}
sourceCurrEpochAtts, err := state.CurrentEpochAttestations()
if err != nil {
return nil, errors.Wrapf(err, "could not get current epoch attestations from state")
}
sourceJustificationBits := state.JustificationBits()
sourcePrevJustifiedCheckpoint := state.PreviousJustifiedCheckpoint()
sourceCurrJustifiedCheckpoint := state.CurrentJustifiedCheckpoint()
sourceFinalizedCheckpoint := state.FinalizedCheckpoint()
resultEth1DataVotes := make([]*ethpbv1.Eth1Data, len(sourceEth1DataVotes))
for i, vote := range sourceEth1DataVotes {
resultEth1DataVotes[i] = &ethpbv1.Eth1Data{
DepositRoot: bytesutil.SafeCopyBytes(vote.DepositRoot),
DepositCount: vote.DepositCount,
BlockHash: bytesutil.SafeCopyBytes(vote.BlockHash),
}
}
resultValidators := make([]*ethpbv1.Validator, len(sourceValidators))
for i, validator := range sourceValidators {
resultValidators[i] = &ethpbv1.Validator{
Pubkey: bytesutil.SafeCopyBytes(validator.PublicKey),
WithdrawalCredentials: bytesutil.SafeCopyBytes(validator.WithdrawalCredentials),
EffectiveBalance: validator.EffectiveBalance,
Slashed: validator.Slashed,
ActivationEligibilityEpoch: validator.ActivationEligibilityEpoch,
ActivationEpoch: validator.ActivationEpoch,
ExitEpoch: validator.ExitEpoch,
WithdrawableEpoch: validator.WithdrawableEpoch,
}
}
resultPrevEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourcePrevEpochAtts))
for i, att := range sourcePrevEpochAtts {
data := att.Data
resultPrevEpochAtts[i] = &ethpbv1.PendingAttestation{
AggregationBits: att.AggregationBits,
Data: &ethpbv1.AttestationData{
Slot: data.Slot,
Index: data.CommitteeIndex,
BeaconBlockRoot: data.BeaconBlockRoot,
Source: &ethpbv1.Checkpoint{
Epoch: data.Source.Epoch,
Root: data.Source.Root,
},
Target: &ethpbv1.Checkpoint{
Epoch: data.Target.Epoch,
Root: data.Target.Root,
},
},
InclusionDelay: att.InclusionDelay,
ProposerIndex: att.ProposerIndex,
}
}
resultCurrEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourceCurrEpochAtts))
for i, att := range sourceCurrEpochAtts {
data := att.Data
resultCurrEpochAtts[i] = &ethpbv1.PendingAttestation{
AggregationBits: att.AggregationBits,
Data: &ethpbv1.AttestationData{
Slot: data.Slot,
Index: data.CommitteeIndex,
BeaconBlockRoot: data.BeaconBlockRoot,
Source: &ethpbv1.Checkpoint{
Epoch: data.Source.Epoch,
Root: data.Source.Root,
},
Target: &ethpbv1.Checkpoint{
Epoch: data.Target.Epoch,
Root: data.Target.Root,
},
},
InclusionDelay: att.InclusionDelay,
ProposerIndex: att.ProposerIndex,
}
}
hRoot, err := state.HistoricalRoots()
if err != nil {
return nil, errors.Wrapf(err, "could not get historical roots from state")
}
result := &ethpbv1.BeaconState{
GenesisTime: state.GenesisTime(),
GenesisValidatorsRoot: bytesutil.SafeCopyBytes(state.GenesisValidatorsRoot()),
Slot: state.Slot(),
Fork: &ethpbv1.Fork{
PreviousVersion: bytesutil.SafeCopyBytes(sourceFork.PreviousVersion),
CurrentVersion: bytesutil.SafeCopyBytes(sourceFork.CurrentVersion),
Epoch: sourceFork.Epoch,
},
LatestBlockHeader: &ethpbv1.BeaconBlockHeader{
Slot: sourceLatestBlockHeader.Slot,
ProposerIndex: sourceLatestBlockHeader.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.StateRoot),
BodyRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.BodyRoot),
},
BlockRoots: bytesutil.SafeCopy2dBytes(state.BlockRoots()),
StateRoots: bytesutil.SafeCopy2dBytes(state.StateRoots()),
HistoricalRoots: bytesutil.SafeCopy2dBytes(hRoot),
Eth1Data: &ethpbv1.Eth1Data{
DepositRoot: bytesutil.SafeCopyBytes(sourceEth1Data.DepositRoot),
DepositCount: sourceEth1Data.DepositCount,
BlockHash: bytesutil.SafeCopyBytes(sourceEth1Data.BlockHash),
},
Eth1DataVotes: resultEth1DataVotes,
Eth1DepositIndex: state.Eth1DepositIndex(),
Validators: resultValidators,
Balances: state.Balances(),
RandaoMixes: bytesutil.SafeCopy2dBytes(state.RandaoMixes()),
Slashings: state.Slashings(),
PreviousEpochAttestations: resultPrevEpochAtts,
CurrentEpochAttestations: resultCurrEpochAtts,
JustificationBits: bytesutil.SafeCopyBytes(sourceJustificationBits),
PreviousJustifiedCheckpoint: &ethpbv1.Checkpoint{
Epoch: sourcePrevJustifiedCheckpoint.Epoch,
Root: bytesutil.SafeCopyBytes(sourcePrevJustifiedCheckpoint.Root),
},
CurrentJustifiedCheckpoint: &ethpbv1.Checkpoint{
Epoch: sourceCurrJustifiedCheckpoint.Epoch,
Root: bytesutil.SafeCopyBytes(sourceCurrJustifiedCheckpoint.Root),
},
FinalizedCheckpoint: &ethpbv1.Checkpoint{
Epoch: sourceFinalizedCheckpoint.Epoch,
Root: bytesutil.SafeCopyBytes(sourceFinalizedCheckpoint.Root),
},
}
return result, nil
}

View File

@ -3,403 +3,12 @@ package migration
import (
"testing"
"github.com/prysmaticlabs/go-bitfield"
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v5/testing/assert"
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/testing/util"
)
var (
slot = primitives.Slot(1)
epoch = primitives.Epoch(1)
validatorIndex = primitives.ValidatorIndex(1)
committeeIndex = primitives.CommitteeIndex(1)
depositCount = uint64(2)
attestingIndices = []uint64{1, 2}
blockNumber = uint64(10)
gasLimit = uint64(10)
gasUsed = uint64(10)
timestamp = uint64(10)
parentRoot = bytesutil.PadTo([]byte("parentroot"), fieldparams.RootLength)
stateRoot = bytesutil.PadTo([]byte("stateroot"), fieldparams.RootLength)
signature = bytesutil.PadTo([]byte("signature"), 96)
randaoReveal = bytesutil.PadTo([]byte("randaoreveal"), 96)
depositRoot = bytesutil.PadTo([]byte("depositroot"), fieldparams.RootLength)
blockHash = bytesutil.PadTo([]byte("blockhash"), 32)
beaconBlockRoot = bytesutil.PadTo([]byte("beaconblockroot"), fieldparams.RootLength)
sourceRoot = bytesutil.PadTo([]byte("sourceroot"), fieldparams.RootLength)
targetRoot = bytesutil.PadTo([]byte("targetroot"), fieldparams.RootLength)
bodyRoot = bytesutil.PadTo([]byte("bodyroot"), fieldparams.RootLength)
selectionProof = bytesutil.PadTo([]byte("selectionproof"), 96)
parentHash = bytesutil.PadTo([]byte("parenthash"), 32)
feeRecipient = bytesutil.PadTo([]byte("feerecipient"), 20)
receiptsRoot = bytesutil.PadTo([]byte("receiptsroot"), 32)
logsBloom = bytesutil.PadTo([]byte("logsbloom"), 256)
prevRandao = bytesutil.PadTo([]byte("prevrandao"), 32)
extraData = bytesutil.PadTo([]byte("extradata"), 32)
baseFeePerGas = bytesutil.PadTo([]byte("basefeepergas"), 32)
transactionsRoot = bytesutil.PadTo([]byte("transactions"), 32)
aggregationBits = bitfield.Bitlist{0x01}
)
func Test_BlockIfaceToV1BlockHeader(t *testing.T) {
alphaBlock := util.HydrateSignedBeaconBlock(&ethpbalpha.SignedBeaconBlock{})
alphaBlock.Block.Slot = slot
alphaBlock.Block.ProposerIndex = validatorIndex
alphaBlock.Block.ParentRoot = parentRoot
alphaBlock.Block.StateRoot = stateRoot
alphaBlock.Signature = signature
wsb, err := blocks.NewSignedBeaconBlock(alphaBlock)
require.NoError(t, err)
v1Header, err := BlockIfaceToV1BlockHeader(wsb)
require.NoError(t, err)
bodyRoot, err := alphaBlock.Block.Body.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, bodyRoot[:], v1Header.Message.BodyRoot)
assert.Equal(t, slot, v1Header.Message.Slot)
assert.Equal(t, validatorIndex, v1Header.Message.ProposerIndex)
assert.DeepEqual(t, parentRoot, v1Header.Message.ParentRoot)
assert.DeepEqual(t, stateRoot, v1Header.Message.StateRoot)
assert.DeepEqual(t, signature, v1Header.Signature)
}
func Test_V1Alpha1AggregateAttAndProofToV1(t *testing.T) {
proof := [32]byte{1}
att := util.HydrateAttestation(&ethpbalpha.Attestation{
Data: &ethpbalpha.AttestationData{
Slot: 5,
},
})
alpha := &ethpbalpha.AggregateAttestationAndProof{
AggregatorIndex: 1,
Aggregate: att,
SelectionProof: proof[:],
}
v1 := V1Alpha1AggregateAttAndProofToV1(alpha)
assert.Equal(t, v1.AggregatorIndex, primitives.ValidatorIndex(1))
assert.DeepSSZEqual(t, v1.Aggregate.Data.Slot, att.Data.Slot)
assert.DeepEqual(t, v1.SelectionProof, proof[:])
}
func Test_V1Alpha1ToV1SignedBlock(t *testing.T) {
alphaBlock := util.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 = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
alphaBlock.Signature = signature
v1Block, err := V1Alpha1ToV1SignedBlock(alphaBlock)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1ToV1Alpha1SignedBlock(t *testing.T) {
v1Block := util.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 = &ethpbv1.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
v1Block.Signature = signature
alphaBlock, err := V1ToV1Alpha1SignedBlock(v1Block)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, alphaRoot)
}
func Test_V1ToV1Alpha1Block(t *testing.T) {
alphaBlock := util.HydrateBeaconBlock(&ethpbalpha.BeaconBlock{})
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,
}
v1Block, err := V1Alpha1ToV1Block(alphaBlock)
require.NoError(t, err)
v1Root, err := v1Block.HashTreeRoot()
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1Alpha1AttSlashingToV1(t *testing.T) {
alphaAttestation := &ethpbalpha.IndexedAttestation{
AttestingIndices: attestingIndices,
Data: &ethpbalpha.AttestationData{
Slot: slot,
CommitteeIndex: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
alphaSlashing := &ethpbalpha.AttesterSlashing{
Attestation_1: alphaAttestation,
Attestation_2: alphaAttestation,
}
v1Slashing := V1Alpha1AttSlashingToV1(alphaSlashing)
alphaRoot, err := alphaSlashing.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Slashing.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1Alpha1ProposerSlashingToV1(t *testing.T) {
alphaHeader := util.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 := &ethpbalpha.ProposerSlashing{
Header_1: alphaHeader,
Header_2: alphaHeader,
}
v1Slashing := V1Alpha1ProposerSlashingToV1(alphaSlashing)
alphaRoot, err := alphaSlashing.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Slashing.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1Alpha1ExitToV1(t *testing.T) {
alphaExit := &ethpbalpha.SignedVoluntaryExit{
Exit: &ethpbalpha.VoluntaryExit{
Epoch: epoch,
ValidatorIndex: validatorIndex,
},
Signature: signature,
}
v1Exit := V1Alpha1ExitToV1(alphaExit)
alphaRoot, err := alphaExit.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Exit.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1ExitToV1Alpha1(t *testing.T) {
v1Exit := &ethpbv1.SignedVoluntaryExit{
Message: &ethpbv1.VoluntaryExit{
Epoch: epoch,
ValidatorIndex: validatorIndex,
},
Signature: signature,
}
alphaExit := V1ExitToV1Alpha1(v1Exit)
alphaRoot, err := alphaExit.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Exit.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1AttSlashingToV1Alpha1(t *testing.T) {
v1Attestation := &ethpbv1.IndexedAttestation{
AttestingIndices: attestingIndices,
Data: &ethpbv1.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
v1Slashing := &ethpbv1.AttesterSlashing{
Attestation_1: v1Attestation,
Attestation_2: v1Attestation,
}
alphaSlashing := V1AttSlashingToV1Alpha1(v1Slashing)
alphaRoot, err := alphaSlashing.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Slashing.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, alphaRoot)
}
func Test_V1ProposerSlashingToV1Alpha1(t *testing.T) {
v1Header := &ethpbv1.SignedBeaconBlockHeader{
Message: &ethpbv1.BeaconBlockHeader{
Slot: slot,
ProposerIndex: validatorIndex,
ParentRoot: parentRoot,
StateRoot: stateRoot,
BodyRoot: bodyRoot,
},
Signature: signature,
}
v1Slashing := &ethpbv1.ProposerSlashing{
SignedHeader_1: v1Header,
SignedHeader_2: v1Header,
}
alphaSlashing := V1ProposerSlashingToV1Alpha1(v1Slashing)
alphaRoot, err := alphaSlashing.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Slashing.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, alphaRoot, v1Root)
}
func Test_V1Alpha1AttToV1(t *testing.T) {
alphaAtt := &ethpbalpha.Attestation{
AggregationBits: aggregationBits,
Data: &ethpbalpha.AttestationData{
Slot: slot,
CommitteeIndex: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpbalpha.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
v1Att := V1Alpha1AttestationToV1(alphaAtt)
v1Root, err := v1Att.HashTreeRoot()
require.NoError(t, err)
alphaRoot, err := alphaAtt.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, alphaRoot)
}
func Test_V1AttToV1Alpha1(t *testing.T) {
v1Att := &ethpbv1.Attestation{
AggregationBits: aggregationBits,
Data: &ethpbv1.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: beaconBlockRoot,
Source: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: sourceRoot,
},
Target: &ethpbv1.Checkpoint{
Epoch: epoch,
Root: targetRoot,
},
},
Signature: signature,
}
alphaAtt := V1AttToV1Alpha1(v1Att)
alphaRoot, err := alphaAtt.HashTreeRoot()
require.NoError(t, err)
v1Root, err := v1Att.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, alphaRoot)
}
func Test_BlockInterfaceToV1Block(t *testing.T) {
v1Alpha1Block := util.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 = &ethpbalpha.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
v1Alpha1Block.Signature = signature
wsb, err := blocks.NewSignedBeaconBlock(v1Alpha1Block)
require.NoError(t, err)
v1Block, err := SignedBeaconBlock(wsb)
require.NoError(t, err)
v1Root, err := v1Block.HashTreeRoot()
require.NoError(t, err)
v1Alpha1Root, err := v1Alpha1Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, v1Alpha1Root)
}
func Test_V1Alpha1ValidatorToV1(t *testing.T) {
v1Alpha1Validator := &ethpbalpha.Validator{
PublicKey: []byte("pubkey"),
WithdrawalCredentials: []byte("withdraw"),
EffectiveBalance: 99,
Slashed: true,
ActivationEligibilityEpoch: 1,
ActivationEpoch: 11,
ExitEpoch: 111,
WithdrawableEpoch: 1111,
}
v1Validator := V1Alpha1ValidatorToV1(v1Alpha1Validator)
require.NotNil(t, v1Validator)
assert.DeepEqual(t, []byte("pubkey"), v1Validator.Pubkey)
assert.DeepEqual(t, []byte("withdraw"), v1Validator.WithdrawalCredentials)
assert.Equal(t, uint64(99), v1Validator.EffectiveBalance)
assert.Equal(t, true, v1Validator.Slashed)
assert.Equal(t, primitives.Epoch(1), v1Validator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), v1Validator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(111), v1Validator.ExitEpoch)
assert.Equal(t, primitives.Epoch(1111), v1Validator.WithdrawableEpoch)
}
func Test_V1ValidatorToV1Alpha1(t *testing.T) {
v1Validator := &ethpbv1.Validator{
Pubkey: []byte("pubkey"),
@ -423,231 +32,3 @@ func Test_V1ValidatorToV1Alpha1(t *testing.T) {
assert.Equal(t, primitives.Epoch(111), v1Alpha1Validator.ExitEpoch)
assert.Equal(t, primitives.Epoch(1111), v1Alpha1Validator.WithdrawableEpoch)
}
func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
v1Att := &ethpbv1.SignedAggregateAttestationAndProof{
Message: &ethpbv1.AggregateAttestationAndProof{
AggregatorIndex: 1,
Aggregate: util.HydrateV1Attestation(&ethpbv1.Attestation{}),
SelectionProof: selectionProof,
},
Signature: signature,
}
v1Alpha1Att := V1SignedAggregateAttAndProofToV1Alpha1(v1Att)
v1Root, err := v1Att.HashTreeRoot()
require.NoError(t, err)
v1Alpha1Root, err := v1Alpha1Att.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, v1Alpha1Root)
}
func Test_V1AttestationToV1Alpha1(t *testing.T) {
v1Att := util.HydrateV1Attestation(&ethpbv1.Attestation{})
v1Alpha1Att := V1AttToV1Alpha1(v1Att)
v1Root, err := v1Att.HashTreeRoot()
require.NoError(t, err)
v1Alpha1Root, err := v1Alpha1Att.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v1Root, v1Alpha1Root)
}
func TestBeaconStateToProto(t *testing.T) {
source, err := util.NewBeaconState(util.FillRootsNaturalOpt, func(state *ethpbalpha.BeaconState) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
state.Slot = 2
state.Fork = &ethpbalpha.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
}
state.LatestBlockHeader = &ethpbalpha.BeaconBlockHeader{
Slot: 4,
ProposerIndex: 5,
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
}
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
state.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
DepositCount: 6,
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
}
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
DepositCount: 7,
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
}}
state.Eth1DepositIndex = 8
state.Validators = []*ethpbalpha.Validator{{
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
EffectiveBalance: 9,
Slashed: true,
ActivationEligibilityEpoch: 10,
ActivationEpoch: 11,
ExitEpoch: 12,
WithdrawableEpoch: 13,
}}
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.PreviousEpochAttestations = []*ethpbalpha.PendingAttestation{{
AggregationBits: bitfield.Bitlist{16},
Data: &ethpbalpha.AttestationData{
Slot: 17,
CommitteeIndex: 18,
BeaconBlockRoot: bytesutil.PadTo([]byte("peabeaconblockroot"), 32),
Source: &ethpbalpha.Checkpoint{
Epoch: 19,
Root: bytesutil.PadTo([]byte("peasroot"), 32),
},
Target: &ethpbalpha.Checkpoint{
Epoch: 20,
Root: bytesutil.PadTo([]byte("peatroot"), 32),
},
},
InclusionDelay: 21,
ProposerIndex: 22,
}}
state.CurrentEpochAttestations = []*ethpbalpha.PendingAttestation{{
AggregationBits: bitfield.Bitlist{23},
Data: &ethpbalpha.AttestationData{
Slot: 24,
CommitteeIndex: 25,
BeaconBlockRoot: bytesutil.PadTo([]byte("ceabeaconblockroot"), 32),
Source: &ethpbalpha.Checkpoint{
Epoch: 26,
Root: bytesutil.PadTo([]byte("ceasroot"), 32),
},
Target: &ethpbalpha.Checkpoint{
Epoch: 27,
Root: bytesutil.PadTo([]byte("ceatroot"), 32),
},
},
InclusionDelay: 28,
ProposerIndex: 29,
}}
state.JustificationBits = bitfield.Bitvector4{1}
state.PreviousJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 30,
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
}
state.CurrentJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 31,
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
}
state.FinalizedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 32,
Root: bytesutil.PadTo([]byte("fcroot"), 32),
}
return nil
})
require.NoError(t, err)
result, err := BeaconStateToProto(source)
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, uint64(1), result.GenesisTime)
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
assert.Equal(t, primitives.Slot(2), result.Slot)
resultFork := result.Fork
require.NotNil(t, resultFork)
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
resultLatestBlockHeader := result.LatestBlockHeader
require.NotNil(t, resultLatestBlockHeader)
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
assert.Equal(t, 8192, len(result.BlockRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
assert.Equal(t, 1, len(result.HistoricalRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
require.Equal(t, 1, len(result.Eth1DataVotes))
resultEth1DataVote := result.Eth1DataVotes[0]
require.NotNil(t, resultEth1DataVote)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
require.Equal(t, 1, len(result.Validators))
resultValidator := result.Validators[0]
require.NotNil(t, resultValidator)
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
assert.Equal(t, true, resultValidator.Slashed)
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
assert.DeepEqual(t, []uint64{14}, result.Balances)
assert.Equal(t, 65536, len(result.RandaoMixes))
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
assert.DeepEqual(t, []uint64{15}, result.Slashings)
require.Equal(t, 1, len(result.PreviousEpochAttestations))
resultPrevEpochAtt := result.PreviousEpochAttestations[0]
require.NotNil(t, resultPrevEpochAtt)
assert.DeepEqual(t, bitfield.Bitlist{16}, resultPrevEpochAtt.AggregationBits)
resultPrevEpochAttData := resultPrevEpochAtt.Data
require.NotNil(t, resultPrevEpochAttData)
assert.Equal(t, primitives.Slot(17), resultPrevEpochAttData.Slot)
assert.Equal(t, primitives.CommitteeIndex(18), resultPrevEpochAttData.Index)
assert.DeepEqual(t, bytesutil.PadTo([]byte("peabeaconblockroot"), 32), resultPrevEpochAttData.BeaconBlockRoot)
resultPrevEpochAttSource := resultPrevEpochAttData.Source
require.NotNil(t, resultPrevEpochAttSource)
assert.Equal(t, primitives.Epoch(19), resultPrevEpochAttSource.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("peasroot"), 32), resultPrevEpochAttSource.Root)
resultPrevEpochAttTarget := resultPrevEpochAttData.Target
require.NotNil(t, resultPrevEpochAttTarget)
assert.Equal(t, primitives.Epoch(20), resultPrevEpochAttTarget.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("peatroot"), 32), resultPrevEpochAttTarget.Root)
assert.Equal(t, primitives.Slot(21), resultPrevEpochAtt.InclusionDelay)
assert.Equal(t, primitives.ValidatorIndex(22), resultPrevEpochAtt.ProposerIndex)
resultCurrEpochAtt := result.CurrentEpochAttestations[0]
require.NotNil(t, resultCurrEpochAtt)
assert.DeepEqual(t, bitfield.Bitlist{23}, resultCurrEpochAtt.AggregationBits)
resultCurrEpochAttData := resultCurrEpochAtt.Data
require.NotNil(t, resultCurrEpochAttData)
assert.Equal(t, primitives.Slot(24), resultCurrEpochAttData.Slot)
assert.Equal(t, primitives.CommitteeIndex(25), resultCurrEpochAttData.Index)
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceabeaconblockroot"), 32), resultCurrEpochAttData.BeaconBlockRoot)
resultCurrEpochAttSource := resultCurrEpochAttData.Source
require.NotNil(t, resultCurrEpochAttSource)
assert.Equal(t, primitives.Epoch(26), resultCurrEpochAttSource.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceasroot"), 32), resultCurrEpochAttSource.Root)
resultCurrEpochAttTarget := resultCurrEpochAttData.Target
require.NotNil(t, resultCurrEpochAttTarget)
assert.Equal(t, primitives.Epoch(27), resultCurrEpochAttTarget.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceatroot"), 32), resultCurrEpochAttTarget.Root)
assert.Equal(t, primitives.Slot(28), resultCurrEpochAtt.InclusionDelay)
assert.Equal(t, primitives.ValidatorIndex(29), resultCurrEpochAtt.ProposerIndex)
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
require.NotNil(t, resultPrevJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
require.NotNil(t, resultCurrJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
resultFinalizedCheckpoint := result.FinalizedCheckpoint
require.NotNil(t, resultFinalizedCheckpoint)
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
}

File diff suppressed because it is too large Load Diff

View File

@ -1,901 +0,0 @@
package migration
import (
"testing"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v5/testing/assert"
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/testing/util"
)
func TestV1Alpha1SignedContributionAndProofToV2(t *testing.T) {
alphaContribution := &ethpbalpha.SignedContributionAndProof{
Message: &ethpbalpha.ContributionAndProof{
AggregatorIndex: validatorIndex,
Contribution: &ethpbalpha.SyncCommitteeContribution{
Slot: slot,
BlockRoot: blockHash,
SubcommitteeIndex: 1,
AggregationBits: bitfield.NewBitvector128(),
Signature: signature,
},
SelectionProof: signature,
},
Signature: signature,
}
v2Contribution := V1Alpha1SignedContributionAndProofToV2(alphaContribution)
require.NotNil(t, v2Contribution)
require.NotNil(t, v2Contribution.Message)
require.NotNil(t, v2Contribution.Message.Contribution)
assert.DeepEqual(t, signature, v2Contribution.Signature)
msg := v2Contribution.Message
assert.Equal(t, validatorIndex, msg.AggregatorIndex)
assert.DeepEqual(t, signature, msg.SelectionProof)
contrib := msg.Contribution
assert.Equal(t, slot, contrib.Slot)
assert.DeepEqual(t, blockHash, contrib.BeaconBlockRoot)
assert.Equal(t, uint64(1), contrib.SubcommitteeIndex)
assert.DeepEqual(t, bitfield.NewBitvector128(), contrib.AggregationBits)
assert.DeepEqual(t, signature, contrib.Signature)
}
func Test_V1Alpha1BeaconBlockAltairToV2(t *testing.T) {
alphaBlock := util.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)
}
func Test_V1Alpha1BeaconBlockBellatrixToV2(t *testing.T) {
alphaBlock := util.HydrateBeaconBlockBellatrix(&ethpbalpha.BeaconBlockBellatrix{})
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 := V1Alpha1BeaconBlockBellatrixToV2(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)
}
func Test_V1Alpha1BeaconBlockBellatrixToV2Blinded(t *testing.T) {
alphaBlock := util.HydrateBeaconBlockBellatrix(&ethpbalpha.BeaconBlockBellatrix{})
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,
}
alphaBlock.Body.ExecutionPayload.Transactions = [][]byte{[]byte("transaction1"), []byte("transaction2")}
v2Block, err := V1Alpha1BeaconBlockBellatrixToV2Blinded(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)
}
func Test_V1Alpha1BeaconBlockCapellaToV2Blinded(t *testing.T) {
alphaBlock := util.HydrateBeaconBlockCapella(&ethpbalpha.BeaconBlockCapella{})
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,
}
alphaBlock.Body.ExecutionPayload.Transactions = [][]byte{[]byte("transaction1"), []byte("transaction2")}
v2Block, err := V1Alpha1BeaconBlockCapellaToV2Blinded(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)
}
func TestBeaconStateAltairToProto(t *testing.T) {
source, err := util.NewBeaconStateAltair(util.FillRootsNaturalOptAltair, func(state *ethpbalpha.BeaconStateAltair) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
state.Slot = 2
state.Fork = &ethpbalpha.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
}
state.LatestBlockHeader = &ethpbalpha.BeaconBlockHeader{
Slot: 4,
ProposerIndex: 5,
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
}
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
state.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
DepositCount: 6,
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
}
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
DepositCount: 7,
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
}}
state.Eth1DepositIndex = 8
state.Validators = []*ethpbalpha.Validator{{
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
EffectiveBalance: 9,
Slashed: true,
ActivationEligibilityEpoch: 10,
ActivationEpoch: 11,
ExitEpoch: 12,
WithdrawableEpoch: 13,
}}
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.JustificationBits = bitfield.Bitvector4{1}
state.PreviousJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 30,
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
}
state.CurrentJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 31,
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
}
state.FinalizedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 32,
Root: bytesutil.PadTo([]byte("fcroot"), 32),
}
state.PreviousEpochParticipation = []byte("previousepochparticipation")
state.CurrentEpochParticipation = []byte("currentepochparticipation")
state.InactivityScores = []uint64{1, 2, 3}
state.CurrentSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
}
state.NextSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
}
return nil
})
require.NoError(t, err)
result, err := BeaconStateAltairToProto(source)
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, uint64(1), result.GenesisTime)
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
assert.Equal(t, primitives.Slot(2), result.Slot)
resultFork := result.Fork
require.NotNil(t, resultFork)
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
resultLatestBlockHeader := result.LatestBlockHeader
require.NotNil(t, resultLatestBlockHeader)
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
assert.Equal(t, 8192, len(result.BlockRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
assert.Equal(t, 1, len(result.HistoricalRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
require.Equal(t, 1, len(result.Eth1DataVotes))
resultEth1DataVote := result.Eth1DataVotes[0]
require.NotNil(t, resultEth1DataVote)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
require.Equal(t, 1, len(result.Validators))
resultValidator := result.Validators[0]
require.NotNil(t, resultValidator)
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
assert.Equal(t, true, resultValidator.Slashed)
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
assert.DeepEqual(t, []uint64{14}, result.Balances)
assert.Equal(t, 65536, len(result.RandaoMixes))
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
assert.DeepEqual(t, []uint64{15}, result.Slashings)
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
require.NotNil(t, resultPrevJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
require.NotNil(t, resultCurrJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
resultFinalizedCheckpoint := result.FinalizedCheckpoint
require.NotNil(t, resultFinalizedCheckpoint)
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
require.NotNil(t, result.CurrentSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
require.NotNil(t, result.NextSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
}
func TestBeaconStateBellatrixToProto(t *testing.T) {
source, err := util.NewBeaconStateBellatrix(util.FillRootsNaturalOptBellatrix, func(state *ethpbalpha.BeaconStateBellatrix) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
state.Slot = 2
state.Fork = &ethpbalpha.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
}
state.LatestBlockHeader = &ethpbalpha.BeaconBlockHeader{
Slot: 4,
ProposerIndex: 5,
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
}
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
state.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
DepositCount: 6,
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
}
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
DepositCount: 7,
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
}}
state.Eth1DepositIndex = 8
state.Validators = []*ethpbalpha.Validator{{
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
EffectiveBalance: 9,
Slashed: true,
ActivationEligibilityEpoch: 10,
ActivationEpoch: 11,
ExitEpoch: 12,
WithdrawableEpoch: 13,
}}
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.JustificationBits = bitfield.Bitvector4{1}
state.PreviousJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 30,
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
}
state.CurrentJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 31,
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
}
state.FinalizedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 32,
Root: bytesutil.PadTo([]byte("fcroot"), 32),
}
state.PreviousEpochParticipation = []byte("previousepochparticipation")
state.CurrentEpochParticipation = []byte("currentepochparticipation")
state.InactivityScores = []uint64{1, 2, 3}
state.CurrentSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
}
state.NextSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
}
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeader{
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
BlockNumber: 123,
GasLimit: 456,
GasUsed: 789,
Timestamp: 012,
ExtraData: []byte("extradata"),
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
}
return nil
})
require.NoError(t, err)
result, err := BeaconStateBellatrixToProto(source)
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, uint64(1), result.GenesisTime)
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
assert.Equal(t, primitives.Slot(2), result.Slot)
resultFork := result.Fork
require.NotNil(t, resultFork)
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
resultLatestBlockHeader := result.LatestBlockHeader
require.NotNil(t, resultLatestBlockHeader)
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
assert.Equal(t, 8192, len(result.BlockRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
assert.Equal(t, 1, len(result.HistoricalRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
require.Equal(t, 1, len(result.Eth1DataVotes))
resultEth1DataVote := result.Eth1DataVotes[0]
require.NotNil(t, resultEth1DataVote)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
require.Equal(t, 1, len(result.Validators))
resultValidator := result.Validators[0]
require.NotNil(t, resultValidator)
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
assert.Equal(t, true, resultValidator.Slashed)
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
assert.DeepEqual(t, []uint64{14}, result.Balances)
assert.Equal(t, 65536, len(result.RandaoMixes))
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
assert.DeepEqual(t, []uint64{15}, result.Slashings)
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
require.NotNil(t, resultPrevJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
require.NotNil(t, resultCurrJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
resultFinalizedCheckpoint := result.FinalizedCheckpoint
require.NotNil(t, resultFinalizedCheckpoint)
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
require.NotNil(t, result.CurrentSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
require.NotNil(t, result.NextSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
require.NotNil(t, resultLatestExecutionPayloadHeader)
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
}
func TestBeaconStateCapellaToProto(t *testing.T) {
source, err := util.NewBeaconStateCapella(util.FillRootsNaturalOptCapella, func(state *ethpbalpha.BeaconStateCapella) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
state.Slot = 2
state.Fork = &ethpbalpha.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
}
state.LatestBlockHeader = &ethpbalpha.BeaconBlockHeader{
Slot: 4,
ProposerIndex: 5,
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
}
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
state.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
DepositCount: 6,
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
}
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
DepositCount: 7,
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
}}
state.Eth1DepositIndex = 8
state.Validators = []*ethpbalpha.Validator{{
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
EffectiveBalance: 9,
Slashed: true,
ActivationEligibilityEpoch: 10,
ActivationEpoch: 11,
ExitEpoch: 12,
WithdrawableEpoch: 13,
}}
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.JustificationBits = bitfield.Bitvector4{1}
state.PreviousJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 30,
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
}
state.CurrentJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 31,
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
}
state.FinalizedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 32,
Root: bytesutil.PadTo([]byte("fcroot"), 32),
}
state.PreviousEpochParticipation = []byte("previousepochparticipation")
state.CurrentEpochParticipation = []byte("currentepochparticipation")
state.InactivityScores = []uint64{1, 2, 3}
state.CurrentSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
}
state.NextSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
}
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeaderCapella{
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
BlockNumber: 123,
GasLimit: 456,
GasUsed: 789,
Timestamp: 012,
ExtraData: []byte("extradata"),
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
WithdrawalsRoot: bytesutil.PadTo([]byte("withdrawalsroot"), 32),
}
state.NextWithdrawalIndex = 123
state.NextWithdrawalValidatorIndex = 123
state.HistoricalSummaries = []*ethpbalpha.HistoricalSummary{
{
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot"), 32),
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot"), 32),
},
{
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot2"), 32),
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot2"), 32),
}}
return nil
})
require.NoError(t, err)
result, err := BeaconStateCapellaToProto(source)
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, uint64(1), result.GenesisTime)
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
assert.Equal(t, primitives.Slot(2), result.Slot)
resultFork := result.Fork
require.NotNil(t, resultFork)
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
resultLatestBlockHeader := result.LatestBlockHeader
require.NotNil(t, resultLatestBlockHeader)
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
assert.Equal(t, 8192, len(result.BlockRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
assert.Equal(t, 1, len(result.HistoricalRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
require.Equal(t, 1, len(result.Eth1DataVotes))
resultEth1DataVote := result.Eth1DataVotes[0]
require.NotNil(t, resultEth1DataVote)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
require.Equal(t, 1, len(result.Validators))
resultValidator := result.Validators[0]
require.NotNil(t, resultValidator)
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
assert.Equal(t, true, resultValidator.Slashed)
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
assert.DeepEqual(t, []uint64{14}, result.Balances)
assert.Equal(t, 65536, len(result.RandaoMixes))
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
assert.DeepEqual(t, []uint64{15}, result.Slashings)
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
require.NotNil(t, resultPrevJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
require.NotNil(t, resultCurrJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
resultFinalizedCheckpoint := result.FinalizedCheckpoint
require.NotNil(t, resultFinalizedCheckpoint)
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
require.NotNil(t, result.CurrentSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
require.NotNil(t, result.NextSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
require.NotNil(t, resultLatestExecutionPayloadHeader)
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalsroot"), 32), resultLatestExecutionPayloadHeader.WithdrawalsRoot)
assert.Equal(t, uint64(123), result.NextWithdrawalIndex)
assert.Equal(t, primitives.ValidatorIndex(123), result.NextWithdrawalValidatorIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot"), 32), result.HistoricalSummaries[0].BlockSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot"), 32), result.HistoricalSummaries[0].StateSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot2"), 32), result.HistoricalSummaries[1].BlockSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot2"), 32), result.HistoricalSummaries[1].StateSummaryRoot)
}
func TestBeaconStateDenebToProto(t *testing.T) {
source, err := util.NewBeaconStateDeneb(util.FillRootsNaturalOptDeneb, func(state *ethpbalpha.BeaconStateDeneb) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
state.Slot = 2
state.Fork = &ethpbalpha.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
}
state.LatestBlockHeader = &ethpbalpha.BeaconBlockHeader{
Slot: 4,
ProposerIndex: 5,
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
}
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
state.Eth1Data = &ethpbalpha.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
DepositCount: 6,
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
}
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
DepositCount: 7,
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
}}
state.Eth1DepositIndex = 8
state.Validators = []*ethpbalpha.Validator{{
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
EffectiveBalance: 9,
Slashed: true,
ActivationEligibilityEpoch: 10,
ActivationEpoch: 11,
ExitEpoch: 12,
WithdrawableEpoch: 13,
}}
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.JustificationBits = bitfield.Bitvector4{1}
state.PreviousJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 30,
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
}
state.CurrentJustifiedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 31,
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
}
state.FinalizedCheckpoint = &ethpbalpha.Checkpoint{
Epoch: 32,
Root: bytesutil.PadTo([]byte("fcroot"), 32),
}
state.PreviousEpochParticipation = []byte("previousepochparticipation")
state.CurrentEpochParticipation = []byte("currentepochparticipation")
state.InactivityScores = []uint64{1, 2, 3}
state.CurrentSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
}
state.NextSyncCommittee = &ethpbalpha.SyncCommittee{
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
}
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
BlockNumber: 123,
GasLimit: 456,
GasUsed: 789,
Timestamp: 012,
ExtraData: []byte("extradata"),
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
WithdrawalsRoot: bytesutil.PadTo([]byte("withdrawalsroot"), 32),
BlobGasUsed: 343,
ExcessBlobGas: 676,
}
state.NextWithdrawalIndex = 123
state.NextWithdrawalValidatorIndex = 123
state.HistoricalSummaries = []*ethpbalpha.HistoricalSummary{
{
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot"), 32),
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot"), 32),
},
{
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot2"), 32),
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot2"), 32),
}}
return nil
})
require.NoError(t, err)
result, err := BeaconStateDenebToProto(source)
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, uint64(1), result.GenesisTime)
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
assert.Equal(t, primitives.Slot(2), result.Slot)
resultFork := result.Fork
require.NotNil(t, resultFork)
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
resultLatestBlockHeader := result.LatestBlockHeader
require.NotNil(t, resultLatestBlockHeader)
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
assert.Equal(t, 8192, len(result.BlockRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
require.Equal(t, 1, len(result.Eth1DataVotes))
resultEth1DataVote := result.Eth1DataVotes[0]
require.NotNil(t, resultEth1DataVote)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
require.Equal(t, 1, len(result.Validators))
resultValidator := result.Validators[0]
require.NotNil(t, resultValidator)
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
assert.Equal(t, true, resultValidator.Slashed)
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
assert.DeepEqual(t, []uint64{14}, result.Balances)
assert.Equal(t, 65536, len(result.RandaoMixes))
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
assert.DeepEqual(t, []uint64{15}, result.Slashings)
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
require.NotNil(t, resultPrevJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
require.NotNil(t, resultCurrJustifiedCheckpoint)
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
resultFinalizedCheckpoint := result.FinalizedCheckpoint
require.NotNil(t, resultFinalizedCheckpoint)
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
require.NotNil(t, result.CurrentSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
require.NotNil(t, result.NextSyncCommittee)
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
require.NotNil(t, resultLatestExecutionPayloadHeader)
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalsroot"), 32), resultLatestExecutionPayloadHeader.WithdrawalsRoot)
assert.DeepEqual(t, uint64(343), resultLatestExecutionPayloadHeader.BlobGasUsed)
assert.DeepEqual(t, uint64(676), resultLatestExecutionPayloadHeader.ExcessBlobGas)
assert.Equal(t, uint64(123), result.NextWithdrawalIndex)
assert.Equal(t, primitives.ValidatorIndex(123), result.NextWithdrawalValidatorIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot"), 32), result.HistoricalSummaries[0].BlockSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot"), 32), result.HistoricalSummaries[0].StateSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot2"), 32), result.HistoricalSummaries[1].BlockSummaryRoot)
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot2"), 32), result.HistoricalSummaries[1].StateSummaryRoot)
}
func TestV1Alpha1SignedBLSToExecChangeToV2(t *testing.T) {
alphaChange := &ethpbalpha.SignedBLSToExecutionChange{
Message: &ethpbalpha.BLSToExecutionChange{
ValidatorIndex: validatorIndex,
FromBlsPubkey: bytesutil.PadTo([]byte("fromblspubkey"), 48),
ToExecutionAddress: bytesutil.PadTo([]byte("toexecutionaddress"), 20),
},
Signature: signature,
}
change := V1Alpha1SignedBLSToExecChangeToV2(alphaChange)
require.NotNil(t, change)
require.NotNil(t, change.Message)
assert.DeepEqual(t, signature, change.Signature)
assert.Equal(t, validatorIndex, change.Message.ValidatorIndex)
assert.DeepEqual(t, bytesutil.PadTo([]byte("fromblspubkey"), 48), change.Message.FromBlsPubkey)
assert.DeepEqual(t, bytesutil.PadTo([]byte("toexecutionaddress"), 20), change.Message.ToExecutionAddress)
}

View File

@ -1,113 +0,0 @@
package migration
import (
"github.com/pkg/errors"
ethpbv2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2"
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"google.golang.org/protobuf/proto"
)
// AltairToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockAltair proto to a v1alpha1 proto.
func AltairToV1Alpha1SignedBlock(altairBlk *ethpbv2.SignedBeaconBlockAltair) (*ethpbalpha.SignedBeaconBlockAltair, error) {
marshaledBlk, err := proto.Marshal(altairBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBeaconBlockAltair{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// BellatrixToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockBellatrix proto to a v1alpha1 proto.
func BellatrixToV1Alpha1SignedBlock(bellatrixBlk *ethpbv2.SignedBeaconBlockBellatrix) (*ethpbalpha.SignedBeaconBlockBellatrix, error) {
marshaledBlk, err := proto.Marshal(bellatrixBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBeaconBlockBellatrix{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// CapellaToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockCapella proto to a v1alpha1 proto.
func CapellaToV1Alpha1SignedBlock(capellaBlk *ethpbv2.SignedBeaconBlockCapella) (*ethpbalpha.SignedBeaconBlockCapella, error) {
marshaledBlk, err := proto.Marshal(capellaBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBeaconBlockCapella{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// DenebToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockDeneb proto to a v1alpha1 proto.
func DenebToV1Alpha1SignedBlock(denebBlk *ethpbv2.SignedBeaconBlockDeneb) (*ethpbalpha.SignedBeaconBlockDeneb, error) {
marshaledBlk, err := proto.Marshal(denebBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBeaconBlockDeneb{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// V2BeaconBlockDenebToV1Alpha1 converts a v2 Deneb beacon block to a v1alpha1
// Deneb block.
func V2BeaconBlockDenebToV1Alpha1(v2block *ethpbv2.BeaconBlockDeneb) (*ethpbalpha.BeaconBlockDeneb, error) {
marshaledBlk, err := proto.Marshal(v2block)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1block := &ethpbalpha.BeaconBlockDeneb{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1block, nil
}
// BlindedBellatrixToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockBellatrix proto to a v1alpha1 proto.
func BlindedBellatrixToV1Alpha1SignedBlock(bellatrixBlk *ethpbv2.SignedBlindedBeaconBlockBellatrix) (*ethpbalpha.SignedBlindedBeaconBlockBellatrix, error) {
marshaledBlk, err := proto.Marshal(bellatrixBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBlindedBeaconBlockBellatrix{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// BlindedCapellaToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockCapella proto to a v1alpha1 proto.
func BlindedCapellaToV1Alpha1SignedBlock(capellaBlk *ethpbv2.SignedBlindedBeaconBlockCapella) (*ethpbalpha.SignedBlindedBeaconBlockCapella, error) {
marshaledBlk, err := proto.Marshal(capellaBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBlindedBeaconBlockCapella{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}
// BlindedDenebToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockDeneb proto to a v1alpha1 proto.
func BlindedDenebToV1Alpha1SignedBlock(denebBlk *ethpbv2.SignedBlindedBeaconBlockDeneb) (*ethpbalpha.SignedBlindedBeaconBlockDeneb, error) {
marshaledBlk, err := proto.Marshal(denebBlk)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1Block := &ethpbalpha.SignedBlindedBeaconBlockDeneb{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1Block, nil
}

View File

@ -1,132 +0,0 @@
package migration
import (
"testing"
"github.com/prysmaticlabs/go-bitfield"
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
ethpbv2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2"
"github.com/prysmaticlabs/prysm/v5/testing/assert"
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/testing/util"
)
func Test_AltairToV1Alpha1SignedBlock(t *testing.T) {
v2Block := util.HydrateV2AltairSignedBeaconBlock(&ethpbv2.SignedBeaconBlockAltair{})
v2Block.Message.Slot = slot
v2Block.Message.ProposerIndex = validatorIndex
v2Block.Message.ParentRoot = parentRoot
v2Block.Message.StateRoot = stateRoot
v2Block.Message.Body.RandaoReveal = randaoReveal
v2Block.Message.Body.Eth1Data = &ethpbv1.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
syncCommitteeBits := bitfield.NewBitvector512()
syncCommitteeBits.SetBitAt(100, true)
v2Block.Message.Body.SyncAggregate = &ethpbv1.SyncAggregate{
SyncCommitteeBits: syncCommitteeBits,
SyncCommitteeSignature: signature,
}
v2Block.Signature = signature
alphaBlock, err := AltairToV1Alpha1SignedBlock(v2Block)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v2Root, err := v2Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v2Root, alphaRoot)
}
func Test_BellatrixToV1Alpha1SignedBlock(t *testing.T) {
v2Block := util.HydrateV2BellatrixSignedBeaconBlock(&ethpbv2.SignedBeaconBlockBellatrix{})
v2Block.Message.Slot = slot
v2Block.Message.ProposerIndex = validatorIndex
v2Block.Message.ParentRoot = parentRoot
v2Block.Message.StateRoot = stateRoot
v2Block.Message.Body.RandaoReveal = randaoReveal
v2Block.Message.Body.Eth1Data = &ethpbv1.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
syncCommitteeBits := bitfield.NewBitvector512()
syncCommitteeBits.SetBitAt(100, true)
v2Block.Message.Body.SyncAggregate = &ethpbv1.SyncAggregate{
SyncCommitteeBits: syncCommitteeBits,
SyncCommitteeSignature: signature,
}
v2Block.Message.Body.ExecutionPayload = &enginev1.ExecutionPayload{
ParentHash: parentHash,
FeeRecipient: feeRecipient,
StateRoot: stateRoot,
ReceiptsRoot: receiptsRoot,
LogsBloom: logsBloom,
PrevRandao: prevRandao,
BlockNumber: blockNumber,
GasLimit: gasLimit,
GasUsed: gasUsed,
Timestamp: timestamp,
ExtraData: extraData,
BaseFeePerGas: baseFeePerGas,
BlockHash: blockHash,
Transactions: [][]byte{[]byte("transaction1"), []byte("transaction2")},
}
v2Block.Signature = signature
alphaBlock, err := BellatrixToV1Alpha1SignedBlock(v2Block)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v2Root, err := v2Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v2Root, alphaRoot)
}
func Test_BlindedBellatrixToV1Alpha1SignedBlock(t *testing.T) {
v2Block := util.HydrateV2SignedBlindedBeaconBlockBellatrix(&ethpbv2.SignedBlindedBeaconBlockBellatrix{})
v2Block.Message.Slot = slot
v2Block.Message.ProposerIndex = validatorIndex
v2Block.Message.ParentRoot = parentRoot
v2Block.Message.StateRoot = stateRoot
v2Block.Message.Body.RandaoReveal = randaoReveal
v2Block.Message.Body.Eth1Data = &ethpbv1.Eth1Data{
DepositRoot: depositRoot,
DepositCount: depositCount,
BlockHash: blockHash,
}
syncCommitteeBits := bitfield.NewBitvector512()
syncCommitteeBits.SetBitAt(100, true)
v2Block.Message.Body.SyncAggregate = &ethpbv1.SyncAggregate{
SyncCommitteeBits: syncCommitteeBits,
SyncCommitteeSignature: signature,
}
v2Block.Message.Body.ExecutionPayloadHeader = &enginev1.ExecutionPayloadHeader{
ParentHash: parentHash,
FeeRecipient: feeRecipient,
StateRoot: stateRoot,
ReceiptsRoot: receiptsRoot,
LogsBloom: logsBloom,
PrevRandao: prevRandao,
BlockNumber: blockNumber,
GasLimit: gasLimit,
GasUsed: gasUsed,
Timestamp: timestamp,
ExtraData: extraData,
BaseFeePerGas: baseFeePerGas,
BlockHash: blockHash,
TransactionsRoot: transactionsRoot,
}
v2Block.Signature = signature
alphaBlock, err := BlindedBellatrixToV1Alpha1SignedBlock(v2Block)
require.NoError(t, err)
alphaRoot, err := alphaBlock.HashTreeRoot()
require.NoError(t, err)
v2Root, err := v2Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, v2Root, alphaRoot)
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v4.23.3
// protoc v4.25.1
// source: proto/testing/test.proto
package testing