Move API structs to api module (#13577)

This commit is contained in:
Radosław Kapka
2024-02-03 12:57:01 +01:00
committed by GitHub
parent 9d1189b222
commit e3ce1bde45
173 changed files with 2596 additions and 2646 deletions

View File

@@ -72,7 +72,7 @@ go_test(
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = [
"//beacon-chain/rpc/eth/shared:go_default_library",
"//api/server/structs:go_default_library",
"//build/bazel:go_default_library",
"//cmd/validator/flags:go_default_library",
"//config/fieldparams:go_default_library",

View File

@@ -6,7 +6,7 @@ import (
"path"
"testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/build/bazel"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
@@ -57,7 +57,7 @@ func TestWriteSignedVoluntaryExitJSON(t *testing.T) {
b, err := file.ReadFileAsBytes(path.Join(output, "validator-exit-300.json"))
require.NoError(t, err)
svej := &shared.SignedVoluntaryExit{}
svej := &structs.SignedVoluntaryExit{}
require.NoError(t, json.Unmarshal(b, svej))
require.Equal(t, fmt.Sprintf("%d", sve.Exit.Epoch), svej.Message.Epoch)

View File

@@ -40,15 +40,10 @@ go_library(
visibility = ["//validator:__subpackages__"],
deps = [
"//api:go_default_library",
"//api/server/structs:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/signing:go_default_library",
"//beacon-chain/rpc/eth/beacon:go_default_library",
"//beacon-chain/rpc/eth/config:go_default_library",
"//beacon-chain/rpc/eth/events:go_default_library",
"//beacon-chain/rpc/eth/node:go_default_library",
"//beacon-chain/rpc/eth/shared:go_default_library",
"//beacon-chain/rpc/eth/validator:go_default_library",
"//beacon-chain/rpc/prysm/validator:go_default_library",
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/validator:go_default_library",
@@ -117,13 +112,8 @@ go_test(
embed = [":go_default_library"],
deps = [
"//api:go_default_library",
"//beacon-chain/rpc/eth/beacon:go_default_library",
"//beacon-chain/rpc/eth/config:go_default_library",
"//beacon-chain/rpc/eth/node:go_default_library",
"//beacon-chain/rpc/eth/shared:go_default_library",
"//api/server/structs:go_default_library",
"//beacon-chain/rpc/eth/shared/testing:go_default_library",
"//beacon-chain/rpc/eth/validator:go_default_library",
"//beacon-chain/rpc/prysm/validator:go_default_library",
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/validator:go_default_library",

View File

@@ -10,7 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/config/params"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -100,14 +100,14 @@ func TestActivation_Nominal(t *testing.T) {
},
}
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
// Instantiate a cancellable context.
ctx, cancel := context.WithCancel(context.Background())
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
req := &beacon.GetValidatorsRequest{
req := &structs.GetValidatorsRequest{
Ids: stringPubKeys,
Statuses: []string{},
}
@@ -125,26 +125,26 @@ func TestActivation_Nominal(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "55293",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKeys[0],
},
},
{
Index: "11877",
Status: "active_exiting",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKeys[1],
},
},
{
Index: "210439",
Status: "exited_slashed",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKeys[3],
},
},
@@ -186,16 +186,16 @@ func TestActivation_Nominal(t *testing.T) {
func TestActivation_InvalidData(t *testing.T) {
testCases := []struct {
name string
data []*beacon.ValidatorContainer
data []*structs.ValidatorContainer
expectedErrorMessage string
}{
{
name: "bad validator public key",
data: []*beacon.ValidatorContainer{
data: []*structs.ValidatorContainer{
{
Index: "55293",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "NotAPubKey",
},
},
@@ -204,11 +204,11 @@ func TestActivation_InvalidData(t *testing.T) {
},
{
name: "bad validator index",
data: []*beacon.ValidatorContainer{
data: []*structs.ValidatorContainer{
{
Index: "NotAnIndex",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -217,11 +217,11 @@ func TestActivation_InvalidData(t *testing.T) {
},
{
name: "invalid validator status",
data: []*beacon.ValidatorContainer{
data: []*structs.ValidatorContainer{
{
Index: "12345",
Status: "NotAStatus",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -249,7 +249,7 @@ func TestActivation_InvalidData(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
structs.GetValidatorsResponse{
Data: testCase.data,
},
).Times(1)

View File

@@ -7,7 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -22,7 +22,7 @@ func (c beaconApiValidatorClient) getAttestationData(
params.Add("committee_index", strconv.FormatUint(uint64(reqCommitteeIndex), 10))
query := buildURL("/eth/v1/validator/attestation_data", params)
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
if err := c.jsonRestHandler.Get(ctx, query, &produceAttestationDataResponseJson); err != nil {
return nil, err

View File

@@ -9,8 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -31,7 +30,7 @@ func TestGetAttestationData_ValidAttestation(t *testing.T) {
defer ctrl.Finish()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -41,16 +40,16 @@ func TestGetAttestationData_ValidAttestation(t *testing.T) {
nil,
).SetArg(
2,
validator.GetAttestationDataResponse{
Data: &shared.AttestationData{
structs.GetAttestationDataResponse{
Data: &structs.AttestationData{
Slot: strconv.FormatUint(expectedSlot, 10),
CommitteeIndex: strconv.FormatUint(expectedCommitteeIndex, 10),
BeaconBlockRoot: expectedBeaconBlockRoot,
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: strconv.FormatUint(expectedSourceEpoch, 10),
Root: expectedSourceRoot,
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: strconv.FormatUint(expectedTargetEpoch, 10),
Root: expectedTargetRoot,
},
@@ -81,13 +80,13 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
testCases := []struct {
name string
generateData func() validator.GetAttestationDataResponse
generateData func() structs.GetAttestationDataResponse
expectedErrorMessage string
}{
{
name: "nil attestation data",
generateData: func() validator.GetAttestationDataResponse {
return validator.GetAttestationDataResponse{
generateData: func() structs.GetAttestationDataResponse {
return structs.GetAttestationDataResponse{
Data: nil,
}
},
@@ -95,7 +94,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid committee index",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.CommitteeIndex = "foo"
return attestation
@@ -104,7 +103,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid block root",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.BeaconBlockRoot = "foo"
return attestation
@@ -113,7 +112,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid slot",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Slot = "foo"
return attestation
@@ -122,7 +121,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "nil source",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Source = nil
return attestation
@@ -131,7 +130,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid source epoch",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Source.Epoch = "foo"
return attestation
@@ -140,7 +139,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid source root",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Source.Root = "foo"
return attestation
@@ -149,7 +148,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "nil target",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Target = nil
return attestation
@@ -158,7 +157,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid target epoch",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Target.Epoch = "foo"
return attestation
@@ -167,7 +166,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
},
{
name: "invalid target root",
generateData: func() validator.GetAttestationDataResponse {
generateData: func() structs.GetAttestationDataResponse {
attestation := generateValidAttestation(1, 2)
attestation.Data.Target.Root = "foo"
return attestation
@@ -181,7 +180,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -211,7 +210,7 @@ func TestGetAttestationData_JsonResponseError(t *testing.T) {
defer ctrl.Finish()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v1/validator/attestation_data?committee_index=%d&slot=%d", committeeIndex, slot),
@@ -225,17 +224,17 @@ func TestGetAttestationData_JsonResponseError(t *testing.T) {
assert.ErrorContains(t, "some specific json response error", err)
}
func generateValidAttestation(slot uint64, committeeIndex uint64) validator.GetAttestationDataResponse {
return validator.GetAttestationDataResponse{
Data: &shared.AttestationData{
func generateValidAttestation(slot uint64, committeeIndex uint64) structs.GetAttestationDataResponse {
return structs.GetAttestationDataResponse{
Data: &structs.AttestationData{
Slot: strconv.FormatUint(slot, 10),
CommitteeIndex: strconv.FormatUint(committeeIndex, 10),
BeaconBlockRoot: "0x5ecf3bff35e39d5f75476d42950d549f81fa93038c46b6652ae89ae1f7ad834f",
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "3",
Root: "0x9023c9e64f23c1d451d5073c641f5f69597c2ad7d82f6f16e67d703e0ce5db8b",
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "4",
Root: "0xb154d46803b15b458ca822466547b054bc124338c6ee1d9c433dcde8c4457cca",
},

View File

@@ -10,8 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -26,8 +25,8 @@ type beaconApiBeaconChainClient struct {
const getValidatorPerformanceEndpoint = "/prysm/validators/performance"
func (c beaconApiBeaconChainClient) getHeadBlockHeaders(ctx context.Context) (*beacon.GetBlockHeaderResponse, error) {
blockHeader := beacon.GetBlockHeaderResponse{}
func (c beaconApiBeaconChainClient) getHeadBlockHeaders(ctx context.Context) (*structs.GetBlockHeaderResponse, error) {
blockHeader := structs.GetBlockHeaderResponse{}
err := c.jsonRestHandler.Get(ctx, "/eth/v1/beacon/headers/head", &blockHeader)
if err != nil {
return nil, err
@@ -47,7 +46,7 @@ func (c beaconApiBeaconChainClient) getHeadBlockHeaders(ctx context.Context) (*b
func (c beaconApiBeaconChainClient) GetChainHead(ctx context.Context, _ *empty.Empty) (*ethpb.ChainHead, error) {
const endpoint = "/eth/v1/beacon/states/head/finality_checkpoints"
finalityCheckpoints := beacon.GetFinalityCheckpointsResponse{}
finalityCheckpoints := structs.GetFinalityCheckpointsResponse{}
if err := c.jsonRestHandler.Get(ctx, endpoint, &finalityCheckpoints); err != nil {
return nil, err
}
@@ -183,7 +182,7 @@ func (c beaconApiBeaconChainClient) ListValidators(ctx context.Context, in *ethp
pubkeys[idx] = hexutil.Encode(pubkey)
}
var stateValidators *beacon.GetValidatorsResponse
var stateValidators *structs.GetValidatorsResponse
var epoch primitives.Epoch
switch queryFilter := in.QueryFilter.(type) {
@@ -321,14 +320,14 @@ func (c beaconApiBeaconChainClient) GetValidatorQueue(ctx context.Context, in *e
}
func (c beaconApiBeaconChainClient) GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) {
request, err := json.Marshal(validator.PerformanceRequest{
request, err := json.Marshal(structs.GetValidatorPerformanceRequest{
PublicKeys: in.PublicKeys,
Indices: in.Indices,
})
if err != nil {
return nil, errors.Wrap(err, "failed to marshal request")
}
resp := &validator.PerformanceResponse{}
resp := &structs.GetValidatorPerformanceResponse{}
if err = c.jsonRestHandler.Post(ctx, getValidatorPerformanceEndpoint, nil, bytes.NewBuffer(request), resp); err != nil {
return nil, err
}

View File

@@ -12,9 +12,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -138,19 +136,19 @@ func TestListValidators(t *testing.T) {
testCases := []struct {
name string
expectedError string
blockHeaderResponse beacon.GetBlockHeaderResponse
blockHeaderResponse structs.GetBlockHeaderResponse
}{
{
name: "nil data",
blockHeaderResponse: beacon.GetBlockHeaderResponse{
blockHeaderResponse: structs.GetBlockHeaderResponse{
Data: nil,
},
expectedError: "block header data is nil",
},
{
name: "nil data header",
blockHeaderResponse: beacon.GetBlockHeaderResponse{
Data: &shared.SignedBeaconBlockHeaderContainer{
blockHeaderResponse: structs.GetBlockHeaderResponse{
Data: &structs.SignedBeaconBlockHeaderContainer{
Header: nil,
},
},
@@ -158,9 +156,9 @@ func TestListValidators(t *testing.T) {
},
{
name: "nil message",
blockHeaderResponse: beacon.GetBlockHeaderResponse{
Data: &shared.SignedBeaconBlockHeaderContainer{
Header: &shared.SignedBeaconBlockHeader{
blockHeaderResponse: structs.GetBlockHeaderResponse{
Data: &structs.SignedBeaconBlockHeaderContainer{
Header: &structs.SignedBeaconBlockHeader{
Message: nil,
},
},
@@ -169,10 +167,10 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid header slot",
blockHeaderResponse: beacon.GetBlockHeaderResponse{
Data: &shared.SignedBeaconBlockHeaderContainer{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
blockHeaderResponse: structs.GetBlockHeaderResponse{
Data: &structs.SignedBeaconBlockHeaderContainer{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "foo",
},
},
@@ -215,12 +213,12 @@ func TestListValidators(t *testing.T) {
})
t.Run("fails to get validators for genesis filter", func(t *testing.T) {
generateValidStateValidatorsResponse := func() *beacon.GetValidatorsResponse {
return &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
generateValidStateValidatorsResponse := func() *structs.GetValidatorsResponse {
return &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "1",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode([]byte{3}),
WithdrawalCredentials: hexutil.Encode([]byte{4}),
EffectiveBalance: "5",
@@ -237,12 +235,12 @@ func TestListValidators(t *testing.T) {
testCases := []struct {
name string
generateStateValidatorsResponse func() *beacon.GetValidatorsResponse
generateStateValidatorsResponse func() *structs.GetValidatorsResponse
expectedError string
}{
{
name: "nil validator",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator = nil
return validatorsResponse
@@ -251,7 +249,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid pubkey",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.Pubkey = "foo"
return validatorsResponse
@@ -260,7 +258,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid withdrawal credentials",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.WithdrawalCredentials = "bar"
return validatorsResponse
@@ -269,7 +267,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid effective balance",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.EffectiveBalance = "foo"
return validatorsResponse
@@ -278,7 +276,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid validator index",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Index = "bar"
return validatorsResponse
@@ -287,7 +285,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid activation eligibility epoch",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.ActivationEligibilityEpoch = "foo"
return validatorsResponse
@@ -296,7 +294,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid activation epoch",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.ActivationEpoch = "bar"
return validatorsResponse
@@ -305,7 +303,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid exit epoch",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.ExitEpoch = "foo"
return validatorsResponse
@@ -314,7 +312,7 @@ func TestListValidators(t *testing.T) {
},
{
name: "invalid withdrawable epoch",
generateStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validatorsResponse := generateValidStateValidatorsResponse()
validatorsResponse.Data[0].Validator.WithdrawableEpoch = "bar"
return validatorsResponse
@@ -345,12 +343,12 @@ func TestListValidators(t *testing.T) {
})
t.Run("correctly returns the expected validators", func(t *testing.T) {
generateValidStateValidatorsResponse := func() *beacon.GetValidatorsResponse {
return &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
generateValidStateValidatorsResponse := func() *structs.GetValidatorsResponse {
return &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "1",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode([]byte{2}),
WithdrawalCredentials: hexutil.Encode([]byte{3}),
EffectiveBalance: "4",
@@ -363,7 +361,7 @@ func TestListValidators(t *testing.T) {
},
{
Index: "9",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode([]byte{10}),
WithdrawalCredentials: hexutil.Encode([]byte{11}),
EffectiveBalance: "12",
@@ -380,7 +378,7 @@ func TestListValidators(t *testing.T) {
testCases := []struct {
name string
generateJsonStateValidatorsResponse func() *beacon.GetValidatorsResponse
generateJsonStateValidatorsResponse func() *structs.GetValidatorsResponse
generateProtoValidatorsResponse func() *ethpb.Validators
pubkeys [][]byte
pubkeyStrings []string
@@ -391,16 +389,16 @@ func TestListValidators(t *testing.T) {
}{
{
name: "page size 0",
generateJsonStateValidatorsResponse: func() *beacon.GetValidatorsResponse {
generateJsonStateValidatorsResponse: func() *structs.GetValidatorsResponse {
validValidatorsResponse := generateValidStateValidatorsResponse()
// Generate more than 250 validators, but expect only 250 to be returned
validators := make([]*beacon.ValidatorContainer, 267)
validators := make([]*structs.ValidatorContainer, 267)
for idx := 0; idx < len(validators); idx++ {
validators[idx] = validValidatorsResponse.Data[0]
}
validatorsResponse := &beacon.GetValidatorsResponse{
validatorsResponse := &structs.GetValidatorsResponse{
Data: validators,
}
@@ -586,18 +584,18 @@ func TestGetChainHead(t *testing.T) {
const finalityCheckpointsEndpoint = "/eth/v1/beacon/states/head/finality_checkpoints"
const headBlockHeadersEndpoint = "/eth/v1/beacon/headers/head"
generateValidFinalityCheckpointsResponse := func() beacon.GetFinalityCheckpointsResponse {
return beacon.GetFinalityCheckpointsResponse{
Data: &beacon.FinalityCheckpoints{
PreviousJustified: &shared.Checkpoint{
generateValidFinalityCheckpointsResponse := func() structs.GetFinalityCheckpointsResponse {
return structs.GetFinalityCheckpointsResponse{
Data: &structs.FinalityCheckpoints{
PreviousJustified: &structs.Checkpoint{
Epoch: "1",
Root: hexutil.Encode([]byte{2}),
},
CurrentJustified: &shared.Checkpoint{
CurrentJustified: &structs.Checkpoint{
Epoch: "3",
Root: hexutil.Encode([]byte{4}),
},
Finalized: &shared.Checkpoint{
Finalized: &structs.Checkpoint{
Epoch: "5",
Root: hexutil.Encode([]byte{6}),
},
@@ -608,7 +606,7 @@ func TestGetChainHead(t *testing.T) {
t.Run("fails to get finality checkpoints", func(t *testing.T) {
testCases := []struct {
name string
generateFinalityCheckpointsResponse func() beacon.GetFinalityCheckpointsResponse
generateFinalityCheckpointsResponse func() structs.GetFinalityCheckpointsResponse
finalityCheckpointsError error
expectedError string
}{
@@ -616,14 +614,14 @@ func TestGetChainHead(t *testing.T) {
name: "query failed",
finalityCheckpointsError: errors.New("foo error"),
expectedError: "foo error",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
return beacon.GetFinalityCheckpointsResponse{}
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
return structs.GetFinalityCheckpointsResponse{}
},
},
{
name: "nil finality checkpoints data",
expectedError: "finality checkpoints data is nil",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data = nil
return validResponse
@@ -632,7 +630,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil finalized checkpoint",
expectedError: "finalized checkpoint is nil",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.Finalized = nil
return validResponse
@@ -641,7 +639,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid finalized epoch",
expectedError: "failed to parse finalized epoch `foo`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.Finalized.Epoch = "foo"
return validResponse
@@ -650,7 +648,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "failed to get first slot of finalized epoch",
expectedError: fmt.Sprintf("failed to get first slot for epoch `%d`", uint64(math.MaxUint64)),
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.Finalized.Epoch = strconv.FormatUint(uint64(math.MaxUint64), 10)
return validResponse
@@ -659,7 +657,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid finalized root",
expectedError: "failed to decode finalized checkpoint root `bar`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.Finalized.Root = "bar"
return validResponse
@@ -668,7 +666,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil current justified checkpoint",
expectedError: "current justified checkpoint is nil",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.CurrentJustified = nil
return validResponse
@@ -677,7 +675,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil current justified epoch",
expectedError: "failed to parse current justified checkpoint epoch `foo`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.CurrentJustified.Epoch = "foo"
return validResponse
@@ -686,7 +684,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "failed to get first slot of current justified epoch",
expectedError: fmt.Sprintf("failed to get first slot for epoch `%d`", uint64(math.MaxUint64)),
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.CurrentJustified.Epoch = strconv.FormatUint(uint64(math.MaxUint64), 10)
return validResponse
@@ -695,7 +693,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid current justified root",
expectedError: "failed to decode current justified checkpoint root `bar`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.CurrentJustified.Root = "bar"
return validResponse
@@ -704,7 +702,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil previous justified checkpoint",
expectedError: "previous justified checkpoint is nil",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.PreviousJustified = nil
return validResponse
@@ -713,7 +711,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil previous justified epoch",
expectedError: "failed to parse previous justified checkpoint epoch `foo`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.PreviousJustified.Epoch = "foo"
return validResponse
@@ -722,7 +720,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "failed to get first slot of previous justified epoch",
expectedError: fmt.Sprintf("failed to get first slot for epoch `%d`", uint64(math.MaxUint64)),
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.PreviousJustified.Epoch = strconv.FormatUint(uint64(math.MaxUint64), 10)
return validResponse
@@ -731,7 +729,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid previous justified root",
expectedError: "failed to decode previous justified checkpoint root `bar`",
generateFinalityCheckpointsResponse: func() beacon.GetFinalityCheckpointsResponse {
generateFinalityCheckpointsResponse: func() structs.GetFinalityCheckpointsResponse {
validResponse := generateValidFinalityCheckpointsResponse()
validResponse.Data.PreviousJustified.Root = "bar"
return validResponse
@@ -745,7 +743,7 @@ func TestGetChainHead(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
finalityCheckpointsResponse := beacon.GetFinalityCheckpointsResponse{}
finalityCheckpointsResponse := structs.GetFinalityCheckpointsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(ctx, finalityCheckpointsEndpoint, &finalityCheckpointsResponse).Return(
testCase.finalityCheckpointsError,
@@ -761,12 +759,12 @@ func TestGetChainHead(t *testing.T) {
}
})
generateValidBlockHeadersResponse := func() beacon.GetBlockHeaderResponse {
return beacon.GetBlockHeaderResponse{
Data: &shared.SignedBeaconBlockHeaderContainer{
generateValidBlockHeadersResponse := func() structs.GetBlockHeaderResponse {
return structs.GetBlockHeaderResponse{
Data: &structs.SignedBeaconBlockHeaderContainer{
Root: hexutil.Encode([]byte{7}),
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "8",
},
},
@@ -777,7 +775,7 @@ func TestGetChainHead(t *testing.T) {
t.Run("fails to get head block headers", func(t *testing.T) {
testCases := []struct {
name string
generateHeadBlockHeadersResponse func() beacon.GetBlockHeaderResponse
generateHeadBlockHeadersResponse func() structs.GetBlockHeaderResponse
headBlockHeadersError error
expectedError string
}{
@@ -785,14 +783,14 @@ func TestGetChainHead(t *testing.T) {
name: "query failed",
headBlockHeadersError: errors.New("foo error"),
expectedError: "failed to get head block header",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
return beacon.GetBlockHeaderResponse{}
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
return structs.GetBlockHeaderResponse{}
},
},
{
name: "nil block header data",
expectedError: "block header data is nil",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
validResponse := generateValidBlockHeadersResponse()
validResponse.Data = nil
return validResponse
@@ -801,7 +799,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil block header data header",
expectedError: "block header data is nil",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
validResponse := generateValidBlockHeadersResponse()
validResponse.Data.Header = nil
return validResponse
@@ -810,7 +808,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "nil block header message",
expectedError: "block header message is nil",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
validResponse := generateValidBlockHeadersResponse()
validResponse.Data.Header.Message = nil
return validResponse
@@ -819,7 +817,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid message slot",
expectedError: "failed to parse head block slot `foo`",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
validResponse := generateValidBlockHeadersResponse()
validResponse.Data.Header.Message.Slot = "foo"
return validResponse
@@ -829,7 +827,7 @@ func TestGetChainHead(t *testing.T) {
{
name: "invalid root",
expectedError: "failed to decode head block root `bar`",
generateHeadBlockHeadersResponse: func() beacon.GetBlockHeaderResponse {
generateHeadBlockHeadersResponse: func() structs.GetBlockHeaderResponse {
validResponse := generateValidBlockHeadersResponse()
validResponse.Data.Root = "bar"
return validResponse
@@ -845,7 +843,7 @@ func TestGetChainHead(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
finalityCheckpointsResponse := beacon.GetFinalityCheckpointsResponse{}
finalityCheckpointsResponse := structs.GetFinalityCheckpointsResponse{}
jsonRestHandler.EXPECT().Get(ctx, finalityCheckpointsEndpoint, &finalityCheckpointsResponse).Return(
nil,
).SetArg(
@@ -853,7 +851,7 @@ func TestGetChainHead(t *testing.T) {
generateValidFinalityCheckpointsResponse(),
)
headBlockHeadersResponse := beacon.GetBlockHeaderResponse{}
headBlockHeadersResponse := structs.GetBlockHeaderResponse{}
jsonRestHandler.EXPECT().Get(ctx, headBlockHeadersEndpoint, &headBlockHeadersResponse).Return(
testCase.headBlockHeadersError,
).SetArg(
@@ -875,7 +873,7 @@ func TestGetChainHead(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
finalityCheckpointsResponse := beacon.GetFinalityCheckpointsResponse{}
finalityCheckpointsResponse := structs.GetFinalityCheckpointsResponse{}
jsonRestHandler.EXPECT().Get(ctx, finalityCheckpointsEndpoint, &finalityCheckpointsResponse).Return(
nil,
).SetArg(
@@ -883,7 +881,7 @@ func TestGetChainHead(t *testing.T) {
generateValidFinalityCheckpointsResponse(),
)
headBlockHeadersResponse := beacon.GetBlockHeaderResponse{}
headBlockHeadersResponse := structs.GetBlockHeaderResponse{}
jsonRestHandler.EXPECT().Get(ctx, headBlockHeadersEndpoint, &headBlockHeadersResponse).Return(
nil,
).SetArg(
@@ -933,12 +931,12 @@ func Test_beaconApiBeaconChainClient_GetValidatorPerformance(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
request, err := json.Marshal(validator.PerformanceRequest{
request, err := json.Marshal(structs.GetValidatorPerformanceRequest{
PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]},
})
require.NoError(t, err)
wantResponse := &validator.PerformanceResponse{}
wantResponse := &structs.GetValidatorPerformanceResponse{}
want := &ethpb.ValidatorPerformanceResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(

View File

@@ -10,9 +10,7 @@ import (
"strconv"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -50,10 +48,10 @@ func buildURL(path string, queryParams ...neturl.Values) string {
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
}
func (c *beaconApiValidatorClient) getFork(ctx context.Context) (*beacon.GetStateForkResponse, error) {
func (c *beaconApiValidatorClient) getFork(ctx context.Context) (*structs.GetStateForkResponse, error) {
const endpoint = "/eth/v1/beacon/states/head/fork"
stateForkResponseJson := &beacon.GetStateForkResponse{}
stateForkResponseJson := &structs.GetStateForkResponse{}
if err := c.jsonRestHandler.Get(ctx, endpoint, stateForkResponseJson); err != nil {
return nil, err
@@ -62,10 +60,10 @@ func (c *beaconApiValidatorClient) getFork(ctx context.Context) (*beacon.GetStat
return stateForkResponseJson, nil
}
func (c *beaconApiValidatorClient) getHeaders(ctx context.Context) (*beacon.GetBlockHeadersResponse, error) {
func (c *beaconApiValidatorClient) getHeaders(ctx context.Context) (*structs.GetBlockHeadersResponse, error) {
const endpoint = "/eth/v1/beacon/headers"
blockHeadersResponseJson := &beacon.GetBlockHeadersResponse{}
blockHeadersResponseJson := &structs.GetBlockHeadersResponse{}
if err := c.jsonRestHandler.Get(ctx, endpoint, blockHeadersResponseJson); err != nil {
return nil, err
@@ -74,11 +72,11 @@ func (c *beaconApiValidatorClient) getHeaders(ctx context.Context) (*beacon.GetB
return blockHeadersResponseJson, nil
}
func (c *beaconApiValidatorClient) getLiveness(ctx context.Context, epoch primitives.Epoch, validatorIndexes []string) (*validator.GetLivenessResponse, error) {
func (c *beaconApiValidatorClient) getLiveness(ctx context.Context, epoch primitives.Epoch, validatorIndexes []string) (*structs.GetLivenessResponse, error) {
const endpoint = "/eth/v1/validator/liveness/"
url := endpoint + strconv.FormatUint(uint64(epoch), 10)
livenessResponseJson := &validator.GetLivenessResponse{}
livenessResponseJson := &structs.GetLivenessResponse{}
marshalledJsonValidatorIndexes, err := json.Marshal(validatorIndexes)
if err != nil {
@@ -92,10 +90,10 @@ func (c *beaconApiValidatorClient) getLiveness(ctx context.Context, epoch primit
return livenessResponseJson, nil
}
func (c *beaconApiValidatorClient) getSyncing(ctx context.Context) (*node.SyncStatusResponse, error) {
func (c *beaconApiValidatorClient) getSyncing(ctx context.Context) (*structs.SyncStatusResponse, error) {
const endpoint = "/eth/v1/node/syncing"
syncingResponseJson := &node.SyncStatusResponse{}
syncingResponseJson := &structs.SyncStatusResponse{}
if err := c.jsonRestHandler.Get(ctx, endpoint, syncingResponseJson); err != nil {
return nil, err

View File

@@ -9,10 +9,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -98,11 +95,11 @@ func TestGetFork_Nominal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
stateForkResponseJson := beacon.GetStateForkResponse{}
stateForkResponseJson := structs.GetStateForkResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
expected := beacon.GetStateForkResponse{
Data: &shared.Fork{
expected := structs.GetStateForkResponse{
Data: &structs.Fork{
PreviousVersion: "0x1",
CurrentVersion: "0x2",
Epoch: "3",
@@ -161,14 +158,14 @@ func TestGetHeaders_Nominal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
blockHeadersResponseJson := beacon.GetBlockHeadersResponse{}
blockHeadersResponseJson := structs.GetBlockHeadersResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
expected := beacon.GetBlockHeadersResponse{
Data: []*shared.SignedBeaconBlockHeaderContainer{
expected := structs.GetBlockHeadersResponse{
Data: []*structs.SignedBeaconBlockHeaderContainer{
{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "42",
},
},
@@ -228,14 +225,14 @@ func TestGetLiveness_Nominal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
livenessResponseJson := validator.GetLivenessResponse{}
livenessResponseJson := structs.GetLivenessResponse{}
indexes := []string{"1", "2"}
marshalledIndexes, err := json.Marshal(indexes)
require.NoError(t, err)
expected := validator.GetLivenessResponse{
Data: []*validator.Liveness{
expected := structs.GetLivenessResponse{
Data: []*structs.Liveness{
{
Index: "1",
IsLive: true,
@@ -315,11 +312,11 @@ func TestGetIsSyncing_Nominal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
syncingResponseJson := node.SyncStatusResponse{}
syncingResponseJson := structs.SyncStatusResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
expected := node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
expected := structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: testCase.isSyncing,
},
}
@@ -352,7 +349,7 @@ func TestGetIsSyncing_Invalid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
syncingResponseJson := node.SyncStatusResponse{}
syncingResponseJson := structs.SyncStatusResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
ctx := context.Background()

View File

@@ -7,8 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/config"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/validator/client/iface"
"google.golang.org/protobuf/types/known/timestamppb"
@@ -21,7 +20,7 @@ type beaconApiNodeClient struct {
}
func (c *beaconApiNodeClient) GetSyncStatus(ctx context.Context, _ *empty.Empty) (*ethpb.SyncStatus, error) {
syncingResponse := node.SyncStatusResponse{}
syncingResponse := structs.SyncStatusResponse{}
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/node/syncing", &syncingResponse); err != nil {
return nil, err
}
@@ -51,7 +50,7 @@ func (c *beaconApiNodeClient) GetGenesis(ctx context.Context, _ *empty.Empty) (*
return nil, errors.Wrapf(err, "failed to parse genesis time `%s`", genesisJson.GenesisTime)
}
depositContractJson := config.GetDepositContractResponse{}
depositContractJson := structs.GetDepositContractResponse{}
if err = c.jsonRestHandler.Get(ctx, "/eth/v1/config/deposit_contract", &depositContractJson); err != nil {
return nil, err
}
@@ -75,7 +74,7 @@ func (c *beaconApiNodeClient) GetGenesis(ctx context.Context, _ *empty.Empty) (*
}
func (c *beaconApiNodeClient) GetVersion(ctx context.Context, _ *empty.Empty) (*ethpb.Version, error) {
var versionResponse node.GetVersionResponse
var versionResponse structs.GetVersionResponse
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/node/version", &versionResponse); err != nil {
return nil, err
}

View File

@@ -7,9 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/config"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/mock"
@@ -20,9 +18,9 @@ import (
func TestGetGenesis(t *testing.T) {
testCases := []struct {
name string
genesisResponse *beacon.Genesis
genesisResponse *structs.Genesis
genesisError error
depositContractResponse config.GetDepositContractResponse
depositContractResponse structs.GetDepositContractResponse
depositContractError error
queriesDepositContract bool
expectedResponse *ethpb.Genesis
@@ -35,7 +33,7 @@ func TestGetGenesis(t *testing.T) {
},
{
name: "fails to decode genesis validator root",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "1",
GenesisValidatorsRoot: "foo",
},
@@ -43,7 +41,7 @@ func TestGetGenesis(t *testing.T) {
},
{
name: "fails to parse genesis time",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "foo",
GenesisValidatorsRoot: hexutil.Encode([]byte{1}),
},
@@ -51,7 +49,7 @@ func TestGetGenesis(t *testing.T) {
},
{
name: "fails to query contract information",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "1",
GenesisValidatorsRoot: hexutil.Encode([]byte{2}),
},
@@ -61,25 +59,25 @@ func TestGetGenesis(t *testing.T) {
},
{
name: "fails to read nil deposit contract data",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "1",
GenesisValidatorsRoot: hexutil.Encode([]byte{2}),
},
queriesDepositContract: true,
depositContractResponse: config.GetDepositContractResponse{
depositContractResponse: structs.GetDepositContractResponse{
Data: nil,
},
expectedError: "deposit contract data is nil",
},
{
name: "fails to decode deposit contract address",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "1",
GenesisValidatorsRoot: hexutil.Encode([]byte{2}),
},
queriesDepositContract: true,
depositContractResponse: config.GetDepositContractResponse{
Data: &config.DepositContractData{
depositContractResponse: structs.GetDepositContractResponse{
Data: &structs.DepositContractData{
Address: "foo",
},
},
@@ -87,13 +85,13 @@ func TestGetGenesis(t *testing.T) {
},
{
name: "successfully retrieves genesis info",
genesisResponse: &beacon.Genesis{
genesisResponse: &structs.Genesis{
GenesisTime: "654812",
GenesisValidatorsRoot: hexutil.Encode([]byte{2}),
},
queriesDepositContract: true,
depositContractResponse: config.GetDepositContractResponse{
Data: &config.DepositContractData{
depositContractResponse: structs.GetDepositContractResponse{
Data: &structs.DepositContractData{
Address: hexutil.Encode([]byte{3}),
},
},
@@ -121,7 +119,7 @@ func TestGetGenesis(t *testing.T) {
testCase.genesisError,
)
depositContractJson := config.GetDepositContractResponse{}
depositContractJson := structs.GetDepositContractResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
if testCase.queriesDepositContract {
@@ -157,7 +155,7 @@ func TestGetSyncStatus(t *testing.T) {
testCases := []struct {
name string
restEndpointResponse node.SyncStatusResponse
restEndpointResponse structs.SyncStatusResponse
restEndpointError error
expectedResponse *ethpb.SyncStatus
expectedError string
@@ -169,13 +167,13 @@ func TestGetSyncStatus(t *testing.T) {
},
{
name: "returns nil syncing data",
restEndpointResponse: node.SyncStatusResponse{Data: nil},
restEndpointResponse: structs.SyncStatusResponse{Data: nil},
expectedError: "syncing data is nil",
},
{
name: "returns false syncing status",
restEndpointResponse: node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
restEndpointResponse: structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: false,
},
},
@@ -185,8 +183,8 @@ func TestGetSyncStatus(t *testing.T) {
},
{
name: "returns true syncing status",
restEndpointResponse: node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
restEndpointResponse: structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: true,
},
},
@@ -202,7 +200,7 @@ func TestGetSyncStatus(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
syncingResponse := node.SyncStatusResponse{}
syncingResponse := structs.SyncStatusResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -232,7 +230,7 @@ func TestGetVersion(t *testing.T) {
testCases := []struct {
name string
restEndpointResponse node.GetVersionResponse
restEndpointResponse structs.GetVersionResponse
restEndpointError error
expectedResponse *ethpb.Version
expectedError string
@@ -244,13 +242,13 @@ func TestGetVersion(t *testing.T) {
},
{
name: "returns nil version data",
restEndpointResponse: node.GetVersionResponse{Data: nil},
restEndpointResponse: structs.GetVersionResponse{Data: nil},
expectedError: "empty version response",
},
{
name: "returns proper version response",
restEndpointResponse: node.GetVersionResponse{
Data: &node.Version{
restEndpointResponse: structs.GetVersionResponse{
Data: &structs.Version{
Version: "prysm/local",
},
},
@@ -266,7 +264,7 @@ func TestGetVersion(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
var versionResponse node.GetVersionResponse
var versionResponse structs.GetVersionResponse
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,

View File

@@ -7,11 +7,10 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -31,7 +30,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataValid(t *testing.T) {
ctx := context.Background()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v1/validator/attestation_data?committee_index=%d&slot=%d", committeeIndex, slot),
@@ -71,7 +70,7 @@ func TestBeaconApiValidatorClient_GetAttestationDataError(t *testing.T) {
ctx := context.Background()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
produceAttestationDataResponseJson := validator.GetAttestationDataResponse{}
produceAttestationDataResponseJson := structs.GetAttestationDataResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v1/validator/attestation_data?committee_index=%d&slot=%d", committeeIndex, slot),
@@ -117,7 +116,7 @@ func TestBeaconApiValidatorClient_DomainDataValid(t *testing.T) {
genesisProvider := mock.NewMockGenesisProvider(ctrl)
genesisProvider.EXPECT().GetGenesis(ctx).Return(
&beacon.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
&structs.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
nil,
).Times(2)

View File

@@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
@@ -14,16 +14,16 @@ import (
)
type BeaconBlockConverter interface {
ConvertRESTPhase0BlockToProto(block *shared.BeaconBlock) (*ethpb.BeaconBlock, error)
ConvertRESTAltairBlockToProto(block *shared.BeaconBlockAltair) (*ethpb.BeaconBlockAltair, error)
ConvertRESTBellatrixBlockToProto(block *shared.BeaconBlockBellatrix) (*ethpb.BeaconBlockBellatrix, error)
ConvertRESTCapellaBlockToProto(block *shared.BeaconBlockCapella) (*ethpb.BeaconBlockCapella, error)
ConvertRESTPhase0BlockToProto(block *structs.BeaconBlock) (*ethpb.BeaconBlock, error)
ConvertRESTAltairBlockToProto(block *structs.BeaconBlockAltair) (*ethpb.BeaconBlockAltair, error)
ConvertRESTBellatrixBlockToProto(block *structs.BeaconBlockBellatrix) (*ethpb.BeaconBlockBellatrix, error)
ConvertRESTCapellaBlockToProto(block *structs.BeaconBlockCapella) (*ethpb.BeaconBlockCapella, error)
}
type beaconApiBeaconBlockConverter struct{}
// ConvertRESTPhase0BlockToProto converts a Phase0 JSON beacon block to its protobuf equivalent
func (c beaconApiBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *shared.BeaconBlock) (*ethpb.BeaconBlock, error) {
func (c beaconApiBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *structs.BeaconBlock) (*ethpb.BeaconBlock, error) {
blockSlot, err := strconv.ParseUint(block.Slot, 10, 64)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse slot `%s`", block.Slot)
@@ -125,19 +125,19 @@ func (c beaconApiBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *shar
}
// ConvertRESTAltairBlockToProto converts an Altair JSON beacon block to its protobuf equivalent
func (c beaconApiBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *shared.BeaconBlockAltair) (*ethpb.BeaconBlockAltair, error) {
func (c beaconApiBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *structs.BeaconBlockAltair) (*ethpb.BeaconBlockAltair, error) {
if block.Body == nil {
return nil, errors.New("block body is nil")
}
// Call convertRESTPhase0BlockToProto to set the phase0 fields because all the error handling and the heavy lifting
// has already been done
phase0Block, err := c.ConvertRESTPhase0BlockToProto(&shared.BeaconBlock{
phase0Block, err := c.ConvertRESTPhase0BlockToProto(&structs.BeaconBlock{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: block.ParentRoot,
StateRoot: block.StateRoot,
Body: &shared.BeaconBlockBody{
Body: &structs.BeaconBlockBody{
RandaoReveal: block.Body.RandaoReveal,
Eth1Data: block.Body.Eth1Data,
Graffiti: block.Body.Graffiti,
@@ -189,19 +189,19 @@ func (c beaconApiBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *shar
}
// ConvertRESTBellatrixBlockToProto converts a Bellatrix JSON beacon block to its protobuf equivalent
func (c beaconApiBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *shared.BeaconBlockBellatrix) (*ethpb.BeaconBlockBellatrix, error) {
func (c beaconApiBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *structs.BeaconBlockBellatrix) (*ethpb.BeaconBlockBellatrix, error) {
if block.Body == nil {
return nil, errors.New("block body is nil")
}
// Call convertRESTAltairBlockToProto to set the altair fields because all the error handling and the heavy lifting
// has already been done
altairBlock, err := c.ConvertRESTAltairBlockToProto(&shared.BeaconBlockAltair{
altairBlock, err := c.ConvertRESTAltairBlockToProto(&structs.BeaconBlockAltair{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: block.ParentRoot,
StateRoot: block.StateRoot,
Body: &shared.BeaconBlockBodyAltair{
Body: &structs.BeaconBlockBodyAltair{
RandaoReveal: block.Body.RandaoReveal,
Eth1Data: block.Body.Eth1Data,
Graffiti: block.Body.Graffiti,
@@ -327,7 +327,7 @@ func (c beaconApiBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *s
}
// ConvertRESTCapellaBlockToProto converts a Capella JSON beacon block to its protobuf equivalent
func (c beaconApiBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *shared.BeaconBlockCapella) (*ethpb.BeaconBlockCapella, error) {
func (c beaconApiBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *structs.BeaconBlockCapella) (*ethpb.BeaconBlockCapella, error) {
if block.Body == nil {
return nil, errors.New("block body is nil")
}
@@ -338,12 +338,12 @@ func (c beaconApiBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *sha
// Call convertRESTBellatrixBlockToProto to set the bellatrix fields because all the error handling and the heavy
// lifting has already been done
bellatrixBlock, err := c.ConvertRESTBellatrixBlockToProto(&shared.BeaconBlockBellatrix{
bellatrixBlock, err := c.ConvertRESTBellatrixBlockToProto(&structs.BeaconBlockBellatrix{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: block.ParentRoot,
StateRoot: block.StateRoot,
Body: &shared.BeaconBlockBodyBellatrix{
Body: &structs.BeaconBlockBodyBellatrix{
RandaoReveal: block.Body.RandaoReveal,
Eth1Data: block.Body.Eth1Data,
Graffiti: block.Body.Graffiti,
@@ -353,7 +353,7 @@ func (c beaconApiBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *sha
Deposits: block.Body.Deposits,
VoluntaryExits: block.Body.VoluntaryExits,
SyncAggregate: block.Body.SyncAggregate,
ExecutionPayload: &shared.ExecutionPayload{
ExecutionPayload: &structs.ExecutionPayload{
ParentHash: block.Body.ExecutionPayload.ParentHash,
FeeRecipient: block.Body.ExecutionPayload.FeeRecipient,
StateRoot: block.Body.ExecutionPayload.StateRoot,

View File

@@ -3,7 +3,7 @@ package beacon_api
import (
"testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
test_helpers "github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/test-helpers"
@@ -21,12 +21,12 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
testCases := []struct {
name string
expectedErrorMessage string
generateData func() *shared.BeaconBlock
generateData func() *structs.BeaconBlock
}{
{
name: "nil body",
expectedErrorMessage: "block body is nil",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body = nil
return beaconBlock
@@ -35,7 +35,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "nil eth1 data",
expectedErrorMessage: "eth1 data is nil",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Eth1Data = nil
return beaconBlock
@@ -44,7 +44,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad slot",
expectedErrorMessage: "failed to parse slot `foo`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Slot = "foo"
return beaconBlock
@@ -53,7 +53,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad proposer index",
expectedErrorMessage: "failed to parse proposer index `bar`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.ProposerIndex = "bar"
return beaconBlock
@@ -62,7 +62,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad parent root",
expectedErrorMessage: "failed to decode parent root `foo`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.ParentRoot = "foo"
return beaconBlock
@@ -71,7 +71,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad state root",
expectedErrorMessage: "failed to decode state root `bar`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.StateRoot = "bar"
return beaconBlock
@@ -80,7 +80,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad randao reveal",
expectedErrorMessage: "failed to decode randao reveal `foo`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.RandaoReveal = "foo"
return beaconBlock
@@ -89,7 +89,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad deposit root",
expectedErrorMessage: "failed to decode deposit root `bar`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Eth1Data.DepositRoot = "bar"
return beaconBlock
@@ -98,7 +98,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad deposit count",
expectedErrorMessage: "failed to parse deposit count `foo`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Eth1Data.DepositCount = "foo"
return beaconBlock
@@ -107,7 +107,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad block hash",
expectedErrorMessage: "failed to decode block hash `bar`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Eth1Data.BlockHash = "bar"
return beaconBlock
@@ -116,7 +116,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad graffiti",
expectedErrorMessage: "failed to decode graffiti `foo`",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Graffiti = "foo"
return beaconBlock
@@ -125,7 +125,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad proposer slashings",
expectedErrorMessage: "failed to get proposer slashings",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.ProposerSlashings[0] = nil
return beaconBlock
@@ -134,7 +134,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad attester slashings",
expectedErrorMessage: "failed to get attester slashings",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.AttesterSlashings[0] = nil
return beaconBlock
@@ -143,7 +143,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad attestations",
expectedErrorMessage: "failed to get attestations",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Attestations[0] = nil
return beaconBlock
@@ -152,7 +152,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad deposits",
expectedErrorMessage: "failed to get deposits",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.Deposits[0] = nil
return beaconBlock
@@ -161,7 +161,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
{
name: "bad voluntary exits",
expectedErrorMessage: "failed to get voluntary exits",
generateData: func() *shared.BeaconBlock {
generateData: func() *structs.BeaconBlock {
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
beaconBlock.Body.VoluntaryExits[0] = nil
return beaconBlock
@@ -192,12 +192,12 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
testCases := []struct {
name string
expectedErrorMessage string
generateData func() *shared.BeaconBlockAltair
generateData func() *structs.BeaconBlockAltair
}{
{
name: "nil body",
expectedErrorMessage: "block body is nil",
generateData: func() *shared.BeaconBlockAltair {
generateData: func() *structs.BeaconBlockAltair {
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
beaconBlock.Body = nil
return beaconBlock
@@ -206,7 +206,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
{
name: "nil sync aggregate",
expectedErrorMessage: "sync aggregate is nil",
generateData: func() *shared.BeaconBlockAltair {
generateData: func() *structs.BeaconBlockAltair {
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
beaconBlock.Body.SyncAggregate = nil
return beaconBlock
@@ -215,7 +215,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
{
name: "bad phase0 fields",
expectedErrorMessage: "failed to get the phase0 fields of the altair block",
generateData: func() *shared.BeaconBlockAltair {
generateData: func() *structs.BeaconBlockAltair {
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
beaconBlock.Body.Eth1Data = nil
return beaconBlock
@@ -224,7 +224,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
{
name: "bad sync committee bits",
expectedErrorMessage: "failed to decode sync committee bits `foo`",
generateData: func() *shared.BeaconBlockAltair {
generateData: func() *structs.BeaconBlockAltair {
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
beaconBlock.Body.SyncAggregate.SyncCommitteeBits = "foo"
return beaconBlock
@@ -233,7 +233,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
{
name: "bad sync committee signature",
expectedErrorMessage: "failed to decode sync committee signature `bar`",
generateData: func() *shared.BeaconBlockAltair {
generateData: func() *structs.BeaconBlockAltair {
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
beaconBlock.Body.SyncAggregate.SyncCommitteeSignature = "bar"
return beaconBlock
@@ -264,12 +264,12 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
testCases := []struct {
name string
expectedErrorMessage string
generateData func() *shared.BeaconBlockBellatrix
generateData func() *structs.BeaconBlockBellatrix
}{
{
name: "nil body",
expectedErrorMessage: "block body is nil",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body = nil
return beaconBlock
@@ -278,7 +278,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "nil execution payload",
expectedErrorMessage: "execution payload is nil",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload = nil
return beaconBlock
@@ -287,7 +287,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad altair fields",
expectedErrorMessage: "failed to get the altair fields of the bellatrix block",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.Eth1Data = nil
return beaconBlock
@@ -296,7 +296,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad parent hash",
expectedErrorMessage: "failed to decode execution payload parent hash `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.ParentHash = "foo"
return beaconBlock
@@ -305,7 +305,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad fee recipient",
expectedErrorMessage: "failed to decode execution payload fee recipient `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.FeeRecipient = "bar"
return beaconBlock
@@ -314,7 +314,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad state root",
expectedErrorMessage: "failed to decode execution payload state root `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.StateRoot = "foo"
return beaconBlock
@@ -323,7 +323,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad receipts root",
expectedErrorMessage: "failed to decode execution payload receipts root `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.ReceiptsRoot = "bar"
return beaconBlock
@@ -332,7 +332,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad logs bloom",
expectedErrorMessage: "failed to decode execution payload logs bloom `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.LogsBloom = "foo"
return beaconBlock
@@ -341,7 +341,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad prev randao",
expectedErrorMessage: "failed to decode execution payload prev randao `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.PrevRandao = "bar"
return beaconBlock
@@ -350,7 +350,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad block number",
expectedErrorMessage: "failed to parse execution payload block number `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.BlockNumber = "foo"
return beaconBlock
@@ -359,7 +359,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad gas limit",
expectedErrorMessage: "failed to parse execution payload gas limit `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.GasLimit = "bar"
return beaconBlock
@@ -368,7 +368,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad gas used",
expectedErrorMessage: "failed to parse execution payload gas used `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.GasUsed = "foo"
return beaconBlock
@@ -377,7 +377,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad timestamp",
expectedErrorMessage: "failed to parse execution payload timestamp `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.Timestamp = "bar"
return beaconBlock
@@ -386,7 +386,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad extra data",
expectedErrorMessage: "failed to decode execution payload extra data `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.ExtraData = "foo"
return beaconBlock
@@ -395,7 +395,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad base fee per gas",
expectedErrorMessage: "failed to parse execution payload base fee per gas `bar`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.BaseFeePerGas = "bar"
return beaconBlock
@@ -404,7 +404,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad block hash",
expectedErrorMessage: "failed to decode execution payload block hash `foo`",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.BlockHash = "foo"
return beaconBlock
@@ -413,7 +413,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
{
name: "bad transactions",
expectedErrorMessage: "failed to get execution payload transactions",
generateData: func() *shared.BeaconBlockBellatrix {
generateData: func() *structs.BeaconBlockBellatrix {
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
beaconBlock.Body.ExecutionPayload.Transactions[0] = "bar"
return beaconBlock
@@ -444,12 +444,12 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
testCases := []struct {
name string
expectedErrorMessage string
generateData func() *shared.BeaconBlockCapella
generateData func() *structs.BeaconBlockCapella
}{
{
name: "nil body",
expectedErrorMessage: "block body is nil",
generateData: func() *shared.BeaconBlockCapella {
generateData: func() *structs.BeaconBlockCapella {
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
beaconBlock.Body = nil
return beaconBlock
@@ -458,7 +458,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
{
name: "nil execution payload",
expectedErrorMessage: "execution payload is nil",
generateData: func() *shared.BeaconBlockCapella {
generateData: func() *structs.BeaconBlockCapella {
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
beaconBlock.Body.ExecutionPayload = nil
return beaconBlock
@@ -467,7 +467,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
{
name: "bad bellatrix fields",
expectedErrorMessage: "failed to get the bellatrix fields of the capella block",
generateData: func() *shared.BeaconBlockCapella {
generateData: func() *structs.BeaconBlockCapella {
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
beaconBlock.Body.Eth1Data = nil
return beaconBlock
@@ -476,7 +476,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
{
name: "bad withdrawals",
expectedErrorMessage: "failed to get withdrawals",
generateData: func() *shared.BeaconBlockCapella {
generateData: func() *structs.BeaconBlockCapella {
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
beaconBlock.Body.ExecutionPayload.Withdrawals[0] = nil
return beaconBlock
@@ -485,7 +485,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
{
name: "bad bls execution changes",
expectedErrorMessage: "failed to get bls to execution changes",
generateData: func() *shared.BeaconBlockCapella {
generateData: func() *structs.BeaconBlockCapella {
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
beaconBlock.Body.BLSToExecutionChanges[0] = nil
return beaconBlock

View File

@@ -4,7 +4,7 @@ import (
"strconv"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -18,15 +18,15 @@ func jsonifyTransactions(transactions [][]byte) []string {
return jsonTransactions
}
func jsonifyBlsToExecutionChanges(blsToExecutionChanges []*ethpb.SignedBLSToExecutionChange) []*shared.SignedBLSToExecutionChange {
jsonBlsToExecutionChanges := make([]*shared.SignedBLSToExecutionChange, len(blsToExecutionChanges))
func jsonifyBlsToExecutionChanges(blsToExecutionChanges []*ethpb.SignedBLSToExecutionChange) []*structs.SignedBLSToExecutionChange {
jsonBlsToExecutionChanges := make([]*structs.SignedBLSToExecutionChange, len(blsToExecutionChanges))
for index, signedBlsToExecutionChange := range blsToExecutionChanges {
blsToExecutionChangeJson := &shared.BLSToExecutionChange{
blsToExecutionChangeJson := &structs.BLSToExecutionChange{
ValidatorIndex: uint64ToString(signedBlsToExecutionChange.Message.ValidatorIndex),
FromBLSPubkey: hexutil.Encode(signedBlsToExecutionChange.Message.FromBlsPubkey),
ToExecutionAddress: hexutil.Encode(signedBlsToExecutionChange.Message.ToExecutionAddress),
}
signedJson := &shared.SignedBLSToExecutionChange{
signedJson := &structs.SignedBLSToExecutionChange{
Message: blsToExecutionChangeJson,
Signature: hexutil.Encode(signedBlsToExecutionChange.Signature),
}
@@ -35,26 +35,26 @@ func jsonifyBlsToExecutionChanges(blsToExecutionChanges []*ethpb.SignedBLSToExec
return jsonBlsToExecutionChanges
}
func jsonifyEth1Data(eth1Data *ethpb.Eth1Data) *shared.Eth1Data {
return &shared.Eth1Data{
func jsonifyEth1Data(eth1Data *ethpb.Eth1Data) *structs.Eth1Data {
return &structs.Eth1Data{
BlockHash: hexutil.Encode(eth1Data.BlockHash),
DepositCount: uint64ToString(eth1Data.DepositCount),
DepositRoot: hexutil.Encode(eth1Data.DepositRoot),
}
}
func jsonifyAttestations(attestations []*ethpb.Attestation) []*shared.Attestation {
jsonAttestations := make([]*shared.Attestation, len(attestations))
func jsonifyAttestations(attestations []*ethpb.Attestation) []*structs.Attestation {
jsonAttestations := make([]*structs.Attestation, len(attestations))
for index, attestation := range attestations {
jsonAttestations[index] = jsonifyAttestation(attestation)
}
return jsonAttestations
}
func jsonifyAttesterSlashings(attesterSlashings []*ethpb.AttesterSlashing) []*shared.AttesterSlashing {
jsonAttesterSlashings := make([]*shared.AttesterSlashing, len(attesterSlashings))
func jsonifyAttesterSlashings(attesterSlashings []*ethpb.AttesterSlashing) []*structs.AttesterSlashing {
jsonAttesterSlashings := make([]*structs.AttesterSlashing, len(attesterSlashings))
for index, attesterSlashing := range attesterSlashings {
jsonAttesterSlashing := &shared.AttesterSlashing{
jsonAttesterSlashing := &structs.AttesterSlashing{
Attestation1: jsonifyIndexedAttestation(attesterSlashing.Attestation_1),
Attestation2: jsonifyIndexedAttestation(attesterSlashing.Attestation_2),
}
@@ -63,16 +63,16 @@ func jsonifyAttesterSlashings(attesterSlashings []*ethpb.AttesterSlashing) []*sh
return jsonAttesterSlashings
}
func jsonifyDeposits(deposits []*ethpb.Deposit) []*shared.Deposit {
jsonDeposits := make([]*shared.Deposit, len(deposits))
func jsonifyDeposits(deposits []*ethpb.Deposit) []*structs.Deposit {
jsonDeposits := make([]*structs.Deposit, len(deposits))
for depositIndex, deposit := range deposits {
proofs := make([]string, len(deposit.Proof))
for proofIndex, proof := range deposit.Proof {
proofs[proofIndex] = hexutil.Encode(proof)
}
jsonDeposit := &shared.Deposit{
Data: &shared.DepositData{
jsonDeposit := &structs.Deposit{
Data: &structs.DepositData{
Amount: uint64ToString(deposit.Data.Amount),
Pubkey: hexutil.Encode(deposit.Data.PublicKey),
Signature: hexutil.Encode(deposit.Data.Signature),
@@ -85,10 +85,10 @@ func jsonifyDeposits(deposits []*ethpb.Deposit) []*shared.Deposit {
return jsonDeposits
}
func jsonifyProposerSlashings(proposerSlashings []*ethpb.ProposerSlashing) []*shared.ProposerSlashing {
jsonProposerSlashings := make([]*shared.ProposerSlashing, len(proposerSlashings))
func jsonifyProposerSlashings(proposerSlashings []*ethpb.ProposerSlashing) []*structs.ProposerSlashing {
jsonProposerSlashings := make([]*structs.ProposerSlashing, len(proposerSlashings))
for index, proposerSlashing := range proposerSlashings {
jsonProposerSlashing := &shared.ProposerSlashing{
jsonProposerSlashing := &structs.ProposerSlashing{
SignedHeader1: jsonifySignedBeaconBlockHeader(proposerSlashing.Header_1),
SignedHeader2: jsonifySignedBeaconBlockHeader(proposerSlashing.Header_2),
}
@@ -98,11 +98,11 @@ func jsonifyProposerSlashings(proposerSlashings []*ethpb.ProposerSlashing) []*sh
}
// JsonifySignedVoluntaryExits converts an array of voluntary exit structs to a JSON hex string compatible format.
func JsonifySignedVoluntaryExits(voluntaryExits []*ethpb.SignedVoluntaryExit) []*shared.SignedVoluntaryExit {
jsonSignedVoluntaryExits := make([]*shared.SignedVoluntaryExit, len(voluntaryExits))
func JsonifySignedVoluntaryExits(voluntaryExits []*ethpb.SignedVoluntaryExit) []*structs.SignedVoluntaryExit {
jsonSignedVoluntaryExits := make([]*structs.SignedVoluntaryExit, len(voluntaryExits))
for index, signedVoluntaryExit := range voluntaryExits {
jsonSignedVoluntaryExit := &shared.SignedVoluntaryExit{
Message: &shared.VoluntaryExit{
jsonSignedVoluntaryExit := &structs.SignedVoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: uint64ToString(signedVoluntaryExit.Exit.Epoch),
ValidatorIndex: uint64ToString(signedVoluntaryExit.Exit.ValidatorIndex),
},
@@ -113,9 +113,9 @@ func JsonifySignedVoluntaryExits(voluntaryExits []*ethpb.SignedVoluntaryExit) []
return jsonSignedVoluntaryExits
}
func jsonifySignedBeaconBlockHeader(signedBeaconBlockHeader *ethpb.SignedBeaconBlockHeader) *shared.SignedBeaconBlockHeader {
return &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
func jsonifySignedBeaconBlockHeader(signedBeaconBlockHeader *ethpb.SignedBeaconBlockHeader) *structs.SignedBeaconBlockHeader {
return &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
BodyRoot: hexutil.Encode(signedBeaconBlockHeader.Header.BodyRoot),
ParentRoot: hexutil.Encode(signedBeaconBlockHeader.Header.ParentRoot),
ProposerIndex: uint64ToString(signedBeaconBlockHeader.Header.ProposerIndex),
@@ -126,47 +126,47 @@ func jsonifySignedBeaconBlockHeader(signedBeaconBlockHeader *ethpb.SignedBeaconB
}
}
func jsonifyIndexedAttestation(indexedAttestation *ethpb.IndexedAttestation) *shared.IndexedAttestation {
func jsonifyIndexedAttestation(indexedAttestation *ethpb.IndexedAttestation) *structs.IndexedAttestation {
attestingIndices := make([]string, len(indexedAttestation.AttestingIndices))
for index, attestingIndex := range indexedAttestation.AttestingIndices {
attestingIndex := uint64ToString(attestingIndex)
attestingIndices[index] = attestingIndex
}
return &shared.IndexedAttestation{
return &structs.IndexedAttestation{
AttestingIndices: attestingIndices,
Data: jsonifyAttestationData(indexedAttestation.Data),
Signature: hexutil.Encode(indexedAttestation.Signature),
}
}
func jsonifyAttestationData(attestationData *ethpb.AttestationData) *shared.AttestationData {
return &shared.AttestationData{
func jsonifyAttestationData(attestationData *ethpb.AttestationData) *structs.AttestationData {
return &structs.AttestationData{
BeaconBlockRoot: hexutil.Encode(attestationData.BeaconBlockRoot),
CommitteeIndex: uint64ToString(attestationData.CommitteeIndex),
Slot: uint64ToString(attestationData.Slot),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: uint64ToString(attestationData.Source.Epoch),
Root: hexutil.Encode(attestationData.Source.Root),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: uint64ToString(attestationData.Target.Epoch),
Root: hexutil.Encode(attestationData.Target.Root),
},
}
}
func jsonifyAttestation(attestation *ethpb.Attestation) *shared.Attestation {
return &shared.Attestation{
func jsonifyAttestation(attestation *ethpb.Attestation) *structs.Attestation {
return &structs.Attestation{
AggregationBits: hexutil.Encode(attestation.AggregationBits),
Data: jsonifyAttestationData(attestation.Data),
Signature: hexutil.Encode(attestation.Signature),
}
}
func jsonifySignedAggregateAndProof(signedAggregateAndProof *ethpb.SignedAggregateAttestationAndProof) *shared.SignedAggregateAttestationAndProof {
return &shared.SignedAggregateAttestationAndProof{
Message: &shared.AggregateAttestationAndProof{
func jsonifySignedAggregateAndProof(signedAggregateAndProof *ethpb.SignedAggregateAttestationAndProof) *structs.SignedAggregateAttestationAndProof {
return &structs.SignedAggregateAttestationAndProof{
Message: &structs.AggregateAttestationAndProof{
AggregatorIndex: uint64ToString(signedAggregateAndProof.Message.AggregatorIndex),
Aggregate: jsonifyAttestation(signedAggregateAndProof.Message.Aggregate),
SelectionProof: hexutil.Encode(signedAggregateAndProof.Message.SelectionProof),
@@ -175,10 +175,10 @@ func jsonifySignedAggregateAndProof(signedAggregateAndProof *ethpb.SignedAggrega
}
}
func jsonifyWithdrawals(withdrawals []*enginev1.Withdrawal) []*shared.Withdrawal {
jsonWithdrawals := make([]*shared.Withdrawal, len(withdrawals))
func jsonifyWithdrawals(withdrawals []*enginev1.Withdrawal) []*structs.Withdrawal {
jsonWithdrawals := make([]*structs.Withdrawal, len(withdrawals))
for index, withdrawal := range withdrawals {
jsonWithdrawals[index] = &shared.Withdrawal{
jsonWithdrawals[index] = &structs.Withdrawal{
WithdrawalIndex: strconv.FormatUint(withdrawal.Index, 10),
ValidatorIndex: strconv.FormatUint(uint64(withdrawal.ValidatorIndex), 10),
ExecutionAddress: hexutil.Encode(withdrawal.Address),

View File

@@ -4,7 +4,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -44,9 +44,9 @@ func TestBeaconBlockJsonHelpers_JsonifyBlsToExecutionChanges(t *testing.T) {
},
}
expectedResult := []*shared.SignedBLSToExecutionChange{
expectedResult := []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "1",
FromBLSPubkey: hexutil.Encode([]byte{2}),
ToExecutionAddress: hexutil.Encode([]byte{3}),
@@ -54,7 +54,7 @@ func TestBeaconBlockJsonHelpers_JsonifyBlsToExecutionChanges(t *testing.T) {
Signature: hexutil.Encode([]byte{7}),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "4",
FromBLSPubkey: hexutil.Encode([]byte{5}),
ToExecutionAddress: hexutil.Encode([]byte{6}),
@@ -63,7 +63,7 @@ func TestBeaconBlockJsonHelpers_JsonifyBlsToExecutionChanges(t *testing.T) {
},
}
assert.DeepEqual(t, expectedResult, shared.SignedBLSChangesFromConsensus(input))
assert.DeepEqual(t, expectedResult, structs.SignedBLSChangesFromConsensus(input))
}
func TestBeaconBlockJsonHelpers_JsonifyEth1Data(t *testing.T) {
@@ -73,7 +73,7 @@ func TestBeaconBlockJsonHelpers_JsonifyEth1Data(t *testing.T) {
BlockHash: []byte{3},
}
expectedResult := &shared.Eth1Data{
expectedResult := &structs.Eth1Data{
DepositRoot: hexutil.Encode([]byte{1}),
DepositCount: "2",
BlockHash: hexutil.Encode([]byte{3}),
@@ -121,18 +121,18 @@ func TestBeaconBlockJsonHelpers_JsonifyAttestations(t *testing.T) {
},
}
expectedResult := []*shared.Attestation{
expectedResult := []*structs.Attestation{
{
AggregationBits: hexutil.Encode([]byte{1}),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "2",
CommitteeIndex: "3",
BeaconBlockRoot: hexutil.Encode([]byte{4}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "5",
Root: hexutil.Encode([]byte{6}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "7",
Root: hexutil.Encode([]byte{8}),
},
@@ -141,15 +141,15 @@ func TestBeaconBlockJsonHelpers_JsonifyAttestations(t *testing.T) {
},
{
AggregationBits: hexutil.Encode([]byte{10}),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "11",
CommitteeIndex: "12",
BeaconBlockRoot: hexutil.Encode([]byte{13}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "14",
Root: hexutil.Encode([]byte{15}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "16",
Root: hexutil.Encode([]byte{17}),
},
@@ -238,36 +238,36 @@ func TestBeaconBlockJsonHelpers_JsonifyAttesterSlashings(t *testing.T) {
},
}
expectedResult := []*shared.AttesterSlashing{
expectedResult := []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"1", "2"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "3",
CommitteeIndex: "4",
BeaconBlockRoot: hexutil.Encode([]byte{5}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "8",
Root: hexutil.Encode([]byte{9}),
},
},
Signature: hexutil.Encode([]byte{10}),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"11", "12"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "13",
CommitteeIndex: "14",
BeaconBlockRoot: hexutil.Encode([]byte{15}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "16",
Root: hexutil.Encode([]byte{17}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "18",
Root: hexutil.Encode([]byte{19}),
},
@@ -276,34 +276,34 @@ func TestBeaconBlockJsonHelpers_JsonifyAttesterSlashings(t *testing.T) {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"21", "22"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "23",
CommitteeIndex: "24",
BeaconBlockRoot: hexutil.Encode([]byte{25}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "26",
Root: hexutil.Encode([]byte{27}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "28",
Root: hexutil.Encode([]byte{29}),
},
},
Signature: hexutil.Encode([]byte{30}),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"31", "32"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "33",
CommitteeIndex: "34",
BeaconBlockRoot: hexutil.Encode([]byte{35}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "36",
Root: hexutil.Encode([]byte{37}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "38",
Root: hexutil.Encode([]byte{39}),
},
@@ -342,13 +342,13 @@ func TestBeaconBlockJsonHelpers_JsonifyDeposits(t *testing.T) {
},
}
expectedResult := []*shared.Deposit{
expectedResult := []*structs.Deposit{
{
Proof: []string{
hexutil.Encode([]byte{1}),
hexutil.Encode([]byte{2}),
},
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: hexutil.Encode([]byte{3}),
WithdrawalCredentials: hexutil.Encode([]byte{4}),
Amount: "5",
@@ -360,7 +360,7 @@ func TestBeaconBlockJsonHelpers_JsonifyDeposits(t *testing.T) {
hexutil.Encode([]byte{7}),
hexutil.Encode([]byte{8}),
},
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: hexutil.Encode([]byte{9}),
WithdrawalCredentials: hexutil.Encode([]byte{10}),
Amount: "11",
@@ -421,10 +421,10 @@ func TestBeaconBlockJsonHelpers_JsonifyProposerSlashings(t *testing.T) {
},
}
expectedResult := []*shared.ProposerSlashing{
expectedResult := []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "1",
ProposerIndex: "2",
ParentRoot: hexutil.Encode([]byte{3}),
@@ -433,8 +433,8 @@ func TestBeaconBlockJsonHelpers_JsonifyProposerSlashings(t *testing.T) {
},
Signature: hexutil.Encode([]byte{6}),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "7",
ProposerIndex: "8",
ParentRoot: hexutil.Encode([]byte{9}),
@@ -445,8 +445,8 @@ func TestBeaconBlockJsonHelpers_JsonifyProposerSlashings(t *testing.T) {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "13",
ProposerIndex: "14",
ParentRoot: hexutil.Encode([]byte{15}),
@@ -455,8 +455,8 @@ func TestBeaconBlockJsonHelpers_JsonifyProposerSlashings(t *testing.T) {
},
Signature: hexutil.Encode([]byte{18}),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "19",
ProposerIndex: "20",
ParentRoot: hexutil.Encode([]byte{21}),
@@ -490,16 +490,16 @@ func TestBeaconBlockJsonHelpers_JsonifySignedVoluntaryExits(t *testing.T) {
},
}
expectedResult := []*shared.SignedVoluntaryExit{
expectedResult := []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "1",
ValidatorIndex: "2",
},
Signature: hexutil.Encode([]byte{3}),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "4",
ValidatorIndex: "5",
},
@@ -523,8 +523,8 @@ func TestBeaconBlockJsonHelpers_JsonifySignedBeaconBlockHeader(t *testing.T) {
Signature: []byte{6},
}
expectedResult := &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
expectedResult := &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "1",
ProposerIndex: "2",
ParentRoot: hexutil.Encode([]byte{3}),
@@ -557,17 +557,17 @@ func TestBeaconBlockJsonHelpers_JsonifyIndexedAttestation(t *testing.T) {
Signature: []byte{10},
}
expectedResult := &shared.IndexedAttestation{
expectedResult := &structs.IndexedAttestation{
AttestingIndices: []string{"1", "2"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "3",
CommitteeIndex: "4",
BeaconBlockRoot: hexutil.Encode([]byte{5}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "8",
Root: hexutil.Encode([]byte{9}),
},
@@ -594,15 +594,15 @@ func TestBeaconBlockJsonHelpers_JsonifyAttestationData(t *testing.T) {
},
}
expectedResult := &shared.AttestationData{
expectedResult := &structs.AttestationData{
Slot: "1",
CommitteeIndex: "2",
BeaconBlockRoot: hexutil.Encode([]byte{3}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "4",
Root: hexutil.Encode([]byte{5}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
@@ -628,7 +628,7 @@ func TestBeaconBlockJsonHelpers_JsonifyWithdrawals(t *testing.T) {
},
}
expectedResult := []*shared.Withdrawal{
expectedResult := []*structs.Withdrawal{
{
WithdrawalIndex: "1",
ValidatorIndex: "2",

View File

@@ -5,13 +5,13 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
func convertProposerSlashingsToProto(jsonProposerSlashings []*shared.ProposerSlashing) ([]*ethpb.ProposerSlashing, error) {
func convertProposerSlashingsToProto(jsonProposerSlashings []*structs.ProposerSlashing) ([]*ethpb.ProposerSlashing, error) {
proposerSlashings := make([]*ethpb.ProposerSlashing, len(jsonProposerSlashings))
for index, jsonProposerSlashing := range jsonProposerSlashings {
@@ -38,7 +38,7 @@ func convertProposerSlashingsToProto(jsonProposerSlashings []*shared.ProposerSla
return proposerSlashings, nil
}
func convertProposerSlashingSignedHeaderToProto(signedHeader *shared.SignedBeaconBlockHeader) (*ethpb.SignedBeaconBlockHeader, error) {
func convertProposerSlashingSignedHeaderToProto(signedHeader *structs.SignedBeaconBlockHeader) (*ethpb.SignedBeaconBlockHeader, error) {
if signedHeader == nil {
return nil, errors.New("signed header is nil")
}
@@ -89,7 +89,7 @@ func convertProposerSlashingSignedHeaderToProto(signedHeader *shared.SignedBeaco
}, nil
}
func convertAttesterSlashingsToProto(jsonAttesterSlashings []*shared.AttesterSlashing) ([]*ethpb.AttesterSlashing, error) {
func convertAttesterSlashingsToProto(jsonAttesterSlashings []*structs.AttesterSlashing) ([]*ethpb.AttesterSlashing, error) {
attesterSlashings := make([]*ethpb.AttesterSlashing, len(jsonAttesterSlashings))
for index, jsonAttesterSlashing := range jsonAttesterSlashings {
@@ -116,7 +116,7 @@ func convertAttesterSlashingsToProto(jsonAttesterSlashings []*shared.AttesterSla
return attesterSlashings, nil
}
func convertIndexedAttestationToProto(jsonAttestation *shared.IndexedAttestation) (*ethpb.IndexedAttestation, error) {
func convertIndexedAttestationToProto(jsonAttestation *structs.IndexedAttestation) (*ethpb.IndexedAttestation, error) {
if jsonAttestation == nil {
return nil, errors.New("indexed attestation is nil")
}
@@ -149,7 +149,7 @@ func convertIndexedAttestationToProto(jsonAttestation *shared.IndexedAttestation
}, nil
}
func convertCheckpointToProto(jsonCheckpoint *shared.Checkpoint) (*ethpb.Checkpoint, error) {
func convertCheckpointToProto(jsonCheckpoint *structs.Checkpoint) (*ethpb.Checkpoint, error) {
if jsonCheckpoint == nil {
return nil, errors.New("checkpoint is nil")
}
@@ -170,7 +170,7 @@ func convertCheckpointToProto(jsonCheckpoint *shared.Checkpoint) (*ethpb.Checkpo
}, nil
}
func convertAttestationToProto(jsonAttestation *shared.Attestation) (*ethpb.Attestation, error) {
func convertAttestationToProto(jsonAttestation *structs.Attestation) (*ethpb.Attestation, error) {
if jsonAttestation == nil {
return nil, errors.New("json attestation is nil")
}
@@ -197,7 +197,7 @@ func convertAttestationToProto(jsonAttestation *shared.Attestation) (*ethpb.Atte
}, nil
}
func convertAttestationsToProto(jsonAttestations []*shared.Attestation) ([]*ethpb.Attestation, error) {
func convertAttestationsToProto(jsonAttestations []*structs.Attestation) ([]*ethpb.Attestation, error) {
var attestations []*ethpb.Attestation
for index, jsonAttestation := range jsonAttestations {
if jsonAttestation == nil {
@@ -215,7 +215,7 @@ func convertAttestationsToProto(jsonAttestations []*shared.Attestation) ([]*ethp
return attestations, nil
}
func convertAttestationDataToProto(jsonAttestationData *shared.AttestationData) (*ethpb.AttestationData, error) {
func convertAttestationDataToProto(jsonAttestationData *structs.AttestationData) (*ethpb.AttestationData, error) {
if jsonAttestationData == nil {
return nil, errors.New("attestation data is nil")
}
@@ -254,7 +254,7 @@ func convertAttestationDataToProto(jsonAttestationData *shared.AttestationData)
}, nil
}
func convertDepositsToProto(jsonDeposits []*shared.Deposit) ([]*ethpb.Deposit, error) {
func convertDepositsToProto(jsonDeposits []*structs.Deposit) ([]*ethpb.Deposit, error) {
deposits := make([]*ethpb.Deposit, len(jsonDeposits))
for depositIndex, jsonDeposit := range jsonDeposits {
@@ -310,7 +310,7 @@ func convertDepositsToProto(jsonDeposits []*shared.Deposit) ([]*ethpb.Deposit, e
return deposits, nil
}
func convertVoluntaryExitsToProto(jsonVoluntaryExits []*shared.SignedVoluntaryExit) ([]*ethpb.SignedVoluntaryExit, error) {
func convertVoluntaryExitsToProto(jsonVoluntaryExits []*structs.SignedVoluntaryExit) ([]*ethpb.SignedVoluntaryExit, error) {
attestingIndices := make([]*ethpb.SignedVoluntaryExit, len(jsonVoluntaryExits))
for index, jsonVoluntaryExit := range jsonVoluntaryExits {
@@ -364,7 +364,7 @@ func convertTransactionsToProto(jsonTransactions []string) ([][]byte, error) {
return transactions, nil
}
func convertWithdrawalsToProto(jsonWithdrawals []*shared.Withdrawal) ([]*enginev1.Withdrawal, error) {
func convertWithdrawalsToProto(jsonWithdrawals []*structs.Withdrawal) ([]*enginev1.Withdrawal, error) {
withdrawals := make([]*enginev1.Withdrawal, len(jsonWithdrawals))
for index, jsonWithdrawal := range jsonWithdrawals {
@@ -403,7 +403,7 @@ func convertWithdrawalsToProto(jsonWithdrawals []*shared.Withdrawal) ([]*enginev
return withdrawals, nil
}
func convertBlsToExecutionChangesToProto(jsonSignedBlsToExecutionChanges []*shared.SignedBLSToExecutionChange) ([]*ethpb.SignedBLSToExecutionChange, error) {
func convertBlsToExecutionChangesToProto(jsonSignedBlsToExecutionChanges []*structs.SignedBLSToExecutionChange) ([]*ethpb.SignedBLSToExecutionChange, error) {
signedBlsToExecutionChanges := make([]*ethpb.SignedBLSToExecutionChange, len(jsonSignedBlsToExecutionChanges))
for index, jsonBlsToExecutionChange := range jsonSignedBlsToExecutionChanges {

View File

@@ -4,7 +4,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -14,15 +14,15 @@ import (
func TestBeaconBlockProtoHelpers_ConvertProposerSlashingsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.ProposerSlashing
generateInput func() []*structs.ProposerSlashing
expectedResult []*ethpb.ProposerSlashing
expectedErrorMessage string
}{
{
name: "nil proposer slashing",
expectedErrorMessage: "proposer slashing at index `0` is nil",
generateInput: func() []*shared.ProposerSlashing {
return []*shared.ProposerSlashing{
generateInput: func() []*structs.ProposerSlashing {
return []*structs.ProposerSlashing{
nil,
}
},
@@ -30,7 +30,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingsToProto(t *testing.T) {
{
name: "bad header 1",
expectedErrorMessage: "failed to get proposer header 1",
generateInput: func() []*shared.ProposerSlashing {
generateInput: func() []*structs.ProposerSlashing {
input := generateProposerSlashings()
input[0].SignedHeader1 = nil
return input
@@ -39,7 +39,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingsToProto(t *testing.T) {
{
name: "bad header 2",
expectedErrorMessage: "failed to get proposer header 2",
generateInput: func() []*shared.ProposerSlashing {
generateInput: func() []*structs.ProposerSlashing {
input := generateProposerSlashings()
input[0].SignedHeader2 = nil
return input
@@ -114,19 +114,19 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() *shared.SignedBeaconBlockHeader
generateInput func() *structs.SignedBeaconBlockHeader
expectedResult *ethpb.SignedBeaconBlockHeader
expectedErrorMessage string
}{
{
name: "nil signed header",
expectedErrorMessage: "signed header is nil",
generateInput: func() *shared.SignedBeaconBlockHeader { return nil },
generateInput: func() *structs.SignedBeaconBlockHeader { return nil },
},
{
name: "nil header",
expectedErrorMessage: "header is nil",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message = nil
return input
@@ -135,7 +135,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad slot",
expectedErrorMessage: "failed to parse header slot `foo`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message.Slot = "foo"
return input
@@ -144,7 +144,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad proposer index",
expectedErrorMessage: "failed to parse header proposer index `bar`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message.ProposerIndex = "bar"
return input
@@ -153,7 +153,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad parent root",
expectedErrorMessage: "failed to decode header parent root `foo`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message.ParentRoot = "foo"
return input
@@ -162,7 +162,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad state root",
expectedErrorMessage: "failed to decode header state root `bar`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message.StateRoot = "bar"
return input
@@ -171,7 +171,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad body root",
expectedErrorMessage: "failed to decode header body root `foo`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Message.BodyRoot = "foo"
return input
@@ -180,7 +180,7 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
{
name: "bad parent root",
expectedErrorMessage: "failed to decode signature `bar`",
generateInput: func() *shared.SignedBeaconBlockHeader {
generateInput: func() *structs.SignedBeaconBlockHeader {
input := generateSignedBeaconBlockHeader()
input.Signature = "bar"
return input
@@ -219,15 +219,15 @@ func TestBeaconBlockProtoHelpers_ConvertProposerSlashingSignedHeaderToProto(t *t
func TestBeaconBlockProtoHelpers_ConvertAttesterSlashingsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.AttesterSlashing
generateInput func() []*structs.AttesterSlashing
expectedResult []*ethpb.AttesterSlashing
expectedErrorMessage string
}{
{
name: "nil attester slashing",
expectedErrorMessage: "attester slashing at index `0` is nil",
generateInput: func() []*shared.AttesterSlashing {
return []*shared.AttesterSlashing{
generateInput: func() []*structs.AttesterSlashing {
return []*structs.AttesterSlashing{
nil,
}
},
@@ -235,8 +235,8 @@ func TestBeaconBlockProtoHelpers_ConvertAttesterSlashingsToProto(t *testing.T) {
{
name: "bad attestation 1",
expectedErrorMessage: "failed to get attestation 1",
generateInput: func() []*shared.AttesterSlashing {
return []*shared.AttesterSlashing{
generateInput: func() []*structs.AttesterSlashing {
return []*structs.AttesterSlashing{
{
Attestation1: nil,
Attestation2: nil,
@@ -247,7 +247,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttesterSlashingsToProto(t *testing.T) {
{
name: "bad attestation 2",
expectedErrorMessage: "failed to get attestation 2",
generateInput: func() []*shared.AttesterSlashing {
generateInput: func() []*structs.AttesterSlashing {
input := generateAttesterSlashings()
input[0].Attestation2 = nil
return input
@@ -350,19 +350,19 @@ func TestBeaconBlockProtoHelpers_ConvertAttesterSlashingsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertAttestationToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() *shared.IndexedAttestation
generateInput func() *structs.IndexedAttestation
expectedResult *ethpb.IndexedAttestation
expectedErrorMessage string
}{
{
name: "nil indexed attestation",
expectedErrorMessage: "indexed attestation is nil",
generateInput: func() *shared.IndexedAttestation { return nil },
generateInput: func() *structs.IndexedAttestation { return nil },
},
{
name: "bad attesting index",
expectedErrorMessage: "failed to parse attesting index `foo`",
generateInput: func() *shared.IndexedAttestation {
generateInput: func() *structs.IndexedAttestation {
input := generateIndexedAttestation()
input.AttestingIndices[0] = "foo"
return input
@@ -371,7 +371,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationToProto(t *testing.T) {
{
name: "bad signature",
expectedErrorMessage: "failed to decode attestation signature `bar`",
generateInput: func() *shared.IndexedAttestation {
generateInput: func() *structs.IndexedAttestation {
input := generateIndexedAttestation()
input.Signature = "bar"
return input
@@ -380,7 +380,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationToProto(t *testing.T) {
{
name: "bad data",
expectedErrorMessage: "failed to get attestation data",
generateInput: func() *shared.IndexedAttestation {
generateInput: func() *structs.IndexedAttestation {
input := generateIndexedAttestation()
input.Data = nil
return input
@@ -426,19 +426,19 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertCheckpointToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() *shared.Checkpoint
generateInput func() *structs.Checkpoint
expectedResult *ethpb.Checkpoint
expectedErrorMessage string
}{
{
name: "nil checkpoint",
expectedErrorMessage: "checkpoint is nil",
generateInput: func() *shared.Checkpoint { return nil },
generateInput: func() *structs.Checkpoint { return nil },
},
{
name: "bad epoch",
expectedErrorMessage: "failed to parse checkpoint epoch `foo`",
generateInput: func() *shared.Checkpoint {
generateInput: func() *structs.Checkpoint {
input := generateCheckpoint()
input.Epoch = "foo"
return input
@@ -447,7 +447,7 @@ func TestBeaconBlockProtoHelpers_ConvertCheckpointToProto(t *testing.T) {
{
name: "bad root",
expectedErrorMessage: "failed to decode checkpoint root `bar`",
generateInput: func() *shared.Checkpoint {
generateInput: func() *structs.Checkpoint {
input := generateCheckpoint()
input.Root = "bar"
return input
@@ -480,15 +480,15 @@ func TestBeaconBlockProtoHelpers_ConvertCheckpointToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertAttestationsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.Attestation
generateInput func() []*structs.Attestation
expectedResult []*ethpb.Attestation
expectedErrorMessage string
}{
{
name: "nil attestation",
expectedErrorMessage: "attestation at index `0` is nil",
generateInput: func() []*shared.Attestation {
return []*shared.Attestation{
generateInput: func() []*structs.Attestation {
return []*structs.Attestation{
nil,
}
},
@@ -496,7 +496,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationsToProto(t *testing.T) {
{
name: "bad aggregation bits",
expectedErrorMessage: "failed to decode aggregation bits `foo`",
generateInput: func() []*shared.Attestation {
generateInput: func() []*structs.Attestation {
input := generateAttestations()
input[0].AggregationBits = "foo"
return input
@@ -505,7 +505,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationsToProto(t *testing.T) {
{
name: "bad data",
expectedErrorMessage: "failed to get attestation data",
generateInput: func() []*shared.Attestation {
generateInput: func() []*structs.Attestation {
input := generateAttestations()
input[0].Data = nil
return input
@@ -514,7 +514,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationsToProto(t *testing.T) {
{
name: "bad signature",
expectedErrorMessage: "failed to decode attestation signature `bar`",
generateInput: func() []*shared.Attestation {
generateInput: func() []*structs.Attestation {
input := generateAttestations()
input[0].Signature = "bar"
return input
@@ -579,19 +579,19 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() *shared.AttestationData
generateInput func() *structs.AttestationData
expectedResult *ethpb.AttestationData
expectedErrorMessage string
}{
{
name: "nil attestation data",
expectedErrorMessage: "attestation data is nil",
generateInput: func() *shared.AttestationData { return nil },
generateInput: func() *structs.AttestationData { return nil },
},
{
name: "bad slot",
expectedErrorMessage: "failed to parse attestation slot `foo`",
generateInput: func() *shared.AttestationData {
generateInput: func() *structs.AttestationData {
input := generateAttestationData()
input.Slot = "foo"
return input
@@ -600,7 +600,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
{
name: "bad committee index",
expectedErrorMessage: "failed to parse attestation committee index `bar`",
generateInput: func() *shared.AttestationData {
generateInput: func() *structs.AttestationData {
input := generateAttestationData()
input.CommitteeIndex = "bar"
return input
@@ -609,7 +609,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
{
name: "bad beacon block root",
expectedErrorMessage: "failed to decode attestation beacon block root `foo`",
generateInput: func() *shared.AttestationData {
generateInput: func() *structs.AttestationData {
input := generateAttestationData()
input.BeaconBlockRoot = "foo"
return input
@@ -618,7 +618,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
{
name: "bad source checkpoint",
expectedErrorMessage: "failed to get attestation source checkpoint",
generateInput: func() *shared.AttestationData {
generateInput: func() *structs.AttestationData {
input := generateAttestationData()
input.Source = nil
return input
@@ -627,7 +627,7 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
{
name: "bad target checkpoint",
expectedErrorMessage: "failed to get attestation target checkpoint",
generateInput: func() *shared.AttestationData {
generateInput: func() *structs.AttestationData {
input := generateAttestationData()
input.Target = nil
return input
@@ -669,15 +669,15 @@ func TestBeaconBlockProtoHelpers_ConvertAttestationDataToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.Deposit
generateInput func() []*structs.Deposit
expectedResult []*ethpb.Deposit
expectedErrorMessage string
}{
{
name: "nil deposit",
expectedErrorMessage: "deposit at index `0` is nil",
generateInput: func() []*shared.Deposit {
return []*shared.Deposit{
generateInput: func() []*structs.Deposit {
return []*structs.Deposit{
nil,
}
},
@@ -685,7 +685,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "bad proof",
expectedErrorMessage: "failed to decode deposit proof `foo`",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Proof[0] = "foo"
return input
@@ -694,7 +694,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "nil data",
expectedErrorMessage: "deposit data at index `0` is nil",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Data = nil
return input
@@ -703,7 +703,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "bad public key",
expectedErrorMessage: "failed to decode deposit public key `bar`",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Data.Pubkey = "bar"
return input
@@ -712,7 +712,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "bad withdrawal credentials",
expectedErrorMessage: "failed to decode deposit withdrawal credentials `foo`",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Data.WithdrawalCredentials = "foo"
return input
@@ -721,7 +721,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "bad amount",
expectedErrorMessage: "failed to parse deposit amount `bar`",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Data.Amount = "bar"
return input
@@ -730,7 +730,7 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
{
name: "bad signature",
expectedErrorMessage: "failed to decode signature `foo`",
generateInput: func() []*shared.Deposit {
generateInput: func() []*structs.Deposit {
input := generateDeposits()
input[0].Data.Signature = "foo"
return input
@@ -785,15 +785,15 @@ func TestBeaconBlockProtoHelpers_ConvertDepositsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertVoluntaryExitsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.SignedVoluntaryExit
generateInput func() []*structs.SignedVoluntaryExit
expectedResult []*ethpb.SignedVoluntaryExit
expectedErrorMessage string
}{
{
name: "nil voluntary exit",
expectedErrorMessage: "signed voluntary exit at index `0` is nil",
generateInput: func() []*shared.SignedVoluntaryExit {
return []*shared.SignedVoluntaryExit{
generateInput: func() []*structs.SignedVoluntaryExit {
return []*structs.SignedVoluntaryExit{
nil,
}
},
@@ -801,7 +801,7 @@ func TestBeaconBlockProtoHelpers_ConvertVoluntaryExitsToProto(t *testing.T) {
{
name: "nil data",
expectedErrorMessage: "voluntary exit at index `0` is nil",
generateInput: func() []*shared.SignedVoluntaryExit {
generateInput: func() []*structs.SignedVoluntaryExit {
input := generateSignedVoluntaryExits()
input[0].Message = nil
return input
@@ -810,7 +810,7 @@ func TestBeaconBlockProtoHelpers_ConvertVoluntaryExitsToProto(t *testing.T) {
{
name: "bad epoch",
expectedErrorMessage: "failed to parse voluntary exit epoch `foo`",
generateInput: func() []*shared.SignedVoluntaryExit {
generateInput: func() []*structs.SignedVoluntaryExit {
input := generateSignedVoluntaryExits()
input[0].Message.Epoch = "foo"
return input
@@ -819,7 +819,7 @@ func TestBeaconBlockProtoHelpers_ConvertVoluntaryExitsToProto(t *testing.T) {
{
name: "bad validator index",
expectedErrorMessage: "failed to parse voluntary exit validator index `bar`",
generateInput: func() []*shared.SignedVoluntaryExit {
generateInput: func() []*structs.SignedVoluntaryExit {
input := generateSignedVoluntaryExits()
input[0].Message.ValidatorIndex = "bar"
return input
@@ -828,7 +828,7 @@ func TestBeaconBlockProtoHelpers_ConvertVoluntaryExitsToProto(t *testing.T) {
{
name: "bad signature",
expectedErrorMessage: "failed to decode signature `foo`",
generateInput: func() []*shared.SignedVoluntaryExit {
generateInput: func() []*structs.SignedVoluntaryExit {
input := generateSignedVoluntaryExits()
input[0].Signature = "foo"
return input
@@ -918,14 +918,14 @@ func TestBeaconBlockProtoHelpers_ConvertTransactionsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.Withdrawal
generateInput func() []*structs.Withdrawal
expectedResult []*enginev1.Withdrawal
expectedErrorMessage string
}{
{
name: "nil withdrawal",
expectedErrorMessage: "withdrawal at index `0` is nil",
generateInput: func() []*shared.Withdrawal {
generateInput: func() []*structs.Withdrawal {
input := generateWithdrawals()
input[0] = nil
return input
@@ -934,7 +934,7 @@ func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
{
name: "bad withdrawal index",
expectedErrorMessage: "failed to parse withdrawal index `foo`",
generateInput: func() []*shared.Withdrawal {
generateInput: func() []*structs.Withdrawal {
input := generateWithdrawals()
input[0].WithdrawalIndex = "foo"
return input
@@ -943,7 +943,7 @@ func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
{
name: "bad validator index",
expectedErrorMessage: "failed to parse validator index `bar`",
generateInput: func() []*shared.Withdrawal {
generateInput: func() []*structs.Withdrawal {
input := generateWithdrawals()
input[0].ValidatorIndex = "bar"
return input
@@ -952,7 +952,7 @@ func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
{
name: "bad execution address",
expectedErrorMessage: "failed to decode execution address `foo`",
generateInput: func() []*shared.Withdrawal {
generateInput: func() []*structs.Withdrawal {
input := generateWithdrawals()
input[0].ExecutionAddress = "foo"
return input
@@ -961,7 +961,7 @@ func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
{
name: "bad amount",
expectedErrorMessage: "failed to parse withdrawal amount `bar`",
generateInput: func() []*shared.Withdrawal {
generateInput: func() []*structs.Withdrawal {
input := generateWithdrawals()
input[0].Amount = "bar"
return input
@@ -1004,14 +1004,14 @@ func TestBeaconBlockProtoHelpers_ConvertWithdrawalsToProto(t *testing.T) {
func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.T) {
testCases := []struct {
name string
generateInput func() []*shared.SignedBLSToExecutionChange
generateInput func() []*structs.SignedBLSToExecutionChange
expectedResult []*ethpb.SignedBLSToExecutionChange
expectedErrorMessage string
}{
{
name: "nil bls to execution change",
expectedErrorMessage: "bls to execution change at index `0` is nil",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0] = nil
return input
@@ -1020,7 +1020,7 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
{
name: "nil bls to execution change message",
expectedErrorMessage: "bls to execution change message at index `0` is nil",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0].Message = nil
return input
@@ -1029,7 +1029,7 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
{
name: "bad validator index",
expectedErrorMessage: "failed to decode validator index `foo`",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0].Message.ValidatorIndex = "foo"
return input
@@ -1038,7 +1038,7 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
{
name: "bad from bls pubkey",
expectedErrorMessage: "failed to decode bls pubkey `bar`",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0].Message.FromBLSPubkey = "bar"
return input
@@ -1047,7 +1047,7 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
{
name: "bad to execution address",
expectedErrorMessage: "failed to decode execution address `foo`",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0].Message.ToExecutionAddress = "foo"
return input
@@ -1056,7 +1056,7 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
{
name: "bad signature",
expectedErrorMessage: "failed to decode signature `bar`",
generateInput: func() []*shared.SignedBLSToExecutionChange {
generateInput: func() []*structs.SignedBLSToExecutionChange {
input := generateBlsToExecutionChanges()
input[0].Signature = "bar"
return input
@@ -1078,11 +1078,11 @@ func TestBeaconBlockProtoHelpers_ConvertBlsToExecutionChangesToProto(t *testing.
}
}
func generateProposerSlashings() []*shared.ProposerSlashing {
return []*shared.ProposerSlashing{
func generateProposerSlashings() []*structs.ProposerSlashing {
return []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "1",
ProposerIndex: "2",
ParentRoot: hexutil.Encode([]byte{3}),
@@ -1091,8 +1091,8 @@ func generateProposerSlashings() []*shared.ProposerSlashing {
},
Signature: hexutil.Encode([]byte{6}),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "7",
ProposerIndex: "8",
ParentRoot: hexutil.Encode([]byte{9}),
@@ -1103,8 +1103,8 @@ func generateProposerSlashings() []*shared.ProposerSlashing {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "13",
ProposerIndex: "14",
ParentRoot: hexutil.Encode([]byte{15}),
@@ -1113,8 +1113,8 @@ func generateProposerSlashings() []*shared.ProposerSlashing {
},
Signature: hexutil.Encode([]byte{18}),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "19",
ProposerIndex: "20",
ParentRoot: hexutil.Encode([]byte{21}),
@@ -1127,9 +1127,9 @@ func generateProposerSlashings() []*shared.ProposerSlashing {
}
}
func generateSignedBeaconBlockHeader() *shared.SignedBeaconBlockHeader {
return &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
func generateSignedBeaconBlockHeader() *structs.SignedBeaconBlockHeader {
return &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "1",
ProposerIndex: "2",
ParentRoot: hexutil.Encode([]byte{3}),
@@ -1140,37 +1140,37 @@ func generateSignedBeaconBlockHeader() *shared.SignedBeaconBlockHeader {
}
}
func generateAttesterSlashings() []*shared.AttesterSlashing {
return []*shared.AttesterSlashing{
func generateAttesterSlashings() []*structs.AttesterSlashing {
return []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"1", "2"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "3",
CommitteeIndex: "4",
BeaconBlockRoot: hexutil.Encode([]byte{5}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "8",
Root: hexutil.Encode([]byte{9}),
},
},
Signature: hexutil.Encode([]byte{10}),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"11", "12"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "13",
CommitteeIndex: "14",
BeaconBlockRoot: hexutil.Encode([]byte{15}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "16",
Root: hexutil.Encode([]byte{17}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "18",
Root: hexutil.Encode([]byte{19}),
},
@@ -1179,34 +1179,34 @@ func generateAttesterSlashings() []*shared.AttesterSlashing {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"21", "22"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "23",
CommitteeIndex: "24",
BeaconBlockRoot: hexutil.Encode([]byte{25}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "26",
Root: hexutil.Encode([]byte{27}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "28",
Root: hexutil.Encode([]byte{29}),
},
},
Signature: hexutil.Encode([]byte{30}),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"31", "32"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "33",
CommitteeIndex: "34",
BeaconBlockRoot: hexutil.Encode([]byte{35}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "36",
Root: hexutil.Encode([]byte{37}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "38",
Root: hexutil.Encode([]byte{39}),
},
@@ -1217,18 +1217,18 @@ func generateAttesterSlashings() []*shared.AttesterSlashing {
}
}
func generateIndexedAttestation() *shared.IndexedAttestation {
return &shared.IndexedAttestation{
func generateIndexedAttestation() *structs.IndexedAttestation {
return &structs.IndexedAttestation{
AttestingIndices: []string{"1", "2"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "3",
CommitteeIndex: "4",
BeaconBlockRoot: hexutil.Encode([]byte{5}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "8",
Root: hexutil.Encode([]byte{9}),
},
@@ -1237,26 +1237,26 @@ func generateIndexedAttestation() *shared.IndexedAttestation {
}
}
func generateCheckpoint() *shared.Checkpoint {
return &shared.Checkpoint{
func generateCheckpoint() *structs.Checkpoint {
return &structs.Checkpoint{
Epoch: "1",
Root: hexutil.Encode([]byte{2}),
}
}
func generateAttestations() []*shared.Attestation {
return []*shared.Attestation{
func generateAttestations() []*structs.Attestation {
return []*structs.Attestation{
{
AggregationBits: hexutil.Encode([]byte{1}),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "2",
CommitteeIndex: "3",
BeaconBlockRoot: hexutil.Encode([]byte{4}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "5",
Root: hexutil.Encode([]byte{6}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "7",
Root: hexutil.Encode([]byte{8}),
},
@@ -1265,15 +1265,15 @@ func generateAttestations() []*shared.Attestation {
},
{
AggregationBits: hexutil.Encode([]byte{10}),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "11",
CommitteeIndex: "12",
BeaconBlockRoot: hexutil.Encode([]byte{13}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "14",
Root: hexutil.Encode([]byte{15}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "16",
Root: hexutil.Encode([]byte{17}),
},
@@ -1283,30 +1283,30 @@ func generateAttestations() []*shared.Attestation {
}
}
func generateAttestationData() *shared.AttestationData {
return &shared.AttestationData{
func generateAttestationData() *structs.AttestationData {
return &structs.AttestationData{
Slot: "1",
CommitteeIndex: "2",
BeaconBlockRoot: hexutil.Encode([]byte{3}),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "4",
Root: hexutil.Encode([]byte{5}),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "6",
Root: hexutil.Encode([]byte{7}),
},
}
}
func generateDeposits() []*shared.Deposit {
return []*shared.Deposit{
func generateDeposits() []*structs.Deposit {
return []*structs.Deposit{
{
Proof: []string{
hexutil.Encode([]byte{1}),
hexutil.Encode([]byte{2}),
},
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: hexutil.Encode([]byte{3}),
WithdrawalCredentials: hexutil.Encode([]byte{4}),
Amount: "5",
@@ -1318,7 +1318,7 @@ func generateDeposits() []*shared.Deposit {
hexutil.Encode([]byte{7}),
hexutil.Encode([]byte{8}),
},
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: hexutil.Encode([]byte{9}),
WithdrawalCredentials: hexutil.Encode([]byte{10}),
Amount: "11",
@@ -1328,17 +1328,17 @@ func generateDeposits() []*shared.Deposit {
}
}
func generateSignedVoluntaryExits() []*shared.SignedVoluntaryExit {
return []*shared.SignedVoluntaryExit{
func generateSignedVoluntaryExits() []*structs.SignedVoluntaryExit {
return []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "1",
ValidatorIndex: "2",
},
Signature: hexutil.Encode([]byte{3}),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "4",
ValidatorIndex: "5",
},
@@ -1347,8 +1347,8 @@ func generateSignedVoluntaryExits() []*shared.SignedVoluntaryExit {
}
}
func generateWithdrawals() []*shared.Withdrawal {
return []*shared.Withdrawal{
func generateWithdrawals() []*structs.Withdrawal {
return []*structs.Withdrawal{
{
WithdrawalIndex: "1",
ValidatorIndex: "2",
@@ -1364,10 +1364,10 @@ func generateWithdrawals() []*shared.Withdrawal {
}
}
func generateBlsToExecutionChanges() []*shared.SignedBLSToExecutionChange {
return []*shared.SignedBLSToExecutionChange{
func generateBlsToExecutionChanges() []*structs.SignedBLSToExecutionChange {
return []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "1",
FromBLSPubkey: hexutil.Encode([]byte{2}),
ToExecutionAddress: hexutil.Encode([]byte{3}),
@@ -1375,7 +1375,7 @@ func generateBlsToExecutionChanges() []*shared.SignedBLSToExecutionChange {
Signature: hexutil.Encode([]byte{4}),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "5",
FromBLSPubkey: hexutil.Encode([]byte{6}),
ToExecutionAddress: hexutil.Encode([]byte{7}),

View File

@@ -7,7 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/config/params"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -38,7 +38,7 @@ func TestGetDomainData_ValidDomainData(t *testing.T) {
// Make sure that GetGenesis() is called exactly once
genesisProvider := mock.NewMockGenesisProvider(ctrl)
genesisProvider.EXPECT().GetGenesis(ctx).Return(
&beacon.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
&structs.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
nil,
).Times(1)
@@ -86,7 +86,7 @@ func TestGetDomainData_InvalidGenesisRoot(t *testing.T) {
// Make sure that GetGenesis() is called exactly once
genesisProvider := mock.NewMockGenesisProvider(ctrl)
genesisProvider.EXPECT().GetGenesis(ctx).Return(
&beacon.Genesis{GenesisValidatorsRoot: "foo"},
&structs.Genesis{GenesisValidatorsRoot: "foo"},
nil,
).Times(1)

View File

@@ -9,10 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -49,17 +46,17 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
name string
doppelGangerInput *ethpb.DoppelGangerRequest
doppelGangerExpectedOutput *ethpb.DoppelGangerResponse
getSyncingOutput *node.SyncStatusResponse
getForkOutput *beacon.GetStateForkResponse
getHeadersOutput *beacon.GetBlockHeadersResponse
getSyncingOutput *structs.SyncStatusResponse
getForkOutput *structs.GetStateForkResponse
getHeadersOutput *structs.GetBlockHeadersResponse
getStateValidatorsInterface *struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
}
getLivelinessInterfaces []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
}
}{
{
@@ -109,13 +106,13 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
{PublicKey: pubKey6, DuplicateExists: false},
},
},
getSyncingOutput: &node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
getSyncingOutput: &structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: false,
},
},
getForkOutput: &beacon.GetStateForkResponse{
Data: &shared.Fork{
getForkOutput: &structs.GetStateForkResponse{
Data: &structs.Fork{
PreviousVersion: "0x00000000",
CurrentVersion: "0x00000000",
Epoch: "42",
@@ -144,23 +141,23 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
{PublicKey: pubKey6, DuplicateExists: false},
},
},
getSyncingOutput: &node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
getSyncingOutput: &structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: false,
},
},
getForkOutput: &beacon.GetStateForkResponse{
Data: &shared.Fork{
getForkOutput: &structs.GetStateForkResponse{
Data: &structs.Fork{
PreviousVersion: "0x01000000",
CurrentVersion: "0x02000000",
Epoch: "2",
},
},
getHeadersOutput: &beacon.GetBlockHeadersResponse{
Data: []*shared.SignedBeaconBlockHeaderContainer{
getHeadersOutput: &structs.GetBlockHeadersResponse{
Data: []*structs.SignedBeaconBlockHeaderContainer{
{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "99",
},
},
@@ -190,23 +187,23 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
{PublicKey: pubKey6, DuplicateExists: false}, // not recent - not duplicate
},
},
getSyncingOutput: &node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
getSyncingOutput: &structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: false,
},
},
getForkOutput: &beacon.GetStateForkResponse{
Data: &shared.Fork{
getForkOutput: &structs.GetStateForkResponse{
Data: &structs.Fork{
PreviousVersion: "0x01000000",
CurrentVersion: "0x02000000",
Epoch: "2",
},
},
getHeadersOutput: &beacon.GetBlockHeadersResponse{
Data: []*shared.SignedBeaconBlockHeaderContainer{
getHeadersOutput: &structs.GetBlockHeadersResponse{
Data: []*structs.SignedBeaconBlockHeaderContainer{
{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "3201",
},
},
@@ -215,7 +212,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
},
getStateValidatorsInterface: &struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
}{
input: []string{
// no stringPubKey1 since recent
@@ -225,21 +222,21 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
stringPubKey5, // non existing validator
stringPubKey6, // not recent - not duplicate
},
output: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
output: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
// No "11111" since corresponding validator is recent
{Index: "22222", Validator: &beacon.Validator{Pubkey: stringPubKey2}}, // not recent - duplicate on previous epoch
{Index: "33333", Validator: &beacon.Validator{Pubkey: stringPubKey3}}, // not recent - duplicate on current epoch
{Index: "44444", Validator: &beacon.Validator{Pubkey: stringPubKey4}}, // not recent - duplicate on both previous and current epoch
{Index: "22222", Validator: &structs.Validator{Pubkey: stringPubKey2}}, // not recent - duplicate on previous epoch
{Index: "33333", Validator: &structs.Validator{Pubkey: stringPubKey3}}, // not recent - duplicate on current epoch
{Index: "44444", Validator: &structs.Validator{Pubkey: stringPubKey4}}, // not recent - duplicate on both previous and current epoch
// No "55555" sicee corresponding validator does not exist
{Index: "66666", Validator: &beacon.Validator{Pubkey: stringPubKey6}}, // not recent - not duplicate
{Index: "66666", Validator: &structs.Validator{Pubkey: stringPubKey6}}, // not recent - not duplicate
},
},
},
getLivelinessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
}{
{
inputUrl: "/eth/v1/validator/liveness/99", // previous epoch
@@ -251,8 +248,8 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
// No "55555" since corresponding validator it does not exist
"66666", // not recent - not duplicate
},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{
// No "11111" since corresponding validator is recent
{Index: "22222", IsLive: true}, // not recent - duplicate on previous epoch
{Index: "33333", IsLive: false}, // not recent - duplicate on current epoch
@@ -272,8 +269,8 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
// No "55555" since corresponding validator it does not exist
"66666", // not recent - not duplicate
},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{
// No "11111" since corresponding validator is recent
{Index: "22222", IsLive: false}, // not recent - duplicate on previous epoch
{Index: "33333", IsLive: true}, // not recent - duplicate on current epoch
@@ -297,7 +294,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
ctx := context.Background()
if testCase.getSyncingOutput != nil {
syncingResponseJson := node.SyncStatusResponse{}
syncingResponseJson := structs.SyncStatusResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -312,7 +309,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
}
if testCase.getForkOutput != nil {
stateForkResponseJson := beacon.GetStateForkResponse{}
stateForkResponseJson := structs.GetStateForkResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -327,7 +324,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
}
if testCase.getHeadersOutput != nil {
blockHeadersResponseJson := beacon.GetBlockHeadersResponse{}
blockHeadersResponseJson := structs.GetBlockHeadersResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -343,7 +340,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
if testCase.getLivelinessInterfaces != nil {
for _, iface := range testCase.getLivelinessInterfaces {
livenessResponseJson := validator.GetLivenessResponse{}
livenessResponseJson := structs.GetLivenessResponse{}
marshalledIndexes, err := json.Marshal(iface.inputStringIndexes)
require.NoError(t, err)
@@ -405,23 +402,23 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
},
}
standardGetSyncingOutput := &node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
standardGetSyncingOutput := &structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: false,
},
}
standardGetForkOutput := &beacon.GetStateForkResponse{
Data: &shared.Fork{
standardGetForkOutput := &structs.GetStateForkResponse{
Data: &structs.Fork{
CurrentVersion: "0x02000000",
},
}
standardGetHeadersOutput := &beacon.GetBlockHeadersResponse{
Data: []*shared.SignedBeaconBlockHeaderContainer{
standardGetHeadersOutput := &structs.GetBlockHeadersResponse{
Data: []*structs.SignedBeaconBlockHeaderContainer{
{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "1000",
},
},
@@ -431,15 +428,15 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
standardGetStateValidatorsInterface := &struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
err error
}{
input: []string{stringPubKey},
output: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
output: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "42",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -451,21 +448,21 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
name string
expectedErrorMessage string
inputValidatorRequests []*ethpb.DoppelGangerRequest_ValidatorRequest
getSyncingOutput *node.SyncStatusResponse
getSyncingOutput *structs.SyncStatusResponse
getSyncingError error
getForkOutput *beacon.GetStateForkResponse
getForkOutput *structs.GetStateForkResponse
getForkError error
getHeadersOutput *beacon.GetBlockHeadersResponse
getHeadersOutput *structs.GetBlockHeadersResponse
getHeadersError error
getStateValidatorsInterface *struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
err error
}
getLivenessInterfaces []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}
}{
@@ -485,8 +482,8 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
name: "beacon node not synced",
expectedErrorMessage: "beacon node not synced",
inputValidatorRequests: standardInputValidatorRequests,
getSyncingOutput: &node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
getSyncingOutput: &structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsSyncing: true,
},
},
@@ -496,7 +493,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
expectedErrorMessage: "failed to get fork",
inputValidatorRequests: standardInputValidatorRequests,
getSyncingOutput: standardGetSyncingOutput,
getForkOutput: &beacon.GetStateForkResponse{},
getForkOutput: &structs.GetStateForkResponse{},
getForkError: errors.New("custom error"),
},
{
@@ -504,8 +501,8 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
expectedErrorMessage: "failed to decode fork version",
inputValidatorRequests: standardInputValidatorRequests,
getSyncingOutput: standardGetSyncingOutput,
getForkOutput: &beacon.GetStateForkResponse{
Data: &shared.Fork{CurrentVersion: "not a version"},
getForkOutput: &structs.GetStateForkResponse{
Data: &structs.Fork{CurrentVersion: "not a version"},
},
},
{
@@ -514,7 +511,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
inputValidatorRequests: standardInputValidatorRequests,
getSyncingOutput: standardGetSyncingOutput,
getForkOutput: standardGetForkOutput,
getHeadersOutput: &beacon.GetBlockHeadersResponse{},
getHeadersOutput: &structs.GetBlockHeadersResponse{},
getHeadersError: errors.New("custom error"),
},
{
@@ -523,11 +520,11 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
inputValidatorRequests: standardInputValidatorRequests,
getSyncingOutput: standardGetSyncingOutput,
getForkOutput: standardGetForkOutput,
getHeadersOutput: &beacon.GetBlockHeadersResponse{
Data: []*shared.SignedBeaconBlockHeaderContainer{
getHeadersOutput: &structs.GetBlockHeadersResponse{
Data: []*structs.SignedBeaconBlockHeaderContainer{
{
Header: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
Header: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "not a slot",
},
},
@@ -544,7 +541,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getHeadersOutput: standardGetHeadersOutput,
getStateValidatorsInterface: &struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
err error
}{
input: []string{stringPubKey},
@@ -560,11 +557,11 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getHeadersOutput: standardGetHeadersOutput,
getStateValidatorsInterface: &struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
err error
}{
input: []string{stringPubKey},
output: &beacon.GetValidatorsResponse{Data: []*beacon.ValidatorContainer{nil}},
output: &structs.GetValidatorsResponse{Data: []*structs.ValidatorContainer{nil}},
},
},
{
@@ -576,11 +573,11 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getHeadersOutput: standardGetHeadersOutput,
getStateValidatorsInterface: &struct {
input []string
output *beacon.GetValidatorsResponse
output *structs.GetValidatorsResponse
err error
}{
input: []string{stringPubKey},
output: &beacon.GetValidatorsResponse{Data: []*beacon.ValidatorContainer{{Validator: nil}}},
output: &structs.GetValidatorsResponse{Data: []*structs.ValidatorContainer{{Validator: nil}}},
},
},
{
@@ -594,13 +591,13 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getLivenessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}{
{
inputUrl: "/eth/v1/validator/liveness/30",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{},
output: &structs.GetLivenessResponse{},
err: errors.New("custom error"),
},
},
@@ -616,14 +613,14 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getLivenessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}{
{
inputUrl: "/eth/v1/validator/liveness/30",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{nil},
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{nil},
},
},
},
@@ -639,20 +636,20 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getLivenessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}{
{
inputUrl: "/eth/v1/validator/liveness/30",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{},
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{},
},
},
{
inputUrl: "/eth/v1/validator/liveness/31",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{},
output: &structs.GetLivenessResponse{},
err: errors.New("custom error"),
},
},
@@ -668,21 +665,21 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getLivenessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}{
{
inputUrl: "/eth/v1/validator/liveness/30",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{},
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{},
},
},
{
inputUrl: "/eth/v1/validator/liveness/31",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{},
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{},
},
},
},
@@ -698,14 +695,14 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
getLivenessInterfaces: []struct {
inputUrl string
inputStringIndexes []string
output *validator.GetLivenessResponse
output *structs.GetLivenessResponse
err error
}{
{
inputUrl: "/eth/v1/validator/liveness/30",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{
{
Index: "42",
},
@@ -715,8 +712,8 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
{
inputUrl: "/eth/v1/validator/liveness/31",
inputStringIndexes: []string{"42"},
output: &validator.GetLivenessResponse{
Data: []*validator.Liveness{},
output: &structs.GetLivenessResponse{
Data: []*structs.Liveness{},
},
},
},
@@ -733,7 +730,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
ctx := context.Background()
if testCase.getSyncingOutput != nil {
syncingResponseJson := node.SyncStatusResponse{}
syncingResponseJson := structs.SyncStatusResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -748,7 +745,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
}
if testCase.getForkOutput != nil {
stateForkResponseJson := beacon.GetStateForkResponse{}
stateForkResponseJson := structs.GetStateForkResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -763,7 +760,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
}
if testCase.getHeadersOutput != nil {
blockHeadersResponseJson := beacon.GetBlockHeadersResponse{}
blockHeadersResponseJson := structs.GetBlockHeadersResponse{}
jsonRestHandler.EXPECT().Get(
ctx,
@@ -793,7 +790,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
if testCase.getLivenessInterfaces != nil {
for _, iface := range testCase.getLivenessInterfaces {
livenessResponseJson := validator.GetLivenessResponse{}
livenessResponseJson := structs.GetLivenessResponse{}
marshalledIndexes, err := json.Marshal(iface.inputStringIndexes)
require.NoError(t, err)

View File

@@ -9,19 +9,17 @@ import (
"strconv"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
type dutiesProvider interface {
GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.AttesterDuty, error)
GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*validator.ProposerDuty, error)
GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.SyncCommitteeDuty, error)
GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*shared.Committee, error)
GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error)
GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error)
GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error)
GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error)
}
type beaconApiDutiesProvider struct {
@@ -82,14 +80,14 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
return nil, errors.Wrapf(err, "failed to get attester duties for epoch `%d`", epoch)
}
var syncDuties []*validator.SyncCommitteeDuty
var syncDuties []*structs.SyncCommitteeDuty
if fetchSyncDuties {
if syncDuties, err = c.dutiesProvider.GetSyncDuties(ctx, epoch, multipleValidatorStatus.Indices); err != nil {
return nil, errors.Wrapf(err, "failed to get sync duties for epoch `%d`", epoch)
}
}
var proposerDuties []*validator.ProposerDuty
var proposerDuties []*structs.ProposerDuty
if proposerDuties, err = c.dutiesProvider.GetProposerDuties(ctx, epoch); err != nil {
return nil, errors.Wrapf(err, "failed to get proposer duties for epoch `%d`", epoch)
}
@@ -213,12 +211,12 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
}
// GetCommittees retrieves the committees for the given epoch
func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*shared.Committee, error) {
func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
committeeParams := url.Values{}
committeeParams.Add("epoch", strconv.FormatUint(uint64(epoch), 10))
committeesRequest := buildURL("/eth/v1/beacon/states/head/committees", committeeParams)
var stateCommittees beacon.GetCommitteesResponse
var stateCommittees structs.GetCommitteesResponse
if err := c.jsonRestHandler.Get(ctx, committeesRequest, &stateCommittees); err != nil {
return nil, err
}
@@ -237,7 +235,7 @@ func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primit
}
// GetAttesterDuties retrieves the attester duties for the given epoch and validatorIndices
func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.AttesterDuty, error) {
func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
jsonValidatorIndices := make([]string, len(validatorIndices))
for index, validatorIndex := range validatorIndices {
jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10)
@@ -248,7 +246,7 @@ func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch pr
return nil, errors.Wrap(err, "failed to marshal validator indices")
}
attesterDuties := &validator.GetAttesterDutiesResponse{}
attesterDuties := &structs.GetAttesterDutiesResponse{}
if err = c.jsonRestHandler.Post(
ctx,
fmt.Sprintf("/eth/v1/validator/duties/attester/%d", epoch),
@@ -269,8 +267,8 @@ func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch pr
}
// GetProposerDuties retrieves the proposer duties for the given epoch
func (c beaconApiDutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*validator.ProposerDuty, error) {
proposerDuties := validator.GetProposerDutiesResponse{}
func (c beaconApiDutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
proposerDuties := structs.GetProposerDutiesResponse{}
if err := c.jsonRestHandler.Get(ctx, fmt.Sprintf("/eth/v1/validator/duties/proposer/%d", epoch), &proposerDuties); err != nil {
return nil, err
}
@@ -289,7 +287,7 @@ func (c beaconApiDutiesProvider) GetProposerDuties(ctx context.Context, epoch pr
}
// GetSyncDuties retrieves the sync committee duties for the given epoch and validatorIndices
func (c beaconApiDutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.SyncCommitteeDuty, error) {
func (c beaconApiDutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
jsonValidatorIndices := make([]string, len(validatorIndices))
for index, validatorIndex := range validatorIndices {
jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10)
@@ -300,7 +298,7 @@ func (c beaconApiDutiesProvider) GetSyncDuties(ctx context.Context, epoch primit
return nil, errors.Wrap(err, "failed to marshal validator indices")
}
syncDuties := validator.GetSyncCommitteeDutiesResponse{}
syncDuties := structs.GetSyncCommitteeDutiesResponse{}
if err = c.jsonRestHandler.Post(
ctx,
fmt.Sprintf("/eth/v1/validator/duties/sync/%d", epoch),

View File

@@ -9,14 +9,12 @@ import (
"strconv"
"testing"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
validatormock "github.com/prysmaticlabs/prysm/v4/testing/validator-mock"
"github.com/prysmaticlabs/prysm/v4/validator/client/iface"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -37,8 +35,8 @@ func TestGetAttesterDuties_Valid(t *testing.T) {
validatorIndicesBytes, err := json.Marshal(stringValidatorIndices)
require.NoError(t, err)
expectedAttesterDuties := validator.GetAttesterDutiesResponse{
Data: []*validator.AttesterDuty{
expectedAttesterDuties := structs.GetAttesterDutiesResponse{
Data: []*structs.AttesterDuty{
{
Pubkey: hexutil.Encode([]byte{1}),
ValidatorIndex: "2",
@@ -72,7 +70,7 @@ func TestGetAttesterDuties_Valid(t *testing.T) {
fmt.Sprintf("%s/%d", getAttesterDutiesTestEndpoint, epoch),
nil,
bytes.NewBuffer(validatorIndicesBytes),
&validator.GetAttesterDutiesResponse{},
&structs.GetAttesterDutiesResponse{},
).Return(
nil,
).SetArg(
@@ -129,8 +127,8 @@ func TestGetAttesterDuties_NilAttesterDuty(t *testing.T) {
nil,
).SetArg(
4,
validator.GetAttesterDutiesResponse{
Data: []*validator.AttesterDuty{nil},
structs.GetAttesterDutiesResponse{
Data: []*structs.AttesterDuty{nil},
},
).Times(1)
@@ -142,8 +140,8 @@ func TestGetAttesterDuties_NilAttesterDuty(t *testing.T) {
func TestGetProposerDuties_Valid(t *testing.T) {
const epoch = primitives.Epoch(1)
expectedProposerDuties := validator.GetProposerDutiesResponse{
Data: []*validator.ProposerDuty{
expectedProposerDuties := structs.GetProposerDutiesResponse{
Data: []*structs.ProposerDuty{
{
Pubkey: hexutil.Encode([]byte{1}),
ValidatorIndex: "2",
@@ -166,7 +164,7 @@ func TestGetProposerDuties_Valid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("%s/%d", getProposerDutiesTestEndpoint, epoch),
&validator.GetProposerDutiesResponse{},
&structs.GetProposerDutiesResponse{},
).Return(
nil,
).SetArg(
@@ -219,7 +217,7 @@ func TestGetProposerDuties_NilData(t *testing.T) {
nil,
).SetArg(
2,
validator.GetProposerDutiesResponse{
structs.GetProposerDutiesResponse{
Data: nil,
},
).Times(1)
@@ -246,8 +244,8 @@ func TestGetProposerDuties_NilProposerDuty(t *testing.T) {
nil,
).SetArg(
2,
validator.GetProposerDutiesResponse{
Data: []*validator.ProposerDuty{nil},
structs.GetProposerDutiesResponse{
Data: []*structs.ProposerDuty{nil},
},
).Times(1)
@@ -263,8 +261,8 @@ func TestGetSyncDuties_Valid(t *testing.T) {
validatorIndicesBytes, err := json.Marshal(stringValidatorIndices)
require.NoError(t, err)
expectedSyncDuties := validator.GetSyncCommitteeDutiesResponse{
Data: []*validator.SyncCommitteeDuty{
expectedSyncDuties := structs.GetSyncCommitteeDutiesResponse{
Data: []*structs.SyncCommitteeDuty{
{
Pubkey: hexutil.Encode([]byte{1}),
ValidatorIndex: "2",
@@ -296,7 +294,7 @@ func TestGetSyncDuties_Valid(t *testing.T) {
fmt.Sprintf("%s/%d", getSyncDutiesTestEndpoint, epoch),
nil,
bytes.NewBuffer(validatorIndicesBytes),
&validator.GetSyncCommitteeDutiesResponse{},
&structs.GetSyncCommitteeDutiesResponse{},
).Return(
nil,
).SetArg(
@@ -353,7 +351,7 @@ func TestGetSyncDuties_NilData(t *testing.T) {
nil,
).SetArg(
4,
validator.GetSyncCommitteeDutiesResponse{
structs.GetSyncCommitteeDutiesResponse{
Data: nil,
},
).Times(1)
@@ -382,8 +380,8 @@ func TestGetSyncDuties_NilSyncDuty(t *testing.T) {
nil,
).SetArg(
4,
validator.GetSyncCommitteeDutiesResponse{
Data: []*validator.SyncCommitteeDuty{nil},
structs.GetSyncCommitteeDutiesResponse{
Data: []*structs.SyncCommitteeDuty{nil},
},
).Times(1)
@@ -395,8 +393,8 @@ func TestGetSyncDuties_NilSyncDuty(t *testing.T) {
func TestGetCommittees_Valid(t *testing.T) {
const epoch = primitives.Epoch(1)
expectedCommittees := beacon.GetCommitteesResponse{
Data: []*shared.Committee{
expectedCommittees := structs.GetCommitteesResponse{
Data: []*structs.Committee{
{
Index: "1",
Slot: "2",
@@ -425,7 +423,7 @@ func TestGetCommittees_Valid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("%s?epoch=%d", getCommitteesTestEndpoint, epoch),
&beacon.GetCommitteesResponse{},
&structs.GetCommitteesResponse{},
).Return(
nil,
).SetArg(
@@ -478,7 +476,7 @@ func TestGetCommittees_NilData(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetCommitteesResponse{
structs.GetCommitteesResponse{
Data: nil,
},
).Times(1)
@@ -505,8 +503,8 @@ func TestGetCommittees_NilCommittee(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetCommitteesResponse{
Data: []*shared.Committee{nil},
structs.GetCommitteesResponse{
Data: []*structs.Committee{nil},
},
).Times(1)
@@ -526,13 +524,13 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
testCases := []struct {
name string
expectedError string
generateAttesterDuties func() []*validator.AttesterDuty
generateAttesterDuties func() []*structs.AttesterDuty
fetchAttesterDutiesError error
generateProposerDuties func() []*validator.ProposerDuty
generateProposerDuties func() []*structs.ProposerDuty
fetchProposerDutiesError error
generateSyncDuties func() []*validator.SyncCommitteeDuty
generateSyncDuties func() []*structs.SyncCommitteeDuty
fetchSyncDutiesError error
generateCommittees func() []*shared.Committee
generateCommittees func() []*structs.Committee
fetchCommitteesError error
}{
{
@@ -559,7 +557,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad attester validator index",
expectedError: "failed to parse attester validator index `foo`",
generateAttesterDuties: func() []*validator.AttesterDuty {
generateAttesterDuties: func() []*structs.AttesterDuty {
attesterDuties := generateValidAttesterDuties(pubkeys, validatorIndices, committeeIndices, committeeSlots)
attesterDuties[0].ValidatorIndex = "foo"
return attesterDuties
@@ -568,7 +566,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad attester slot",
expectedError: "failed to parse attester slot `foo`",
generateAttesterDuties: func() []*validator.AttesterDuty {
generateAttesterDuties: func() []*structs.AttesterDuty {
attesterDuties := generateValidAttesterDuties(pubkeys, validatorIndices, committeeIndices, committeeSlots)
attesterDuties[0].Slot = "foo"
return attesterDuties
@@ -577,7 +575,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad attester committee index",
expectedError: "failed to parse attester committee index `foo`",
generateAttesterDuties: func() []*validator.AttesterDuty {
generateAttesterDuties: func() []*structs.AttesterDuty {
attesterDuties := generateValidAttesterDuties(pubkeys, validatorIndices, committeeIndices, committeeSlots)
attesterDuties[0].CommitteeIndex = "foo"
return attesterDuties
@@ -586,7 +584,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad proposer validator index",
expectedError: "failed to parse proposer validator index `foo`",
generateProposerDuties: func() []*validator.ProposerDuty {
generateProposerDuties: func() []*structs.ProposerDuty {
proposerDuties := generateValidProposerDuties(pubkeys, validatorIndices, proposerSlots)
proposerDuties[0].ValidatorIndex = "foo"
return proposerDuties
@@ -595,7 +593,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad proposer slot",
expectedError: "failed to parse proposer slot `foo`",
generateProposerDuties: func() []*validator.ProposerDuty {
generateProposerDuties: func() []*structs.ProposerDuty {
proposerDuties := generateValidProposerDuties(pubkeys, validatorIndices, proposerSlots)
proposerDuties[0].Slot = "foo"
return proposerDuties
@@ -604,7 +602,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad sync validator index",
expectedError: "failed to parse sync validator index `foo`",
generateSyncDuties: func() []*validator.SyncCommitteeDuty {
generateSyncDuties: func() []*structs.SyncCommitteeDuty {
syncDuties := generateValidSyncDuties(pubkeys, validatorIndices)
syncDuties[0].ValidatorIndex = "foo"
return syncDuties
@@ -613,7 +611,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad committee index",
expectedError: "failed to parse committee index `foo`",
generateCommittees: func() []*shared.Committee {
generateCommittees: func() []*structs.Committee {
committees := generateValidCommittees(committeeIndices, committeeSlots, validatorIndices)
committees[0].Index = "foo"
return committees
@@ -622,7 +620,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad committee slot",
expectedError: "failed to parse slot `foo`",
generateCommittees: func() []*shared.Committee {
generateCommittees: func() []*structs.Committee {
committees := generateValidCommittees(committeeIndices, committeeSlots, validatorIndices)
committees[0].Slot = "foo"
return committees
@@ -631,7 +629,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "bad committee validator index",
expectedError: "failed to parse committee validator index `foo`",
generateCommittees: func() []*shared.Committee {
generateCommittees: func() []*structs.Committee {
committees := generateValidCommittees(committeeIndices, committeeSlots, validatorIndices)
committees[0].Validators[0] = "foo"
return committees
@@ -640,14 +638,14 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
{
name: "committee index and slot not found in committees mapping",
expectedError: "failed to find validators for committee index `1` and slot `2`",
generateAttesterDuties: func() []*validator.AttesterDuty {
generateAttesterDuties: func() []*structs.AttesterDuty {
attesterDuties := generateValidAttesterDuties(pubkeys, validatorIndices, committeeIndices, committeeSlots)
attesterDuties[0].CommitteeIndex = "1"
attesterDuties[0].Slot = "2"
return attesterDuties
},
generateCommittees: func() []*shared.Committee {
return []*shared.Committee{}
generateCommittees: func() []*structs.Committee {
return []*structs.Committee{}
},
},
}
@@ -659,28 +657,28 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
ctx := context.Background()
var attesterDuties []*validator.AttesterDuty
var attesterDuties []*structs.AttesterDuty
if testCase.generateAttesterDuties == nil {
attesterDuties = generateValidAttesterDuties(pubkeys, validatorIndices, committeeIndices, committeeSlots)
} else {
attesterDuties = testCase.generateAttesterDuties()
}
var proposerDuties []*validator.ProposerDuty
var proposerDuties []*structs.ProposerDuty
if testCase.generateProposerDuties == nil {
proposerDuties = generateValidProposerDuties(pubkeys, validatorIndices, proposerSlots)
} else {
proposerDuties = testCase.generateProposerDuties()
}
var syncDuties []*validator.SyncCommitteeDuty
var syncDuties []*structs.SyncCommitteeDuty
if testCase.generateSyncDuties == nil {
syncDuties = generateValidSyncDuties(pubkeys, validatorIndices)
} else {
syncDuties = testCase.generateSyncDuties()
}
var committees []*shared.Committee
var committees []*structs.Committee
if testCase.generateCommittees == nil {
committees = generateValidCommittees(committeeIndices, committeeSlots, validatorIndices)
} else {
@@ -1135,12 +1133,12 @@ func TestGetDuties_Valid(t *testing.T) {
gomock.Any(),
gomock.Any(),
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: strconv.FormatUint(uint64(validatorIndices[0]), 10),
Status: "pending_initialized",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[0]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1148,7 +1146,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[1]), 10),
Status: "pending_queued",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[1]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1156,7 +1154,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[2]), 10),
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[2]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1164,7 +1162,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[3]), 10),
Status: "active_exiting",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[3]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1172,7 +1170,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[4]), 10),
Status: "active_slashed",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[4]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1180,7 +1178,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[5]), 10),
Status: "exited_unslashed",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[5]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1188,7 +1186,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[6]), 10),
Status: "exited_slashed",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[6]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1196,7 +1194,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[7]), 10),
Status: "withdrawal_possible",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[7]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1204,7 +1202,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[8]), 10),
Status: "withdrawal_done",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[8]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1212,7 +1210,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[9]), 10),
Status: "pending_initialized",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[9]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1220,7 +1218,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[10]), 10),
Status: "pending_queued",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[10]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1228,7 +1226,7 @@ func TestGetDuties_Valid(t *testing.T) {
{
Index: strconv.FormatUint(uint64(validatorIndices[11]), 10),
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: hexutil.Encode(pubkeys[11]),
ActivationEpoch: strconv.FormatUint(uint64(testCase.epoch), 10),
},
@@ -1330,8 +1328,8 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
gomock.Any(),
gomock.Any(),
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{},
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{},
},
nil,
).Times(1)
@@ -1370,8 +1368,8 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
assert.ErrorContains(t, "foo error", err)
}
func generateValidCommittees(committeeIndices []primitives.CommitteeIndex, slots []primitives.Slot, validatorIndices []primitives.ValidatorIndex) []*shared.Committee {
return []*shared.Committee{
func generateValidCommittees(committeeIndices []primitives.CommitteeIndex, slots []primitives.Slot, validatorIndices []primitives.ValidatorIndex) []*structs.Committee {
return []*structs.Committee{
{
Index: strconv.FormatUint(uint64(committeeIndices[0]), 10),
Slot: strconv.FormatUint(uint64(slots[0]), 10),
@@ -1399,8 +1397,8 @@ func generateValidCommittees(committeeIndices []primitives.CommitteeIndex, slots
}
}
func generateValidAttesterDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex, committeeIndices []primitives.CommitteeIndex, slots []primitives.Slot) []*validator.AttesterDuty {
return []*validator.AttesterDuty{
func generateValidAttesterDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex, committeeIndices []primitives.CommitteeIndex, slots []primitives.Slot) []*structs.AttesterDuty {
return []*structs.AttesterDuty{
{
Pubkey: hexutil.Encode(pubkeys[0]),
ValidatorIndex: strconv.FormatUint(uint64(validatorIndices[0]), 10),
@@ -1440,8 +1438,8 @@ func generateValidAttesterDuties(pubkeys [][]byte, validatorIndices []primitives
}
}
func generateValidProposerDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex, slots []primitives.Slot) []*validator.ProposerDuty {
return []*validator.ProposerDuty{
func generateValidProposerDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex, slots []primitives.Slot) []*structs.ProposerDuty {
return []*structs.ProposerDuty{
{
Pubkey: hexutil.Encode(pubkeys[4]),
ValidatorIndex: strconv.FormatUint(uint64(validatorIndices[4]), 10),
@@ -1485,8 +1483,8 @@ func generateValidProposerDuties(pubkeys [][]byte, validatorIndices []primitives
}
}
func generateValidSyncDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex) []*validator.SyncCommitteeDuty {
return []*validator.SyncCommitteeDuty{
func generateValidSyncDuties(pubkeys [][]byte, validatorIndices []primitives.ValidatorIndex) []*structs.SyncCommitteeDuty {
return []*structs.SyncCommitteeDuty{
{
Pubkey: hexutil.Encode(pubkeys[5]),
ValidatorIndex: strconv.FormatUint(uint64(validatorIndices[5]), 10),

View File

@@ -8,13 +8,13 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
type GenesisProvider interface {
GetGenesis(ctx context.Context) (*beacon.Genesis, error)
GetGenesis(ctx context.Context) (*structs.Genesis, error)
}
type beaconApiGenesisProvider struct {
@@ -64,8 +64,8 @@ func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb
}
// GetGenesis gets the genesis information from the beacon node via the /eth/v1/beacon/genesis endpoint
func (c beaconApiGenesisProvider) GetGenesis(ctx context.Context) (*beacon.Genesis, error) {
genesisJson := &beacon.GetGenesisResponse{}
func (c beaconApiGenesisProvider) GetGenesis(ctx context.Context) (*structs.Genesis, error) {
genesisJson := &structs.GetGenesisResponse{}
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/beacon/genesis", genesisJson); err != nil {
return nil, err
}

View File

@@ -5,7 +5,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
"github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/mock"
@@ -17,7 +17,7 @@ func TestGetGenesis_ValidGenesis(t *testing.T) {
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -27,8 +27,8 @@ func TestGetGenesis_ValidGenesis(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetGenesisResponse{
Data: &beacon.Genesis{
structs.GetGenesisResponse{
Data: &structs.Genesis{
GenesisTime: "1234",
GenesisValidatorsRoot: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
},
@@ -49,7 +49,7 @@ func TestGetGenesis_NilData(t *testing.T) {
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -59,7 +59,7 @@ func TestGetGenesis_NilData(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetGenesisResponse{Data: nil},
structs.GetGenesisResponse{Data: nil},
).Times(1)
genesisProvider := &beaconApiGenesisProvider{jsonRestHandler: jsonRestHandler}

View File

@@ -10,8 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -37,7 +36,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
// Try v3 endpoint first. If it's not supported, then we fall back to older endpoints.
// We try the blinded block endpoint first. If it fails, we assume that we got a full block and try the full block endpoint.
queryUrl := buildURL(fmt.Sprintf("/eth/v3/validator/blocks/%d", slot), queryParams)
produceBlockV3ResponseJson := validator.ProduceBlockV3Response{}
produceBlockV3ResponseJson := structs.ProduceBlockV3Response{}
err := c.jsonRestHandler.Get(ctx, queryUrl, &produceBlockV3ResponseJson)
errJson := &httputil.DefaultJsonError{}
if err != nil {
@@ -74,7 +73,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
var response *ethpb.GenericBeaconBlock
switch ver {
case version.String(version.Phase0):
jsonPhase0Block := shared.BeaconBlock{}
jsonPhase0Block := structs.BeaconBlock{}
if err := decoder.Decode(&jsonPhase0Block); err != nil {
return nil, errors.Wrap(err, "failed to decode phase0 block response json")
}
@@ -84,7 +83,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
response = genericBlock
case version.String(version.Altair):
jsonAltairBlock := shared.BeaconBlockAltair{}
jsonAltairBlock := structs.BeaconBlockAltair{}
if err := decoder.Decode(&jsonAltairBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode altair block response json")
}
@@ -95,7 +94,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
response = genericBlock
case version.String(version.Bellatrix):
if blinded {
jsonBellatrixBlock := shared.BlindedBeaconBlockBellatrix{}
jsonBellatrixBlock := structs.BlindedBeaconBlockBellatrix{}
if err := decoder.Decode(&jsonBellatrixBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode blinded bellatrix block response json")
}
@@ -105,7 +104,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
response = genericBlock
} else {
jsonBellatrixBlock := shared.BeaconBlockBellatrix{}
jsonBellatrixBlock := structs.BeaconBlockBellatrix{}
if err := decoder.Decode(&jsonBellatrixBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode bellatrix block response json")
}
@@ -117,7 +116,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
case version.String(version.Capella):
if blinded {
jsonCapellaBlock := shared.BlindedBeaconBlockCapella{}
jsonCapellaBlock := structs.BlindedBeaconBlockCapella{}
if err := decoder.Decode(&jsonCapellaBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode blinded capella block response json")
}
@@ -127,7 +126,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
response = genericBlock
} else {
jsonCapellaBlock := shared.BeaconBlockCapella{}
jsonCapellaBlock := structs.BeaconBlockCapella{}
if err := decoder.Decode(&jsonCapellaBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode capella block response json")
}
@@ -139,7 +138,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
case version.String(version.Deneb):
if blinded {
jsonDenebBlock := shared.BlindedBeaconBlockDeneb{}
jsonDenebBlock := structs.BlindedBeaconBlockDeneb{}
if err := decoder.Decode(&jsonDenebBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode blinded deneb block response json")
}
@@ -149,7 +148,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
}
response = genericBlock
} else {
jsonDenebBlockContents := shared.BeaconBlockContentsDeneb{}
jsonDenebBlockContents := structs.BeaconBlockContentsDeneb{}
if err := decoder.Decode(&jsonDenebBlockContents); err != nil {
return nil, errors.Wrap(err, "failed to decode deneb block response json")
}

View File

@@ -10,7 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -127,10 +127,10 @@ func TestGetBeaconBlock_Error(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
gomock.Any(),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: testCase.consensusVersion,
Data: testCase.data,
},
@@ -163,10 +163,10 @@ func TestGetBeaconBlock_Phase0Valid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "phase0",
Data: bytes,
},
@@ -206,10 +206,10 @@ func TestGetBeaconBlock_AltairValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "altair",
Data: bytes,
},
@@ -249,10 +249,10 @@ func TestGetBeaconBlock_BellatrixValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "bellatrix",
ExecutionPayloadBlinded: false,
Data: bytes,
@@ -294,10 +294,10 @@ func TestGetBeaconBlock_BlindedBellatrixValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "bellatrix",
ExecutionPayloadBlinded: true,
Data: bytes,
@@ -339,10 +339,10 @@ func TestGetBeaconBlock_CapellaValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "capella",
ExecutionPayloadBlinded: false,
Data: bytes,
@@ -384,10 +384,10 @@ func TestGetBeaconBlock_BlindedCapellaValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "capella",
ExecutionPayloadBlinded: true,
Data: bytes,
@@ -429,10 +429,10 @@ func TestGetBeaconBlock_DenebValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "deneb",
ExecutionPayloadBlinded: false,
Data: bytes,
@@ -474,10 +474,10 @@ func TestGetBeaconBlock_BlindedDenebValid(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).SetArg(
2,
validator.ProduceBlockV3Response{
structs.ProduceBlockV3Response{
Version: "deneb",
ExecutionPayloadBlinded: true,
Data: bytes,
@@ -519,7 +519,7 @@ func TestGetBeaconBlock_FallbackToBlindedBlock(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).Return(
&httputil.DefaultJsonError{Code: http.StatusNotFound},
).Times(1)
@@ -570,7 +570,7 @@ func TestGetBeaconBlock_FallbackToFullBlock(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("/eth/v3/validator/blocks/%d?graffiti=%s&randao_reveal=%s", slot, hexutil.Encode(graffiti), hexutil.Encode(randaoReveal)),
&validator.ProduceBlockV3Response{},
&structs.ProduceBlockV3Response{},
).Return(
&httputil.DefaultJsonError{Code: http.StatusNotFound},
).Times(1)

View File

@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -22,7 +22,7 @@ const stringPubKey = "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200
func getPubKeyAndReqBuffer(t *testing.T) ([]byte, *bytes.Buffer) {
pubKey, err := hexutil.Decode(stringPubKey)
require.NoError(t, err)
req := beacon.GetValidatorsRequest{
req := structs.GetValidatorsRequest{
Ids: []string{stringPubKey},
Statuses: []string{},
}
@@ -38,7 +38,7 @@ func TestIndex_Nominal(t *testing.T) {
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
ctx := context.Background()
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(
@@ -51,12 +51,12 @@ func TestIndex_Nominal(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "55293",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -88,7 +88,7 @@ func TestIndex_UnexistingValidator(t *testing.T) {
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
ctx := context.Background()
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(
@@ -101,8 +101,8 @@ func TestIndex_UnexistingValidator(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{},
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{},
},
).Times(1)
@@ -130,7 +130,7 @@ func TestIndex_BadIndexError(t *testing.T) {
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
ctx := context.Background()
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(
@@ -143,12 +143,12 @@ func TestIndex_BadIndexError(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "This is not an index",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -179,7 +179,7 @@ func TestIndex_JsonResponseError(t *testing.T) {
pubKey, reqBuffer := getPubKeyAndReqBuffer(t)
ctx := context.Background()
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(

View File

@@ -12,7 +12,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/api"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -21,8 +21,8 @@ import (
func TestGet(t *testing.T) {
ctx := context.Background()
const endpoint = "/example/rest/api/endpoint"
genesisJson := &beacon.GetGenesisResponse{
Data: &beacon.Genesis{
genesisJson := &structs.GetGenesisResponse{
Data: &structs.Genesis{
GenesisTime: "123",
GenesisValidatorsRoot: "0x456",
GenesisForkVersion: "0x789",
@@ -44,7 +44,7 @@ func TestGet(t *testing.T) {
HttpClient: http.Client{Timeout: time.Second * 5},
Host: server.URL,
}
resp := &beacon.GetGenesisResponse{}
resp := &structs.GetGenesisResponse{}
require.NoError(t, jsonRestHandler.Get(ctx, endpoint+"?arg1=abc&arg2=def", resp))
assert.DeepEqual(t, genesisJson, resp)
}
@@ -55,8 +55,8 @@ func TestPost(t *testing.T) {
dataBytes := []byte{1, 2, 3, 4, 5}
headers := map[string]string{"foo": "bar"}
genesisJson := &beacon.GetGenesisResponse{
Data: &beacon.Genesis{
genesisJson := &structs.GetGenesisResponse{
Data: &structs.Genesis{
GenesisTime: "123",
GenesisValidatorsRoot: "0x456",
GenesisForkVersion: "0x789",
@@ -90,7 +90,7 @@ func TestPost(t *testing.T) {
HttpClient: http.Client{Timeout: time.Second * 5},
Host: server.URL,
}
resp := &beacon.GetGenesisResponse{}
resp := &structs.GetGenesisResponse{}
require.NoError(t, jsonRestHandler.Post(ctx, endpoint, headers, bytes.NewBuffer(dataBytes), resp))
assert.DeepEqual(t, genesisJson, resp)
}

View File

@@ -12,9 +12,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/mock",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/rpc/eth/beacon:go_default_library",
"//beacon-chain/rpc/eth/shared:go_default_library",
"//beacon-chain/rpc/eth/validator:go_default_library",
"//api/server/structs:go_default_library",
"//consensus-types/primitives:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",

View File

@@ -8,7 +8,7 @@ import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
shared "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -36,7 +36,7 @@ func (m *MockBeaconBlockConverter) EXPECT() *MockBeaconBlockConverterMockRecorde
}
// ConvertRESTAltairBlockToProto mocks base method.
func (m *MockBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *shared.BeaconBlockAltair) (*eth.BeaconBlockAltair, error) {
func (m *MockBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *structs.BeaconBlockAltair) (*eth.BeaconBlockAltair, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConvertRESTAltairBlockToProto", block)
ret0, _ := ret[0].(*eth.BeaconBlockAltair)
@@ -51,7 +51,7 @@ func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTAltairBlockToProto(bl
}
// ConvertRESTBellatrixBlockToProto mocks base method.
func (m *MockBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *shared.BeaconBlockBellatrix) (*eth.BeaconBlockBellatrix, error) {
func (m *MockBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *structs.BeaconBlockBellatrix) (*eth.BeaconBlockBellatrix, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConvertRESTBellatrixBlockToProto", block)
ret0, _ := ret[0].(*eth.BeaconBlockBellatrix)
@@ -66,7 +66,7 @@ func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTBellatrixBlockToProto
}
// ConvertRESTCapellaBlockToProto mocks base method.
func (m *MockBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *shared.BeaconBlockCapella) (*eth.BeaconBlockCapella, error) {
func (m *MockBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *structs.BeaconBlockCapella) (*eth.BeaconBlockCapella, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConvertRESTCapellaBlockToProto", block)
ret0, _ := ret[0].(*eth.BeaconBlockCapella)
@@ -81,7 +81,7 @@ func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTCapellaBlockToProto(b
}
// ConvertRESTPhase0BlockToProto mocks base method.
func (m *MockBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *shared.BeaconBlock) (*eth.BeaconBlock, error) {
func (m *MockBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *structs.BeaconBlock) (*eth.BeaconBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConvertRESTPhase0BlockToProto", block)
ret0, _ := ret[0].(*eth.BeaconBlock)

View File

@@ -9,8 +9,7 @@ import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
shared "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
validator "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
)
@@ -38,10 +37,10 @@ func (m *MockdutiesProvider) EXPECT() *MockdutiesProviderMockRecorder {
}
// GetAttesterDuties mocks base method.
func (m *MockdutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.AttesterDuty, error) {
func (m *MockdutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAttesterDuties", ctx, epoch, validatorIndices)
ret0, _ := ret[0].([]*validator.AttesterDuty)
ret0, _ := ret[0].([]*structs.AttesterDuty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -53,10 +52,10 @@ func (mr *MockdutiesProviderMockRecorder) GetAttesterDuties(ctx, epoch, validato
}
// GetCommittees mocks base method.
func (m *MockdutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*shared.Committee, error) {
func (m *MockdutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCommittees", ctx, epoch)
ret0, _ := ret[0].([]*shared.Committee)
ret0, _ := ret[0].([]*structs.Committee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -68,10 +67,10 @@ func (mr *MockdutiesProviderMockRecorder) GetCommittees(ctx, epoch interface{})
}
// GetProposerDuties mocks base method.
func (m *MockdutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*validator.ProposerDuty, error) {
func (m *MockdutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetProposerDuties", ctx, epoch)
ret0, _ := ret[0].([]*validator.ProposerDuty)
ret0, _ := ret[0].([]*structs.ProposerDuty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -83,10 +82,10 @@ func (mr *MockdutiesProviderMockRecorder) GetProposerDuties(ctx, epoch interface
}
// GetSyncDuties mocks base method.
func (m *MockdutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*validator.SyncCommitteeDuty, error) {
func (m *MockdutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSyncDuties", ctx, epoch, validatorIndices)
ret0, _ := ret[0].([]*validator.SyncCommitteeDuty)
ret0, _ := ret[0].([]*structs.SyncCommitteeDuty)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@@ -9,7 +9,7 @@ import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
beacon "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
)
// MockGenesisProvider is a mock of GenesisProvider interface.
@@ -36,10 +36,10 @@ func (m *MockGenesisProvider) EXPECT() *MockGenesisProviderMockRecorder {
}
// GetGenesis mocks base method.
func (m *MockGenesisProvider) GetGenesis(arg0 context.Context) (*beacon.Genesis, error) {
func (m *MockGenesisProvider) GetGenesis(arg0 context.Context) (*structs.Genesis, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetGenesis", arg0)
ret0, _ := ret[0].(*beacon.Genesis)
ret0, _ := ret[0].(*structs.Genesis)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@@ -9,7 +9,7 @@ import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
beacon "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
)
@@ -37,10 +37,10 @@ func (m *MockStateValidatorsProvider) EXPECT() *MockStateValidatorsProviderMockR
}
// GetStateValidators mocks base method.
func (m *MockStateValidatorsProvider) GetStateValidators(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*beacon.GetValidatorsResponse, error) {
func (m *MockStateValidatorsProvider) GetStateValidators(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetStateValidators", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*beacon.GetValidatorsResponse)
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -52,10 +52,10 @@ func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidators(arg0, arg1
}
// GetStateValidatorsForHead mocks base method.
func (m *MockStateValidatorsProvider) GetStateValidatorsForHead(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*beacon.GetValidatorsResponse, error) {
func (m *MockStateValidatorsProvider) GetStateValidatorsForHead(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetStateValidatorsForHead", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*beacon.GetValidatorsResponse)
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -67,10 +67,10 @@ func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForHead(arg
}
// GetStateValidatorsForSlot mocks base method.
func (m *MockStateValidatorsProvider) GetStateValidatorsForSlot(arg0 context.Context, arg1 primitives.Slot, arg2 []string, arg3 []primitives.ValidatorIndex, arg4 []string) (*beacon.GetValidatorsResponse, error) {
func (m *MockStateValidatorsProvider) GetStateValidatorsForSlot(arg0 context.Context, arg1 primitives.Slot, arg2 []string, arg3 []primitives.ValidatorIndex, arg4 []string) (*structs.GetValidatorsResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetStateValidatorsForSlot", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(*beacon.GetValidatorsResponse)
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@@ -8,14 +8,14 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
func (c *beaconApiValidatorClient) prepareBeaconProposer(ctx context.Context, recipients []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer) error {
jsonRecipients := make([]*shared.FeeRecipient, len(recipients))
jsonRecipients := make([]*structs.FeeRecipient, len(recipients))
for index, recipient := range recipients {
jsonRecipients[index] = &shared.FeeRecipient{
jsonRecipients[index] = &structs.FeeRecipient{
FeeRecipient: hexutil.Encode(recipient.FeeRecipient),
ValidatorIndex: strconv.FormatUint(uint64(recipient.ValidatorIndex), 10),
}

View File

@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -28,7 +28,7 @@ func TestPrepareBeaconProposer_Valid(t *testing.T) {
ctx := context.Background()
jsonRecipients := []*shared.FeeRecipient{
jsonRecipients := []*structs.FeeRecipient{
{
ValidatorIndex: "1",
FeeRecipient: feeRecipient1,

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -97,7 +97,7 @@ func (c beaconApiValidatorClient) proposeBeaconBlock(ctx context.Context, in *et
if err != nil {
return nil, errors.Wrap(err, "failed to compute block root for deneb beacon block")
}
signedBlock, err := shared.SignedBeaconBlockContentsDenebFromConsensus(blockType.Deneb)
signedBlock, err := structs.SignedBeaconBlockContentsDenebFromConsensus(blockType.Deneb)
if err != nil {
return nil, errors.Wrap(err, "failed to convert deneb beacon block contents")
}
@@ -112,7 +112,7 @@ func (c beaconApiValidatorClient) proposeBeaconBlock(ctx context.Context, in *et
if err != nil {
return nil, errors.Wrap(err, "failed to compute block root for blinded deneb beacon block")
}
signedBlock, err := shared.SignedBlindedBeaconBlockDenebFromConsensus(blockType.BlindedDeneb)
signedBlock, err := structs.SignedBlindedBeaconBlockDenebFromConsensus(blockType.BlindedDeneb)
if err != nil {
return nil, errors.Wrap(err, "failed to convert blinded deneb beacon block contents")
}
@@ -150,10 +150,10 @@ func (c beaconApiValidatorClient) proposeBeaconBlock(ctx context.Context, in *et
}
func marshallBeaconBlockPhase0(block *ethpb.SignedBeaconBlock) ([]byte, error) {
signedBeaconBlockJson := &shared.SignedBeaconBlock{
signedBeaconBlockJson := &structs.SignedBeaconBlock{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BeaconBlock{
Body: &shared.BeaconBlockBody{
Message: &structs.BeaconBlock{
Body: &structs.BeaconBlockBody{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -174,14 +174,14 @@ func marshallBeaconBlockPhase0(block *ethpb.SignedBeaconBlock) ([]byte, error) {
}
func marshallBeaconBlockAltair(block *ethpb.SignedBeaconBlockAltair) ([]byte, error) {
signedBeaconBlockAltairJson := &shared.SignedBeaconBlockAltair{
signedBeaconBlockAltairJson := &structs.SignedBeaconBlockAltair{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BeaconBlockAltair{
Message: &structs.BeaconBlockAltair{
ParentRoot: hexutil.Encode(block.Block.ParentRoot),
ProposerIndex: uint64ToString(block.Block.ProposerIndex),
Slot: uint64ToString(block.Block.Slot),
StateRoot: hexutil.Encode(block.Block.StateRoot),
Body: &shared.BeaconBlockBodyAltair{
Body: &structs.BeaconBlockBodyAltair{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -190,7 +190,7 @@ func marshallBeaconBlockAltair(block *ethpb.SignedBeaconBlockAltair) ([]byte, er
ProposerSlashings: jsonifyProposerSlashings(block.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(block.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(block.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
@@ -202,14 +202,14 @@ func marshallBeaconBlockAltair(block *ethpb.SignedBeaconBlockAltair) ([]byte, er
}
func marshallBeaconBlockBellatrix(block *ethpb.SignedBeaconBlockBellatrix) ([]byte, error) {
signedBeaconBlockBellatrixJson := &shared.SignedBeaconBlockBellatrix{
signedBeaconBlockBellatrixJson := &structs.SignedBeaconBlockBellatrix{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BeaconBlockBellatrix{
Message: &structs.BeaconBlockBellatrix{
ParentRoot: hexutil.Encode(block.Block.ParentRoot),
ProposerIndex: uint64ToString(block.Block.ProposerIndex),
Slot: uint64ToString(block.Block.Slot),
StateRoot: hexutil.Encode(block.Block.StateRoot),
Body: &shared.BeaconBlockBodyBellatrix{
Body: &structs.BeaconBlockBodyBellatrix{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -218,11 +218,11 @@ func marshallBeaconBlockBellatrix(block *ethpb.SignedBeaconBlockBellatrix) ([]by
ProposerSlashings: jsonifyProposerSlashings(block.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(block.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(block.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayload: &shared.ExecutionPayload{
ExecutionPayload: &structs.ExecutionPayload{
ParentHash: hexutil.Encode(block.Block.Body.ExecutionPayload.ParentHash),
FeeRecipient: hexutil.Encode(block.Block.Body.ExecutionPayload.FeeRecipient),
StateRoot: hexutil.Encode(block.Block.Body.ExecutionPayload.StateRoot),
@@ -246,14 +246,14 @@ func marshallBeaconBlockBellatrix(block *ethpb.SignedBeaconBlockBellatrix) ([]by
}
func marshallBeaconBlockBlindedBellatrix(block *ethpb.SignedBlindedBeaconBlockBellatrix) ([]byte, error) {
signedBeaconBlockBellatrixJson := &shared.SignedBlindedBeaconBlockBellatrix{
signedBeaconBlockBellatrixJson := &structs.SignedBlindedBeaconBlockBellatrix{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BlindedBeaconBlockBellatrix{
Message: &structs.BlindedBeaconBlockBellatrix{
ParentRoot: hexutil.Encode(block.Block.ParentRoot),
ProposerIndex: uint64ToString(block.Block.ProposerIndex),
Slot: uint64ToString(block.Block.Slot),
StateRoot: hexutil.Encode(block.Block.StateRoot),
Body: &shared.BlindedBeaconBlockBodyBellatrix{
Body: &structs.BlindedBeaconBlockBodyBellatrix{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -262,11 +262,11 @@ func marshallBeaconBlockBlindedBellatrix(block *ethpb.SignedBlindedBeaconBlockBe
ProposerSlashings: jsonifyProposerSlashings(block.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(block.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(block.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeader{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeader{
ParentHash: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.ParentHash),
FeeRecipient: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.FeeRecipient),
StateRoot: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.StateRoot),
@@ -290,14 +290,14 @@ func marshallBeaconBlockBlindedBellatrix(block *ethpb.SignedBlindedBeaconBlockBe
}
func marshallBeaconBlockCapella(block *ethpb.SignedBeaconBlockCapella) ([]byte, error) {
signedBeaconBlockCapellaJson := &shared.SignedBeaconBlockCapella{
signedBeaconBlockCapellaJson := &structs.SignedBeaconBlockCapella{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BeaconBlockCapella{
Message: &structs.BeaconBlockCapella{
ParentRoot: hexutil.Encode(block.Block.ParentRoot),
ProposerIndex: uint64ToString(block.Block.ProposerIndex),
Slot: uint64ToString(block.Block.Slot),
StateRoot: hexutil.Encode(block.Block.StateRoot),
Body: &shared.BeaconBlockBodyCapella{
Body: &structs.BeaconBlockBodyCapella{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -306,11 +306,11 @@ func marshallBeaconBlockCapella(block *ethpb.SignedBeaconBlockCapella) ([]byte,
ProposerSlashings: jsonifyProposerSlashings(block.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(block.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(block.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayload: &shared.ExecutionPayloadCapella{
ExecutionPayload: &structs.ExecutionPayloadCapella{
ParentHash: hexutil.Encode(block.Block.Body.ExecutionPayload.ParentHash),
FeeRecipient: hexutil.Encode(block.Block.Body.ExecutionPayload.FeeRecipient),
StateRoot: hexutil.Encode(block.Block.Body.ExecutionPayload.StateRoot),
@@ -336,14 +336,14 @@ func marshallBeaconBlockCapella(block *ethpb.SignedBeaconBlockCapella) ([]byte,
}
func marshallBeaconBlockBlindedCapella(block *ethpb.SignedBlindedBeaconBlockCapella) ([]byte, error) {
signedBeaconBlockCapellaJson := &shared.SignedBlindedBeaconBlockCapella{
signedBeaconBlockCapellaJson := &structs.SignedBlindedBeaconBlockCapella{
Signature: hexutil.Encode(block.Signature),
Message: &shared.BlindedBeaconBlockCapella{
Message: &structs.BlindedBeaconBlockCapella{
ParentRoot: hexutil.Encode(block.Block.ParentRoot),
ProposerIndex: uint64ToString(block.Block.ProposerIndex),
Slot: uint64ToString(block.Block.Slot),
StateRoot: hexutil.Encode(block.Block.StateRoot),
Body: &shared.BlindedBeaconBlockBodyCapella{
Body: &structs.BlindedBeaconBlockBodyCapella{
Attestations: jsonifyAttestations(block.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(block.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(block.Block.Body.Deposits),
@@ -352,11 +352,11 @@ func marshallBeaconBlockBlindedCapella(block *ethpb.SignedBlindedBeaconBlockCape
ProposerSlashings: jsonifyProposerSlashings(block.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(block.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(block.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(block.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeaderCapella{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeaderCapella{
ParentHash: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.ParentHash),
FeeRecipient: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.FeeRecipient),
StateRoot: hexutil.Encode(block.Block.Body.ExecutionPayloadHeader.StateRoot),

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -26,14 +26,14 @@ func TestProposeBeaconBlock_Altair(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = altairBlock
jsonAltairBlock := &shared.SignedBeaconBlockAltair{
jsonAltairBlock := &structs.SignedBeaconBlockAltair{
Signature: hexutil.Encode(altairBlock.Altair.Signature),
Message: &shared.BeaconBlockAltair{
Message: &structs.BeaconBlockAltair{
ParentRoot: hexutil.Encode(altairBlock.Altair.Block.ParentRoot),
ProposerIndex: uint64ToString(altairBlock.Altair.Block.ProposerIndex),
Slot: uint64ToString(altairBlock.Altair.Block.Slot),
StateRoot: hexutil.Encode(altairBlock.Altair.Block.StateRoot),
Body: &shared.BeaconBlockBodyAltair{
Body: &structs.BeaconBlockBodyAltair{
Attestations: jsonifyAttestations(altairBlock.Altair.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(altairBlock.Altair.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(altairBlock.Altair.Block.Body.Deposits),
@@ -42,7 +42,7 @@ func TestProposeBeaconBlock_Altair(t *testing.T) {
ProposerSlashings: jsonifyProposerSlashings(altairBlock.Altair.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(altairBlock.Altair.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(altairBlock.Altair.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(altairBlock.Altair.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(altairBlock.Altair.Block.Body.SyncAggregate.SyncCommitteeSignature),
},

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -27,14 +27,14 @@ func TestProposeBeaconBlock_Bellatrix(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = bellatrixBlock
jsonBellatrixBlock := &shared.SignedBeaconBlockBellatrix{
jsonBellatrixBlock := &structs.SignedBeaconBlockBellatrix{
Signature: hexutil.Encode(bellatrixBlock.Bellatrix.Signature),
Message: &shared.BeaconBlockBellatrix{
Message: &structs.BeaconBlockBellatrix{
ParentRoot: hexutil.Encode(bellatrixBlock.Bellatrix.Block.ParentRoot),
ProposerIndex: uint64ToString(bellatrixBlock.Bellatrix.Block.ProposerIndex),
Slot: uint64ToString(bellatrixBlock.Bellatrix.Block.Slot),
StateRoot: hexutil.Encode(bellatrixBlock.Bellatrix.Block.StateRoot),
Body: &shared.BeaconBlockBodyBellatrix{
Body: &structs.BeaconBlockBodyBellatrix{
Attestations: jsonifyAttestations(bellatrixBlock.Bellatrix.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(bellatrixBlock.Bellatrix.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(bellatrixBlock.Bellatrix.Block.Body.Deposits),
@@ -43,11 +43,11 @@ func TestProposeBeaconBlock_Bellatrix(t *testing.T) {
ProposerSlashings: jsonifyProposerSlashings(bellatrixBlock.Bellatrix.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(bellatrixBlock.Bellatrix.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(bellatrixBlock.Bellatrix.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(bellatrixBlock.Bellatrix.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(bellatrixBlock.Bellatrix.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayload: &shared.ExecutionPayload{
ExecutionPayload: &structs.ExecutionPayload{
BaseFeePerGas: bytesutil.LittleEndianBytesToBigInt(bellatrixBlock.Bellatrix.Block.Body.ExecutionPayload.BaseFeePerGas).String(),
BlockHash: hexutil.Encode(bellatrixBlock.Bellatrix.Block.Body.ExecutionPayload.BlockHash),
BlockNumber: uint64ToString(bellatrixBlock.Bellatrix.Block.Body.ExecutionPayload.BlockNumber),

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -28,14 +28,14 @@ func TestProposeBeaconBlock_BlindedBellatrix(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = blindedBellatrixBlock
jsonBlindedBellatrixBlock := &shared.SignedBlindedBeaconBlockBellatrix{
jsonBlindedBellatrixBlock := &structs.SignedBlindedBeaconBlockBellatrix{
Signature: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Signature),
Message: &shared.BlindedBeaconBlockBellatrix{
Message: &structs.BlindedBeaconBlockBellatrix{
ParentRoot: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.ParentRoot),
ProposerIndex: uint64ToString(blindedBellatrixBlock.BlindedBellatrix.Block.ProposerIndex),
Slot: uint64ToString(blindedBellatrixBlock.BlindedBellatrix.Block.Slot),
StateRoot: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.StateRoot),
Body: &shared.BlindedBeaconBlockBodyBellatrix{
Body: &structs.BlindedBeaconBlockBodyBellatrix{
Attestations: jsonifyAttestations(blindedBellatrixBlock.BlindedBellatrix.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(blindedBellatrixBlock.BlindedBellatrix.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(blindedBellatrixBlock.BlindedBellatrix.Block.Body.Deposits),
@@ -44,11 +44,11 @@ func TestProposeBeaconBlock_BlindedBellatrix(t *testing.T) {
ProposerSlashings: jsonifyProposerSlashings(blindedBellatrixBlock.BlindedBellatrix.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(blindedBellatrixBlock.BlindedBellatrix.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeader{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeader{
BaseFeePerGas: bytesutil.LittleEndianBytesToBigInt(blindedBellatrixBlock.BlindedBellatrix.Block.Body.ExecutionPayloadHeader.BaseFeePerGas).String(),
BlockHash: hexutil.Encode(blindedBellatrixBlock.BlindedBellatrix.Block.Body.ExecutionPayloadHeader.BlockHash),
BlockNumber: uint64ToString(blindedBellatrixBlock.BlindedBellatrix.Block.Body.ExecutionPayloadHeader.BlockNumber),

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -28,14 +28,14 @@ func TestProposeBeaconBlock_BlindedCapella(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = blindedCapellaBlock
jsonBlindedCapellaBlock := &shared.SignedBlindedBeaconBlockCapella{
jsonBlindedCapellaBlock := &structs.SignedBlindedBeaconBlockCapella{
Signature: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Signature),
Message: &shared.BlindedBeaconBlockCapella{
Message: &structs.BlindedBeaconBlockCapella{
ParentRoot: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.ParentRoot),
ProposerIndex: uint64ToString(blindedCapellaBlock.BlindedCapella.Block.ProposerIndex),
Slot: uint64ToString(blindedCapellaBlock.BlindedCapella.Block.Slot),
StateRoot: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.StateRoot),
Body: &shared.BlindedBeaconBlockBodyCapella{
Body: &structs.BlindedBeaconBlockBodyCapella{
Attestations: jsonifyAttestations(blindedCapellaBlock.BlindedCapella.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(blindedCapellaBlock.BlindedCapella.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(blindedCapellaBlock.BlindedCapella.Block.Body.Deposits),
@@ -44,11 +44,11 @@ func TestProposeBeaconBlock_BlindedCapella(t *testing.T) {
ProposerSlashings: jsonifyProposerSlashings(blindedCapellaBlock.BlindedCapella.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(blindedCapellaBlock.BlindedCapella.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeaderCapella{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeaderCapella{
BaseFeePerGas: bytesutil.LittleEndianBytesToBigInt(blindedCapellaBlock.BlindedCapella.Block.Body.ExecutionPayloadHeader.BaseFeePerGas).String(),
BlockHash: hexutil.Encode(blindedCapellaBlock.BlindedCapella.Block.Body.ExecutionPayloadHeader.BlockHash),
BlockNumber: uint64ToString(blindedCapellaBlock.BlindedCapella.Block.Body.ExecutionPayloadHeader.BlockNumber),

View File

@@ -7,7 +7,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
rpctesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared/testing"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -20,7 +20,7 @@ func TestProposeBeaconBlock_BlindedDeneb(t *testing.T) {
defer ctrl.Finish()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
var block shared.SignedBlindedBeaconBlockDeneb
var block structs.SignedBlindedBeaconBlockDeneb
err := json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block)
require.NoError(t, err)
genericSignedBlock, err := block.ToGeneric()

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -27,14 +27,14 @@ func TestProposeBeaconBlock_Capella(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = capellaBlock
jsonCapellaBlock := &shared.SignedBeaconBlockCapella{
jsonCapellaBlock := &structs.SignedBeaconBlockCapella{
Signature: hexutil.Encode(capellaBlock.Capella.Signature),
Message: &shared.BeaconBlockCapella{
Message: &structs.BeaconBlockCapella{
ParentRoot: hexutil.Encode(capellaBlock.Capella.Block.ParentRoot),
ProposerIndex: uint64ToString(capellaBlock.Capella.Block.ProposerIndex),
Slot: uint64ToString(capellaBlock.Capella.Block.Slot),
StateRoot: hexutil.Encode(capellaBlock.Capella.Block.StateRoot),
Body: &shared.BeaconBlockBodyCapella{
Body: &structs.BeaconBlockBodyCapella{
Attestations: jsonifyAttestations(capellaBlock.Capella.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(capellaBlock.Capella.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(capellaBlock.Capella.Block.Body.Deposits),
@@ -43,11 +43,11 @@ func TestProposeBeaconBlock_Capella(t *testing.T) {
ProposerSlashings: jsonifyProposerSlashings(capellaBlock.Capella.Block.Body.ProposerSlashings),
RandaoReveal: hexutil.Encode(capellaBlock.Capella.Block.Body.RandaoReveal),
VoluntaryExits: JsonifySignedVoluntaryExits(capellaBlock.Capella.Block.Body.VoluntaryExits),
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: hexutil.Encode(capellaBlock.Capella.Block.Body.SyncAggregate.SyncCommitteeBits),
SyncCommitteeSignature: hexutil.Encode(capellaBlock.Capella.Block.Body.SyncAggregate.SyncCommitteeSignature),
},
ExecutionPayload: &shared.ExecutionPayloadCapella{
ExecutionPayload: &structs.ExecutionPayloadCapella{
BaseFeePerGas: bytesutil.LittleEndianBytesToBigInt(capellaBlock.Capella.Block.Body.ExecutionPayload.BaseFeePerGas).String(),
BlockHash: hexutil.Encode(capellaBlock.Capella.Block.Body.ExecutionPayload.BlockHash),
BlockNumber: uint64ToString(capellaBlock.Capella.Block.Body.ExecutionPayload.BlockNumber),

View File

@@ -7,7 +7,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
rpctesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared/testing"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -21,7 +21,7 @@ func TestProposeBeaconBlock_Deneb(t *testing.T) {
defer ctrl.Finish()
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
var blockContents shared.SignedBeaconBlockContentsDeneb
var blockContents structs.SignedBeaconBlockContentsDeneb
err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &blockContents)
require.NoError(t, err)
genericSignedBlock, err := blockContents.ToGeneric()

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -26,14 +26,14 @@ func TestProposeBeaconBlock_Phase0(t *testing.T) {
genericSignedBlock := &ethpb.GenericSignedBeaconBlock{}
genericSignedBlock.Block = phase0Block
jsonPhase0Block := &shared.SignedBeaconBlock{
jsonPhase0Block := &structs.SignedBeaconBlock{
Signature: hexutil.Encode(phase0Block.Phase0.Signature),
Message: &shared.BeaconBlock{
Message: &structs.BeaconBlock{
ParentRoot: hexutil.Encode(phase0Block.Phase0.Block.ParentRoot),
ProposerIndex: uint64ToString(phase0Block.Phase0.Block.ProposerIndex),
Slot: uint64ToString(phase0Block.Phase0.Block.Slot),
StateRoot: hexutil.Encode(phase0Block.Phase0.Block.StateRoot),
Body: &shared.BeaconBlockBody{
Body: &structs.BeaconBlockBody{
Attestations: jsonifyAttestations(phase0Block.Phase0.Block.Body.Attestations),
AttesterSlashings: jsonifyAttesterSlashings(phase0Block.Phase0.Block.Body.AttesterSlashings),
Deposits: jsonifyDeposits(phase0Block.Phase0.Block.Body.Deposits),

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -21,8 +21,8 @@ func (c beaconApiValidatorClient) proposeExit(ctx context.Context, signedVolunta
return nil, errors.New("exit is nil")
}
jsonSignedVoluntaryExit := shared.SignedVoluntaryExit{
Message: &shared.VoluntaryExit{
jsonSignedVoluntaryExit := structs.SignedVoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: strconv.FormatUint(uint64(signedVoluntaryExit.Exit.Epoch), 10),
ValidatorIndex: strconv.FormatUint(uint64(signedVoluntaryExit.Exit.ValidatorIndex), 10),
},

View File

@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -24,8 +24,8 @@ func TestProposeExit_Valid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
jsonSignedVoluntaryExit := shared.SignedVoluntaryExit{
Message: &shared.VoluntaryExit{
jsonSignedVoluntaryExit := structs.SignedVoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "1",
ValidatorIndex: "2",
},

View File

@@ -8,7 +8,7 @@ import (
"strings"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
validator2 "github.com/prysmaticlabs/prysm/v4/consensus-types/validator"
"github.com/prysmaticlabs/prysm/v4/validator/client/iface"
)
@@ -44,7 +44,7 @@ func (c prysmBeaconChainClient) GetValidatorCount(ctx context.Context, stateID s
queryUrl := buildURL(fmt.Sprintf("/eth/v1/beacon/states/%s/validator_count", stateID), queryParams)
var validatorCountResponse validator.CountResponse
var validatorCountResponse structs.GetValidatorCountResponse
if err = c.jsonRestHandler.Get(ctx, queryUrl, &validatorCountResponse); err != nil {
return nil, err
}

View File

@@ -6,17 +6,17 @@ import (
"encoding/json"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
func (c *beaconApiValidatorClient) submitValidatorRegistrations(ctx context.Context, registrations []*ethpb.SignedValidatorRegistrationV1) error {
const endpoint = "/eth/v1/validator/register_validator"
jsonRegistration := make([]*shared.SignedValidatorRegistration, len(registrations))
jsonRegistration := make([]*structs.SignedValidatorRegistration, len(registrations))
for index, registration := range registrations {
jsonRegistration[index] = shared.SignedValidatorRegistrationFromConsensus(registration)
jsonRegistration[index] = structs.SignedValidatorRegistrationFromConsensus(registration)
}
marshalledJsonRegistration, err := json.Marshal(jsonRegistration)

View File

@@ -10,7 +10,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -33,9 +33,9 @@ func TestRegistration_Valid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
jsonRegistrations := []*shared.SignedValidatorRegistration{
jsonRegistrations := []*structs.SignedValidatorRegistration{
{
Message: &shared.ValidatorRegistration{
Message: &structs.ValidatorRegistration{
FeeRecipient: feeRecipient1,
GasLimit: "100",
Timestamp: "1000",
@@ -44,7 +44,7 @@ func TestRegistration_Valid(t *testing.T) {
Signature: signature1,
},
{
Message: &shared.ValidatorRegistration{
Message: &structs.ValidatorRegistration{
FeeRecipient: feeRecipient2,
GasLimit: "200",
Timestamp: "2000",
@@ -53,7 +53,7 @@ func TestRegistration_Valid(t *testing.T) {
Signature: signature2,
},
{
Message: &shared.ValidatorRegistration{
Message: &structs.ValidatorRegistration{
FeeRecipient: feeRecipient3,
GasLimit: "300",
Timestamp: "3000",

View File

@@ -8,14 +8,14 @@ import (
"strconv"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
)
type StateValidatorsProvider interface {
GetStateValidators(context.Context, []string, []primitives.ValidatorIndex, []string) (*beacon.GetValidatorsResponse, error)
GetStateValidatorsForSlot(context.Context, primitives.Slot, []string, []primitives.ValidatorIndex, []string) (*beacon.GetValidatorsResponse, error)
GetStateValidatorsForHead(context.Context, []string, []primitives.ValidatorIndex, []string) (*beacon.GetValidatorsResponse, error)
GetStateValidators(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
GetStateValidatorsForSlot(context.Context, primitives.Slot, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
GetStateValidatorsForHead(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
}
type beaconApiStateValidatorsProvider struct {
@@ -27,7 +27,7 @@ func (c beaconApiStateValidatorsProvider) GetStateValidators(
stringPubkeys []string,
indexes []primitives.ValidatorIndex,
statuses []string,
) (*beacon.GetValidatorsResponse, error) {
) (*structs.GetValidatorsResponse, error) {
stringIndices := convertValidatorIndicesToStrings(indexes)
return c.getStateValidatorsHelper(ctx, "/eth/v1/beacon/states/head/validators", append(stringIndices, stringPubkeys...), statuses)
}
@@ -38,7 +38,7 @@ func (c beaconApiStateValidatorsProvider) GetStateValidatorsForSlot(
stringPubkeys []string,
indices []primitives.ValidatorIndex,
statuses []string,
) (*beacon.GetValidatorsResponse, error) {
) (*structs.GetValidatorsResponse, error) {
stringIndices := convertValidatorIndicesToStrings(indices)
url := fmt.Sprintf("/eth/v1/beacon/states/%d/validators", slot)
return c.getStateValidatorsHelper(ctx, url, append(stringIndices, stringPubkeys...), statuses)
@@ -49,7 +49,7 @@ func (c beaconApiStateValidatorsProvider) GetStateValidatorsForHead(
stringPubkeys []string,
indices []primitives.ValidatorIndex,
statuses []string,
) (*beacon.GetValidatorsResponse, error) {
) (*structs.GetValidatorsResponse, error) {
stringIndices := convertValidatorIndicesToStrings(indices)
return c.getStateValidatorsHelper(ctx, "/eth/v1/beacon/states/head/validators", append(stringIndices, stringPubkeys...), statuses)
}
@@ -71,8 +71,8 @@ func (c beaconApiStateValidatorsProvider) getStateValidatorsHelper(
endpoint string,
vals []string,
statuses []string,
) (*beacon.GetValidatorsResponse, error) {
req := beacon.GetValidatorsRequest{
) (*structs.GetValidatorsResponse, error) {
req := structs.GetValidatorsRequest{
Ids: []string{},
Statuses: []string{},
}
@@ -90,7 +90,7 @@ func (c beaconApiStateValidatorsProvider) getStateValidatorsHelper(
if err != nil {
return nil, errors.Wrapf(err, "failed to marshal request into JSON")
}
stateValidatorsJson := &beacon.GetValidatorsResponse{}
stateValidatorsJson := &structs.GetValidatorsResponse{}
if err = c.jsonRestHandler.Post(ctx, endpoint, nil, bytes.NewBuffer(reqBytes), stateValidatorsJson); err != nil {
return nil, err
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -19,7 +19,7 @@ func TestGetStateValidators_Nominal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
req := &beacon.GetValidatorsRequest{
req := &structs.GetValidatorsRequest{
Ids: []string{
"12345",
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13",
@@ -32,35 +32,35 @@ func TestGetStateValidators_Nominal(t *testing.T) {
reqBytes, err := json.Marshal(req)
require.NoError(t, err)
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
wanted := []*beacon.ValidatorContainer{
wanted := []*structs.ValidatorContainer{
{
Index: "12345",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be19",
},
},
{
Index: "55293",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13",
},
},
{
Index: "55294",
Status: "active_exiting",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x80000e851c0f53c3246ff726d7ff7766661ca5e12a07c45c114d208d54f0f8233d4380b2e9aff759d69795d1df905526",
},
},
{
Index: "55295",
Status: "exited_slashed",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x800015473bdc3a7f45ef8eb8abc598bc20021e55ad6e6ad1d745aaef9730dd2c28ec08bf42df18451de94dd4a6d24ec5",
},
},
@@ -78,7 +78,7 @@ func TestGetStateValidators_Nominal(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
structs.GetValidatorsResponse{
Data: wanted,
},
).Times(1)
@@ -105,14 +105,14 @@ func TestGetStateValidators_GetRestJsonResponseOnError(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
req := &beacon.GetValidatorsRequest{
req := &structs.GetValidatorsRequest{
Ids: []string{"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13"},
Statuses: []string{},
}
reqBytes, err := json.Marshal(req)
require.NoError(t, err)
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
ctx := context.Background()
@@ -141,7 +141,7 @@ func TestGetStateValidators_DataIsNil(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
req := &beacon.GetValidatorsRequest{
req := &structs.GetValidatorsRequest{
Ids: []string{"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13"},
Statuses: []string{},
}
@@ -149,7 +149,7 @@ func TestGetStateValidators_DataIsNil(t *testing.T) {
require.NoError(t, err)
ctx := context.Background()
stateValidatorsResponseJson := beacon.GetValidatorsResponse{}
stateValidatorsResponseJson := structs.GetValidatorsResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Post(
@@ -161,7 +161,7 @@ func TestGetStateValidators_DataIsNil(t *testing.T) {
nil,
).SetArg(
4,
beacon.GetValidatorsResponse{
structs.GetValidatorsResponse{
Data: nil,
},
).Times(1)

View File

@@ -6,13 +6,11 @@ import (
"fmt"
"testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
validator2 "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/validator/client/iface"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -39,12 +37,12 @@ func TestValidatorStatus_Nominal(t *testing.T) {
nil,
nil,
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "35000",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringValidatorPubKey,
ActivationEpoch: "56",
},
@@ -65,7 +63,7 @@ func TestValidatorStatus_Nominal(t *testing.T) {
}
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",
@@ -104,7 +102,7 @@ func TestValidatorStatus_Error(t *testing.T) {
nil,
nil,
).Return(
&beacon.GetValidatorsResponse{},
&structs.GetValidatorsResponse{},
errors.New("a specific error"),
).Times(1)
@@ -146,12 +144,12 @@ func TestMultipleValidatorStatus_Nominal(t *testing.T) {
[]primitives.ValidatorIndex{},
nil,
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "11111",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13",
ActivationEpoch: "12",
},
@@ -159,7 +157,7 @@ func TestMultipleValidatorStatus_Nominal(t *testing.T) {
{
Index: "22222",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000a6c975761b488bdb0dfba4ed37c0d97d6e6b968562ef5c84aa9a5dfb92d8e309195004e97709077723739bf04463",
ActivationEpoch: "34",
},
@@ -172,7 +170,7 @@ func TestMultipleValidatorStatus_Nominal(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",
@@ -231,7 +229,7 @@ func TestMultipleValidatorStatus_Error(t *testing.T) {
[]primitives.ValidatorIndex{},
nil,
).Return(
&beacon.GetValidatorsResponse{},
&structs.GetValidatorsResponse{},
errors.New("a specific error"),
).Times(1)
@@ -283,12 +281,12 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
validatorsIndex,
nil,
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "11111",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13",
ActivationEpoch: "12",
},
@@ -296,7 +294,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
{
Index: "22222",
Status: "active_exiting",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x800010c20716ef4264a6d93b3873a008ece58fb9312ac2cc3b0ccc40aedb050f2038281e6a92242a35476af9903c7919",
ActivationEpoch: "34",
},
@@ -304,7 +302,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
{
Index: "33333",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: extraStringValidatorKey,
ActivationEpoch: "56",
},
@@ -312,7 +310,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
{
Index: "40000",
Status: "pending_queued",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000a6c975761b488bdb0dfba4ed37c0d97d6e6b968562ef5c84aa9a5dfb92d8e309195004e97709077723739bf04463",
ActivationEpoch: fmt.Sprintf("%d", params.BeaconConfig().FarFutureEpoch),
},
@@ -320,7 +318,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
{
Index: "50000",
Status: "pending_queued",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000ab56b051f9d8f31c687528c6e91c9b98e4c3a241e752f9ccfbea7c5a7fbbd272bdf2c0a7e52ce7e0b57693df364c",
ActivationEpoch: fmt.Sprintf("%d", params.BeaconConfig().FarFutureEpoch),
},
@@ -333,7 +331,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",
@@ -342,10 +340,10 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
nil,
).SetArg(
2,
node.GetVersionResponse{Data: &node.Version{Version: "prysm/v0.0.1"}},
structs.GetVersionResponse{Data: &structs.Version{Version: "prysm/v0.0.1"}},
).Times(1)
var validatorCountResponse validator2.CountResponse
var validatorCountResponse structs.GetValidatorCountResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/beacon/states/head/validator_count?",
@@ -354,8 +352,8 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
nil,
).SetArg(
2,
validator2.CountResponse{
Data: []*validator2.Count{
structs.GetValidatorCountResponse{
Data: []*structs.ValidatorCount{
{
Status: "active",
Count: "50001",
@@ -463,12 +461,12 @@ func TestGetValidatorsStatusResponse_Nominal_NoActiveValidators(t *testing.T) {
nil,
nil,
).Return(
&beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
&structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "40000",
Status: "pending_queued",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "0x8000a6c975761b488bdb0dfba4ed37c0d97d6e6b968562ef5c84aa9a5dfb92d8e309195004e97709077723739bf04463",
ActivationEpoch: fmt.Sprintf("%d", params.BeaconConfig().FarFutureEpoch),
},
@@ -481,7 +479,7 @@ func TestGetValidatorsStatusResponse_Nominal_NoActiveValidators(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",
@@ -524,7 +522,7 @@ type getStateValidatorsInterface struct {
inputStatuses []string
// Outputs
outputStateValidatorsResponseJson *beacon.GetValidatorsResponse
outputStateValidatorsResponseJson *structs.GetValidatorsResponse
outputErr error
}
@@ -551,7 +549,7 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputGetStateValidatorsInterface: getStateValidatorsInterface{
inputStringPubKeys: []string{stringPubKey},
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{},
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{},
outputErr: errors.New("a specific error"),
},
outputErrMessage: "failed to get state validators",
@@ -566,11 +564,11 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputStatuses: nil,
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "0",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: "NotAPublicKey",
},
},
@@ -592,11 +590,11 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputStatuses: nil,
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "NotAnIndex",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -617,12 +615,12 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputStatuses: nil,
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "12345",
Status: "NotAStatus",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -643,12 +641,12 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputStatuses: nil,
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "12345",
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
ActivationEpoch: "NotAnEpoch",
},
@@ -685,8 +683,8 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
inputIndexes: nil,
inputStatuses: nil,
outputStateValidatorsResponseJson: &beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
outputStateValidatorsResponseJson: &structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: "NotAnIndex",
},
@@ -720,7 +718,7 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",

View File

@@ -9,8 +9,8 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/events"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"google.golang.org/grpc"
@@ -75,7 +75,7 @@ func (c *streamSlotsClient) Recv() (*ethpb.StreamSlotsResponse, error) {
if rawEvent.eventType != events.HeadTopic {
continue
}
e := &events.HeadEvent{}
e := &structs.HeadEvent{}
if err := json.Unmarshal([]byte(rawEvent.data), e); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal head event into JSON")
}
@@ -131,7 +131,7 @@ func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context)
switch signedBlockResponseJson.Version {
case "phase0":
jsonPhase0Block := shared.SignedBeaconBlock{}
jsonPhase0Block := structs.SignedBeaconBlock{}
if err := decoder.Decode(&jsonPhase0Block); err != nil {
return nil, errors.Wrap(err, "failed to decode signed phase0 block response json")
}
@@ -156,7 +156,7 @@ func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context)
slot = phase0Block.Slot
case "altair":
jsonAltairBlock := shared.SignedBeaconBlockAltair{}
jsonAltairBlock := structs.SignedBeaconBlockAltair{}
if err := decoder.Decode(&jsonAltairBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode signed altair block response json")
}
@@ -181,7 +181,7 @@ func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context)
slot = altairBlock.Slot
case "bellatrix":
jsonBellatrixBlock := shared.SignedBeaconBlockBellatrix{}
jsonBellatrixBlock := structs.SignedBeaconBlockBellatrix{}
if err := decoder.Decode(&jsonBellatrixBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode signed bellatrix block response json")
}
@@ -206,7 +206,7 @@ func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context)
slot = bellatrixBlock.Slot
case "capella":
jsonCapellaBlock := shared.SignedBeaconBlockCapella{}
jsonCapellaBlock := structs.SignedBeaconBlockCapella{}
if err := decoder.Decode(&jsonCapellaBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode signed capella block response json")
}
@@ -230,7 +230,7 @@ func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context)
slot = capellaBlock.Slot
case "deneb":
jsonDenebBlock := shared.SignedBeaconBlockDeneb{}
jsonDenebBlock := structs.SignedBeaconBlockDeneb{}
if err := decoder.Decode(&jsonDenebBlock); err != nil {
return nil, errors.Wrap(err, "failed to decode signed deneb block response json")
}

View File

@@ -10,7 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
rpctesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared/testing"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -122,7 +122,7 @@ func TestStreamBlocks_Error(t *testing.T) {
expectedErrorMessage: "failed to get signed %s block",
conversionError: errors.New("foo"),
generateData: func(consensusVersion string) []byte {
blockBytes, err := json.Marshal(shared.SignedBeaconBlock{Signature: "0x01"})
blockBytes, err := json.Marshal(structs.SignedBeaconBlock{Signature: "0x01"})
require.NoError(t, err)
return blockBytes
},
@@ -131,7 +131,7 @@ func TestStreamBlocks_Error(t *testing.T) {
name: "signature decoding failed",
expectedErrorMessage: "failed to decode %s block signature `foo`",
generateData: func(consensusVersion string) []byte {
blockBytes, err := json.Marshal(shared.SignedBeaconBlock{Signature: "foo"})
blockBytes, err := json.Marshal(structs.SignedBeaconBlock{Signature: "foo"})
require.NoError(t, err)
return blockBytes
},
@@ -205,7 +205,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
phase0BeaconBlock1 := test_helpers.GenerateJsonPhase0BeaconBlock()
phase0BeaconBlock1.Slot = "1"
signedBeaconBlockContainer1 := shared.SignedBeaconBlock{
signedBeaconBlockContainer1 := structs.SignedBeaconBlock{
Message: phase0BeaconBlock1,
Signature: "0x01",
}
@@ -242,7 +242,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
phase0BeaconBlock2 := test_helpers.GenerateJsonPhase0BeaconBlock()
phase0BeaconBlock2.Slot = "2"
signedBeaconBlockContainer2 := shared.SignedBeaconBlock{
signedBeaconBlockContainer2 := structs.SignedBeaconBlock{
Message: phase0BeaconBlock2,
Signature: "0x02",
}
@@ -366,7 +366,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
altairBeaconBlock1 := test_helpers.GenerateJsonAltairBeaconBlock()
altairBeaconBlock1.Slot = "1"
signedBeaconBlockContainer1 := shared.SignedBeaconBlockAltair{
signedBeaconBlockContainer1 := structs.SignedBeaconBlockAltair{
Message: altairBeaconBlock1,
Signature: "0x01",
}
@@ -403,7 +403,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
altairBeaconBlock2 := test_helpers.GenerateJsonAltairBeaconBlock()
altairBeaconBlock2.Slot = "2"
signedBeaconBlockContainer2 := shared.SignedBeaconBlockAltair{
signedBeaconBlockContainer2 := structs.SignedBeaconBlockAltair{
Message: altairBeaconBlock2,
Signature: "0x02",
}
@@ -527,7 +527,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
bellatrixBeaconBlock1 := test_helpers.GenerateJsonBellatrixBeaconBlock()
bellatrixBeaconBlock1.Slot = "1"
signedBeaconBlockContainer1 := shared.SignedBeaconBlockBellatrix{
signedBeaconBlockContainer1 := structs.SignedBeaconBlockBellatrix{
Message: bellatrixBeaconBlock1,
Signature: "0x01",
}
@@ -564,7 +564,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
bellatrixBeaconBlock2 := test_helpers.GenerateJsonBellatrixBeaconBlock()
bellatrixBeaconBlock2.Slot = "2"
signedBeaconBlockContainer2 := shared.SignedBeaconBlockBellatrix{
signedBeaconBlockContainer2 := structs.SignedBeaconBlockBellatrix{
Message: bellatrixBeaconBlock2,
Signature: "0x02",
}
@@ -688,7 +688,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
capellaBeaconBlock1 := test_helpers.GenerateJsonCapellaBeaconBlock()
capellaBeaconBlock1.Slot = "1"
signedBeaconBlockContainer1 := shared.SignedBeaconBlockCapella{
signedBeaconBlockContainer1 := structs.SignedBeaconBlockCapella{
Message: capellaBeaconBlock1,
Signature: "0x01",
}
@@ -725,7 +725,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
capellaBeaconBlock2 := test_helpers.GenerateJsonCapellaBeaconBlock()
capellaBeaconBlock2.Slot = "2"
signedBeaconBlockContainer2 := shared.SignedBeaconBlockCapella{
signedBeaconBlockContainer2 := structs.SignedBeaconBlockCapella{
Message: capellaBeaconBlock2,
Signature: "0x02",
}
@@ -847,7 +847,7 @@ func TestStreamBlocks_DenebValid(t *testing.T) {
// For the first call, return a block that satisfies the verifiedOnly condition. This block should be returned by the first Recv().
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
var blockContents shared.SignedBeaconBlockContentsDeneb
var blockContents structs.SignedBeaconBlockContentsDeneb
err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &blockContents)
require.NoError(t, err)
sig := "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"
@@ -875,7 +875,7 @@ func TestStreamBlocks_DenebValid(t *testing.T) {
// For the third call, return a block with a different slot than the previous one, but with the verifiedOnly condition not satisfied.
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
var blockContents2 shared.SignedBeaconBlockContentsDeneb
var blockContents2 structs.SignedBeaconBlockContentsDeneb
err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &blockContents2)
require.NoError(t, err)
sig2 := "0x2b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"

View File

@@ -7,11 +7,12 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/time/slots"
"github.com/sirupsen/logrus"
)
func (c *beaconApiValidatorClient) submitAggregateSelectionProof(ctx context.Context, in *ethpb.AggregateSelectionRequest) (*ethpb.AggregateSelectionResponse, error) {
@@ -65,6 +66,7 @@ func (c *beaconApiValidatorClient) submitAggregateSelectionProof(ctx context.Con
return nil, errors.Wrap(err, "failed to calculate attestation data root")
}
logrus.Infof("Aggregator requested attestation %#x", attestationDataRoot)
aggregateAttestationResponse, err := c.getAggregateAttestation(ctx, in.Slot, attestationDataRoot[:])
if err != nil {
return nil, err
@@ -88,13 +90,13 @@ func (c *beaconApiValidatorClient) getAggregateAttestation(
ctx context.Context,
slot primitives.Slot,
attestationDataRoot []byte,
) (*validator.AggregateAttestationResponse, error) {
) (*structs.AggregateAttestationResponse, error) {
params := url.Values{}
params.Add("slot", strconv.FormatUint(uint64(slot), 10))
params.Add("attestation_data_root", hexutil.Encode(attestationDataRoot))
endpoint := buildURL("/eth/v1/validator/aggregate_attestation", params)
var aggregateAttestationResponse validator.AggregateAttestationResponse
var aggregateAttestationResponse structs.AggregateAttestationResponse
if err := c.jsonRestHandler.Get(ctx, endpoint, &aggregateAttestationResponse); err != nil {
return nil, err
}

View File

@@ -10,9 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -36,7 +34,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
committeeIndex = primitives.CommitteeIndex(1)
)
attesterDuties := []*validator.AttesterDuty{
attesterDuties := []*structs.AttesterDuty{
{
Pubkey: pubkeyStr,
ValidatorIndex: validatorIndex,
@@ -69,7 +67,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
dutiesErr error
attestationDataErr error
aggregateAttestationErr error
duties []*validator.AttesterDuty
duties []*structs.AttesterDuty
validatorsCalled int
attesterDutiesCalled int
attestationDataCalled int
@@ -129,7 +127,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
},
{
name: "validator is not an aggregator",
duties: []*validator.AttesterDuty{
duties: []*structs.AttesterDuty{
{
Pubkey: pubkeyStr,
ValidatorIndex: validatorIndex,
@@ -144,7 +142,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
},
{
name: "no attester duties",
duties: []*validator.AttesterDuty{},
duties: []*structs.AttesterDuty{},
validatorsCalled: 1,
attesterDutiesCalled: 1,
expectedErrorMsg: fmt.Sprintf("no attester duty for the given slot %d", slot),
@@ -160,11 +158,11 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
syncingEndpoint,
&node.SyncStatusResponse{},
&structs.SyncStatusResponse{},
).SetArg(
2,
node.SyncStatusResponse{
Data: &node.SyncStatusResponseData{
structs.SyncStatusResponse{
Data: &structs.SyncStatusResponseData{
IsOptimistic: test.isOptimistic,
},
},
@@ -172,7 +170,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
test.syncingErr,
).Times(1)
valsReq := &beacon.GetValidatorsRequest{
valsReq := &structs.GetValidatorsRequest{
Ids: []string{stringPubKey},
Statuses: []string{},
}
@@ -185,15 +183,15 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
validatorsEndpoint,
nil,
bytes.NewBuffer(valReqBytes),
&beacon.GetValidatorsResponse{},
&structs.GetValidatorsResponse{},
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: validatorIndex,
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: pubkeyStr,
},
},
@@ -211,10 +209,10 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
fmt.Sprintf("%s/%d", attesterDutiesEndpoint, slots.ToEpoch(slot)),
nil,
bytes.NewBuffer(validatorIndicesBytes),
&validator.GetAttesterDutiesResponse{},
&structs.GetAttesterDutiesResponse{},
).SetArg(
4,
validator.GetAttesterDutiesResponse{
structs.GetAttesterDutiesResponse{
Data: test.duties,
},
).Return(
@@ -225,7 +223,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("%s?committee_index=%d&slot=%d", attestationDataEndpoint, committeeIndex, slot),
&validator.GetAttestationDataResponse{},
&structs.GetAttestationDataResponse{},
).SetArg(
2,
attestationDataResponse,
@@ -237,10 +235,10 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
fmt.Sprintf("%s?attestation_data_root=%s&slot=%d", aggregateAttestationEndpoint, hexutil.Encode(attestationDataRootBytes[:]), slot),
&validator.AggregateAttestationResponse{},
&structs.AggregateAttestationResponse{},
).SetArg(
2,
validator.AggregateAttestationResponse{
structs.AggregateAttestationResponse{
Data: jsonifyAttestation(aggregateAttestation),
},
).Return(

View File

@@ -6,12 +6,12 @@ import (
"encoding/json"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
func (c *beaconApiValidatorClient) submitSignedAggregateSelectionProof(ctx context.Context, in *ethpb.SignedAggregateSubmitRequest) (*ethpb.SignedAggregateSubmitResponse, error) {
body, err := json.Marshal([]*shared.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(in.SignedAggregateAndProof)})
body, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(in.SignedAggregateAndProof)})
if err != nil {
return nil, errors.Wrap(err, "failed to marshal SignedAggregateAttestationAndProof")
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -21,7 +21,7 @@ func TestSubmitSignedAggregateSelectionProof_Valid(t *testing.T) {
defer ctrl.Finish()
signedAggregateAndProof := generateSignedAggregateAndProofJson()
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*shared.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
require.NoError(t, err)
ctx := context.Background()
@@ -53,7 +53,7 @@ func TestSubmitSignedAggregateSelectionProof_BadRequest(t *testing.T) {
defer ctrl.Finish()
signedAggregateAndProof := generateSignedAggregateAndProofJson()
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*shared.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
marshalledSignedAggregateSignedAndProof, err := json.Marshal([]*structs.SignedAggregateAttestationAndProof{jsonifySignedAggregateAndProof(signedAggregateAndProof)})
require.NoError(t, err)
ctx := context.Background()

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -25,11 +25,11 @@ func (c beaconApiValidatorClient) submitSignedContributionAndProof(ctx context.C
return errors.New("signed contribution and proof contribution is nil")
}
jsonContributionAndProofs := []shared.SignedContributionAndProof{
jsonContributionAndProofs := []structs.SignedContributionAndProof{
{
Message: &shared.ContributionAndProof{
Message: &structs.ContributionAndProof{
AggregatorIndex: strconv.FormatUint(uint64(in.Message.AggregatorIndex), 10),
Contribution: &shared.SyncCommitteeContribution{
Contribution: &structs.SyncCommitteeContribution{
Slot: strconv.FormatUint(uint64(in.Message.Contribution.Slot), 10),
BeaconBlockRoot: hexutil.Encode(in.Message.Contribution.BlockRoot),
SubcommitteeIndex: strconv.FormatUint(in.Message.Contribution.SubcommitteeIndex, 10),

View File

@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -22,11 +22,11 @@ func TestSubmitSignedContributionAndProof_Valid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
jsonContributionAndProofs := []shared.SignedContributionAndProof{
jsonContributionAndProofs := []structs.SignedContributionAndProof{
{
Message: &shared.ContributionAndProof{
Message: &structs.ContributionAndProof{
AggregatorIndex: "1",
Contribution: &shared.SyncCommitteeContribution{
Contribution: &structs.SyncCommitteeContribution{
Slot: "2",
BeaconBlockRoot: hexutil.Encode([]byte{3}),
SubcommitteeIndex: "4",

View File

@@ -7,7 +7,7 @@ import (
"strconv"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -23,7 +23,7 @@ func (c beaconApiValidatorClient) subscribeCommitteeSubnets(ctx context.Context,
}
slotToCommitteesAtSlotMap := make(map[primitives.Slot]uint64)
jsonCommitteeSubscriptions := make([]*shared.BeaconCommitteeSubscription, len(in.CommitteeIds))
jsonCommitteeSubscriptions := make([]*structs.BeaconCommitteeSubscription, len(in.CommitteeIds))
for index := range in.CommitteeIds {
subscribeSlot := in.Slots[index]
subscribeCommitteeId := in.CommitteeIds[index]
@@ -59,7 +59,7 @@ func (c beaconApiValidatorClient) subscribeCommitteeSubnets(ctx context.Context,
}
}
jsonCommitteeSubscriptions[index] = &shared.BeaconCommitteeSubscription{
jsonCommitteeSubscriptions[index] = &structs.BeaconCommitteeSubscription{
CommitteeIndex: strconv.FormatUint(uint64(subscribeCommitteeId), 10),
CommitteesAtSlot: strconv.FormatUint(committeesAtSlot, 10),
Slot: strconv.FormatUint(uint64(subscribeSlot), 10),

View File

@@ -9,8 +9,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -31,9 +30,9 @@ func TestSubscribeCommitteeSubnets_Valid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
jsonCommitteeSubscriptions := make([]*shared.BeaconCommitteeSubscription, len(subscribeSlots))
jsonCommitteeSubscriptions := make([]*structs.BeaconCommitteeSubscription, len(subscribeSlots))
for index := range jsonCommitteeSubscriptions {
jsonCommitteeSubscriptions[index] = &shared.BeaconCommitteeSubscription{
jsonCommitteeSubscriptions[index] = &structs.BeaconCommitteeSubscription{
ValidatorIndex: strconv.FormatUint(uint64(validatorIndices[index]), 10),
CommitteeIndex: strconv.FormatUint(uint64(committeeIndices[index]), 10),
CommitteesAtSlot: strconv.FormatUint(committeesAtSlot[index], 10),
@@ -58,9 +57,9 @@ func TestSubscribeCommitteeSubnets_Valid(t *testing.T) {
nil,
).Times(1)
duties := make([]*validator.AttesterDuty, len(subscribeSlots))
duties := make([]*structs.AttesterDuty, len(subscribeSlots))
for index := range duties {
duties[index] = &validator.AttesterDuty{
duties[index] = &structs.AttesterDuty{
ValidatorIndex: strconv.FormatUint(uint64(validatorIndices[index]), 10),
CommitteeIndex: strconv.FormatUint(uint64(committeeIndices[index]), 10),
CommitteesAtSlot: strconv.FormatUint(committeesAtSlot[index], 10),
@@ -75,7 +74,7 @@ func TestSubscribeCommitteeSubnets_Valid(t *testing.T) {
slots.ToEpoch(subscribeSlots[0]),
validatorIndices,
).Return(
[]*validator.AttesterDuty{
[]*structs.AttesterDuty{
{
CommitteesAtSlot: strconv.FormatUint(committeesAtSlot[0], 10),
Slot: strconv.FormatUint(uint64(subscribeSlots[0]), 10),
@@ -93,7 +92,7 @@ func TestSubscribeCommitteeSubnets_Valid(t *testing.T) {
slots.ToEpoch(subscribeSlots[2]),
validatorIndices,
).Return(
[]*validator.AttesterDuty{
[]*structs.AttesterDuty{
{
CommitteesAtSlot: strconv.FormatUint(committeesAtSlot[2], 10),
Slot: strconv.FormatUint(uint64(subscribeSlots[2]), 10),
@@ -125,7 +124,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
name string
subscribeRequest *ethpb.CommitteeSubnetsSubscribeRequest
validatorIndices []primitives.ValidatorIndex
attesterDuty *validator.AttesterDuty
attesterDuty *structs.AttesterDuty
dutiesError error
expectGetDutiesQuery bool
expectSubscribeRestCall bool
@@ -196,7 +195,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
IsAggregator: []bool{false},
},
validatorIndices: []primitives.ValidatorIndex{3},
attesterDuty: &validator.AttesterDuty{
attesterDuty: &structs.AttesterDuty{
Slot: "foo",
CommitteesAtSlot: "1",
},
@@ -211,7 +210,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
IsAggregator: []bool{false},
},
validatorIndices: []primitives.ValidatorIndex{3},
attesterDuty: &validator.AttesterDuty{
attesterDuty: &structs.AttesterDuty{
Slot: "1",
CommitteesAtSlot: "foo",
},
@@ -226,7 +225,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
IsAggregator: []bool{false},
},
validatorIndices: []primitives.ValidatorIndex{3},
attesterDuty: &validator.AttesterDuty{
attesterDuty: &structs.AttesterDuty{
Slot: "2",
CommitteesAtSlot: "3",
},
@@ -241,7 +240,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
IsAggregator: []bool{false},
},
validatorIndices: []primitives.ValidatorIndex{3},
attesterDuty: &validator.AttesterDuty{
attesterDuty: &structs.AttesterDuty{
Slot: "1",
CommitteesAtSlot: "2",
},
@@ -265,7 +264,7 @@ func TestSubscribeCommitteeSubnets_Error(t *testing.T) {
gomock.Any(),
gomock.Any(),
).Return(
[]*validator.AttesterDuty{testCase.attesterDuty},
[]*structs.AttesterDuty{testCase.attesterDuty},
testCase.dutiesError,
).Times(1)
}

View File

@@ -9,9 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -20,14 +18,14 @@ import (
func (c *beaconApiValidatorClient) submitSyncMessage(ctx context.Context, syncMessage *ethpb.SyncCommitteeMessage) error {
const endpoint = "/eth/v1/beacon/pool/sync_committees"
jsonSyncCommitteeMessage := &shared.SyncCommitteeMessage{
jsonSyncCommitteeMessage := &structs.SyncCommitteeMessage{
Slot: strconv.FormatUint(uint64(syncMessage.Slot), 10),
BeaconBlockRoot: hexutil.Encode(syncMessage.BlockRoot),
ValidatorIndex: strconv.FormatUint(uint64(syncMessage.ValidatorIndex), 10),
Signature: hexutil.Encode(syncMessage.Signature),
}
marshalledJsonSyncCommitteeMessage, err := json.Marshal([]*shared.SyncCommitteeMessage{jsonSyncCommitteeMessage})
marshalledJsonSyncCommitteeMessage, err := json.Marshal([]*structs.SyncCommitteeMessage{jsonSyncCommitteeMessage})
if err != nil {
return errors.Wrap(err, "failed to marshal sync committee message")
}
@@ -37,7 +35,7 @@ func (c *beaconApiValidatorClient) submitSyncMessage(ctx context.Context, syncMe
func (c *beaconApiValidatorClient) getSyncMessageBlockRoot(ctx context.Context) (*ethpb.SyncMessageBlockRootResponse, error) {
// Get head beacon block root.
var resp beacon.BlockRootResponse
var resp structs.BlockRootResponse
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/beacon/blocks/head/root", &resp); err != nil {
return nil, err
}
@@ -84,7 +82,7 @@ func (c *beaconApiValidatorClient) getSyncCommitteeContribution(
url := buildURL("/eth/v1/validator/sync_committee_contribution", params)
var resp validator.ProduceSyncCommitteeContributionResponse
var resp structs.ProduceSyncCommitteeContributionResponse
if err = c.jsonRestHandler.Get(ctx, url, &resp); err != nil {
return nil, err
}
@@ -123,7 +121,7 @@ func (c *beaconApiValidatorClient) getSyncSubcommitteeIndex(ctx context.Context,
return &ethpb.SyncSubcommitteeIndexResponse{Indices: indices}, nil
}
func convertSyncContributionJsonToProto(contribution *shared.SyncCommitteeContribution) (*ethpb.SyncCommitteeContribution, error) {
func convertSyncContributionJsonToProto(contribution *structs.SyncCommitteeContribution) (*ethpb.SyncCommitteeContribution, error) {
if contribution == nil {
return nil, errors.New("sync committee contribution is nil")
}

View File

@@ -11,9 +11,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
@@ -35,14 +33,14 @@ func TestSubmitSyncMessage_Valid(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
jsonSyncCommitteeMessage := &shared.SyncCommitteeMessage{
jsonSyncCommitteeMessage := &structs.SyncCommitteeMessage{
Slot: "42",
BeaconBlockRoot: beaconBlockRoot,
ValidatorIndex: "12345",
Signature: signature,
}
marshalledJsonRegistrations, err := json.Marshal([]*shared.SyncCommitteeMessage{jsonSyncCommitteeMessage})
marshalledJsonRegistrations, err := json.Marshal([]*structs.SyncCommitteeMessage{jsonSyncCommitteeMessage})
require.NoError(t, err)
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
@@ -99,12 +97,12 @@ func TestGetSyncMessageBlockRoot(t *testing.T) {
name string
endpointError error
expectedErrorMessage string
expectedResponse beacon.BlockRootResponse
expectedResponse structs.BlockRootResponse
}{
{
name: "valid request",
expectedResponse: beacon.BlockRootResponse{
Data: &beacon.BlockRoot{
expectedResponse: structs.BlockRootResponse{
Data: &structs.BlockRoot{
Root: blockRoot,
},
},
@@ -116,20 +114,20 @@ func TestGetSyncMessageBlockRoot(t *testing.T) {
},
{
name: "execution optimistic",
expectedResponse: beacon.BlockRootResponse{
expectedResponse: structs.BlockRootResponse{
ExecutionOptimistic: true,
},
expectedErrorMessage: "the node is currently optimistic and cannot serve validators",
},
{
name: "no data",
expectedResponse: beacon.BlockRootResponse{},
expectedResponse: structs.BlockRootResponse{},
expectedErrorMessage: "no data returned",
},
{
name: "no root",
expectedResponse: beacon.BlockRootResponse{
Data: new(beacon.BlockRoot),
expectedResponse: structs.BlockRootResponse{
Data: new(structs.BlockRoot),
},
expectedErrorMessage: "no root returned",
},
@@ -142,7 +140,7 @@ func TestGetSyncMessageBlockRoot(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/beacon/blocks/head/root",
&beacon.BlockRootResponse{},
&structs.BlockRootResponse{},
).SetArg(
2,
test.expectedResponse,
@@ -180,7 +178,7 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
SubnetId: 1,
}
contributionJson := &shared.SyncCommitteeContribution{
contributionJson := &structs.SyncCommitteeContribution{
Slot: "1",
BeaconBlockRoot: blockRoot,
SubcommitteeIndex: "1",
@@ -190,13 +188,13 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
tests := []struct {
name string
contribution validator.ProduceSyncCommitteeContributionResponse
contribution structs.ProduceSyncCommitteeContributionResponse
endpointErr error
expectedErrMsg string
}{
{
name: "valid request",
contribution: validator.ProduceSyncCommitteeContributionResponse{Data: contributionJson},
contribution: structs.ProduceSyncCommitteeContributionResponse{Data: contributionJson},
},
{
name: "bad request",
@@ -212,11 +210,11 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/beacon/blocks/head/root",
&beacon.BlockRootResponse{},
&structs.BlockRootResponse{},
).SetArg(
2,
beacon.BlockRootResponse{
Data: &beacon.BlockRoot{
structs.BlockRootResponse{
Data: &structs.BlockRoot{
Root: blockRoot,
},
},
@@ -228,7 +226,7 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
ctx,
fmt.Sprintf("/eth/v1/validator/sync_committee_contribution?beacon_block_root=%s&slot=%d&subcommittee_index=%d",
blockRoot, uint64(request.Slot), request.SubnetId),
&validator.ProduceSyncCommitteeContributionResponse{},
&structs.ProduceSyncCommitteeContributionResponse{},
).SetArg(
2,
test.contribution,
@@ -264,7 +262,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
Indices: []primitives.CommitteeIndex{123, 456},
}
syncDuties := []*validator.SyncCommitteeDuty{
syncDuties := []*structs.SyncCommitteeDuty{
{
Pubkey: hexutil.Encode([]byte{1}),
ValidatorIndex: validatorIndex,
@@ -280,7 +278,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
tests := []struct {
name string
duties []*validator.SyncCommitteeDuty
duties []*structs.SyncCommitteeDuty
validatorsErr error
dutiesErr error
expectedErrorMsg string
@@ -291,7 +289,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
},
{
name: "no sync duties",
duties: []*validator.SyncCommitteeDuty{},
duties: []*structs.SyncCommitteeDuty{},
expectedErrorMsg: fmt.Sprintf("no sync committee duty for the given slot %d", slot),
},
{
@@ -309,7 +307,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ctx := context.Background()
valsReq := &beacon.GetValidatorsRequest{
valsReq := &structs.GetValidatorsRequest{
Ids: []string{pubkeyStr},
Statuses: []string{},
}
@@ -321,15 +319,15 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
validatorsEndpoint,
nil,
bytes.NewBuffer(valsReqBytes),
&beacon.GetValidatorsResponse{},
&structs.GetValidatorsResponse{},
).SetArg(
4,
beacon.GetValidatorsResponse{
Data: []*beacon.ValidatorContainer{
structs.GetValidatorsResponse{
Data: []*structs.ValidatorContainer{
{
Index: validatorIndex,
Status: "active_ongoing",
Validator: &beacon.Validator{
Validator: &structs.Validator{
Pubkey: stringPubKey,
},
},
@@ -352,10 +350,10 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
fmt.Sprintf("%s/%d", syncDutiesEndpoint, slots.ToEpoch(slot)),
nil,
bytes.NewBuffer(validatorIndicesBytes),
&validator.GetSyncCommitteeDutiesResponse{},
&structs.GetSyncCommitteeDutiesResponse{},
).SetArg(
4,
validator.GetSyncCommitteeDutiesResponse{
structs.GetSyncCommitteeDutiesResponse{
Data: test.duties,
},
).Return(

View File

@@ -14,7 +14,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/test-helpers",
visibility = ["//validator:__subpackages__"],
deps = [
"//beacon-chain/rpc/eth/shared:go_default_library",
"//api/server/structs:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",

View File

@@ -1,7 +1,7 @@
package test_helpers
import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -219,24 +219,24 @@ func GenerateProtoAltairBeaconBlock() *ethpb.BeaconBlockAltair {
}
}
func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
return &shared.BeaconBlockAltair{
func GenerateJsonAltairBeaconBlock() *structs.BeaconBlockAltair {
return &structs.BeaconBlockAltair{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BeaconBlockBodyAltair{
Body: &structs.BeaconBlockBodyAltair{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -245,8 +245,8 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -257,8 +257,8 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -267,8 +267,8 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -279,36 +279,36 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -317,34 +317,34 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -353,18 +353,18 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -373,15 +373,15 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -389,10 +389,10 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -401,7 +401,7 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -409,23 +409,23 @@ func GenerateJsonAltairBeaconBlock() *shared.BeaconBlockAltair {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},

View File

@@ -1,7 +1,7 @@
package test_helpers
import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -470,24 +470,24 @@ func GenerateProtoBlindedBellatrixBeaconBlock() *ethpb.BlindedBeaconBlockBellatr
}
}
func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
return &shared.BeaconBlockBellatrix{
func GenerateJsonBellatrixBeaconBlock() *structs.BeaconBlockBellatrix {
return &structs.BeaconBlockBellatrix{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BeaconBlockBodyBellatrix{
Body: &structs.BeaconBlockBodyBellatrix{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -496,8 +496,8 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -508,8 +508,8 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -518,8 +518,8 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -530,36 +530,36 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -568,34 +568,34 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -604,18 +604,18 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -624,15 +624,15 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -640,10 +640,10 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -652,7 +652,7 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -660,27 +660,27 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayload: &shared.ExecutionPayload{
ExecutionPayload: &structs.ExecutionPayload{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),
@@ -703,24 +703,24 @@ func GenerateJsonBellatrixBeaconBlock() *shared.BeaconBlockBellatrix {
}
}
func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatrix {
return &shared.BlindedBeaconBlockBellatrix{
func GenerateJsonBlindedBellatrixBeaconBlock() *structs.BlindedBeaconBlockBellatrix {
return &structs.BlindedBeaconBlockBellatrix{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BlindedBeaconBlockBodyBellatrix{
Body: &structs.BlindedBeaconBlockBodyBellatrix{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -729,8 +729,8 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -741,8 +741,8 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -751,8 +751,8 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -763,36 +763,36 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -801,34 +801,34 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -837,18 +837,18 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -857,15 +857,15 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -873,10 +873,10 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -885,7 +885,7 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -893,27 +893,27 @@ func GenerateJsonBlindedBellatrixBeaconBlock() *shared.BlindedBeaconBlockBellatr
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeader{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeader{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),

View File

@@ -1,7 +1,7 @@
package test_helpers
import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -521,24 +521,24 @@ func GenerateProtoBlindedCapellaBeaconBlock() *ethpb.BlindedBeaconBlockCapella {
}
}
func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
return &shared.BeaconBlockCapella{
func GenerateJsonCapellaBeaconBlock() *structs.BeaconBlockCapella {
return &structs.BeaconBlockCapella{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BeaconBlockBodyCapella{
Body: &structs.BeaconBlockBodyCapella{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -547,8 +547,8 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -559,8 +559,8 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -569,8 +569,8 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -581,36 +581,36 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -619,34 +619,34 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -655,18 +655,18 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -675,15 +675,15 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -691,10 +691,10 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -703,7 +703,7 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -711,27 +711,27 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayload: &shared.ExecutionPayloadCapella{
ExecutionPayload: &structs.ExecutionPayloadCapella{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),
@@ -749,7 +749,7 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
FillEncodedByteSlice(32, 125),
FillEncodedByteSlice(32, 126),
},
Withdrawals: []*shared.Withdrawal{
Withdrawals: []*structs.Withdrawal{
{
WithdrawalIndex: "127",
ValidatorIndex: "128",
@@ -764,9 +764,9 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
},
},
},
BLSToExecutionChanges: []*shared.SignedBLSToExecutionChange{
BLSToExecutionChanges: []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "135",
FromBLSPubkey: FillEncodedByteSlice(48, 136),
ToExecutionAddress: FillEncodedByteSlice(20, 137),
@@ -774,7 +774,7 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
Signature: FillEncodedByteSlice(96, 138),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "139",
FromBLSPubkey: FillEncodedByteSlice(48, 140),
ToExecutionAddress: FillEncodedByteSlice(20, 141),
@@ -786,24 +786,24 @@ func GenerateJsonCapellaBeaconBlock() *shared.BeaconBlockCapella {
}
}
func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
return &shared.BlindedBeaconBlockCapella{
func GenerateJsonBlindedCapellaBeaconBlock() *structs.BlindedBeaconBlockCapella {
return &structs.BlindedBeaconBlockCapella{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BlindedBeaconBlockBodyCapella{
Body: &structs.BlindedBeaconBlockBodyCapella{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -812,8 +812,8 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -824,8 +824,8 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -834,8 +834,8 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -846,36 +846,36 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -884,34 +884,34 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -920,18 +920,18 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -940,15 +940,15 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -956,10 +956,10 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -968,7 +968,7 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -976,27 +976,27 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeaderCapella{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeaderCapella{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),
@@ -1013,9 +1013,9 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
TransactionsRoot: FillEncodedByteSlice(32, 125),
WithdrawalsRoot: FillEncodedByteSlice(32, 126),
},
BLSToExecutionChanges: []*shared.SignedBLSToExecutionChange{
BLSToExecutionChanges: []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "135",
FromBLSPubkey: FillEncodedByteSlice(48, 136),
ToExecutionAddress: FillEncodedByteSlice(20, 137),
@@ -1023,7 +1023,7 @@ func GenerateJsonBlindedCapellaBeaconBlock() *shared.BlindedBeaconBlockCapella {
Signature: FillEncodedByteSlice(96, 138),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "139",
FromBLSPubkey: FillEncodedByteSlice(48, 140),
ToExecutionAddress: FillEncodedByteSlice(20, 141),

View File

@@ -1,7 +1,7 @@
package test_helpers
import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
@@ -531,25 +531,25 @@ func GenerateProtoBlindedDenebBeaconBlock() *ethpb.BlindedBeaconBlockDeneb {
}
}
func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
return &shared.BeaconBlockContentsDeneb{
Block: &shared.BeaconBlockDeneb{
func GenerateJsonDenebBeaconBlockContents() *structs.BeaconBlockContentsDeneb {
return &structs.BeaconBlockContentsDeneb{
Block: &structs.BeaconBlockDeneb{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BeaconBlockBodyDeneb{
Body: &structs.BeaconBlockBodyDeneb{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -558,8 +558,8 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -570,8 +570,8 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -580,8 +580,8 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -592,36 +592,36 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -630,34 +630,34 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -666,18 +666,18 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -686,15 +686,15 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -702,10 +702,10 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -714,7 +714,7 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -722,27 +722,27 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayload: &shared.ExecutionPayloadDeneb{
ExecutionPayload: &structs.ExecutionPayloadDeneb{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),
@@ -760,7 +760,7 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
FillEncodedByteSlice(32, 125),
FillEncodedByteSlice(32, 126),
},
Withdrawals: []*shared.Withdrawal{
Withdrawals: []*structs.Withdrawal{
{
WithdrawalIndex: "127",
ValidatorIndex: "128",
@@ -777,9 +777,9 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
BlobGasUsed: "135",
ExcessBlobGas: "136",
},
BLSToExecutionChanges: []*shared.SignedBLSToExecutionChange{
BLSToExecutionChanges: []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "137",
FromBLSPubkey: FillEncodedByteSlice(48, 138),
ToExecutionAddress: FillEncodedByteSlice(20, 139),
@@ -787,7 +787,7 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
Signature: FillEncodedByteSlice(96, 140),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "141",
FromBLSPubkey: FillEncodedByteSlice(48, 142),
ToExecutionAddress: FillEncodedByteSlice(20, 143),
@@ -803,24 +803,24 @@ func GenerateJsonDenebBeaconBlockContents() *shared.BeaconBlockContentsDeneb {
}
}
func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
return &shared.BlindedBeaconBlockDeneb{
func GenerateJsonBlindedDenebBeaconBlock() *structs.BlindedBeaconBlockDeneb {
return &structs.BlindedBeaconBlockDeneb{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BlindedBeaconBlockBodyDeneb{
Body: &structs.BlindedBeaconBlockBodyDeneb{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -829,8 +829,8 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -841,8 +841,8 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -851,8 +851,8 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -863,36 +863,36 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -901,34 +901,34 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -937,18 +937,18 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(4, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -957,15 +957,15 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -973,10 +973,10 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -985,7 +985,7 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -993,27 +993,27 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},
Signature: FillEncodedByteSlice(96, 109),
},
},
SyncAggregate: &shared.SyncAggregate{
SyncAggregate: &structs.SyncAggregate{
SyncCommitteeBits: FillEncodedByteSlice(64, 110),
SyncCommitteeSignature: FillEncodedByteSlice(96, 111),
},
ExecutionPayloadHeader: &shared.ExecutionPayloadHeaderDeneb{
ExecutionPayloadHeader: &structs.ExecutionPayloadHeaderDeneb{
ParentHash: FillEncodedByteSlice(32, 112),
FeeRecipient: FillEncodedByteSlice(20, 113),
StateRoot: FillEncodedByteSlice(32, 114),
@@ -1032,9 +1032,9 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
BlobGasUsed: "127",
ExcessBlobGas: "128",
},
BLSToExecutionChanges: []*shared.SignedBLSToExecutionChange{
BLSToExecutionChanges: []*structs.SignedBLSToExecutionChange{
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "129",
FromBLSPubkey: FillEncodedByteSlice(48, 130),
ToExecutionAddress: FillEncodedByteSlice(20, 131),
@@ -1042,7 +1042,7 @@ func GenerateJsonBlindedDenebBeaconBlock() *shared.BlindedBeaconBlockDeneb {
Signature: FillEncodedByteSlice(96, 132),
},
{
Message: &shared.BLSToExecutionChange{
Message: &structs.BLSToExecutionChange{
ValidatorIndex: "133",
FromBLSPubkey: FillEncodedByteSlice(48, 134),
ToExecutionAddress: FillEncodedByteSlice(20, 135),

View File

@@ -1,7 +1,7 @@
package test_helpers
import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
@@ -215,24 +215,24 @@ func GenerateProtoPhase0BeaconBlock() *ethpb.BeaconBlock {
}
}
func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
return &shared.BeaconBlock{
func GenerateJsonPhase0BeaconBlock() *structs.BeaconBlock {
return &structs.BeaconBlock{
Slot: "1",
ProposerIndex: "2",
ParentRoot: FillEncodedByteSlice(32, 3),
StateRoot: FillEncodedByteSlice(32, 4),
Body: &shared.BeaconBlockBody{
Body: &structs.BeaconBlockBody{
RandaoReveal: FillEncodedByteSlice(96, 5),
Eth1Data: &shared.Eth1Data{
Eth1Data: &structs.Eth1Data{
DepositRoot: FillEncodedByteSlice(32, 6),
DepositCount: "7",
BlockHash: FillEncodedByteSlice(32, 8),
},
Graffiti: FillEncodedByteSlice(32, 9),
ProposerSlashings: []*shared.ProposerSlashing{
ProposerSlashings: []*structs.ProposerSlashing{
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "10",
ProposerIndex: "11",
ParentRoot: FillEncodedByteSlice(32, 12),
@@ -241,8 +241,8 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
Signature: FillEncodedByteSlice(96, 15),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "16",
ProposerIndex: "17",
ParentRoot: FillEncodedByteSlice(32, 18),
@@ -253,8 +253,8 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
},
{
SignedHeader1: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader1: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "22",
ProposerIndex: "23",
ParentRoot: FillEncodedByteSlice(32, 24),
@@ -263,8 +263,8 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
Signature: FillEncodedByteSlice(96, 27),
},
SignedHeader2: &shared.SignedBeaconBlockHeader{
Message: &shared.BeaconBlockHeader{
SignedHeader2: &structs.SignedBeaconBlockHeader{
Message: &structs.BeaconBlockHeader{
Slot: "28",
ProposerIndex: "29",
ParentRoot: FillEncodedByteSlice(32, 30),
@@ -275,36 +275,36 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
},
},
AttesterSlashings: []*shared.AttesterSlashing{
AttesterSlashings: []*structs.AttesterSlashing{
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"34", "35"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "36",
CommitteeIndex: "37",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "39",
Root: FillEncodedByteSlice(32, 40),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "41",
Root: FillEncodedByteSlice(32, 42),
},
},
Signature: FillEncodedByteSlice(96, 43),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"44", "45"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "46",
CommitteeIndex: "47",
BeaconBlockRoot: FillEncodedByteSlice(32, 48),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "49",
Root: FillEncodedByteSlice(32, 50),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "51",
Root: FillEncodedByteSlice(32, 52),
},
@@ -313,34 +313,34 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
},
{
Attestation1: &shared.IndexedAttestation{
Attestation1: &structs.IndexedAttestation{
AttestingIndices: []string{"54", "55"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "56",
CommitteeIndex: "57",
BeaconBlockRoot: FillEncodedByteSlice(32, 58),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "59",
Root: FillEncodedByteSlice(32, 60),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "61",
Root: FillEncodedByteSlice(32, 62),
},
},
Signature: FillEncodedByteSlice(96, 63),
},
Attestation2: &shared.IndexedAttestation{
Attestation2: &structs.IndexedAttestation{
AttestingIndices: []string{"64", "65"},
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "66",
CommitteeIndex: "67",
BeaconBlockRoot: FillEncodedByteSlice(32, 68),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "69",
Root: FillEncodedByteSlice(32, 70),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "71",
Root: FillEncodedByteSlice(32, 72),
},
@@ -349,18 +349,18 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
},
},
Attestations: []*shared.Attestation{
Attestations: []*structs.Attestation{
{
AggregationBits: FillEncodedByteSlice(32, 74),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "75",
CommitteeIndex: "76",
BeaconBlockRoot: FillEncodedByteSlice(32, 77),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "78",
Root: FillEncodedByteSlice(32, 79),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "80",
Root: FillEncodedByteSlice(32, 81),
},
@@ -369,15 +369,15 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
{
AggregationBits: FillEncodedByteSlice(4, 83),
Data: &shared.AttestationData{
Data: &structs.AttestationData{
Slot: "84",
CommitteeIndex: "85",
BeaconBlockRoot: FillEncodedByteSlice(32, 38),
Source: &shared.Checkpoint{
Source: &structs.Checkpoint{
Epoch: "87",
Root: FillEncodedByteSlice(32, 88),
},
Target: &shared.Checkpoint{
Target: &structs.Checkpoint{
Epoch: "89",
Root: FillEncodedByteSlice(32, 90),
},
@@ -385,10 +385,10 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
Signature: FillEncodedByteSlice(96, 91),
},
},
Deposits: []*shared.Deposit{
Deposits: []*structs.Deposit{
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 92)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 94),
WithdrawalCredentials: FillEncodedByteSlice(32, 95),
Amount: "96",
@@ -397,7 +397,7 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
{
Proof: FillEncodedByteArraySlice(33, FillEncodedByteSlice(32, 98)),
Data: &shared.DepositData{
Data: &structs.DepositData{
Pubkey: FillEncodedByteSlice(48, 100),
WithdrawalCredentials: FillEncodedByteSlice(32, 101),
Amount: "102",
@@ -405,16 +405,16 @@ func GenerateJsonPhase0BeaconBlock() *shared.BeaconBlock {
},
},
},
VoluntaryExits: []*shared.SignedVoluntaryExit{
VoluntaryExits: []*structs.SignedVoluntaryExit{
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "104",
ValidatorIndex: "105",
},
Signature: FillEncodedByteSlice(96, 106),
},
{
Message: &shared.VoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: "107",
ValidatorIndex: "108",
},

View File

@@ -6,8 +6,7 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node"
validator2 "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/consensus-types/validator"
"github.com/prysmaticlabs/prysm/v4/testing/require"
"github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api/mock"
@@ -21,21 +20,21 @@ func TestGetValidatorCount(t *testing.T) {
name string
versionEndpointError error
validatorCountEndpointError error
versionResponse node.GetVersionResponse
validatorCountResponse validator2.CountResponse
versionResponse structs.GetVersionResponse
validatorCountResponse structs.GetValidatorCountResponse
validatorCountCalled int
expectedResponse []iface.ValidatorCount
expectedError string
}{
{
name: "success",
versionResponse: node.GetVersionResponse{
Data: &node.Version{Version: nodeVersion},
versionResponse: structs.GetVersionResponse{
Data: &structs.Version{Version: nodeVersion},
},
validatorCountResponse: validator2.CountResponse{
validatorCountResponse: structs.GetValidatorCountResponse{
ExecutionOptimistic: "false",
Finalized: "true",
Data: []*validator2.Count{
Data: []*structs.ValidatorCount{
{
Status: "active",
Count: "10",
@@ -52,8 +51,8 @@ func TestGetValidatorCount(t *testing.T) {
},
{
name: "not supported beacon node",
versionResponse: node.GetVersionResponse{
Data: &node.Version{Version: "lighthouse/v0.0.1"},
versionResponse: structs.GetVersionResponse{
Data: &structs.Version{Version: "lighthouse/v0.0.1"},
},
expectedError: "endpoint not supported",
},
@@ -64,8 +63,8 @@ func TestGetValidatorCount(t *testing.T) {
},
{
name: "fails to get validator count",
versionResponse: node.GetVersionResponse{
Data: &node.Version{Version: nodeVersion},
versionResponse: structs.GetVersionResponse{
Data: &structs.Version{Version: nodeVersion},
},
validatorCountEndpointError: errors.New("foo error"),
validatorCountCalled: 1,
@@ -73,10 +72,10 @@ func TestGetValidatorCount(t *testing.T) {
},
{
name: "nil validator count data",
versionResponse: node.GetVersionResponse{
Data: &node.Version{Version: nodeVersion},
versionResponse: structs.GetVersionResponse{
Data: &structs.Version{Version: nodeVersion},
},
validatorCountResponse: validator2.CountResponse{
validatorCountResponse: structs.GetValidatorCountResponse{
ExecutionOptimistic: "false",
Finalized: "true",
Data: nil,
@@ -86,13 +85,13 @@ func TestGetValidatorCount(t *testing.T) {
},
{
name: "invalid validator count",
versionResponse: node.GetVersionResponse{
Data: &node.Version{Version: nodeVersion},
versionResponse: structs.GetVersionResponse{
Data: &structs.Version{Version: nodeVersion},
},
validatorCountResponse: validator2.CountResponse{
validatorCountResponse: structs.GetValidatorCountResponse{
ExecutionOptimistic: "false",
Finalized: "true",
Data: []*validator2.Count{
Data: []*structs.ValidatorCount{
{
Status: "active",
Count: "10",
@@ -117,7 +116,7 @@ func TestGetValidatorCount(t *testing.T) {
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// Expect node version endpoint call.
var nodeVersionResponse node.GetVersionResponse
var nodeVersionResponse structs.GetVersionResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/node/version",
@@ -129,7 +128,7 @@ func TestGetValidatorCount(t *testing.T) {
test.versionResponse,
)
var validatorCountResponse validator2.CountResponse
var validatorCountResponse structs.GetValidatorCountResponse
jsonRestHandler.EXPECT().Get(
ctx,
"/eth/v1/beacon/states/head/validator_count?status=active",

View File

@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/network/httputil"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
@@ -21,7 +21,7 @@ func TestWaitForChainStart_ValidGenesis(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -31,8 +31,8 @@ func TestWaitForChainStart_ValidGenesis(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetGenesisResponse{
Data: &beacon.Genesis{
structs.GetGenesisResponse{
Data: &structs.Genesis{
GenesisTime: "1234",
GenesisValidatorsRoot: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
},
@@ -56,7 +56,7 @@ func TestWaitForChainStart_ValidGenesis(t *testing.T) {
func TestWaitForChainStart_BadGenesis(t *testing.T) {
testCases := []struct {
name string
data *beacon.Genesis
data *structs.Genesis
errorMessage string
}{
{
@@ -66,7 +66,7 @@ func TestWaitForChainStart_BadGenesis(t *testing.T) {
},
{
name: "invalid time",
data: &beacon.Genesis{
data: &structs.Genesis{
GenesisTime: "foo",
GenesisValidatorsRoot: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
},
@@ -74,7 +74,7 @@ func TestWaitForChainStart_BadGenesis(t *testing.T) {
},
{
name: "invalid root",
data: &beacon.Genesis{
data: &structs.Genesis{
GenesisTime: "1234",
GenesisValidatorsRoot: "0xzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
},
@@ -88,7 +88,7 @@ func TestWaitForChainStart_BadGenesis(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -98,7 +98,7 @@ func TestWaitForChainStart_BadGenesis(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetGenesisResponse{
structs.GetGenesisResponse{
Data: testCase.data,
},
).Times(1)
@@ -116,7 +116,7 @@ func TestWaitForChainStart_JsonResponseError(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
jsonRestHandler.EXPECT().Get(
ctx,
@@ -139,7 +139,7 @@ func TestWaitForChainStart_JsonResponseError404(t *testing.T) {
defer ctrl.Finish()
ctx := context.Background()
genesisResponseJson := beacon.GetGenesisResponse{}
genesisResponseJson := structs.GetGenesisResponse{}
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl)
// First, mock a request that receives a 404 error (which means that the genesis data is not available yet)
@@ -163,8 +163,8 @@ func TestWaitForChainStart_JsonResponseError404(t *testing.T) {
nil,
).SetArg(
2,
beacon.GetGenesisResponse{
Data: &beacon.Genesis{
structs.GetGenesisResponse{
Data: &structs.Genesis{
GenesisTime: "1234",
GenesisValidatorsRoot: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
},

View File

@@ -26,6 +26,7 @@ go_library(
"//api/grpc:go_default_library",
"//api/pagination:go_default_library",
"//api/server:go_default_library",
"//api/server/structs:go_default_library",
"//async/event:go_default_library",
"//beacon-chain/rpc/eth/shared:go_default_library",
"//cmd:go_default_library",

View File

@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/config/params"
@@ -371,8 +372,8 @@ func (s *Server) SetVoluntaryExit(w http.ResponseWriter, r *http.Request) {
}
response := &SetVoluntaryExitResponse{
Data: &shared.SignedVoluntaryExit{
Message: &shared.VoluntaryExit{
Data: &structs.SignedVoluntaryExit{
Message: &structs.VoluntaryExit{
Epoch: fmt.Sprintf("%d", sve.Exit.Epoch),
ValidatorIndex: fmt.Sprintf("%d", sve.Exit.ValidatorIndex),
},

View File

@@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/api/server"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
@@ -45,7 +45,7 @@ type DeleteKeystoresResponse struct {
// voluntary exit keymanager api
type SetVoluntaryExitResponse struct {
Data *shared.SignedVoluntaryExit `json:"data"`
Data *structs.SignedVoluntaryExit `json:"data"`
}
// gas limit keymanager api