diff --git a/api/client/beacon/BUILD.bazel b/api/client/beacon/BUILD.bazel index 0750d28dda..001e9ae845 100644 --- a/api/client/beacon/BUILD.bazel +++ b/api/client/beacon/BUILD.bazel @@ -12,11 +12,8 @@ go_library( deps = [ "//api/client:go_default_library", "//api/server:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/core/helpers:go_default_library", - "//beacon-chain/rpc/eth/beacon:go_default_library", - "//beacon-chain/rpc/eth/config:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", - "//beacon-chain/rpc/prysm/beacon:go_default_library", "//beacon-chain/state:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", diff --git a/api/client/beacon/client.go b/api/client/beacon/client.go index 995fe9be43..c9224e1d28 100644 --- a/api/client/beacon/client.go +++ b/api/client/beacon/client.go @@ -17,10 +17,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api/client" "github.com/prysmaticlabs/prysm/v4/api/server" - "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/shared" - apibeacon "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/beacon" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v4/network/forks" @@ -150,8 +147,8 @@ func (c *Client) GetFork(ctx context.Context, stateId StateOrBlockId) (*ethpb.Fo if err != nil { return nil, errors.Wrapf(err, "error requesting fork by state id = %s", stateId) } - fr := &shared.Fork{} - dataWrapper := &struct{ Data *shared.Fork }{Data: fr} + fr := &structs.Fork{} + dataWrapper := &struct{ Data *structs.Fork }{Data: fr} err = json.Unmarshal(body, dataWrapper) if err != nil { return nil, errors.Wrap(err, "error decoding json response in GetFork") @@ -179,12 +176,12 @@ func (c *Client) GetForkSchedule(ctx context.Context) (forks.OrderedSchedule, er } // GetConfigSpec retrieve the current configs of the network used by the beacon node. -func (c *Client) GetConfigSpec(ctx context.Context) (*config.GetSpecResponse, error) { +func (c *Client) GetConfigSpec(ctx context.Context) (*structs.GetSpecResponse, error) { body, err := c.Get(ctx, getConfigSpecPath) if err != nil { return nil, errors.Wrap(err, "error requesting configSpecPath") } - fsr := &config.GetSpecResponse{} + fsr := &structs.GetSpecResponse{} err = json.Unmarshal(body, fsr) if err != nil { return nil, err @@ -259,7 +256,7 @@ func (c *Client) GetWeakSubjectivity(ctx context.Context) (*WeakSubjectivityData if err != nil { return nil, err } - v := &apibeacon.GetWeakSubjectivityResponse{} + v := &structs.GetWeakSubjectivityResponse{} err = json.Unmarshal(body, v) if err != nil { return nil, err @@ -285,7 +282,7 @@ func (c *Client) GetWeakSubjectivity(ctx context.Context) (*WeakSubjectivityData // SubmitChangeBLStoExecution calls a beacon API endpoint to set the withdrawal addresses based on the given signed messages. // If the API responds with something other than OK there will be failure messages associated to the corresponding request message. -func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*shared.SignedBLSToExecutionChange) error { +func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*structs.SignedBLSToExecutionChange) error { u := c.BaseURL().ResolveReference(&url.URL{Path: changeBLStoExecutionPath}) body, err := json.Marshal(request) if err != nil { @@ -324,12 +321,12 @@ func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*shar // GetBLStoExecutionChanges gets all the set withdrawal messages in the node's operation pool. // Returns a struct representation of json response. -func (c *Client) GetBLStoExecutionChanges(ctx context.Context) (*beacon.BLSToExecutionChangesPoolResponse, error) { +func (c *Client) GetBLStoExecutionChanges(ctx context.Context) (*structs.BLSToExecutionChangesPoolResponse, error) { body, err := c.Get(ctx, changeBLStoExecutionPath) if err != nil { return nil, err } - poolResponse := &beacon.BLSToExecutionChangesPoolResponse{} + poolResponse := &structs.BLSToExecutionChangesPoolResponse{} err = json.Unmarshal(body, poolResponse) if err != nil { return nil, err @@ -338,7 +335,7 @@ func (c *Client) GetBLStoExecutionChanges(ctx context.Context) (*beacon.BLSToExe } type forkScheduleResponse struct { - Data []shared.Fork + Data []structs.Fork } func (fsr *forkScheduleResponse) OrderedForkSchedule() (forks.OrderedSchedule, error) { diff --git a/api/client/builder/BUILD.bazel b/api/client/builder/BUILD.bazel index 79ff9739b3..f2723ccea0 100644 --- a/api/client/builder/BUILD.bazel +++ b/api/client/builder/BUILD.bazel @@ -11,7 +11,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v4/api/client/builder", visibility = ["//visibility:public"], deps = [ - "//beacon-chain/rpc/eth/shared:go_default_library", + "//api/server/structs:go_default_library", "//config/fieldparams:go_default_library", "//consensus-types:go_default_library", "//consensus-types/blocks:go_default_library", @@ -40,7 +40,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", "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", diff --git a/api/client/builder/client.go b/api/client/builder/client.go index 8b0a490bab..5415b3504f 100644 --- a/api/client/builder/client.go +++ b/api/client/builder/client.go @@ -14,7 +14,7 @@ import ( "text/template" "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/blocks" "github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" @@ -267,9 +267,9 @@ func (c *Client) RegisterValidator(ctx context.Context, svr []*ethpb.SignedValid tracing.AnnotateError(span, err) return err } - vs := make([]*shared.SignedValidatorRegistration, len(svr)) + vs := make([]*structs.SignedValidatorRegistration, len(svr)) for i := 0; i < len(svr); i++ { - vs[i] = shared.SignedValidatorRegistrationFromConsensus(svr[i]) + vs[i] = structs.SignedValidatorRegistrationFromConsensus(svr[i]) } body, err := json.Marshal(vs) if err != nil { @@ -294,7 +294,7 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS if err != nil { return nil, nil, errors.Wrapf(err, "could not get protobuf block") } - b, err := shared.SignedBlindedBeaconBlockBellatrixFromConsensus(ðpb.SignedBlindedBeaconBlockBellatrix{Block: psb.Block, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) + b, err := structs.SignedBlindedBeaconBlockBellatrixFromConsensus(ðpb.SignedBlindedBeaconBlockBellatrix{Block: psb.Block, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) if err != nil { return nil, nil, errors.Wrapf(err, "could not convert SignedBlindedBeaconBlockBellatrix to json marshalable type") } @@ -331,7 +331,7 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS if err != nil { return nil, nil, errors.Wrapf(err, "could not get protobuf block") } - b, err := shared.SignedBlindedBeaconBlockCapellaFromConsensus(ðpb.SignedBlindedBeaconBlockCapella{Block: psb.Block, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) + b, err := structs.SignedBlindedBeaconBlockCapellaFromConsensus(ðpb.SignedBlindedBeaconBlockCapella{Block: psb.Block, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) if err != nil { return nil, nil, errors.Wrapf(err, "could not convert SignedBlindedBeaconBlockCapella to json marshalable type") } @@ -368,7 +368,7 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS if err != nil { return nil, nil, errors.Wrapf(err, "could not get protobuf block") } - b, err := shared.SignedBlindedBeaconBlockDenebFromConsensus(ðpb.SignedBlindedBeaconBlockDeneb{Message: psb.Message, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) + b, err := structs.SignedBlindedBeaconBlockDenebFromConsensus(ðpb.SignedBlindedBeaconBlockDeneb{Message: psb.Message, Signature: bytesutil.SafeCopyBytes(psb.Signature)}) if err != nil { return nil, nil, errors.Wrapf(err, "could not convert SignedBlindedBeaconBlockDeneb to json marshalable type") } diff --git a/api/client/builder/client_test.go b/api/client/builder/client_test.go index 7f01aeef3e..3f8bd64413 100644 --- a/api/client/builder/client_test.go +++ b/api/client/builder/client_test.go @@ -13,7 +13,7 @@ import ( "testing" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" types "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" @@ -376,7 +376,7 @@ func TestSubmitBlindedBlock(t *testing.T) { Transport: roundtrip(func(r *http.Request) (*http.Response, error) { require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path) require.Equal(t, "deneb", r.Header.Get("Eth-Consensus-Version")) - var req shared.SignedBlindedBeaconBlockDeneb + var req structs.SignedBlindedBeaconBlockDeneb err := json.NewDecoder(r.Body).Decode(&req) require.NoError(t, err) block, err := req.ToConsensus() diff --git a/api/client/builder/types_test.go b/api/client/builder/types_test.go index d49336d5cc..e2bfe93e33 100644 --- a/api/client/builder/types_test.go +++ b/api/client/builder/types_test.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/go-bitfield" - "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/math" v1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1" @@ -38,7 +38,7 @@ func TestSignedValidatorRegistration_MarshalJSON(t *testing.T) { }, Signature: make([]byte, 96), } - a := shared.SignedValidatorRegistrationFromConsensus(svr) + a := structs.SignedValidatorRegistrationFromConsensus(svr) je, err := json.Marshal(a) require.NoError(t, err) // decode with a struct w/ plain strings so we can check the string encoding of the hex fields @@ -55,7 +55,7 @@ func TestSignedValidatorRegistration_MarshalJSON(t *testing.T) { require.Equal(t, "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", un.Message.Pubkey) t.Run("roundtrip", func(t *testing.T) { - b := &shared.SignedValidatorRegistration{} + b := &structs.SignedValidatorRegistration{} if err := json.Unmarshal(je, b); err != nil { require.NoError(t, err) } @@ -1718,7 +1718,7 @@ func TestUint256UnmarshalTooBig(t *testing.T) { func TestMarshalBlindedBeaconBlockBodyBellatrix(t *testing.T) { expected, err := os.ReadFile("testdata/blinded-block.json") require.NoError(t, err) - b, err := shared.BlindedBeaconBlockBellatrixFromConsensus(ð.BlindedBeaconBlockBellatrix{ + b, err := structs.BlindedBeaconBlockBellatrixFromConsensus(ð.BlindedBeaconBlockBellatrix{ Slot: 1, ProposerIndex: 1, ParentRoot: ezDecode(t, "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"), @@ -1748,7 +1748,7 @@ func TestMarshalBlindedBeaconBlockBodyBellatrix(t *testing.T) { func TestMarshalBlindedBeaconBlockBodyCapella(t *testing.T) { expected, err := os.ReadFile("testdata/blinded-block-capella.json") require.NoError(t, err) - b, err := shared.BlindedBeaconBlockCapellaFromConsensus(ð.BlindedBeaconBlockCapella{ + b, err := structs.BlindedBeaconBlockCapellaFromConsensus(ð.BlindedBeaconBlockCapella{ Slot: 1, ProposerIndex: 1, ParentRoot: ezDecode(t, "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"), diff --git a/api/server/structs/BUILD.bazel b/api/server/structs/BUILD.bazel new file mode 100644 index 0000000000..823bfe0225 --- /dev/null +++ b/api/server/structs/BUILD.bazel @@ -0,0 +1,40 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "block.go", + "conversions.go", + "conversions_block.go", + "conversions_state.go", + "endpoints_beacon.go", + "endpoints_blob.go", + "endpoints_builder.go", + "endpoints_config.go", + "endpoints_debug.go", + "endpoints_events.go", + "endpoints_lightclient.go", + "endpoints_node.go", + "endpoints_rewards.go", + "endpoints_validator.go", + "other.go", + "state.go", + ], + importpath = "github.com/prysmaticlabs/prysm/v4/api/server/structs", + visibility = ["//visibility:public"], + deps = [ + "//api/server:go_default_library", + "//beacon-chain/state:go_default_library", + "//config/fieldparams:go_default_library", + "//consensus-types/primitives:go_default_library", + "//consensus-types/validator:go_default_library", + "//container/slice:go_default_library", + "//encoding/bytesutil:go_default_library", + "//math:go_default_library", + "//proto/engine/v1:go_default_library", + "//proto/prysm/v1alpha1:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_pkg_errors//:go_default_library", + ], +) diff --git a/beacon-chain/rpc/eth/shared/structs_block.go b/api/server/structs/block.go similarity index 99% rename from beacon-chain/rpc/eth/shared/structs_block.go rename to api/server/structs/block.go index c911cac571..b5cfc1f27d 100644 --- a/beacon-chain/rpc/eth/shared/structs_block.go +++ b/api/server/structs/block.go @@ -1,4 +1,4 @@ -package shared +package structs type SignedBeaconBlock struct { Message *BeaconBlock `json:"message"` diff --git a/beacon-chain/rpc/eth/shared/conversions.go b/api/server/structs/conversions.go similarity index 99% rename from beacon-chain/rpc/eth/shared/conversions.go rename to api/server/structs/conversions.go index 3cb9a7ed8c..018b6e0f4e 100644 --- a/beacon-chain/rpc/eth/shared/conversions.go +++ b/api/server/structs/conversions.go @@ -1,4 +1,4 @@ -package shared +package structs import ( "fmt" @@ -23,7 +23,7 @@ var errNilValue = errors.New("nil value") func ValidatorFromConsensus(v *eth.Validator) *Validator { return &Validator{ - PublicKey: hexutil.Encode(v.PublicKey), + Pubkey: hexutil.Encode(v.PublicKey), WithdrawalCredentials: hexutil.Encode(v.WithdrawalCredentials), EffectiveBalance: fmt.Sprintf("%d", v.EffectiveBalance), Slashed: v.Slashed, diff --git a/beacon-chain/rpc/eth/shared/conversions_block.go b/api/server/structs/conversions_block.go similarity index 99% rename from beacon-chain/rpc/eth/shared/conversions_block.go rename to api/server/structs/conversions_block.go index 8529989700..cb9721b4fa 100644 --- a/beacon-chain/rpc/eth/shared/conversions_block.go +++ b/api/server/structs/conversions_block.go @@ -1,4 +1,4 @@ -package shared +package structs import ( "fmt" diff --git a/beacon-chain/rpc/eth/shared/conversions_state.go b/api/server/structs/conversions_state.go similarity index 99% rename from beacon-chain/rpc/eth/shared/conversions_state.go rename to api/server/structs/conversions_state.go index de0714a6c7..10535db476 100644 --- a/beacon-chain/rpc/eth/shared/conversions_state.go +++ b/api/server/structs/conversions_state.go @@ -1,4 +1,4 @@ -package shared +package structs import ( "errors" diff --git a/beacon-chain/rpc/eth/beacon/structs.go b/api/server/structs/endpoints_beacon.go similarity index 65% rename from beacon-chain/rpc/eth/beacon/structs.go rename to api/server/structs/endpoints_beacon.go index fc7c51681c..fcdec29645 100644 --- a/beacon-chain/rpc/eth/beacon/structs.go +++ b/api/server/structs/endpoints_beacon.go @@ -1,9 +1,7 @@ -package beacon +package structs import ( "encoding/json" - - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" ) type BlockRootResponse struct { @@ -17,31 +15,31 @@ type BlockRoot struct { } type GetCommitteesResponse struct { - Data []*shared.Committee `json:"data"` - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` + Data []*Committee `json:"data"` + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` } type ListAttestationsResponse struct { - Data []*shared.Attestation `json:"data"` + Data []*Attestation `json:"data"` } type SubmitAttestationsRequest struct { - Data []*shared.Attestation `json:"data"` + Data []*Attestation `json:"data"` } type ListVoluntaryExitsResponse struct { - Data []*shared.SignedVoluntaryExit `json:"data"` + Data []*SignedVoluntaryExit `json:"data"` } type SubmitSyncCommitteeSignaturesRequest struct { - Data []*shared.SyncCommitteeMessage `json:"data"` + Data []*SyncCommitteeMessage `json:"data"` } type GetStateForkResponse struct { - Data *shared.Fork `json:"data"` - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` + Data *Fork `json:"data"` + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` } type GetFinalityCheckpointsResponse struct { @@ -51,9 +49,9 @@ type GetFinalityCheckpointsResponse struct { } type FinalityCheckpoints struct { - PreviousJustified *shared.Checkpoint `json:"previous_justified"` - CurrentJustified *shared.Checkpoint `json:"current_justified"` - Finalized *shared.Checkpoint `json:"finalized"` + PreviousJustified *Checkpoint `json:"previous_justified"` + CurrentJustified *Checkpoint `json:"current_justified"` + Finalized *Checkpoint `json:"finalized"` } type GetGenesisResponse struct { @@ -67,15 +65,15 @@ type Genesis struct { } type GetBlockHeadersResponse struct { - Data []*shared.SignedBeaconBlockHeaderContainer `json:"data"` - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` + Data []*SignedBeaconBlockHeaderContainer `json:"data"` + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` } type GetBlockHeaderResponse struct { - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` - Data *shared.SignedBeaconBlockHeaderContainer `json:"data"` + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` + Data *SignedBeaconBlockHeaderContainer `json:"data"` } type GetValidatorsRequest struct { @@ -108,17 +106,6 @@ type ValidatorContainer struct { Validator *Validator `json:"validator"` } -type Validator struct { - Pubkey string `json:"pubkey"` - WithdrawalCredentials string `json:"withdrawal_credentials"` - EffectiveBalance string `json:"effective_balance"` - Slashed bool `json:"slashed"` - ActivationEligibilityEpoch string `json:"activation_eligibility_epoch"` - ActivationEpoch string `json:"activation_epoch"` - ExitEpoch string `json:"exit_epoch"` - WithdrawableEpoch string `json:"withdrawable_epoch"` -} - type ValidatorBalance struct { Index string `json:"index"` Balance string `json:"balance"` @@ -141,9 +128,9 @@ type SignedBlock struct { } type GetBlockAttestationsResponse struct { - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` - Data []*shared.Attestation `json:"data"` + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` + Data []*Attestation `json:"data"` } type GetStateRootResponse struct { @@ -178,13 +165,22 @@ type SyncCommitteeValidators struct { } type BLSToExecutionChangesPoolResponse struct { - Data []*shared.SignedBLSToExecutionChange `json:"data"` + Data []*SignedBLSToExecutionChange `json:"data"` } type GetAttesterSlashingsResponse struct { - Data []*shared.AttesterSlashing `json:"data"` + Data []*AttesterSlashing `json:"data"` } type GetProposerSlashingsResponse struct { - Data []*shared.ProposerSlashing `json:"data"` + Data []*ProposerSlashing `json:"data"` +} + +type GetWeakSubjectivityResponse struct { + Data *WeakSubjectivityData `json:"data"` +} + +type WeakSubjectivityData struct { + WsCheckpoint *Checkpoint `json:"ws_checkpoint"` + StateRoot string `json:"state_root"` } diff --git a/api/server/structs/endpoints_blob.go b/api/server/structs/endpoints_blob.go new file mode 100644 index 0000000000..2ea737945e --- /dev/null +++ b/api/server/structs/endpoints_blob.go @@ -0,0 +1,14 @@ +package structs + +type SidecarsResponse struct { + Data []*Sidecar `json:"data"` +} + +type Sidecar struct { + Index string `json:"index"` + Blob string `json:"blob"` + SignedBeaconBlockHeader *SignedBeaconBlockHeader `json:"signed_block_header"` + KzgCommitment string `json:"kzg_commitment"` + KzgProof string `json:"kzg_proof"` + CommitmentInclusionProof []string `json:"kzg_commitment_inclusion_proof"` +} diff --git a/beacon-chain/rpc/eth/builder/structs.go b/api/server/structs/endpoints_builder.go similarity index 96% rename from beacon-chain/rpc/eth/builder/structs.go rename to api/server/structs/endpoints_builder.go index a33b45a39f..e55af7cc9d 100644 --- a/beacon-chain/rpc/eth/builder/structs.go +++ b/api/server/structs/endpoints_builder.go @@ -1,4 +1,4 @@ -package builder +package structs type ExpectedWithdrawalsResponse struct { Data []*ExpectedWithdrawal `json:"data"` diff --git a/beacon-chain/rpc/eth/config/structs.go b/api/server/structs/endpoints_config.go similarity index 70% rename from beacon-chain/rpc/eth/config/structs.go rename to api/server/structs/endpoints_config.go index 8a7ca30ec4..12e9adf650 100644 --- a/beacon-chain/rpc/eth/config/structs.go +++ b/api/server/structs/endpoints_config.go @@ -1,6 +1,4 @@ -package config - -import "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" +package structs type GetDepositContractResponse struct { Data *DepositContractData `json:"data"` @@ -12,7 +10,7 @@ type DepositContractData struct { } type GetForkScheduleResponse struct { - Data []*shared.Fork `json:"data"` + Data []*Fork `json:"data"` } type GetSpecResponse struct { diff --git a/beacon-chain/rpc/eth/debug/structs.go b/api/server/structs/endpoints_debug.go similarity index 74% rename from beacon-chain/rpc/eth/debug/structs.go rename to api/server/structs/endpoints_debug.go index 7efb1436a7..fbcc3a6bbb 100644 --- a/beacon-chain/rpc/eth/debug/structs.go +++ b/api/server/structs/endpoints_debug.go @@ -1,9 +1,7 @@ -package debug +package structs import ( "encoding/json" - - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" ) type GetBeaconStateV2Response struct { @@ -24,18 +22,18 @@ type ForkChoiceHead struct { } type GetForkChoiceDumpResponse struct { - JustifiedCheckpoint *shared.Checkpoint `json:"justified_checkpoint"` - FinalizedCheckpoint *shared.Checkpoint `json:"finalized_checkpoint"` + JustifiedCheckpoint *Checkpoint `json:"justified_checkpoint"` + FinalizedCheckpoint *Checkpoint `json:"finalized_checkpoint"` ForkChoiceNodes []*ForkChoiceNode `json:"fork_choice_nodes"` ExtraData *ForkChoiceDumpExtraData `json:"extra_data"` } type ForkChoiceDumpExtraData struct { - UnrealizedJustifiedCheckpoint *shared.Checkpoint `json:"unrealized_justified_checkpoint"` - UnrealizedFinalizedCheckpoint *shared.Checkpoint `json:"unrealized_finalized_checkpoint"` - ProposerBoostRoot string `json:"proposer_boost_root"` - PreviousProposerBoostRoot string `json:"previous_proposer_boost_root"` - HeadRoot string `json:"head_root"` + UnrealizedJustifiedCheckpoint *Checkpoint `json:"unrealized_justified_checkpoint"` + UnrealizedFinalizedCheckpoint *Checkpoint `json:"unrealized_finalized_checkpoint"` + ProposerBoostRoot string `json:"proposer_boost_root"` + PreviousProposerBoostRoot string `json:"previous_proposer_boost_root"` + HeadRoot string `json:"head_root"` } type ForkChoiceNode struct { diff --git a/beacon-chain/rpc/eth/events/structs.go b/api/server/structs/endpoints_events.go similarity index 65% rename from beacon-chain/rpc/eth/events/structs.go rename to api/server/structs/endpoints_events.go index e66327d26e..5b6d30cf3f 100644 --- a/beacon-chain/rpc/eth/events/structs.go +++ b/api/server/structs/endpoints_events.go @@ -1,9 +1,7 @@ -package events +package structs import ( "encoding/json" - - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" ) type HeadEvent struct { @@ -23,13 +21,13 @@ type BlockEvent struct { } type AggregatedAttEventSource struct { - Aggregate *shared.Attestation `json:"aggregate"` + Aggregate *Attestation `json:"aggregate"` } type UnaggregatedAttEventSource struct { - AggregationBits string `json:"aggregation_bits"` - Data *shared.AttestationData `json:"data"` - Signature string `json:"signature"` + AggregationBits string `json:"aggregation_bits"` + Data *AttestationData `json:"data"` + Signature string `json:"signature"` } type FinalizedCheckpointEvent struct { @@ -71,18 +69,18 @@ type PayloadAttributesV1 struct { } type PayloadAttributesV2 struct { - Timestamp string `json:"timestamp"` - PrevRandao string `json:"prev_randao"` - SuggestedFeeRecipient string `json:"suggested_fee_recipient"` - Withdrawals []*shared.Withdrawal `json:"withdrawals"` + Timestamp string `json:"timestamp"` + PrevRandao string `json:"prev_randao"` + SuggestedFeeRecipient string `json:"suggested_fee_recipient"` + Withdrawals []*Withdrawal `json:"withdrawals"` } type PayloadAttributesV3 struct { - Timestamp string `json:"timestamp"` - PrevRandao string `json:"prev_randao"` - SuggestedFeeRecipient string `json:"suggested_fee_recipient"` - Withdrawals []*shared.Withdrawal `json:"withdrawals"` - ParentBeaconBlockRoot string `json:"parent_beacon_block_root"` + Timestamp string `json:"timestamp"` + PrevRandao string `json:"prev_randao"` + SuggestedFeeRecipient string `json:"suggested_fee_recipient"` + Withdrawals []*Withdrawal `json:"withdrawals"` + ParentBeaconBlockRoot string `json:"parent_beacon_block_root"` } type BlobSidecarEvent struct { @@ -99,11 +97,11 @@ type LightClientFinalityUpdateEvent struct { } type LightClientFinalityUpdate struct { - AttestedHeader *shared.BeaconBlockHeader `json:"attested_header"` - FinalizedHeader *shared.BeaconBlockHeader `json:"finalized_header"` - FinalityBranch []string `json:"finality_branch"` - SyncAggregate *shared.SyncAggregate `json:"sync_aggregate"` - SignatureSlot string `json:"signature_slot"` + AttestedHeader *BeaconBlockHeader `json:"attested_header"` + FinalizedHeader *BeaconBlockHeader `json:"finalized_header"` + FinalityBranch []string `json:"finality_branch"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + SignatureSlot string `json:"signature_slot"` } type LightClientOptimisticUpdateEvent struct { @@ -112,7 +110,7 @@ type LightClientOptimisticUpdateEvent struct { } type LightClientOptimisticUpdate struct { - AttestedHeader *shared.BeaconBlockHeader `json:"attested_header"` - SyncAggregate *shared.SyncAggregate `json:"sync_aggregate"` - SignatureSlot string `json:"signature_slot"` + AttestedHeader *BeaconBlockHeader `json:"attested_header"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + SignatureSlot string `json:"signature_slot"` } diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go new file mode 100644 index 0000000000..7204e177dc --- /dev/null +++ b/api/server/structs/endpoints_lightclient.go @@ -0,0 +1,31 @@ +package structs + +type LightClientBootstrapResponse struct { + Version string `json:"version"` + Data *LightClientBootstrap `json:"data"` +} + +type LightClientBootstrap struct { + Header *BeaconBlockHeader `json:"header"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` +} + +type LightClientUpdate struct { + AttestedHeader *BeaconBlockHeader `json:"attested_header"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` + FinalizedHeader *BeaconBlockHeader `json:"finalized_header,omitempty"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` + FinalityBranch []string `json:"finality_branch,omitempty"` + SignatureSlot string `json:"signature_slot"` +} + +type LightClientUpdateWithVersion struct { + Version string `json:"version"` + Data *LightClientUpdate `json:"data"` +} + +type LightClientUpdatesByRangeResponse struct { + Updates []*LightClientUpdateWithVersion `json:"updates"` +} diff --git a/beacon-chain/rpc/eth/node/structs.go b/api/server/structs/endpoints_node.go similarity index 92% rename from beacon-chain/rpc/eth/node/structs.go rename to api/server/structs/endpoints_node.go index 704f66d19f..f5fe856e64 100644 --- a/beacon-chain/rpc/eth/node/structs.go +++ b/api/server/structs/endpoints_node.go @@ -1,4 +1,4 @@ -package node +package structs type SyncStatusResponse struct { Data *SyncStatusResponseData `json:"data"` @@ -63,3 +63,11 @@ type GetVersionResponse struct { type Version struct { Version string `json:"version"` } + +type AddrRequest struct { + Addr string `json:"addr"` +} + +type PeersResponse struct { + Peers []*Peer `json:"peers"` +} diff --git a/beacon-chain/rpc/eth/rewards/structs.go b/api/server/structs/endpoints_rewards.go similarity index 99% rename from beacon-chain/rpc/eth/rewards/structs.go rename to api/server/structs/endpoints_rewards.go index 7eb3bdaa2d..754d37d66f 100644 --- a/beacon-chain/rpc/eth/rewards/structs.go +++ b/api/server/structs/endpoints_rewards.go @@ -1,4 +1,4 @@ -package rewards +package structs type BlockRewardsResponse struct { Data *BlockRewards `json:"data"` diff --git a/beacon-chain/rpc/eth/validator/structs.go b/api/server/structs/endpoints_validator.go similarity index 59% rename from beacon-chain/rpc/eth/validator/structs.go rename to api/server/structs/endpoints_validator.go index c58bac7f0f..1180d1433c 100644 --- a/beacon-chain/rpc/eth/validator/structs.go +++ b/api/server/structs/endpoints_validator.go @@ -1,37 +1,37 @@ -package validator +package structs import ( "encoding/json" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" + "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" ) type AggregateAttestationResponse struct { - Data *shared.Attestation `json:"data"` + Data *Attestation `json:"data"` } type SubmitContributionAndProofsRequest struct { - Data []*shared.SignedContributionAndProof `json:"data"` + Data []*SignedContributionAndProof `json:"data"` } type SubmitAggregateAndProofsRequest struct { - Data []*shared.SignedAggregateAttestationAndProof `json:"data"` + Data []*SignedAggregateAttestationAndProof `json:"data"` } type SubmitSyncCommitteeSubscriptionsRequest struct { - Data []*shared.SyncCommitteeSubscription `json:"data"` + Data []*SyncCommitteeSubscription `json:"data"` } type SubmitBeaconCommitteeSubscriptionsRequest struct { - Data []*shared.BeaconCommitteeSubscription `json:"data"` + Data []*BeaconCommitteeSubscription `json:"data"` } type GetAttestationDataResponse struct { - Data *shared.AttestationData `json:"data"` + Data *AttestationData `json:"data"` } type ProduceSyncCommitteeContributionResponse struct { - Data *shared.SyncCommitteeContribution `json:"data"` + Data *SyncCommitteeContribution `json:"data"` } type GetAttesterDutiesResponse struct { @@ -90,3 +90,31 @@ type Liveness struct { Index string `json:"index"` IsLive bool `json:"is_live"` } + +type GetValidatorCountResponse struct { + ExecutionOptimistic string `json:"execution_optimistic"` + Finalized string `json:"finalized"` + Data []*ValidatorCount `json:"data"` +} + +type ValidatorCount struct { + Status string `json:"status"` + Count string `json:"count"` +} + +type GetValidatorPerformanceRequest struct { + PublicKeys [][]byte `json:"public_keys,omitempty"` + Indices []primitives.ValidatorIndex `json:"indices,omitempty"` +} + +type GetValidatorPerformanceResponse struct { + PublicKeys [][]byte `json:"public_keys,omitempty"` + CorrectlyVotedSource []bool `json:"correctly_voted_source,omitempty"` + CorrectlyVotedTarget []bool `json:"correctly_voted_target,omitempty"` + CorrectlyVotedHead []bool `json:"correctly_voted_head,omitempty"` + CurrentEffectiveBalances []uint64 `json:"current_effective_balances,omitempty"` + BalancesBeforeEpochTransition []uint64 `json:"balances_before_epoch_transition,omitempty"` + BalancesAfterEpochTransition []uint64 `json:"balances_after_epoch_transition,omitempty"` + MissingValidators [][]byte `json:"missing_validators,omitempty"` + InactivityScores []uint64 `json:"inactivity_scores,omitempty"` +} diff --git a/beacon-chain/rpc/eth/shared/structs.go b/api/server/structs/other.go similarity index 98% rename from beacon-chain/rpc/eth/shared/structs.go rename to api/server/structs/other.go index 93fb926ecf..5694893d13 100644 --- a/beacon-chain/rpc/eth/shared/structs.go +++ b/api/server/structs/other.go @@ -1,7 +1,7 @@ -package shared +package structs type Validator struct { - PublicKey string `json:"pubkey"` + Pubkey string `json:"pubkey"` WithdrawalCredentials string `json:"withdrawal_credentials"` EffectiveBalance string `json:"effective_balance"` Slashed bool `json:"slashed"` diff --git a/beacon-chain/rpc/eth/shared/structs_state.go b/api/server/structs/state.go similarity index 99% rename from beacon-chain/rpc/eth/shared/structs_state.go rename to api/server/structs/state.go index 74a620aad0..4b07cfc20a 100644 --- a/beacon-chain/rpc/eth/shared/structs_state.go +++ b/api/server/structs/state.go @@ -1,4 +1,4 @@ -package shared +package structs type BeaconState struct { GenesisTime string `json:"genesis_time"` diff --git a/beacon-chain/rpc/eth/beacon/BUILD.bazel b/beacon-chain/rpc/eth/beacon/BUILD.bazel index fe0a40cf65..b04274a356 100644 --- a/beacon-chain/rpc/eth/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/beacon/BUILD.bazel @@ -9,13 +9,13 @@ go_library( "handlers_validator.go", "log.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon", visibility = ["//visibility:public"], deps = [ "//api:go_default_library", "//api/server:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/blocks:go_default_library", @@ -75,6 +75,7 @@ go_test( deps = [ "//api:go_default_library", "//api/server:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/core/signing:go_default_library", "//beacon-chain/core/time:go_default_library", @@ -90,7 +91,6 @@ go_test( "//beacon-chain/operations/voluntaryexits/mock:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/rpc/core:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/eth/shared/testing:go_default_library", "//beacon-chain/rpc/lookup:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", diff --git a/beacon-chain/rpc/eth/beacon/handlers.go b/beacon-chain/rpc/eth/beacon/handlers.go index ed4bcec6ae..1fbd4fdfba 100644 --- a/beacon-chain/rpc/eth/beacon/handlers.go +++ b/beacon-chain/rpc/eth/beacon/handlers.go @@ -14,6 +14,7 @@ import ( "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" corehelpers "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/transition" "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/filters" @@ -76,7 +77,7 @@ func (s *Server) getBlock(ctx context.Context, w http.ResponseWriter, blk interf httputil.HandleError(w, "Could not get block: "+err.Error(), http.StatusInternalServerError) return } - resp := &GetBlockResponse{Data: v2Resp.Data} + resp := &structs.GetBlockResponse{Data: v2Resp.Data} httputil.WriteJson(w, resp) } @@ -121,7 +122,7 @@ func (s *Server) getBlockV2(ctx context.Context, w http.ResponseWriter, blk inte } finalized := s.FinalizationFetcher.IsFinalized(ctx, blkRoot) - getBlockHandler := func(get func(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error)) handled { + getBlockHandler := func(get func(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error)) handled { result, err := get(ctx, blk) if result != nil { result.Finalized = finalized @@ -221,7 +222,7 @@ func (s *Server) getBlindedBlock(ctx context.Context, w http.ResponseWriter, blk } finalized := s.FinalizationFetcher.IsFinalized(ctx, blkRoot) - getBlockHandler := func(get func(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error)) handled { + getBlockHandler := func(get func(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error)) handled { result, err := get(ctx, blk) if result != nil { result.Finalized = finalized @@ -290,7 +291,7 @@ func (s *Server) getBlindedBlockSSZ(ctx context.Context, w http.ResponseWriter, httputil.HandleError(w, fmt.Sprintf("Unknown block type %T", blk), http.StatusInternalServerError) } -func (*Server) getBlockPhase0(_ context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (*Server) getBlockPhase0(_ context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { consensusBlk, err := blk.PbPhase0Block() if err != nil { return nil, err @@ -298,22 +299,22 @@ func (*Server) getBlockPhase0(_ context.Context, blk interfaces.ReadOnlySignedBe if consensusBlk == nil { return nil, errNilBlock } - respBlk := shared.SignedBeaconBlockFromConsensus(consensusBlk) + respBlk := structs.SignedBeaconBlockFromConsensus(consensusBlk) jsonBytes, err := json.Marshal(respBlk.Message) if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Phase0), ExecutionOptimistic: false, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (*Server) getBlockAltair(_ context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (*Server) getBlockAltair(_ context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { consensusBlk, err := blk.PbAltairBlock() if err != nil { return nil, err @@ -321,22 +322,22 @@ func (*Server) getBlockAltair(_ context.Context, blk interfaces.ReadOnlySignedBe if consensusBlk == nil { return nil, errNilBlock } - respBlk := shared.SignedBeaconBlockAltairFromConsensus(consensusBlk) + respBlk := structs.SignedBeaconBlockAltairFromConsensus(consensusBlk) jsonBytes, err := json.Marshal(respBlk.Message) if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Altair), ExecutionOptimistic: false, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (s *Server) getBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { consensusBlk, err := blk.PbBellatrixBlock() if err != nil { // ErrUnsupportedField means that we have another block type @@ -372,7 +373,7 @@ func (s *Server) getBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlyS if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBeaconBlockBellatrixFromConsensus(consensusBlk) + respBlk, err := structs.SignedBeaconBlockBellatrixFromConsensus(consensusBlk) if err != nil { return nil, err } @@ -380,17 +381,17 @@ func (s *Server) getBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlyS if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Bellatrix), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (s *Server) getBlockCapella(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlockCapella(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { consensusBlk, err := blk.PbCapellaBlock() if err != nil { // ErrUnsupportedField means that we have another block type @@ -426,7 +427,7 @@ func (s *Server) getBlockCapella(ctx context.Context, blk interfaces.ReadOnlySig if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBeaconBlockCapellaFromConsensus(consensusBlk) + respBlk, err := structs.SignedBeaconBlockCapellaFromConsensus(consensusBlk) if err != nil { return nil, err } @@ -434,17 +435,17 @@ func (s *Server) getBlockCapella(ctx context.Context, blk interfaces.ReadOnlySig if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Capella), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (s *Server) getBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { consensusBlk, err := blk.PbDenebBlock() if err != nil { // ErrUnsupportedGetter means that we have another block type @@ -480,7 +481,7 @@ func (s *Server) getBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySigne if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBeaconBlockDenebFromConsensus(consensusBlk) + respBlk, err := structs.SignedBeaconBlockDenebFromConsensus(consensusBlk) if err != nil { return nil, err } @@ -488,10 +489,10 @@ func (s *Server) getBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySigne if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Deneb), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, @@ -633,7 +634,7 @@ func (s *Server) getBlockDenebSSZ(ctx context.Context, blk interfaces.ReadOnlySi return sszData, nil } -func (s *Server) getBlindedBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlindedBlockBellatrix(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { blindedConsensusBlk, err := blk.PbBlindedBellatrixBlock() if err != nil { // ErrUnsupportedField means that we have another block type @@ -669,7 +670,7 @@ func (s *Server) getBlindedBlockBellatrix(ctx context.Context, blk interfaces.Re if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBlindedBeaconBlockBellatrixFromConsensus(blindedConsensusBlk) + respBlk, err := structs.SignedBlindedBeaconBlockBellatrixFromConsensus(blindedConsensusBlk) if err != nil { return nil, err } @@ -677,17 +678,17 @@ func (s *Server) getBlindedBlockBellatrix(ctx context.Context, blk interfaces.Re if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Bellatrix), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (s *Server) getBlindedBlockCapella(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlindedBlockCapella(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { blindedConsensusBlk, err := blk.PbBlindedCapellaBlock() if err != nil { // ErrUnsupportedField means that we have another block type @@ -723,7 +724,7 @@ func (s *Server) getBlindedBlockCapella(ctx context.Context, blk interfaces.Read if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBlindedBeaconBlockCapellaFromConsensus(blindedConsensusBlk) + respBlk, err := structs.SignedBlindedBeaconBlockCapellaFromConsensus(blindedConsensusBlk) if err != nil { return nil, err } @@ -731,17 +732,17 @@ func (s *Server) getBlindedBlockCapella(ctx context.Context, blk interfaces.Read if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Capella), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, }, nil } -func (s *Server) getBlindedBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*GetBlockV2Response, error) { +func (s *Server) getBlindedBlockDeneb(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*structs.GetBlockV2Response, error) { blindedConsensusBlk, err := blk.PbBlindedDenebBlock() if err != nil { // ErrUnsupportedGetter means that we have another block type @@ -777,7 +778,7 @@ func (s *Server) getBlindedBlockDeneb(ctx context.Context, blk interfaces.ReadOn if err != nil { return nil, errors.Wrapf(err, "could not check if block is optimistic") } - respBlk, err := shared.SignedBlindedBeaconBlockDenebFromConsensus(blindedConsensusBlk) + respBlk, err := structs.SignedBlindedBeaconBlockDenebFromConsensus(blindedConsensusBlk) if err != nil { return nil, err } @@ -785,10 +786,10 @@ func (s *Server) getBlindedBlockDeneb(ctx context.Context, blk interfaces.ReadOn if err != nil { return nil, err } - return &GetBlockV2Response{ + return &structs.GetBlockV2Response{ Version: version.String(version.Deneb), ExecutionOptimistic: isOptimistic, - Data: &SignedBlock{ + Data: &structs.SignedBlock{ Message: jsonBytes, Signature: respBlk.Signature, }, @@ -916,9 +917,9 @@ func (s *Server) GetBlockAttestations(w http.ResponseWriter, r *http.Request) { } consensusAtts := blk.Block().Body().Attestations() - atts := make([]*shared.Attestation, len(consensusAtts)) + atts := make([]*structs.Attestation, len(consensusAtts)) for i, att := range consensusAtts { - atts[i] = shared.AttFromConsensus(att) + atts[i] = structs.AttFromConsensus(att) } root, err := blk.Block().HashTreeRoot() if err != nil { @@ -931,7 +932,7 @@ func (s *Server) GetBlockAttestations(w http.ResponseWriter, r *http.Request) { return } - resp := &GetBlockAttestationsResponse{ + resp := &structs.GetBlockAttestationsResponse{ Data: atts, ExecutionOptimistic: isOptimistic, Finalized: s.FinalizationFetcher.IsFinalized(ctx, root), @@ -1126,7 +1127,7 @@ func (s *Server) publishBlindedBlock(ctx context.Context, w http.ResponseWriter, var consensusBlock *eth.GenericSignedBeaconBlock - var denebBlock *shared.SignedBlindedBeaconBlockDeneb + var denebBlock *structs.SignedBlindedBeaconBlockDeneb if err = unmarshalStrict(body, &denebBlock); err == nil { consensusBlock, err = denebBlock.ToGeneric() if err == nil { @@ -1147,7 +1148,7 @@ func (s *Server) publishBlindedBlock(ctx context.Context, w http.ResponseWriter, return } - var capellaBlock *shared.SignedBlindedBeaconBlockCapella + var capellaBlock *structs.SignedBlindedBeaconBlockCapella if err = unmarshalStrict(body, &capellaBlock); err == nil { consensusBlock, err = capellaBlock.ToGeneric() if err == nil { @@ -1168,7 +1169,7 @@ func (s *Server) publishBlindedBlock(ctx context.Context, w http.ResponseWriter, return } - var bellatrixBlock *shared.SignedBlindedBeaconBlockBellatrix + var bellatrixBlock *structs.SignedBlindedBeaconBlockBellatrix if err = unmarshalStrict(body, &bellatrixBlock); err == nil { consensusBlock, err = bellatrixBlock.ToGeneric() if err == nil { @@ -1189,7 +1190,7 @@ func (s *Server) publishBlindedBlock(ctx context.Context, w http.ResponseWriter, return } - var altairBlock *shared.SignedBeaconBlockAltair + var altairBlock *structs.SignedBeaconBlockAltair if err = unmarshalStrict(body, &altairBlock); err == nil { consensusBlock, err = altairBlock.ToGeneric() if err == nil { @@ -1210,7 +1211,7 @@ func (s *Server) publishBlindedBlock(ctx context.Context, w http.ResponseWriter, return } - var phase0Block *shared.SignedBeaconBlock + var phase0Block *structs.SignedBeaconBlock if err = unmarshalStrict(body, &phase0Block); err == nil { consensusBlock, err = phase0Block.ToGeneric() if err == nil { @@ -1421,7 +1422,7 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt var consensusBlock *eth.GenericSignedBeaconBlock - var denebBlockContents *shared.SignedBeaconBlockContentsDeneb + var denebBlockContents *structs.SignedBeaconBlockContentsDeneb if err = unmarshalStrict(body, &denebBlockContents); err == nil { consensusBlock, err = denebBlockContents.ToGeneric() if err == nil { @@ -1442,7 +1443,7 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt return } - var capellaBlock *shared.SignedBeaconBlockCapella + var capellaBlock *structs.SignedBeaconBlockCapella if err = unmarshalStrict(body, &capellaBlock); err == nil { consensusBlock, err = capellaBlock.ToGeneric() if err == nil { @@ -1463,7 +1464,7 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt return } - var bellatrixBlock *shared.SignedBeaconBlockBellatrix + var bellatrixBlock *structs.SignedBeaconBlockBellatrix if err = unmarshalStrict(body, &bellatrixBlock); err == nil { consensusBlock, err = bellatrixBlock.ToGeneric() if err == nil { @@ -1484,7 +1485,7 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt return } - var altairBlock *shared.SignedBeaconBlockAltair + var altairBlock *structs.SignedBeaconBlockAltair if err = unmarshalStrict(body, &altairBlock); err == nil { consensusBlock, err = altairBlock.ToGeneric() if err == nil { @@ -1505,7 +1506,7 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt return } - var phase0Block *shared.SignedBeaconBlock + var phase0Block *structs.SignedBeaconBlock if err = unmarshalStrict(body, &phase0Block); err == nil { consensusBlock, err = phase0Block.ToGeneric() if err == nil { @@ -1700,8 +1701,8 @@ func (s *Server) GetBlockRoot(w http.ResponseWriter, r *http.Request) { httputil.HandleError(w, "Could not check if block is optimistic: "+err.Error(), http.StatusInternalServerError) return } - response := &BlockRootResponse{ - Data: &BlockRoot{ + response := &structs.BlockRootResponse{ + Data: &structs.BlockRoot{ Root: hexutil.Encode(root), }, ExecutionOptimistic: isOptimistic, @@ -1736,8 +1737,8 @@ func (s *Server) GetStateFork(w http.ResponseWriter, r *http.Request) { return } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - response := &GetStateForkResponse{ - Data: &shared.Fork{ + response := &structs.GetStateForkResponse{ + Data: &structs.Fork{ PreviousVersion: hexutil.Encode(fork.PreviousVersion), CurrentVersion: hexutil.Encode(fork.CurrentVersion), Epoch: fmt.Sprintf("%d", fork.Epoch), @@ -1800,7 +1801,7 @@ func (s *Server) GetCommittees(w http.ResponseWriter, r *http.Request) { return } committeesPerSlot := corehelpers.SlotCommitteeCount(activeCount) - committees := make([]*shared.Committee, 0) + committees := make([]*structs.Committee, 0) for slot := startSlot; slot <= endSlot; slot++ { if rawSlot != "" && slot != primitives.Slot(sl) { continue @@ -1818,7 +1819,7 @@ func (s *Server) GetCommittees(w http.ResponseWriter, r *http.Request) { for _, v := range committee { validators = append(validators, strconv.FormatUint(uint64(v), 10)) } - committeeContainer := &shared.Committee{ + committeeContainer := &structs.Committee{ Index: strconv.FormatUint(uint64(index), 10), Slot: strconv.FormatUint(uint64(slot), 10), Validators: validators, @@ -1839,7 +1840,7 @@ func (s *Server) GetCommittees(w http.ResponseWriter, r *http.Request) { return } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - httputil.WriteJson(w, &GetCommitteesResponse{Data: committees, ExecutionOptimistic: isOptimistic, Finalized: isFinalized}) + httputil.WriteJson(w, &structs.GetCommitteesResponse{Data: committees, ExecutionOptimistic: isOptimistic, Finalized: isFinalized}) } // GetBlockHeaders retrieves block headers matching given query. By default it will fetch current head slot blocks. @@ -1889,7 +1890,7 @@ func (s *Server) GetBlockHeaders(w http.ResponseWriter, r *http.Request) { isOptimistic := false isFinalized := true - blkHdrs := make([]*shared.SignedBeaconBlockHeaderContainer, len(blks)) + blkHdrs := make([]*structs.SignedBeaconBlockHeaderContainer, len(blks)) for i, bl := range blks { v1alpha1Header, err := bl.Header() if err != nil { @@ -1916,9 +1917,9 @@ func (s *Server) GetBlockHeaders(w http.ResponseWriter, r *http.Request) { if isFinalized { isFinalized = s.FinalizationFetcher.IsFinalized(ctx, blkRoots[i]) } - blkHdrs[i] = &shared.SignedBeaconBlockHeaderContainer{ - Header: &shared.SignedBeaconBlockHeader{ - Message: shared.BeaconBlockHeaderFromConsensus(v1alpha1Header.Header), + blkHdrs[i] = &structs.SignedBeaconBlockHeaderContainer{ + Header: &structs.SignedBeaconBlockHeader{ + Message: structs.BeaconBlockHeaderFromConsensus(v1alpha1Header.Header), Signature: hexutil.Encode(v1alpha1Header.Signature), }, Root: hexutil.Encode(headerRoot[:]), @@ -1926,7 +1927,7 @@ func (s *Server) GetBlockHeaders(w http.ResponseWriter, r *http.Request) { } } - response := &GetBlockHeadersResponse{ + response := &structs.GetBlockHeadersResponse{ Data: blkHdrs, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -1976,12 +1977,12 @@ func (s *Server) GetBlockHeader(w http.ResponseWriter, r *http.Request) { return } - resp := &GetBlockHeaderResponse{ - Data: &shared.SignedBeaconBlockHeaderContainer{ + resp := &structs.GetBlockHeaderResponse{ + Data: &structs.SignedBeaconBlockHeaderContainer{ Root: hexutil.Encode(headerRoot[:]), Canonical: canonical, - Header: &shared.SignedBeaconBlockHeader{ - Message: shared.BeaconBlockHeaderFromConsensus(blockHeader.Header), + Header: &structs.SignedBeaconBlockHeader{ + Message: structs.BeaconBlockHeaderFromConsensus(blockHeader.Header), Signature: hexutil.Encode(blockHeader.Signature), }, }, @@ -2023,17 +2024,17 @@ func (s *Server) GetFinalityCheckpoints(w http.ResponseWriter, r *http.Request) pj := st.PreviousJustifiedCheckpoint() cj := st.CurrentJustifiedCheckpoint() f := st.FinalizedCheckpoint() - resp := &GetFinalityCheckpointsResponse{ - Data: &FinalityCheckpoints{ - PreviousJustified: &shared.Checkpoint{ + resp := &structs.GetFinalityCheckpointsResponse{ + Data: &structs.FinalityCheckpoints{ + PreviousJustified: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(pj.Epoch), 10), Root: hexutil.Encode(pj.Root), }, - CurrentJustified: &shared.Checkpoint{ + CurrentJustified: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(cj.Epoch), 10), Root: hexutil.Encode(cj.Root), }, - Finalized: &shared.Checkpoint{ + Finalized: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(f.Epoch), 10), Root: hexutil.Encode(f.Root), }, @@ -2061,8 +2062,8 @@ func (s *Server) GetGenesis(w http.ResponseWriter, r *http.Request) { } forkVersion := params.BeaconConfig().GenesisForkVersion - resp := &GetGenesisResponse{ - Data: &Genesis{ + resp := &structs.GetGenesisResponse{ + Data: &structs.Genesis{ GenesisTime: strconv.FormatUint(uint64(genesisTime.Unix()), 10), GenesisValidatorsRoot: hexutil.Encode(validatorsRoot[:]), GenesisForkVersion: hexutil.Encode(forkVersion), diff --git a/beacon-chain/rpc/eth/beacon/handlers_pool.go b/beacon-chain/rpc/eth/beacon/handlers_pool.go index 9bd254e414..94f3796c8f 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_pool.go +++ b/beacon-chain/rpc/eth/beacon/handlers_pool.go @@ -11,6 +11,7 @@ import ( "time" "github.com/prysmaticlabs/prysm/v4/api/server" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/operation" @@ -55,25 +56,25 @@ func (s *Server) ListAttestations(w http.ResponseWriter, r *http.Request) { attestations = append(attestations, unaggAtts...) isEmptyReq := rawSlot == "" && rawCommitteeIndex == "" if isEmptyReq { - allAtts := make([]*shared.Attestation, len(attestations)) + allAtts := make([]*structs.Attestation, len(attestations)) for i, att := range attestations { - allAtts[i] = shared.AttFromConsensus(att) + allAtts[i] = structs.AttFromConsensus(att) } - httputil.WriteJson(w, &ListAttestationsResponse{Data: allAtts}) + httputil.WriteJson(w, &structs.ListAttestationsResponse{Data: allAtts}) return } bothDefined := rawSlot != "" && rawCommitteeIndex != "" - filteredAtts := make([]*shared.Attestation, 0, len(attestations)) + filteredAtts := make([]*structs.Attestation, 0, len(attestations)) for _, att := range attestations { committeeIndexMatch := rawCommitteeIndex != "" && att.Data.CommitteeIndex == primitives.CommitteeIndex(committeeIndex) slotMatch := rawSlot != "" && att.Data.Slot == primitives.Slot(slot) shouldAppend := (bothDefined && committeeIndexMatch && slotMatch) || (!bothDefined && (committeeIndexMatch || slotMatch)) if shouldAppend { - filteredAtts = append(filteredAtts, shared.AttFromConsensus(att)) + filteredAtts = append(filteredAtts, structs.AttFromConsensus(att)) } } - httputil.WriteJson(w, &ListAttestationsResponse{Data: filteredAtts}) + httputil.WriteJson(w, &structs.ListAttestationsResponse{Data: filteredAtts}) } // SubmitAttestations submits an attestation object to node. If the attestation passes all validation @@ -82,7 +83,7 @@ func (s *Server) SubmitAttestations(w http.ResponseWriter, r *http.Request) { ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitAttestations") defer span.End() - var req SubmitAttestationsRequest + var req structs.SubmitAttestationsRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -186,12 +187,12 @@ func (s *Server) ListVoluntaryExits(w http.ResponseWriter, r *http.Request) { httputil.HandleError(w, "Could not get exits from the pool: "+err.Error(), http.StatusInternalServerError) return } - exits := make([]*shared.SignedVoluntaryExit, len(sourceExits)) + exits := make([]*structs.SignedVoluntaryExit, len(sourceExits)) for i, e := range sourceExits { - exits[i] = shared.SignedExitFromConsensus(e) + exits[i] = structs.SignedExitFromConsensus(e) } - httputil.WriteJson(w, &ListVoluntaryExitsResponse{Data: exits}) + httputil.WriteJson(w, &structs.ListVoluntaryExitsResponse{Data: exits}) } // SubmitVoluntaryExit submits a SignedVoluntaryExit object to node's pool @@ -200,7 +201,7 @@ func (s *Server) SubmitVoluntaryExit(w http.ResponseWriter, r *http.Request) { ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitVoluntaryExit") defer span.End() - var req shared.SignedVoluntaryExit + var req structs.SignedVoluntaryExit err := json.NewDecoder(r.Body).Decode(&req) switch { case err == io.EOF: @@ -258,7 +259,7 @@ func (s *Server) SubmitSyncCommitteeSignatures(w http.ResponseWriter, r *http.Re ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitPoolSyncCommitteeSignatures") defer span.End() - var req SubmitSyncCommitteeSignaturesRequest + var req structs.SubmitSyncCommitteeSignaturesRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -317,7 +318,7 @@ func (s *Server) SubmitBLSToExecutionChanges(w http.ResponseWriter, r *http.Requ var failures []*server.IndexedVerificationFailure var toBroadcast []*eth.SignedBLSToExecutionChange - var req []*shared.SignedBLSToExecutionChange + var req []*structs.SignedBLSToExecutionChange err = json.NewDecoder(r.Body).Decode(&req) switch { case err == io.EOF: @@ -437,8 +438,8 @@ func (s *Server) ListBLSToExecutionChanges(w http.ResponseWriter, r *http.Reques return } - httputil.WriteJson(w, &BLSToExecutionChangesPoolResponse{ - Data: shared.SignedBLSChangesFromConsensus(sourceChanges), + httputil.WriteJson(w, &structs.BLSToExecutionChangesPoolResponse{ + Data: structs.SignedBLSChangesFromConsensus(sourceChanges), }) } @@ -454,9 +455,9 @@ func (s *Server) GetAttesterSlashings(w http.ResponseWriter, r *http.Request) { return } sourceSlashings := s.SlashingsPool.PendingAttesterSlashings(ctx, headState, true /* return unlimited slashings */) - slashings := shared.AttesterSlashingsFromConsensus(sourceSlashings) + slashings := structs.AttesterSlashingsFromConsensus(sourceSlashings) - httputil.WriteJson(w, &GetAttesterSlashingsResponse{Data: slashings}) + httputil.WriteJson(w, &structs.GetAttesterSlashingsResponse{Data: slashings}) } // SubmitAttesterSlashing submits an attester slashing object to node's pool and @@ -465,7 +466,7 @@ func (s *Server) SubmitAttesterSlashing(w http.ResponseWriter, r *http.Request) ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitAttesterSlashing") defer span.End() - var req shared.AttesterSlashing + var req structs.AttesterSlashing err := json.NewDecoder(r.Body).Decode(&req) switch { case err == io.EOF: @@ -528,9 +529,9 @@ func (s *Server) GetProposerSlashings(w http.ResponseWriter, r *http.Request) { return } sourceSlashings := s.SlashingsPool.PendingProposerSlashings(ctx, headState, true /* return unlimited slashings */) - slashings := shared.ProposerSlashingsFromConsensus(sourceSlashings) + slashings := structs.ProposerSlashingsFromConsensus(sourceSlashings) - httputil.WriteJson(w, &GetProposerSlashingsResponse{Data: slashings}) + httputil.WriteJson(w, &structs.GetProposerSlashingsResponse{Data: slashings}) } // SubmitProposerSlashing submits a proposer slashing object to node's pool and if @@ -539,7 +540,7 @@ func (s *Server) SubmitProposerSlashing(w http.ResponseWriter, r *http.Request) ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitProposerSlashing") defer span.End() - var req shared.ProposerSlashing + var req structs.ProposerSlashing err := json.NewDecoder(r.Body).Decode(&req) switch { case err == io.EOF: diff --git a/beacon-chain/rpc/eth/beacon/handlers_pool_test.go b/beacon-chain/rpc/eth/beacon/handlers_pool_test.go index 7e8c688c19..e897766d5c 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_pool_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_pool_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/v4/api/server" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" blockchainmock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing" prysmtime "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time" @@ -26,7 +27,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/voluntaryexits/mock" p2pMock "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/core" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" @@ -126,7 +126,7 @@ func TestListAttestations(t *testing.T) { s.ListAttestations(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ListAttestationsResponse{} + resp := &structs.ListAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -140,7 +140,7 @@ func TestListAttestations(t *testing.T) { s.ListAttestations(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ListAttestationsResponse{} + resp := &structs.ListAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -157,7 +157,7 @@ func TestListAttestations(t *testing.T) { s.ListAttestations(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ListAttestationsResponse{} + resp := &structs.ListAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -174,7 +174,7 @@ func TestListAttestations(t *testing.T) { s.ListAttestations(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ListAttestationsResponse{} + resp := &structs.ListAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -340,7 +340,7 @@ func TestListVoluntaryExits(t *testing.T) { s.ListVoluntaryExits(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ListVoluntaryExitsResponse{} + resp := &structs.ListVoluntaryExitsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -660,11 +660,11 @@ func TestListBLSToExecutionChanges(t *testing.T) { s.ListBLSToExecutionChanges(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BLSToExecutionChangesPoolResponse{} + resp := &structs.BLSToExecutionChangesPoolResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) - assert.DeepEqual(t, shared.SignedBLSChangeFromConsensus(change1), resp.Data[0]) - assert.DeepEqual(t, shared.SignedBLSChangeFromConsensus(change2), resp.Data[1]) + assert.DeepEqual(t, structs.SignedBLSChangeFromConsensus(change1), resp.Data[0]) + assert.DeepEqual(t, structs.SignedBLSChangeFromConsensus(change2), resp.Data[1]) } func TestSubmitSignedBLSToExecutionChanges_Ok(t *testing.T) { @@ -722,12 +722,12 @@ func TestSubmitSignedBLSToExecutionChanges_Ok(t *testing.T) { st, err := state_native.InitializeFromProtoCapella(spb) require.NoError(t, err) - signedChanges := make([]*shared.SignedBLSToExecutionChange, numValidators) + signedChanges := make([]*structs.SignedBLSToExecutionChange, numValidators) for i, message := range blsChanges { signature, err := signing.ComputeDomainAndSign(st, prysmtime.CurrentEpoch(st), message, params.BeaconConfig().DomainBLSToExecutionChange, privKeys[i]) require.NoError(t, err) - signed := &shared.SignedBLSToExecutionChange{ - Message: shared.BLSChangeFromConsensus(message), + signed := &structs.SignedBLSToExecutionChange{ + Message: structs.BLSChangeFromConsensus(message), Signature: hexutil.Encode(signature), } signedChanges[i] = signed @@ -834,13 +834,13 @@ func TestSubmitSignedBLSToExecutionChanges_Bellatrix(t *testing.T) { stc, err := state_native.InitializeFromProtoCapella(spc) require.NoError(t, err) - signedChanges := make([]*shared.SignedBLSToExecutionChange, numValidators) + signedChanges := make([]*structs.SignedBLSToExecutionChange, numValidators) for i, message := range blsChanges { signature, err := signing.ComputeDomainAndSign(stc, prysmtime.CurrentEpoch(stc), message, params.BeaconConfig().DomainBLSToExecutionChange, privKeys[i]) require.NoError(t, err) - signedChanges[i] = &shared.SignedBLSToExecutionChange{ - Message: shared.BLSChangeFromConsensus(message), + signedChanges[i] = &structs.SignedBLSToExecutionChange{ + Message: structs.BLSChangeFromConsensus(message), Signature: hexutil.Encode(signature), } } @@ -934,15 +934,15 @@ func TestSubmitSignedBLSToExecutionChanges_Failures(t *testing.T) { st, err := state_native.InitializeFromProtoCapella(spb) require.NoError(t, err) - signedChanges := make([]*shared.SignedBLSToExecutionChange, numValidators) + signedChanges := make([]*structs.SignedBLSToExecutionChange, numValidators) for i, message := range blsChanges { signature, err := signing.ComputeDomainAndSign(st, prysmtime.CurrentEpoch(st), message, params.BeaconConfig().DomainBLSToExecutionChange, privKeys[i]) require.NoError(t, err) if i == 1 { signature[0] = 0x00 } - signedChanges[i] = &shared.SignedBLSToExecutionChange{ - Message: shared.BLSChangeFromConsensus(message), + signedChanges[i] = &structs.SignedBLSToExecutionChange{ + Message: structs.BLSChangeFromConsensus(message), Signature: hexutil.Encode(signature), } } @@ -975,10 +975,10 @@ func TestSubmitSignedBLSToExecutionChanges_Failures(t *testing.T) { poolChanges, err := s.BLSChangesPool.PendingBLSToExecChanges() require.Equal(t, len(poolChanges)+1, len(signedChanges)) require.NoError(t, err) - require.DeepEqual(t, shared.SignedBLSChangeFromConsensus(poolChanges[0]), signedChanges[0]) + require.DeepEqual(t, structs.SignedBLSChangeFromConsensus(poolChanges[0]), signedChanges[0]) for i := 2; i < numValidators; i++ { - require.DeepEqual(t, shared.SignedBLSChangeFromConsensus(poolChanges[i-1]), signedChanges[i]) + require.DeepEqual(t, structs.SignedBLSChangeFromConsensus(poolChanges[i-1]), signedChanges[i]) } } @@ -1069,7 +1069,7 @@ func TestGetAttesterSlashings(t *testing.T) { s.GetAttesterSlashings(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterSlashingsResponse{} + resp := &structs.GetAttesterSlashingsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -1135,7 +1135,7 @@ func TestGetProposerSlashings(t *testing.T) { s.GetProposerSlashings(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetProposerSlashingsResponse{} + resp := &structs.GetProposerSlashingsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -1213,7 +1213,7 @@ func TestSubmitAttesterSlashing_Ok(t *testing.T) { OperationNotifier: chainmock.OperationNotifier(), } - toSubmit := shared.AttesterSlashingsFromConsensus([]*ethpbv1alpha1.AttesterSlashing{slashing}) + toSubmit := structs.AttesterSlashingsFromConsensus([]*ethpbv1alpha1.AttesterSlashing{slashing}) b, err := json.Marshal(toSubmit[0]) require.NoError(t, err) var body bytes.Buffer @@ -1305,7 +1305,7 @@ func TestSubmitAttesterSlashing_AcrossFork(t *testing.T) { OperationNotifier: chainmock.OperationNotifier(), } - toSubmit := shared.AttesterSlashingsFromConsensus([]*ethpbv1alpha1.AttesterSlashing{slashing}) + toSubmit := structs.AttesterSlashingsFromConsensus([]*ethpbv1alpha1.AttesterSlashing{slashing}) b, err := json.Marshal(toSubmit[0]) require.NoError(t, err) var body bytes.Buffer @@ -1416,7 +1416,7 @@ func TestSubmitProposerSlashing_Ok(t *testing.T) { OperationNotifier: chainmock.OperationNotifier(), } - toSubmit := shared.ProposerSlashingsFromConsensus([]*ethpbv1alpha1.ProposerSlashing{slashing}) + toSubmit := structs.ProposerSlashingsFromConsensus([]*ethpbv1alpha1.ProposerSlashing{slashing}) b, err := json.Marshal(toSubmit[0]) require.NoError(t, err) var body bytes.Buffer @@ -1500,7 +1500,7 @@ func TestSubmitProposerSlashing_AcrossFork(t *testing.T) { OperationNotifier: chainmock.OperationNotifier(), } - toSubmit := shared.ProposerSlashingsFromConsensus([]*ethpbv1alpha1.ProposerSlashing{slashing}) + toSubmit := structs.ProposerSlashingsFromConsensus([]*ethpbv1alpha1.ProposerSlashing{slashing}) b, err := json.Marshal(toSubmit[0]) require.NoError(t, err) var body bytes.Buffer diff --git a/beacon-chain/rpc/eth/beacon/handlers_state.go b/beacon-chain/rpc/eth/beacon/handlers_state.go index 2cb4b06b91..29a5ccd9e3 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_state.go +++ b/beacon-chain/rpc/eth/beacon/handlers_state.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" @@ -67,8 +68,8 @@ func (s *Server) GetStateRoot(w http.ResponseWriter, r *http.Request) { } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - resp := &GetStateRootResponse{ - Data: &StateRoot{ + resp := &structs.GetStateRootResponse{ + Data: &structs.StateRoot{ Root: hexutil.Encode(stateRoot), }, ExecutionOptimistic: isOptimistic, @@ -137,8 +138,8 @@ func (s *Server) GetRandao(w http.ResponseWriter, r *http.Request) { } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - resp := &GetRandaoResponse{ - Data: &Randao{Randao: hexutil.Encode(randao)}, + resp := &structs.GetRandaoResponse{ + Data: &structs.Randao{Randao: hexutil.Encode(randao)}, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, } @@ -239,8 +240,8 @@ func (s *Server) GetSyncCommittees(w http.ResponseWriter, r *http.Request) { } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - resp := GetSyncCommitteeResponse{ - Data: &SyncCommitteeValidators{ + resp := structs.GetSyncCommitteeResponse{ + Data: &structs.SyncCommitteeValidators{ Validators: committeeIndices, ValidatorAggregates: subcommittees, }, diff --git a/beacon-chain/rpc/eth/beacon/handlers_state_test.go b/beacon-chain/rpc/eth/beacon/handlers_state_test.go index 63b1f2a91e..ce0b18265e 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_state_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_state_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" chainMock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" dbTest "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" @@ -61,7 +62,7 @@ func TestGetStateRoot(t *testing.T) { s.GetStateRoot(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetStateRootResponse{} + resp := &structs.GetStateRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(stateRoot[:]), resp.Data.Root) @@ -85,7 +86,7 @@ func TestGetStateRoot(t *testing.T) { s.GetStateRoot(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetStateRootResponse{} + resp := &structs.GetStateRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.DeepEqual(t, true, resp.ExecutionOptimistic) }) @@ -116,7 +117,7 @@ func TestGetStateRoot(t *testing.T) { s.GetStateRoot(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetStateRootResponse{} + resp := &structs.GetStateRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.DeepEqual(t, true, resp.Finalized) }) @@ -163,7 +164,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(mixCurrent[:]), resp.Data.Randao) }) @@ -175,7 +176,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(mixCurrent[:]), resp.Data.Randao) }) @@ -187,7 +188,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(mixOld[:]), resp.Data.Randao) }) @@ -203,7 +204,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(headRandao[:]), resp.Data.Randao) }) @@ -262,7 +263,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.DeepEqual(t, true, resp.ExecutionOptimistic) }) @@ -299,7 +300,7 @@ func TestGetRandao(t *testing.T) { s.GetRandao(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetRandaoResponse{} + resp := &structs.GetRandaoResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.DeepEqual(t, true, resp.Finalized) }) @@ -458,7 +459,7 @@ func TestGetSyncCommittees(t *testing.T) { s.GetSyncCommittees(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeResponse{} + resp := &structs.GetSyncCommitteeResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) committeeVals := resp.Data.Validators require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(committeeVals))) @@ -508,7 +509,7 @@ func TestGetSyncCommittees(t *testing.T) { s.GetSyncCommittees(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeResponse{} + resp := &structs.GetSyncCommitteeResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -552,7 +553,7 @@ func TestGetSyncCommittees(t *testing.T) { s.GetSyncCommittees(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeResponse{} + resp := &structs.GetSyncCommitteeResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -629,7 +630,7 @@ func TestGetSyncCommittees_Future(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetSyncCommittees(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeResponse{} + resp := &structs.GetSyncCommitteeResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) committeeVals := resp.Data.Validators require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(committeeVals))) diff --git a/beacon-chain/rpc/eth/beacon/handlers_test.go b/beacon-chain/rpc/eth/beacon/handlers_test.go index 134b3c3c9c..ada8350f04 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_test.go @@ -18,12 +18,12 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" chainMock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/transition" "github.com/prysmaticlabs/prysm/v4/beacon-chain/db" dbTest "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing" doublylinkedtree "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/doubly-linked-tree" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" rpctesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/lookup" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" @@ -97,9 +97,9 @@ func TestGetBlock(t *testing.T) { s.GetBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockResponse{} + resp := &structs.GetBlockResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) - sbb := &shared.SignedBeaconBlock{Message: &shared.BeaconBlock{}} + sbb := &structs.SignedBeaconBlock{Message: &structs.BeaconBlock{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -153,10 +153,10 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Phase0), resp.Version) - sbb := &shared.SignedBeaconBlock{Message: &shared.BeaconBlock{}} + sbb := &structs.SignedBeaconBlock{Message: &structs.BeaconBlock{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -186,10 +186,10 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Altair), resp.Version) - sbb := &shared.SignedBeaconBlockAltair{Message: &shared.BeaconBlockAltair{}} + sbb := &structs.SignedBeaconBlockAltair{Message: &structs.BeaconBlockAltair{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -220,10 +220,10 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Bellatrix), resp.Version) - sbb := &shared.SignedBeaconBlockBellatrix{Message: &shared.BeaconBlockBellatrix{}} + sbb := &structs.SignedBeaconBlockBellatrix{Message: &structs.BeaconBlockBellatrix{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -254,10 +254,10 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Capella), resp.Version) - sbb := &shared.SignedBeaconBlockCapella{Message: &shared.BeaconBlockCapella{}} + sbb := &structs.SignedBeaconBlockCapella{Message: &structs.BeaconBlockCapella{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -288,10 +288,10 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Deneb), resp.Version) - sbb := &shared.SignedBeaconBlockDeneb{Message: &shared.BeaconBlockDeneb{}} + sbb := &structs.SignedBeaconBlockDeneb{Message: &structs.BeaconBlockDeneb{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature blk, err := sbb.ToConsensus() @@ -322,7 +322,7 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -349,7 +349,7 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -368,7 +368,7 @@ func TestGetBlockV2(t *testing.T) { s.GetBlockV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.Finalized) }) @@ -552,7 +552,7 @@ func TestGetBlockAttestations(t *testing.T) { s.GetBlockAttestations(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockAttestationsResponse{} + resp := &structs.GetBlockAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, len(b.Block.Body.Attestations), len(resp.Data)) atts := make([]*eth.Attestation, len(b.Block.Body.Attestations)) @@ -586,7 +586,7 @@ func TestGetBlockAttestations(t *testing.T) { s.GetBlockAttestations(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockAttestationsResponse{} + resp := &structs.GetBlockAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -613,7 +613,7 @@ func TestGetBlockAttestations(t *testing.T) { s.GetBlockAttestations(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockAttestationsResponse{} + resp := &structs.GetBlockAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -632,7 +632,7 @@ func TestGetBlockAttestations(t *testing.T) { s.GetBlockAttestations(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockAttestationsResponse{} + resp := &structs.GetBlockAttestationsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.ExecutionOptimistic) }) @@ -657,10 +657,10 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Phase0), resp.Version) - sbb := &shared.SignedBeaconBlock{Message: &shared.BeaconBlock{}} + sbb := &structs.SignedBeaconBlock{Message: &structs.BeaconBlock{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -686,10 +686,10 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Altair), resp.Version) - sbb := &shared.SignedBeaconBlockAltair{Message: &shared.BeaconBlockAltair{}} + sbb := &structs.SignedBeaconBlockAltair{Message: &structs.BeaconBlockAltair{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -717,10 +717,10 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Bellatrix), resp.Version) - sbb := &shared.SignedBlindedBeaconBlockBellatrix{Message: &shared.BlindedBeaconBlockBellatrix{}} + sbb := &structs.SignedBlindedBeaconBlockBellatrix{Message: &structs.BlindedBeaconBlockBellatrix{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -748,10 +748,10 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Capella), resp.Version) - sbb := &shared.SignedBlindedBeaconBlockCapella{Message: &shared.BlindedBeaconBlockCapella{}} + sbb := &structs.SignedBlindedBeaconBlockCapella{Message: &structs.BlindedBeaconBlockCapella{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature genericBlk, err := sbb.ToGeneric() @@ -779,10 +779,10 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Deneb), resp.Version) - sbb := &shared.SignedBlindedBeaconBlockDeneb{Message: &shared.BlindedBeaconBlockDeneb{}} + sbb := &structs.SignedBlindedBeaconBlockDeneb{Message: &structs.BlindedBeaconBlockDeneb{}} require.NoError(t, json.Unmarshal(resp.Data.Message, sbb.Message)) sbb.Signature = resp.Data.Signature blk, err := sbb.ToConsensus() @@ -812,7 +812,7 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -838,7 +838,7 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -864,7 +864,7 @@ func TestGetBlindedBlock(t *testing.T) { s.GetBlindedBlock(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockV2Response{} + resp := &structs.GetBlockV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.Finalized) }) @@ -989,10 +989,10 @@ func TestPublishBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1011,10 +1011,10 @@ func TestPublishBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1033,9 +1033,9 @@ func TestPublishBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Bellatrix) - converted, err := shared.BeaconBlockBellatrixFromConsensus(block.Bellatrix.Block) + converted, err := structs.BeaconBlockBellatrixFromConsensus(block.Bellatrix.Block) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockBellatrix + var signedblock *structs.SignedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BellatrixBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1057,9 +1057,9 @@ func TestPublishBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Capella) - converted, err := shared.BeaconBlockCapellaFromConsensus(block.Capella.Block) + converted, err := structs.BeaconBlockCapellaFromConsensus(block.Capella.Block) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockCapella + var signedblock *structs.SignedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.CapellaBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1081,9 +1081,9 @@ func TestPublishBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Deneb) - converted, err := shared.SignedBeaconBlockContentsDenebFromConsensus(block.Deneb) + converted, err := structs.SignedBeaconBlockContentsDenebFromConsensus(block.Deneb) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockContentsDeneb + var signedblock *structs.SignedBeaconBlockContentsDeneb err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock) @@ -1150,10 +1150,10 @@ func TestPublishBlockSSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1161,7 +1161,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlock + var blk structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1180,10 +1180,10 @@ func TestPublishBlockSSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1191,7 +1191,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockAltair + var blk structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1216,7 +1216,7 @@ func TestPublishBlockSSZ(t *testing.T) { V1Alpha1ValidatorServer: v1alpha1Server, SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockBellatrix + var blk structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1242,7 +1242,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockCapella + var blk structs.SignedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.CapellaBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1268,7 +1268,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockContentsDeneb + var blk structs.SignedBeaconBlockContentsDeneb err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1288,7 +1288,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1309,7 +1309,7 @@ func TestPublishBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockBellatrix + var blk structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1350,10 +1350,10 @@ func TestPublishBlindedBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1372,10 +1372,10 @@ func TestPublishBlindedBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1394,9 +1394,9 @@ func TestPublishBlindedBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedBellatrix) - converted, err := shared.BlindedBeaconBlockBellatrixFromConsensus(block.BlindedBellatrix.Block) + converted, err := structs.BlindedBeaconBlockBellatrixFromConsensus(block.BlindedBellatrix.Block) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockBellatrix + var signedblock *structs.SignedBlindedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1418,9 +1418,9 @@ func TestPublishBlindedBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedCapella) - converted, err := shared.BlindedBeaconBlockCapellaFromConsensus(block.BlindedCapella.Block) + converted, err := structs.BlindedBeaconBlockCapellaFromConsensus(block.BlindedCapella.Block) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockCapella + var signedblock *structs.SignedBlindedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1442,9 +1442,9 @@ func TestPublishBlindedBlock(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedDeneb) - converted, err := shared.BlindedBeaconBlockDenebFromConsensus(block.BlindedDeneb.Message) + converted, err := structs.BlindedBeaconBlockDenebFromConsensus(block.BlindedDeneb.Message) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockDeneb + var signedblock *structs.SignedBlindedBeaconBlockDeneb err = json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1512,10 +1512,10 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1523,7 +1523,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlock + var blk structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1542,10 +1542,10 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1553,7 +1553,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockAltair + var blk structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1579,7 +1579,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1605,7 +1605,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockCapella + var blk structs.SignedBlindedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1631,7 +1631,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockDeneb + var blk structs.SignedBlindedBeaconBlockDeneb err := json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1664,7 +1664,7 @@ func TestPublishBlindedBlockSSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1705,10 +1705,10 @@ func TestPublishBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1727,10 +1727,10 @@ func TestPublishBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1749,9 +1749,9 @@ func TestPublishBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Bellatrix) - converted, err := shared.BeaconBlockBellatrixFromConsensus(block.Bellatrix.Block) + converted, err := structs.BeaconBlockBellatrixFromConsensus(block.Bellatrix.Block) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockBellatrix + var signedblock *structs.SignedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BellatrixBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1773,9 +1773,9 @@ func TestPublishBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Capella) - converted, err := shared.BeaconBlockCapellaFromConsensus(block.Capella.Block) + converted, err := structs.BeaconBlockCapellaFromConsensus(block.Capella.Block) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockCapella + var signedblock *structs.SignedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.CapellaBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -1797,9 +1797,9 @@ func TestPublishBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Deneb) - converted, err := shared.SignedBeaconBlockContentsDenebFromConsensus(block.Deneb) + converted, err := structs.SignedBeaconBlockContentsDenebFromConsensus(block.Deneb) require.NoError(t, err) - var signedblock *shared.SignedBeaconBlockContentsDeneb + var signedblock *structs.SignedBeaconBlockContentsDeneb err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock) @@ -1880,10 +1880,10 @@ func TestPublishBlockV2SSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -1891,7 +1891,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlock + var blk structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1910,10 +1910,10 @@ func TestPublishBlockV2SSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -1921,7 +1921,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockAltair + var blk structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1946,7 +1946,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { V1Alpha1ValidatorServer: v1alpha1Server, SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockBellatrix + var blk structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1972,7 +1972,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockCapella + var blk structs.SignedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.CapellaBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -1998,7 +1998,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockContentsDeneb + var blk structs.SignedBeaconBlockContentsDeneb err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2018,7 +2018,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2039,7 +2039,7 @@ func TestPublishBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockBellatrix + var blk structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2093,10 +2093,10 @@ func TestPublishBlindedBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -2115,10 +2115,10 @@ func TestPublishBlindedBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -2137,9 +2137,9 @@ func TestPublishBlindedBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedBellatrix) - converted, err := shared.BlindedBeaconBlockBellatrixFromConsensus(block.BlindedBellatrix.Block) + converted, err := structs.BlindedBeaconBlockBellatrixFromConsensus(block.BlindedBellatrix.Block) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockBellatrix + var signedblock *structs.SignedBlindedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -2161,9 +2161,9 @@ func TestPublishBlindedBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedCapella) - converted, err := shared.BlindedBeaconBlockCapellaFromConsensus(block.BlindedCapella.Block) + converted, err := structs.BlindedBeaconBlockCapellaFromConsensus(block.BlindedCapella.Block) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockCapella + var signedblock *structs.SignedBlindedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -2185,9 +2185,9 @@ func TestPublishBlindedBlockV2(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_BlindedDeneb) - converted, err := shared.BlindedBeaconBlockDenebFromConsensus(block.BlindedDeneb.Message) + converted, err := structs.BlindedBeaconBlockDenebFromConsensus(block.BlindedDeneb.Message) require.NoError(t, err) - var signedblock *shared.SignedBlindedBeaconBlockDeneb + var signedblock *structs.SignedBlindedBeaconBlockDeneb err = json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &signedblock) require.NoError(t, err) require.DeepEqual(t, converted, signedblock.Message) @@ -2267,10 +2267,10 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Phase0) - var signedblock *shared.SignedBeaconBlock + var signedblock *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockFromConsensus(block.Phase0.Block), signedblock.Message) return ok })) server := &Server{ @@ -2278,7 +2278,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlock + var blk structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2297,10 +2297,10 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), mock.MatchedBy(func(req *eth.GenericSignedBeaconBlock) bool { block, ok := req.Block.(*eth.GenericSignedBeaconBlock_Altair) - var signedblock *shared.SignedBeaconBlockAltair + var signedblock *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &signedblock) require.NoError(t, err) - require.DeepEqual(t, shared.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) + require.DeepEqual(t, structs.BeaconBlockAltairFromConsensus(block.Altair.Block), signedblock.Message) return ok })) server := &Server{ @@ -2308,7 +2308,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBeaconBlockAltair + var blk structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2334,7 +2334,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2360,7 +2360,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockCapella + var blk structs.SignedBlindedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2386,7 +2386,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockDeneb + var blk structs.SignedBlindedBeaconBlockDeneb err := json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2419,7 +2419,7 @@ func TestPublishBlindedBlockV2SSZ(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, } - var blk shared.SignedBlindedBeaconBlockBellatrix + var blk structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &blk) require.NoError(t, err) genericBlock, err := blk.ToGeneric() @@ -2639,7 +2639,7 @@ func TestServer_GetBlockRoot(t *testing.T) { bs.GetBlockRoot(writer, request) assert.Equal(t, tt.wantCode, writer.Code) - resp := &BlockRootResponse{} + resp := &structs.BlockRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) if tt.wantErr != "" { require.ErrorContains(t, tt.wantErr, errors.New(writer.Body.String())) @@ -2681,7 +2681,7 @@ func TestServer_GetBlockRoot(t *testing.T) { bs.GetBlockRoot(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRootResponse{} + resp := &structs.BlockRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.DeepEqual(t, resp.ExecutionOptimistic, true) }) @@ -2716,7 +2716,7 @@ func TestServer_GetBlockRoot(t *testing.T) { bs.GetBlockRoot(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRootResponse{} + resp := &structs.BlockRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.DeepEqual(t, resp.Finalized, true) }) @@ -2728,7 +2728,7 @@ func TestServer_GetBlockRoot(t *testing.T) { bs.GetBlockRoot(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRootResponse{} + resp := &structs.BlockRootResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.DeepEqual(t, resp.Finalized, false) }) @@ -2768,7 +2768,7 @@ func TestGetStateFork(t *testing.T) { server.GetStateFork(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var stateForkReponse *GetStateForkResponse + var stateForkReponse *structs.GetStateForkResponse err = json.Unmarshal(writer.Body.Bytes(), &stateForkReponse) require.NoError(t, err) expectedFork := fakeState.Fork() @@ -2872,7 +2872,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, int(params.BeaconConfig().SlotsPerEpoch)*2, len(resp.Data)) for _, datum := range resp.Data { @@ -2893,7 +2893,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) for _, datum := range resp.Data { slot, err := strconv.ParseUint(datum.Slot, 10, 32) @@ -2910,7 +2910,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 2, len(resp.Data)) @@ -2936,7 +2936,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, int(params.BeaconConfig().SlotsPerEpoch), len(resp.Data)) @@ -2962,7 +2962,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 1, len(resp.Data)) @@ -3005,7 +3005,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -3042,7 +3042,7 @@ func TestGetCommittees(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetCommittees(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetCommitteesResponse{} + resp := &structs.GetCommitteesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NoError(t, err) assert.Equal(t, true, resp.Finalized) @@ -3141,7 +3141,7 @@ func TestGetBlockHeaders(t *testing.T) { bs.GetBlockHeaders(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeadersResponse{} + resp := &structs.GetBlockHeadersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, len(tt.want), len(resp.Data)) @@ -3158,7 +3158,7 @@ func TestGetBlockHeaders(t *testing.T) { expectedHeaderRoot, err := expectedHeader.HashTreeRoot() require.NoError(t, err) assert.DeepEqual(t, hexutil.Encode(expectedHeaderRoot[:]), resp.Data[i].Root) - assert.DeepEqual(t, shared.BeaconBlockHeaderFromConsensus(expectedHeader), resp.Data[i].Header.Message) + assert.DeepEqual(t, structs.BeaconBlockHeaderFromConsensus(expectedHeader), resp.Data[i].Header.Message) } }) } @@ -3193,7 +3193,7 @@ func TestGetBlockHeaders(t *testing.T) { bs.GetBlockHeaders(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeadersResponse{} + resp := &structs.GetBlockHeadersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -3237,7 +3237,7 @@ func TestGetBlockHeaders(t *testing.T) { bs.GetBlockHeaders(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeadersResponse{} + resp := &structs.GetBlockHeadersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -3251,7 +3251,7 @@ func TestGetBlockHeaders(t *testing.T) { bs.GetBlockHeaders(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeadersResponse{} + resp := &structs.GetBlockHeadersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.Finalized) }) @@ -3264,7 +3264,7 @@ func TestGetBlockHeaders(t *testing.T) { bs.GetBlockHeaders(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeadersResponse{} + resp := &structs.GetBlockHeadersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.Finalized) }) @@ -3315,7 +3315,7 @@ func TestServer_GetBlockHeader(t *testing.T) { s.GetBlockHeader(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeaderResponse{} + resp := &structs.GetBlockHeaderResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Data.Canonical) assert.Equal(t, "0xd7d92f6206707f2c9c4e7e82320617d5abac2b6461a65ea5bb1a154b5b5ea2fa", resp.Data.Root) @@ -3359,7 +3359,7 @@ func TestServer_GetBlockHeader(t *testing.T) { s.GetBlockHeader(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeaderResponse{} + resp := &structs.GetBlockHeaderResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -3383,7 +3383,7 @@ func TestServer_GetBlockHeader(t *testing.T) { s.GetBlockHeader(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeaderResponse{} + resp := &structs.GetBlockHeaderResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -3403,7 +3403,7 @@ func TestServer_GetBlockHeader(t *testing.T) { s.GetBlockHeader(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBlockHeaderResponse{} + resp := &structs.GetBlockHeaderResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, false, resp.Finalized) }) @@ -3455,7 +3455,7 @@ func TestGetFinalityCheckpoints(t *testing.T) { s.GetFinalityCheckpoints(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetFinalityCheckpointsResponse{} + resp := &structs.GetFinalityCheckpointsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) assert.Equal(t, strconv.FormatUint(uint64(fakeState.FinalizedCheckpoint().Epoch), 10), resp.Data.Finalized.Epoch) @@ -3508,7 +3508,7 @@ func TestGetFinalityCheckpoints(t *testing.T) { s.GetFinalityCheckpoints(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetFinalityCheckpointsResponse{} + resp := &structs.GetFinalityCheckpointsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -3536,7 +3536,7 @@ func TestGetFinalityCheckpoints(t *testing.T) { s.GetFinalityCheckpoints(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetFinalityCheckpointsResponse{} + resp := &structs.GetFinalityCheckpointsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -3566,7 +3566,7 @@ func TestGetGenesis(t *testing.T) { s.GetGenesis(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetGenesisResponse{} + resp := &structs.GetGenesisResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) diff --git a/beacon-chain/rpc/eth/beacon/handlers_validator.go b/beacon-chain/rpc/eth/beacon/handlers_validator.go index 6092771ef5..924274a7f0 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_validator.go +++ b/beacon-chain/rpc/eth/beacon/handlers_validator.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" @@ -51,7 +52,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - var req GetValidatorsRequest + var req structs.GetValidatorsRequest if r.Method == http.MethodPost { err = json.NewDecoder(r.Body).Decode(&req) switch { @@ -83,8 +84,8 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { } // return no data if all IDs are ignored if len(rawIds) > 0 && len(ids) == 0 { - resp := &GetValidatorsResponse{ - Data: []*ValidatorContainer{}, + resp := &structs.GetValidatorsResponse{ + Data: []*structs.ValidatorContainer{}, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, } @@ -100,7 +101,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { // Exit early if no matching validators were found or we don't want to further filter validators by status. if len(readOnlyVals) == 0 || len(statuses) == 0 { - containers := make([]*ValidatorContainer, len(readOnlyVals)) + containers := make([]*structs.ValidatorContainer, len(readOnlyVals)) for i, val := range readOnlyVals { valStatus, err := helpers.ValidatorSubStatus(val, epoch) if err != nil { @@ -118,7 +119,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { } containers[i] = valContainerFromReadOnlyVal(val, id, balance, valStatus) } - resp := &GetValidatorsResponse{ + resp := &structs.GetValidatorsResponse{ Data: containers, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -136,7 +137,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { } filteredStatuses[vs] = true } - valContainers := make([]*ValidatorContainer, 0, len(readOnlyVals)) + valContainers := make([]*structs.ValidatorContainer, 0, len(readOnlyVals)) for i, val := range readOnlyVals { valStatus, err := helpers.ValidatorStatus(val, epoch) if err != nil { @@ -149,7 +150,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { return } if filteredStatuses[valStatus] || filteredStatuses[valSubStatus] { - var container *ValidatorContainer + var container *structs.ValidatorContainer id := primitives.ValidatorIndex(i) if len(ids) > 0 { id = ids[i] @@ -164,7 +165,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { } } - resp := &GetValidatorsResponse{ + resp := &structs.GetValidatorsResponse{ Data: valContainers, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -229,7 +230,7 @@ func (s *Server) GetValidator(w http.ResponseWriter, r *http.Request) { } isFinalized := s.FinalizationFetcher.IsFinalized(ctx, blockRoot) - resp := &GetValidatorResponse{ + resp := &structs.GetValidatorResponse{ Data: container, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -286,8 +287,8 @@ func (s *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request) { } // return no data if all IDs are ignored if len(rawIds) > 0 && len(ids) == 0 { - resp := &GetValidatorBalancesResponse{ - Data: []*ValidatorBalance{}, + resp := &structs.GetValidatorBalancesResponse{ + Data: []*structs.ValidatorBalance{}, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, } @@ -296,26 +297,26 @@ func (s *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request) { } bals := st.Balances() - var valBalances []*ValidatorBalance + var valBalances []*structs.ValidatorBalance if len(ids) == 0 { - valBalances = make([]*ValidatorBalance, len(bals)) + valBalances = make([]*structs.ValidatorBalance, len(bals)) for i, b := range bals { - valBalances[i] = &ValidatorBalance{ + valBalances[i] = &structs.ValidatorBalance{ Index: strconv.FormatUint(uint64(i), 10), Balance: strconv.FormatUint(b, 10), } } } else { - valBalances = make([]*ValidatorBalance, len(ids)) + valBalances = make([]*structs.ValidatorBalance, len(ids)) for i, id := range ids { - valBalances[i] = &ValidatorBalance{ + valBalances[i] = &structs.ValidatorBalance{ Index: strconv.FormatUint(uint64(id), 10), Balance: strconv.FormatUint(bals[id], 10), } } } - resp := &GetValidatorBalancesResponse{ + resp := &structs.GetValidatorBalancesResponse{ Data: valBalances, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -404,13 +405,13 @@ func valContainerFromReadOnlyVal( id primitives.ValidatorIndex, bal uint64, valStatus validator.Status, -) *ValidatorContainer { +) *structs.ValidatorContainer { pubkey := val.PublicKey() - return &ValidatorContainer{ + return &structs.ValidatorContainer{ Index: strconv.FormatUint(uint64(id), 10), Balance: strconv.FormatUint(bal, 10), Status: valStatus.String(), - Validator: &Validator{ + Validator: &structs.Validator{ Pubkey: hexutil.Encode(pubkey[:]), WithdrawalCredentials: hexutil.Encode(val.WithdrawalCredentials()), EffectiveBalance: strconv.FormatUint(val.EffectiveBalance(), 10), diff --git a/beacon-chain/rpc/eth/beacon/handlers_validators_test.go b/beacon-chain/rpc/eth/beacon/handlers_validators_test.go index b5b27f13b0..9aa21ee9a5 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_validators_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_validators_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" chainMock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/lookup" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" @@ -52,7 +53,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) val := resp.Data[0] @@ -91,7 +92,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -123,7 +124,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -153,7 +154,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -202,7 +203,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "1", resp.Data[0].Index) @@ -225,7 +226,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "1", resp.Data[0].Index) @@ -248,7 +249,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -276,7 +277,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -292,7 +293,7 @@ func TestGetValidators(t *testing.T) { } var body bytes.Buffer - req := &GetValidatorsRequest{ + req := &structs.GetValidatorsRequest{ Ids: []string{"0", strconv.Itoa(exitedValIndex)}, Statuses: []string{"exited"}, } @@ -311,7 +312,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "3", resp.Data[0].Index) @@ -328,7 +329,7 @@ func TestGetValidators(t *testing.T) { } var body bytes.Buffer - req := &GetValidatorsRequest{ + req := &structs.GetValidatorsRequest{ Ids: nil, Statuses: nil, } @@ -347,7 +348,7 @@ func TestGetValidators(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) }) @@ -497,7 +498,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 3, len(resp.Data)) for _, vc := range resp.Data { @@ -528,7 +529,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 2, len(resp.Data)) for _, vc := range resp.Data { @@ -558,7 +559,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 4, len(resp.Data)) for _, vc := range resp.Data { @@ -591,7 +592,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 4, len(resp.Data)) for _, vc := range resp.Data { @@ -624,7 +625,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 2, len(resp.Data)) for _, vc := range resp.Data { @@ -659,7 +660,7 @@ func TestGetValidator(t *testing.T) { s.GetValidator(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorResponse{} + resp := &structs.GetValidatorResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "0", resp.Data.Index) assert.Equal(t, "32000000000", resp.Data.Balance) @@ -694,7 +695,7 @@ func TestGetValidator(t *testing.T) { s.GetValidator(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorResponse{} + resp := &structs.GetValidatorResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "0", resp.Data.Index) }) @@ -796,7 +797,7 @@ func TestGetValidator(t *testing.T) { s.GetValidator(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorResponse{} + resp := &structs.GetValidatorResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -824,7 +825,7 @@ func TestGetValidator(t *testing.T) { s.GetValidator(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorResponse{} + resp := &structs.GetValidatorResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -858,7 +859,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) val := resp.Data[3] @@ -887,7 +888,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -919,7 +920,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -949,7 +950,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidators(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorsResponse{} + resp := &structs.GetValidatorsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) @@ -979,7 +980,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "1", resp.Data[0].Index) @@ -1002,7 +1003,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "1", resp.Data[0].Index) @@ -1048,7 +1049,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -1080,7 +1081,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -1113,7 +1114,7 @@ func TestGetValidatorBalances(t *testing.T) { s.GetValidatorBalances(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetValidatorBalancesResponse{} + resp := &structs.GetValidatorBalancesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) assert.Equal(t, "0", resp.Data[0].Index) diff --git a/beacon-chain/rpc/eth/blob/BUILD.bazel b/beacon-chain/rpc/eth/blob/BUILD.bazel index 13a56c9ffe..77320dc2f5 100644 --- a/beacon-chain/rpc/eth/blob/BUILD.bazel +++ b/beacon-chain/rpc/eth/blob/BUILD.bazel @@ -5,13 +5,12 @@ go_library( srcs = [ "handlers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/blob", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/rpc/core:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/lookup:go_default_library", "//config/fieldparams:go_default_library", "//network/httputil:go_default_library", @@ -26,6 +25,7 @@ go_test( srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/db/filesystem:go_default_library", "//beacon-chain/db/testing:go_default_library", diff --git a/beacon-chain/rpc/eth/blob/handlers.go b/beacon-chain/rpc/eth/blob/handlers.go index 5e14e5efbe..ba80b0b1c8 100644 --- a/beacon-chain/rpc/eth/blob/handlers.go +++ b/beacon-chain/rpc/eth/blob/handlers.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/core" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" field_params "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/network/httputil" eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" @@ -85,18 +85,18 @@ loop: return indices } -func buildSidecarsResponse(sidecars []*eth.BlobSidecar) *SidecarsResponse { - resp := &SidecarsResponse{Data: make([]*Sidecar, len(sidecars))} +func buildSidecarsResponse(sidecars []*eth.BlobSidecar) *structs.SidecarsResponse { + resp := &structs.SidecarsResponse{Data: make([]*structs.Sidecar, len(sidecars))} for i, sc := range sidecars { proofs := make([]string, len(sc.CommitmentInclusionProof)) for j := range sc.CommitmentInclusionProof { proofs[j] = hexutil.Encode(sc.CommitmentInclusionProof[j]) } - resp.Data[i] = &Sidecar{ + resp.Data[i] = &structs.Sidecar{ Index: strconv.FormatUint(sc.Index, 10), Blob: hexutil.Encode(sc.Blob), KzgCommitment: hexutil.Encode(sc.KzgCommitment), - SignedBeaconBlockHeader: shared.SignedBeaconBlockHeaderFromConsensus(sc.SignedBlockHeader), + SignedBeaconBlockHeader: structs.SignedBeaconBlockHeaderFromConsensus(sc.SignedBlockHeader), KzgProof: hexutil.Encode(sc.KzgProof), CommitmentInclusionProof: proofs, } diff --git a/beacon-chain/rpc/eth/blob/handlers_test.go b/beacon-chain/rpc/eth/blob/handlers_test.go index 7a6c571df5..f489eaa233 100644 --- a/beacon-chain/rpc/eth/blob/handlers_test.go +++ b/beacon-chain/rpc/eth/blob/handlers_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mockChain "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/filesystem" testDB "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing" @@ -80,7 +81,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) sidecar := resp.Data[0] @@ -125,7 +126,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) }) @@ -146,7 +147,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) }) @@ -166,7 +167,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) }) @@ -186,7 +187,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 4, len(resp.Data)) }) @@ -207,7 +208,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) sidecar := resp.Data[0] @@ -233,7 +234,7 @@ func TestBlobs(t *testing.T) { s.Blobs(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SidecarsResponse{} + resp := &structs.SidecarsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, len(resp.Data), 0) }) diff --git a/beacon-chain/rpc/eth/blob/structs.go b/beacon-chain/rpc/eth/blob/structs.go deleted file mode 100644 index ec8056d268..0000000000 --- a/beacon-chain/rpc/eth/blob/structs.go +++ /dev/null @@ -1,16 +0,0 @@ -package blob - -import "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" - -type SidecarsResponse struct { - Data []*Sidecar `json:"data"` -} - -type Sidecar struct { - Index string `json:"index"` - Blob string `json:"blob"` - SignedBeaconBlockHeader *shared.SignedBeaconBlockHeader `json:"signed_block_header"` - KzgCommitment string `json:"kzg_commitment"` - KzgProof string `json:"kzg_proof"` - CommitmentInclusionProof []string `json:"kzg_commitment_inclusion_proof"` -} diff --git a/beacon-chain/rpc/eth/builder/BUILD.bazel b/beacon-chain/rpc/eth/builder/BUILD.bazel index bb131d7986..17fe572416 100644 --- a/beacon-chain/rpc/eth/builder/BUILD.bazel +++ b/beacon-chain/rpc/eth/builder/BUILD.bazel @@ -5,11 +5,11 @@ go_library( srcs = [ "handlers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/builder", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/transition:go_default_library", @@ -30,6 +30,7 @@ go_test( srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", "//beacon-chain/state:go_default_library", diff --git a/beacon-chain/rpc/eth/builder/handlers.go b/beacon-chain/rpc/eth/builder/handlers.go index 6b80b0cfe1..60b21fc3e3 100644 --- a/beacon-chain/rpc/eth/builder/handlers.go +++ b/beacon-chain/rpc/eth/builder/handlers.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" "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/core/transition" "github.com/prysmaticlabs/prysm/v4/config/params" @@ -103,17 +104,17 @@ func (s *Server) ExpectedWithdrawals(w http.ResponseWriter, r *http.Request) { }) return } - httputil.WriteJson(w, &ExpectedWithdrawalsResponse{ + httputil.WriteJson(w, &structs.ExpectedWithdrawalsResponse{ ExecutionOptimistic: isOptimistic, Finalized: isFinalized, Data: buildExpectedWithdrawalsData(withdrawals), }) } -func buildExpectedWithdrawalsData(withdrawals []*enginev1.Withdrawal) []*ExpectedWithdrawal { - data := make([]*ExpectedWithdrawal, len(withdrawals)) +func buildExpectedWithdrawalsData(withdrawals []*enginev1.Withdrawal) []*structs.ExpectedWithdrawal { + data := make([]*structs.ExpectedWithdrawal, len(withdrawals)) for i, withdrawal := range withdrawals { - data[i] = &ExpectedWithdrawal{ + data[i] = &structs.ExpectedWithdrawal{ Address: hexutil.Encode(withdrawal.Address), Amount: strconv.FormatUint(withdrawal.Amount, 10), Index: strconv.FormatUint(withdrawal.Index, 10), diff --git a/beacon-chain/rpc/eth/builder/handlers_test.go b/beacon-chain/rpc/eth/builder/handlers_test.go index a421ab8737..75435eef06 100644 --- a/beacon-chain/rpc/eth/builder/handlers_test.go +++ b/beacon-chain/rpc/eth/builder/handlers_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" @@ -177,26 +178,26 @@ func TestExpectedWithdrawals(t *testing.T) { s.ExpectedWithdrawals(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ExpectedWithdrawalsResponse{} + resp := &structs.ExpectedWithdrawalsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) assert.Equal(t, false, resp.Finalized) assert.Equal(t, 3, len(resp.Data)) - expectedWithdrawal1 := &ExpectedWithdrawal{ + expectedWithdrawal1 := &structs.ExpectedWithdrawal{ Index: strconv.FormatUint(0, 10), ValidatorIndex: strconv.FormatUint(5, 10), Address: hexutil.Encode(validators[5].WithdrawalCredentials[12:]), // Decreased due to epoch processing when state advanced forward Amount: strconv.FormatUint(31998257885, 10), } - expectedWithdrawal2 := &ExpectedWithdrawal{ + expectedWithdrawal2 := &structs.ExpectedWithdrawal{ Index: strconv.FormatUint(1, 10), ValidatorIndex: strconv.FormatUint(14, 10), Address: hexutil.Encode(validators[14].WithdrawalCredentials[12:]), // MaxEffectiveBalance + MinDepositAmount + decrease after epoch processing Amount: strconv.FormatUint(32998257885, 10), } - expectedWithdrawal3 := &ExpectedWithdrawal{ + expectedWithdrawal3 := &structs.ExpectedWithdrawal{ Index: strconv.FormatUint(2, 10), ValidatorIndex: strconv.FormatUint(15, 10), Address: hexutil.Encode(validators[15].WithdrawalCredentials[12:]), diff --git a/beacon-chain/rpc/eth/config/BUILD.bazel b/beacon-chain/rpc/eth/config/BUILD.bazel index 99602f935c..c7233bf98d 100644 --- a/beacon-chain/rpc/eth/config/BUILD.bazel +++ b/beacon-chain/rpc/eth/config/BUILD.bazel @@ -2,14 +2,11 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = [ - "handlers.go", - "structs.go", - ], + srcs = ["handlers.go"], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/config", visibility = ["//visibility:public"], deps = [ - "//beacon-chain/rpc/eth/shared:go_default_library", + "//api/server/structs:go_default_library", "//config/params:go_default_library", "//network/forks:go_default_library", "//network/httputil:go_default_library", @@ -23,6 +20,7 @@ go_test( srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/beacon-chain/rpc/eth/config/handlers.go b/beacon-chain/rpc/eth/config/handlers.go index 4792f7a9bb..3381e7b705 100644 --- a/beacon-chain/rpc/eth/config/handlers.go +++ b/beacon-chain/rpc/eth/config/handlers.go @@ -8,7 +8,7 @@ import ( "strings" "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" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/network/forks" "github.com/prysmaticlabs/prysm/v4/network/httputil" @@ -20,8 +20,8 @@ func GetDepositContract(w http.ResponseWriter, r *http.Request) { _, span := trace.StartSpan(r.Context(), "config.GetDepositContract") defer span.End() - httputil.WriteJson(w, &GetDepositContractResponse{ - Data: &DepositContractData{ + httputil.WriteJson(w, &structs.GetDepositContractResponse{ + Data: &structs.DepositContractData{ ChainId: strconv.FormatUint(params.BeaconConfig().DepositChainID, 10), Address: params.BeaconConfig().DepositContractAddress, }, @@ -35,14 +35,14 @@ func GetForkSchedule(w http.ResponseWriter, r *http.Request) { schedule := params.BeaconConfig().ForkVersionSchedule if len(schedule) == 0 { - httputil.WriteJson(w, &GetForkScheduleResponse{ - Data: make([]*shared.Fork, 0), + httputil.WriteJson(w, &structs.GetForkScheduleResponse{ + Data: make([]*structs.Fork, 0), }) return } versions := forks.SortedForkVersions(schedule) - chainForks := make([]*shared.Fork, len(schedule)) + chainForks := make([]*structs.Fork, len(schedule)) var previous, current []byte for i, v := range versions { if i == 0 { @@ -52,14 +52,14 @@ func GetForkSchedule(w http.ResponseWriter, r *http.Request) { } copyV := v current = copyV[:] - chainForks[i] = &shared.Fork{ + chainForks[i] = &structs.Fork{ PreviousVersion: hexutil.Encode(previous), CurrentVersion: hexutil.Encode(current), Epoch: fmt.Sprintf("%d", schedule[v]), } } - httputil.WriteJson(w, &GetForkScheduleResponse{ + httputil.WriteJson(w, &structs.GetForkScheduleResponse{ Data: chainForks, }) } @@ -77,7 +77,7 @@ func GetSpec(w http.ResponseWriter, r *http.Request) { httputil.HandleError(w, "Could not prepare config spec: "+err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &GetSpecResponse{Data: data}) + httputil.WriteJson(w, &structs.GetSpecResponse{Data: data}) } func prepareConfigSpec() (map[string]string, error) { diff --git a/beacon-chain/rpc/eth/config/handlers_test.go b/beacon-chain/rpc/eth/config/handlers_test.go index 21c3058ffd..e091b2551c 100644 --- a/beacon-chain/rpc/eth/config/handlers_test.go +++ b/beacon-chain/rpc/eth/config/handlers_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" @@ -33,7 +34,7 @@ func TestGetDepositContract(t *testing.T) { GetDepositContract(writer, request) require.Equal(t, http.StatusOK, writer.Code) - response := GetDepositContractResponse{} + response := structs.GetDepositContractResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &response)) assert.Equal(t, "10", response.Data.ChainId) assert.Equal(t, "0x4242424242424242424242424242424242424242", response.Data.Address) @@ -167,7 +168,7 @@ func TestGetSpec(t *testing.T) { GetSpec(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := GetSpecResponse{} + resp := structs.GetSpecResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) data, ok := resp.Data.(map[string]interface{}) require.Equal(t, true, ok) @@ -486,7 +487,7 @@ func TestForkSchedule_Ok(t *testing.T) { GetForkSchedule(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetForkScheduleResponse{} + resp := &structs.GetForkScheduleResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 3, len(resp.Data)) fork := resp.Data[0] @@ -509,7 +510,7 @@ func TestForkSchedule_Ok(t *testing.T) { GetForkSchedule(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetForkScheduleResponse{} + resp := &structs.GetForkScheduleResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) os := forks.NewOrderedSchedule(params.BeaconConfig()) assert.Equal(t, os.Len(), len(resp.Data)) diff --git a/beacon-chain/rpc/eth/debug/BUILD.bazel b/beacon-chain/rpc/eth/debug/BUILD.bazel index a192e0ff9c..8d57213004 100644 --- a/beacon-chain/rpc/eth/debug/BUILD.bazel +++ b/beacon-chain/rpc/eth/debug/BUILD.bazel @@ -5,12 +5,12 @@ go_library( srcs = [ "handlers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/debug", visibility = ["//visibility:public"], deps = [ "//api:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", "//beacon-chain/rpc/eth/helpers:go_default_library", @@ -30,11 +30,11 @@ go_test( embed = [":go_default_library"], deps = [ "//api:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/db/testing:go_default_library", "//beacon-chain/forkchoice/doubly-linked-tree:go_default_library", "//beacon-chain/forkchoice/types:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", "//encoding/bytesutil:go_default_library", "//runtime/version:go_default_library", diff --git a/beacon-chain/rpc/eth/debug/handlers.go b/beacon-chain/rpc/eth/debug/handlers.go index 3a885d750e..81cf1231b4 100644 --- a/beacon-chain/rpc/eth/debug/handlers.go +++ b/beacon-chain/rpc/eth/debug/handlers.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/network/httputil" @@ -84,31 +85,31 @@ func (s *Server) getBeaconStateV2(ctx context.Context, w http.ResponseWriter, id switch st.Version() { case version.Phase0: - respSt, err = shared.BeaconStateFromConsensus(st) + respSt, err = structs.BeaconStateFromConsensus(st) if err != nil { httputil.HandleError(w, errMsgStateFromConsensus+": "+err.Error(), http.StatusInternalServerError) return } case version.Altair: - respSt, err = shared.BeaconStateAltairFromConsensus(st) + respSt, err = structs.BeaconStateAltairFromConsensus(st) if err != nil { httputil.HandleError(w, errMsgStateFromConsensus+": "+err.Error(), http.StatusInternalServerError) return } case version.Bellatrix: - respSt, err = shared.BeaconStateBellatrixFromConsensus(st) + respSt, err = structs.BeaconStateBellatrixFromConsensus(st) if err != nil { httputil.HandleError(w, errMsgStateFromConsensus+": "+err.Error(), http.StatusInternalServerError) return } case version.Capella: - respSt, err = shared.BeaconStateCapellaFromConsensus(st) + respSt, err = structs.BeaconStateCapellaFromConsensus(st) if err != nil { httputil.HandleError(w, errMsgStateFromConsensus+": "+err.Error(), http.StatusInternalServerError) return } case version.Deneb: - respSt, err = shared.BeaconStateDenebFromConsensus(st) + respSt, err = structs.BeaconStateDenebFromConsensus(st) if err != nil { httputil.HandleError(w, errMsgStateFromConsensus+": "+err.Error(), http.StatusInternalServerError) return @@ -124,7 +125,7 @@ func (s *Server) getBeaconStateV2(ctx context.Context, w http.ResponseWriter, id return } ver := version.String(st.Version()) - resp := &GetBeaconStateV2Response{ + resp := &structs.GetBeaconStateV2Response{ Version: ver, ExecutionOptimistic: isOptimistic, Finalized: isFinalized, @@ -156,8 +157,8 @@ func (s *Server) GetForkChoiceHeadsV2(w http.ResponseWriter, r *http.Request) { defer span.End() headRoots, headSlots := s.HeadFetcher.ChainHeads() - resp := &GetForkChoiceHeadsV2Response{ - Data: make([]*ForkChoiceHead, len(headRoots)), + resp := &structs.GetForkChoiceHeadsV2Response{ + Data: make([]*structs.ForkChoiceHead, len(headRoots)), } for i := range headRoots { isOptimistic, err := s.OptimisticModeFetcher.IsOptimisticForRoot(ctx, headRoots[i]) @@ -165,7 +166,7 @@ func (s *Server) GetForkChoiceHeadsV2(w http.ResponseWriter, r *http.Request) { httputil.HandleError(w, "Could not check if head is optimistic: "+err.Error(), http.StatusInternalServerError) return } - resp.Data[i] = &ForkChoiceHead{ + resp.Data[i] = &structs.ForkChoiceHead{ Root: hexutil.Encode(headRoots[i][:]), Slot: fmt.Sprintf("%d", headSlots[i]), ExecutionOptimistic: isOptimistic, @@ -186,9 +187,9 @@ func (s *Server) GetForkChoice(w http.ResponseWriter, r *http.Request) { return } - nodes := make([]*ForkChoiceNode, len(dump.ForkChoiceNodes)) + nodes := make([]*structs.ForkChoiceNode, len(dump.ForkChoiceNodes)) for i, n := range dump.ForkChoiceNodes { - nodes[i] = &ForkChoiceNode{ + nodes[i] = &structs.ForkChoiceNode{ Slot: fmt.Sprintf("%d", n.Slot), BlockRoot: hexutil.Encode(n.BlockRoot), ParentRoot: hexutil.Encode(n.ParentRoot), @@ -197,7 +198,7 @@ func (s *Server) GetForkChoice(w http.ResponseWriter, r *http.Request) { Weight: fmt.Sprintf("%d", n.Weight), ExecutionBlockHash: hexutil.Encode(n.ExecutionBlockHash), Validity: n.Validity.String(), - ExtraData: &ForkChoiceNodeExtraData{ + ExtraData: &structs.ForkChoiceNodeExtraData{ UnrealizedJustifiedEpoch: fmt.Sprintf("%d", n.UnrealizedJustifiedEpoch), UnrealizedFinalizedEpoch: fmt.Sprintf("%d", n.UnrealizedFinalizedEpoch), Balance: fmt.Sprintf("%d", n.Balance), @@ -206,13 +207,13 @@ func (s *Server) GetForkChoice(w http.ResponseWriter, r *http.Request) { }, } } - resp := &GetForkChoiceDumpResponse{ - JustifiedCheckpoint: shared.CheckpointFromConsensus(dump.JustifiedCheckpoint), - FinalizedCheckpoint: shared.CheckpointFromConsensus(dump.FinalizedCheckpoint), + resp := &structs.GetForkChoiceDumpResponse{ + JustifiedCheckpoint: structs.CheckpointFromConsensus(dump.JustifiedCheckpoint), + FinalizedCheckpoint: structs.CheckpointFromConsensus(dump.FinalizedCheckpoint), ForkChoiceNodes: nodes, - ExtraData: &ForkChoiceDumpExtraData{ - UnrealizedJustifiedCheckpoint: shared.CheckpointFromConsensus(dump.UnrealizedJustifiedCheckpoint), - UnrealizedFinalizedCheckpoint: shared.CheckpointFromConsensus(dump.UnrealizedFinalizedCheckpoint), + ExtraData: &structs.ForkChoiceDumpExtraData{ + UnrealizedJustifiedCheckpoint: structs.CheckpointFromConsensus(dump.UnrealizedJustifiedCheckpoint), + UnrealizedFinalizedCheckpoint: structs.CheckpointFromConsensus(dump.UnrealizedFinalizedCheckpoint), ProposerBoostRoot: hexutil.Encode(dump.ProposerBoostRoot), PreviousProposerBoostRoot: hexutil.Encode(dump.PreviousProposerBoostRoot), HeadRoot: hexutil.Encode(dump.HeadRoot), diff --git a/beacon-chain/rpc/eth/debug/handlers_test.go b/beacon-chain/rpc/eth/debug/handlers_test.go index 3931c308ef..ab9e294c1e 100644 --- a/beacon-chain/rpc/eth/debug/handlers_test.go +++ b/beacon-chain/rpc/eth/debug/handlers_test.go @@ -11,11 +11,11 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" blockchainmock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" dbtest "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing" doublylinkedtree "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/doubly-linked-tree" forkchoicetypes "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/types" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v4/runtime/version" @@ -71,10 +71,10 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Phase0), resp.Version) - st := &shared.BeaconState{} + st := &structs.BeaconState{} require.NoError(t, json.Unmarshal(resp.Data, st)) assert.Equal(t, "123", st.Slot) }) @@ -99,10 +99,10 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Altair), resp.Version) - st := &shared.BeaconStateAltair{} + st := &structs.BeaconStateAltair{} require.NoError(t, json.Unmarshal(resp.Data, st)) assert.Equal(t, "123", st.Slot) }) @@ -127,10 +127,10 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Bellatrix), resp.Version) - st := &shared.BeaconStateBellatrix{} + st := &structs.BeaconStateBellatrix{} require.NoError(t, json.Unmarshal(resp.Data, st)) assert.Equal(t, "123", st.Slot) }) @@ -155,10 +155,10 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Capella), resp.Version) - st := &shared.BeaconStateCapella{} + st := &structs.BeaconStateCapella{} require.NoError(t, json.Unmarshal(resp.Data, st)) assert.Equal(t, "123", st.Slot) }) @@ -183,10 +183,10 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, version.String(version.Deneb), resp.Version) - st := &shared.BeaconStateDeneb{} + st := &structs.BeaconStateDeneb{} require.NoError(t, json.Unmarshal(resp.Data, st)) assert.Equal(t, "123", st.Slot) }) @@ -219,7 +219,7 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -258,7 +258,7 @@ func TestGetBeaconStateV2(t *testing.T) { s.GetBeaconStateV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetBeaconStateV2Response{} + resp := &structs.GetBeaconStateV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.Finalized) }) @@ -411,7 +411,7 @@ func TestGetForkChoiceHeadsV2(t *testing.T) { s.GetForkChoiceHeadsV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetForkChoiceHeadsV2Response{} + resp := &structs.GetForkChoiceHeadsV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 2, len(resp.Data)) for _, sr := range expectedSlotsAndRoots { @@ -447,7 +447,7 @@ func TestGetForkChoiceHeadsV2(t *testing.T) { s.GetForkChoiceHeadsV2(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetForkChoiceHeadsV2Response{} + resp := &structs.GetForkChoiceHeadsV2Response{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 2, len(resp.Data)) for _, sr := range expectedSlotsAndRoots { @@ -477,7 +477,7 @@ func TestGetForkChoice(t *testing.T) { s.GetForkChoice(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetForkChoiceDumpResponse{} + resp := &structs.GetForkChoiceDumpResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, "2", resp.FinalizedCheckpoint.Epoch) } diff --git a/beacon-chain/rpc/eth/events/BUILD.bazel b/beacon-chain/rpc/eth/events/BUILD.bazel index 378fd828d5..de29757964 100644 --- a/beacon-chain/rpc/eth/events/BUILD.bazel +++ b/beacon-chain/rpc/eth/events/BUILD.bazel @@ -5,12 +5,12 @@ go_library( srcs = [ "events.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/events", visibility = ["//visibility:public"], deps = [ "//api:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/feed:go_default_library", "//beacon-chain/core/feed/operation:go_default_library", @@ -18,7 +18,6 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/time:go_default_library", "//beacon-chain/core/transition:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//config/params:go_default_library", "//network/httputil:go_default_library", "//proto/eth/v1:go_default_library", diff --git a/beacon-chain/rpc/eth/events/events.go b/beacon-chain/rpc/eth/events/events.go index e922e90600..cf38d74147 100644 --- a/beacon-chain/rpc/eth/events/events.go +++ b/beacon-chain/rpc/eth/events/events.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/operation" @@ -16,7 +17,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/transition" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/network/httputil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/eth/v1" @@ -151,7 +151,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, AttestationTopic) return } - att := shared.AttFromConsensus(attData.Attestation.Aggregate) + att := structs.AttFromConsensus(attData.Attestation.Aggregate) send(w, flusher, AttestationTopic, att) case operation.UnaggregatedAttReceived: if _, ok := requestedTopics[AttestationTopic]; !ok { @@ -162,7 +162,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, AttestationTopic) return } - att := shared.AttFromConsensus(attData.Attestation) + att := structs.AttFromConsensus(attData.Attestation) send(w, flusher, AttestationTopic, att) case operation.ExitReceived: if _, ok := requestedTopics[VoluntaryExitTopic]; !ok { @@ -173,7 +173,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, VoluntaryExitTopic) return } - exit := shared.SignedExitFromConsensus(exitData.Exit) + exit := structs.SignedExitFromConsensus(exitData.Exit) send(w, flusher, VoluntaryExitTopic, exit) case operation.SyncCommitteeContributionReceived: if _, ok := requestedTopics[SyncCommitteeContributionTopic]; !ok { @@ -184,7 +184,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, SyncCommitteeContributionTopic) return } - contribution := shared.SignedContributionAndProofFromConsensus(contributionData.Contribution) + contribution := structs.SignedContributionAndProofFromConsensus(contributionData.Contribution) send(w, flusher, SyncCommitteeContributionTopic, contribution) case operation.BLSToExecutionChangeReceived: if _, ok := requestedTopics[BLSToExecutionChangeTopic]; !ok { @@ -195,7 +195,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, BLSToExecutionChangeTopic) return } - send(w, flusher, BLSToExecutionChangeTopic, shared.SignedBLSChangeFromConsensus(changeData.Change)) + send(w, flusher, BLSToExecutionChangeTopic, structs.SignedBLSChangeFromConsensus(changeData.Change)) case operation.BlobSidecarReceived: if _, ok := requestedTopics[BlobSidecarTopic]; !ok { return @@ -206,7 +206,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req return } versionedHash := blockchain.ConvertKzgCommitmentToVersionedHash(blobData.Blob.KzgCommitment) - blobEvent := &BlobSidecarEvent{ + blobEvent := &structs.BlobSidecarEvent{ BlockRoot: hexutil.Encode(blobData.Blob.BlockRootSlice()), Index: fmt.Sprintf("%d", blobData.Blob.Index), Slot: fmt.Sprintf("%d", blobData.Blob.Slot()), @@ -223,7 +223,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, AttesterSlashingTopic) return } - send(w, flusher, AttesterSlashingTopic, shared.AttesterSlashingFromConsensus(attesterSlashingData.AttesterSlashing)) + send(w, flusher, AttesterSlashingTopic, structs.AttesterSlashingFromConsensus(attesterSlashingData.AttesterSlashing)) case operation.ProposerSlashingReceived: if _, ok := requestedTopics[ProposerSlashingTopic]; !ok { return @@ -233,7 +233,7 @@ func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, req write(w, flusher, topicDataMismatch, event.Data, ProposerSlashingTopic) return } - send(w, flusher, ProposerSlashingTopic, shared.ProposerSlashingFromConsensus(proposerSlashingData.ProposerSlashing)) + send(w, flusher, ProposerSlashingTopic, structs.ProposerSlashingFromConsensus(proposerSlashingData.ProposerSlashing)) } } @@ -246,7 +246,7 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f write(w, flusher, topicDataMismatch, event.Data, HeadTopic) return } - head := &HeadEvent{ + head := &structs.HeadEvent{ Slot: fmt.Sprintf("%d", headData.Slot), Block: hexutil.Encode(headData.Block), State: hexutil.Encode(headData.State), @@ -273,7 +273,7 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f write(w, flusher, topicDataMismatch, event.Data, FinalizedCheckpointTopic) return } - checkpoint := &FinalizedCheckpointEvent{ + checkpoint := &structs.FinalizedCheckpointEvent{ Block: hexutil.Encode(checkpointData.Block), State: hexutil.Encode(checkpointData.State), Epoch: fmt.Sprintf("%d", checkpointData.Epoch), @@ -294,24 +294,24 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f for _, b := range updateData.Data.FinalityBranch { finalityBranch = append(finalityBranch, hexutil.Encode(b)) } - update := &LightClientFinalityUpdateEvent{ + update := &structs.LightClientFinalityUpdateEvent{ Version: version.String(int(updateData.Version)), - Data: &LightClientFinalityUpdate{ - AttestedHeader: &shared.BeaconBlockHeader{ + Data: &structs.LightClientFinalityUpdate{ + AttestedHeader: &structs.BeaconBlockHeader{ Slot: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Slot), ProposerIndex: fmt.Sprintf("%d", updateData.Data.AttestedHeader.ProposerIndex), ParentRoot: hexutil.Encode(updateData.Data.AttestedHeader.ParentRoot), StateRoot: hexutil.Encode(updateData.Data.AttestedHeader.StateRoot), BodyRoot: hexutil.Encode(updateData.Data.AttestedHeader.BodyRoot), }, - FinalizedHeader: &shared.BeaconBlockHeader{ + FinalizedHeader: &structs.BeaconBlockHeader{ Slot: fmt.Sprintf("%d", updateData.Data.FinalizedHeader.Slot), ProposerIndex: fmt.Sprintf("%d", updateData.Data.FinalizedHeader.ProposerIndex), ParentRoot: hexutil.Encode(updateData.Data.FinalizedHeader.ParentRoot), StateRoot: hexutil.Encode(updateData.Data.FinalizedHeader.StateRoot), }, FinalityBranch: finalityBranch, - SyncAggregate: &shared.SyncAggregate{ + SyncAggregate: &structs.SyncAggregate{ SyncCommitteeBits: hexutil.Encode(updateData.Data.SyncAggregate.SyncCommitteeBits), SyncCommitteeSignature: hexutil.Encode(updateData.Data.SyncAggregate.SyncCommitteeSignature), }, @@ -328,17 +328,17 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f write(w, flusher, topicDataMismatch, event.Data, LightClientOptimisticUpdateTopic) return } - update := &LightClientOptimisticUpdateEvent{ + update := &structs.LightClientOptimisticUpdateEvent{ Version: version.String(int(updateData.Version)), - Data: &LightClientOptimisticUpdate{ - AttestedHeader: &shared.BeaconBlockHeader{ + Data: &structs.LightClientOptimisticUpdate{ + AttestedHeader: &structs.BeaconBlockHeader{ Slot: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Slot), ProposerIndex: fmt.Sprintf("%d", updateData.Data.AttestedHeader.ProposerIndex), ParentRoot: hexutil.Encode(updateData.Data.AttestedHeader.ParentRoot), StateRoot: hexutil.Encode(updateData.Data.AttestedHeader.StateRoot), BodyRoot: hexutil.Encode(updateData.Data.AttestedHeader.BodyRoot), }, - SyncAggregate: &shared.SyncAggregate{ + SyncAggregate: &structs.SyncAggregate{ SyncCommitteeBits: hexutil.Encode(updateData.Data.SyncAggregate.SyncCommitteeBits), SyncCommitteeSignature: hexutil.Encode(updateData.Data.SyncAggregate.SyncCommitteeSignature), }, @@ -355,7 +355,7 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f write(w, flusher, topicDataMismatch, event.Data, ChainReorgTopic) return } - reorg := &ChainReorgEvent{ + reorg := &structs.ChainReorgEvent{ Slot: fmt.Sprintf("%d", reorgData.Slot), Depth: fmt.Sprintf("%d", reorgData.Depth), OldHeadBlock: hexutil.Encode(reorgData.OldHeadBlock), @@ -380,7 +380,7 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f write(w, flusher, "Could not get block root: "+err.Error()) return } - blk := &BlockEvent{ + blk := &structs.BlockEvent{ Slot: fmt.Sprintf("%d", blkData.Slot), Block: hexutil.Encode(blockRoot[:]), ExecutionOptimistic: blkData.Optimistic, @@ -442,7 +442,7 @@ func (s *Server) sendPayloadAttributes(ctx context.Context, w http.ResponseWrite var attributes interface{} switch headState.Version() { case version.Bellatrix: - attributes = &PayloadAttributesV1{ + attributes = &structs.PayloadAttributesV1{ Timestamp: fmt.Sprintf("%d", t.Unix()), PrevRandao: hexutil.Encode(prevRando), SuggestedFeeRecipient: hexutil.Encode(headPayload.FeeRecipient()), @@ -453,11 +453,11 @@ func (s *Server) sendPayloadAttributes(ctx context.Context, w http.ResponseWrite write(w, flusher, "Could not get head state expected withdrawals: "+err.Error()) return } - attributes = &PayloadAttributesV2{ + attributes = &structs.PayloadAttributesV2{ Timestamp: fmt.Sprintf("%d", t.Unix()), PrevRandao: hexutil.Encode(prevRando), SuggestedFeeRecipient: hexutil.Encode(headPayload.FeeRecipient()), - Withdrawals: shared.WithdrawalsFromConsensus(withdrawals), + Withdrawals: structs.WithdrawalsFromConsensus(withdrawals), } case version.Deneb: withdrawals, err := headState.ExpectedWithdrawals() @@ -470,11 +470,11 @@ func (s *Server) sendPayloadAttributes(ctx context.Context, w http.ResponseWrite write(w, flusher, "Could not get head block root: "+err.Error()) return } - attributes = &PayloadAttributesV3{ + attributes = &structs.PayloadAttributesV3{ Timestamp: fmt.Sprintf("%d", t.Unix()), PrevRandao: hexutil.Encode(prevRando), SuggestedFeeRecipient: hexutil.Encode(headPayload.FeeRecipient()), - Withdrawals: shared.WithdrawalsFromConsensus(withdrawals), + Withdrawals: structs.WithdrawalsFromConsensus(withdrawals), ParentBeaconBlockRoot: hexutil.Encode(parentRoot[:]), } default: @@ -487,7 +487,7 @@ func (s *Server) sendPayloadAttributes(ctx context.Context, w http.ResponseWrite write(w, flusher, err.Error()) return } - eventData := PayloadAttributesEventData{ + eventData := structs.PayloadAttributesEventData{ ProposerIndex: fmt.Sprintf("%d", proposerIndex), ProposalSlot: fmt.Sprintf("%d", headState.Slot()), ParentBlockNumber: fmt.Sprintf("%d", headPayload.BlockNumber()), @@ -500,7 +500,7 @@ func (s *Server) sendPayloadAttributes(ctx context.Context, w http.ResponseWrite write(w, flusher, err.Error()) return } - send(w, flusher, PayloadAttributesTopic, &PayloadAttributesEvent{ + send(w, flusher, PayloadAttributesTopic, &structs.PayloadAttributesEvent{ Version: version.String(headState.Version()), Data: eventDataBytes, }) diff --git a/beacon-chain/rpc/eth/helpers/BUILD.bazel b/beacon-chain/rpc/eth/helpers/BUILD.bazel index 6dfd51c5e6..7e01fbfcc2 100644 --- a/beacon-chain/rpc/eth/helpers/BUILD.bazel +++ b/beacon-chain/rpc/eth/helpers/BUILD.bazel @@ -11,9 +11,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//api/grpc:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/lookup:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", diff --git a/beacon-chain/rpc/eth/helpers/sync.go b/beacon-chain/rpc/eth/helpers/sync.go index 6589fb869e..bb3d1c9557 100644 --- a/beacon-chain/rpc/eth/helpers/sync.go +++ b/beacon-chain/rpc/eth/helpers/sync.go @@ -9,9 +9,9 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api/grpc" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/v4/beacon-chain/db" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/lookup" "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v4/config/params" @@ -40,8 +40,8 @@ func ValidateSyncGRPC( return status.Errorf(codes.Internal, "Could not check optimistic status: %v", err) } - syncDetailsContainer := &shared.SyncDetailsContainer{ - Data: &shared.SyncDetails{ + syncDetailsContainer := &structs.SyncDetailsContainer{ + Data: &structs.SyncDetails{ HeadSlot: strconv.FormatUint(uint64(headSlot), 10), SyncDistance: strconv.FormatUint(uint64(timeFetcher.CurrentSlot()-headSlot), 10), IsSyncing: true, diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index 2ee5a3efd4..bc6ffd51c3 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -6,11 +6,11 @@ go_library( "handlers.go", "helpers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/light-client", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/lookup:go_default_library", @@ -37,6 +37,7 @@ go_test( srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 30beb9318a..6148402f27 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "go.opencensus.io/trace" "github.com/wealdtech/go-bytesutil" @@ -53,7 +54,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - response := &LightClientBootstrapResponse{ + response := &structs.LightClientBootstrapResponse{ Version: version.String(blk.Version()), Data: bootstrap, } @@ -118,7 +119,7 @@ func (s *Server) GetLightClientUpdatesByRange(w http.ResponseWriter, req *http.R } // Populate updates - var updates []*LightClientUpdateWithVersion + var updates []*structs.LightClientUpdateWithVersion for period := startPeriod; period <= endPeriod; period++ { // Get the last known state of the period, // 1. We wish the block has a parent in the same period if possible @@ -208,7 +209,7 @@ func (s *Server) GetLightClientUpdatesByRange(w http.ResponseWriter, req *http.R ) if err == nil { - updates = append(updates, &LightClientUpdateWithVersion{ + updates = append(updates, &structs.LightClientUpdateWithVersion{ Version: version.String(attestedState.Version()), Data: update, }) @@ -282,7 +283,7 @@ func (s *Server) GetLightClientFinalityUpdate(w http.ResponseWriter, req *http.R return } - response := &LightClientUpdateWithVersion{ + response := &structs.LightClientUpdateWithVersion{ Version: version.String(attestedState.Version()), Data: update, } @@ -339,7 +340,7 @@ func (s *Server) GetLightClientOptimisticUpdate(w http.ResponseWriter, req *http return } - response := &LightClientUpdateWithVersion{ + response := &structs.LightClientUpdateWithVersion{ Version: version.String(attestedState.Version()), Data: update, } diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index c66e50bb8a..5596894b70 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" @@ -70,7 +71,7 @@ func TestLightClientHandler_GetLightClientBootstrap(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &LightClientBootstrapResponse{} + resp := &structs.LightClientBootstrapResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, "capella", resp.Version) require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.BodyRoot) @@ -171,7 +172,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []LightClientUpdateWithVersion + var resp []structs.LightClientUpdateWithVersion require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) require.Equal(t, 1, len(resp)) require.Equal(t, "capella", resp[0].Version) @@ -274,7 +275,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCount(t *tes s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []LightClientUpdateWithVersion + var resp []structs.LightClientUpdateWithVersion require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) require.Equal(t, 1, len(resp)) // Even with big count input, the response is still the max available period, which is 1 in test case. require.Equal(t, "capella", resp[0].Version) @@ -377,7 +378,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriod(t *testi s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []LightClientUpdateWithVersion + var resp []structs.LightClientUpdateWithVersion require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) require.Equal(t, 1, len(resp)) require.Equal(t, "capella", resp[0].Version) @@ -480,7 +481,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []LightClientUpdateWithVersion + var resp []structs.LightClientUpdateWithVersion require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) require.Equal(t, 1, len(resp)) require.Equal(t, "capella", resp[0].Version) @@ -684,7 +685,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdate(t *testing.T) { s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &LightClientUpdateWithVersion{} + resp := &structs.LightClientUpdateWithVersion{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, "capella", resp.Version) require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.BodyRoot) @@ -790,7 +791,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &LightClientUpdateWithVersion{} + resp := &structs.LightClientUpdateWithVersion{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, "capella", resp.Version) require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.BodyRoot) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 98e2106547..974e5b4807 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -6,8 +6,8 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" @@ -35,7 +35,7 @@ import ( // current_sync_committee=state.current_sync_committee, // current_sync_committee_branch=compute_merkle_proof_for_state(state, CURRENT_SYNC_COMMITTEE_INDEX) // ) -func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (*LightClientBootstrap, error) { +func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrap, error) { // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) @@ -53,7 +53,7 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) } - committee := shared.SyncCommitteeFromConsensus(currentSyncCommittee) + committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) if err != nil { @@ -65,7 +65,7 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* branch[i] = hexutil.Encode(proof) } - header := shared.BeaconBlockHeaderFromConsensus(latestBlockHeader) + header := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) if header == nil { return nil, fmt.Errorf("could not get beacon block header") } @@ -78,7 +78,7 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* header.StateRoot = hexutil.Encode(stateRoot[:]) // Return result - result := &LightClientBootstrap{ + result := &structs.LightClientBootstrap{ Header: header, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, @@ -150,7 +150,7 @@ func createLightClientUpdate( state state.BeaconState, block interfaces.ReadOnlySignedBeaconBlock, attestedState state.BeaconState, - finalizedBlock interfaces.ReadOnlySignedBeaconBlock) (*LightClientUpdate, error) { + finalizedBlock interfaces.ReadOnlySignedBeaconBlock) (*structs.LightClientUpdate, error) { result, err := blockchain.NewLightClientFinalityUpdateFromBeaconState(ctx, state, block, attestedState, finalizedBlock) if err != nil { return nil, err @@ -208,7 +208,7 @@ func newLightClientFinalityUpdateFromBeaconState( state state.BeaconState, block interfaces.ReadOnlySignedBeaconBlock, attestedState state.BeaconState, - finalizedBlock interfaces.ReadOnlySignedBeaconBlock) (*LightClientUpdate, error) { + finalizedBlock interfaces.ReadOnlySignedBeaconBlock) (*structs.LightClientUpdate, error) { result, err := blockchain.NewLightClientFinalityUpdateFromBeaconState(ctx, state, block, attestedState, finalizedBlock) if err != nil { return nil, err @@ -221,7 +221,7 @@ func newLightClientOptimisticUpdateFromBeaconState( ctx context.Context, state state.BeaconState, block interfaces.ReadOnlySignedBeaconBlock, - attestedState state.BeaconState) (*LightClientUpdate, error) { + attestedState state.BeaconState) (*structs.LightClientUpdate, error) { result, err := blockchain.NewLightClientOptimisticUpdateFromBeaconState(ctx, state, block, attestedState) if err != nil { return nil, err @@ -230,7 +230,7 @@ func newLightClientOptimisticUpdateFromBeaconState( return newLightClientUpdateToJSON(result), nil } -func NewLightClientBootstrapFromJSON(bootstrapJSON *LightClientBootstrap) (*v2.LightClientBootstrap, error) { +func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { bootstrap := &v2.LightClientBootstrap{} var err error @@ -276,33 +276,33 @@ func branchToJSON(branchBytes [][]byte) []string { return branch } -func syncAggregateToJSON(input *v1.SyncAggregate) *shared.SyncAggregate { +func syncAggregateToJSON(input *v1.SyncAggregate) *structs.SyncAggregate { if input == nil { return nil } - return &shared.SyncAggregate{ + return &structs.SyncAggregate{ SyncCommitteeBits: hexutil.Encode(input.SyncCommitteeBits), SyncCommitteeSignature: hexutil.Encode(input.SyncCommitteeSignature), } } -func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *LightClientUpdate { +func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClientUpdate { if input == nil { return nil } - var nextSyncCommittee *shared.SyncCommittee + var nextSyncCommittee *structs.SyncCommittee if input.NextSyncCommittee != nil { - nextSyncCommittee = shared.SyncCommitteeFromConsensus(migration.V2SyncCommitteeToV1Alpha1(input.NextSyncCommittee)) + nextSyncCommittee = structs.SyncCommitteeFromConsensus(migration.V2SyncCommitteeToV1Alpha1(input.NextSyncCommittee)) } - var finalizedHeader *shared.BeaconBlockHeader + var finalizedHeader *structs.BeaconBlockHeader if input.FinalizedHeader != nil { - finalizedHeader = shared.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.FinalizedHeader)) + finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.FinalizedHeader)) } - return &LightClientUpdate{ - AttestedHeader: shared.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.AttestedHeader)), + return &structs.LightClientUpdate{ + AttestedHeader: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.AttestedHeader)), NextSyncCommittee: nextSyncCommittee, NextSyncCommitteeBranch: branchToJSON(input.NextSyncCommitteeBranch), FinalizedHeader: finalizedHeader, diff --git a/beacon-chain/rpc/eth/light-client/structs.go b/beacon-chain/rpc/eth/light-client/structs.go deleted file mode 100644 index 822545505f..0000000000 --- a/beacon-chain/rpc/eth/light-client/structs.go +++ /dev/null @@ -1,35 +0,0 @@ -package lightclient - -import ( - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" -) - -type LightClientBootstrapResponse struct { - Version string `json:"version"` - Data *LightClientBootstrap `json:"data"` -} - -type LightClientBootstrap struct { - Header *shared.BeaconBlockHeader `json:"header"` - CurrentSyncCommittee *shared.SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` -} - -type LightClientUpdate struct { - AttestedHeader *shared.BeaconBlockHeader `json:"attested_header"` - NextSyncCommittee *shared.SyncCommittee `json:"next_sync_committee,omitempty"` - FinalizedHeader *shared.BeaconBlockHeader `json:"finalized_header,omitempty"` - SyncAggregate *shared.SyncAggregate `json:"sync_aggregate"` - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` - FinalityBranch []string `json:"finality_branch,omitempty"` - SignatureSlot string `json:"signature_slot"` -} - -type LightClientUpdateWithVersion struct { - Version string `json:"version"` - Data *LightClientUpdate `json:"data"` -} - -type LightClientUpdatesByRangeResponse struct { - Updates []*LightClientUpdateWithVersion `json:"updates"` -} diff --git a/beacon-chain/rpc/eth/node/BUILD.bazel b/beacon-chain/rpc/eth/node/BUILD.bazel index 62db0ee177..7f43ddbc8c 100644 --- a/beacon-chain/rpc/eth/node/BUILD.bazel +++ b/beacon-chain/rpc/eth/node/BUILD.bazel @@ -6,11 +6,11 @@ go_library( "handlers.go", "handlers_peers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/node", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", "//beacon-chain/execution:go_default_library", @@ -41,6 +41,7 @@ go_test( ], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/p2p:go_default_library", "//beacon-chain/p2p/peers:go_default_library", diff --git a/beacon-chain/rpc/eth/node/handlers.go b/beacon-chain/rpc/eth/node/handlers.go index d4bba432bf..121cb7fa49 100644 --- a/beacon-chain/rpc/eth/node/handlers.go +++ b/beacon-chain/rpc/eth/node/handlers.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/network/httputil" @@ -37,8 +38,8 @@ func (s *Server) GetSyncStatus(w http.ResponseWriter, r *http.Request) { } headSlot := s.HeadFetcher.HeadSlot() - response := &SyncStatusResponse{ - Data: &SyncStatusResponseData{ + response := &structs.SyncStatusResponse{ + Data: &structs.SyncStatusResponseData{ HeadSlot: strconv.FormatUint(uint64(headSlot), 10), SyncDistance: strconv.FormatUint(uint64(s.GenesisTimeFetcher.CurrentSlot()-headSlot), 10), IsSyncing: s.SyncChecker.Syncing(), @@ -75,13 +76,13 @@ func (s *Server) GetIdentity(w http.ResponseWriter, r *http.Request) { return } - resp := &GetIdentityResponse{ - Data: &Identity{ + resp := &structs.GetIdentityResponse{ + Data: &structs.Identity{ PeerId: peerId, Enr: "enr:" + serializedEnr, P2PAddresses: p2pAddresses, DiscoveryAddresses: discoveryAddresses, - Metadata: &Metadata{ + Metadata: &structs.Metadata{ SeqNumber: strconv.FormatUint(s.MetadataProvider.MetadataSeq(), 10), Attnets: hexutil.Encode(s.MetadataProvider.Metadata().AttnetsBitfield()), }, @@ -97,8 +98,8 @@ func (*Server) GetVersion(w http.ResponseWriter, r *http.Request) { defer span.End() v := fmt.Sprintf("Prysm/%s (%s %s)", version.SemanticVersion(), runtime.GOOS, runtime.GOARCH) - resp := &GetVersionResponse{ - Data: &Version{ + resp := &structs.GetVersionResponse{ + Data: &structs.Version{ Version: v, }, } diff --git a/beacon-chain/rpc/eth/node/handlers_peers.go b/beacon-chain/rpc/eth/node/handlers_peers.go index 281d51ad73..559db191fe 100644 --- a/beacon-chain/rpc/eth/node/handlers_peers.go +++ b/beacon-chain/rpc/eth/node/handlers_peers.go @@ -8,6 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers/peerdata" @@ -75,8 +76,8 @@ func (s *Server) GetPeer(w http.ResponseWriter, r *http.Request) { return } - resp := &GetPeerResponse{ - Data: &Peer{ + resp := &structs.GetPeerResponse{ + Data: &structs.Peer{ PeerId: rawId, Enr: "enr:" + serializedEnr, LastSeenP2PAddress: p2pAddress.String(), @@ -100,7 +101,7 @@ func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request) { if emptyStateFilter && emptyDirectionFilter { allIds := peerStatus.All() - allPeers := make([]*Peer, 0, len(allIds)) + allPeers := make([]*structs.Peer, 0, len(allIds)) for _, id := range allIds { p, err := peerInfo(peerStatus, id) if err != nil { @@ -112,7 +113,7 @@ func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request) { } allPeers = append(allPeers, p) } - resp := &GetPeersResponse{Data: allPeers} + resp := &structs.GetPeersResponse{Data: allPeers} httputil.WriteJson(w, resp) return } @@ -164,7 +165,7 @@ func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request) { } } } - filteredPeers := make([]*Peer, 0, len(filteredIds)) + filteredPeers := make([]*structs.Peer, 0, len(filteredIds)) for _, id := range filteredIds { p, err := peerInfo(peerStatus, id) if err != nil { @@ -177,7 +178,7 @@ func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request) { filteredPeers = append(filteredPeers, p) } - resp := &GetPeersResponse{Data: filteredPeers} + resp := &structs.GetPeersResponse{Data: filteredPeers} httputil.WriteJson(w, resp) } @@ -188,8 +189,8 @@ func (s *Server) GetPeerCount(w http.ResponseWriter, r *http.Request) { peerStatus := s.PeersFetcher.Peers() - resp := &GetPeerCountResponse{ - Data: &PeerCount{ + resp := &structs.GetPeerCountResponse{ + Data: &structs.PeerCount{ Disconnected: strconv.FormatInt(int64(len(peerStatus.Disconnected())), 10), Connecting: strconv.FormatInt(int64(len(peerStatus.Connecting())), 10), Connected: strconv.FormatInt(int64(len(peerStatus.Connected())), 10), @@ -224,7 +225,7 @@ func handleEmptyFilters(states []string, directions []string) (emptyState, empty return emptyState, emptyDirection } -func peerInfo(peerStatus *peers.Status, id peer.ID) (*Peer, error) { +func peerInfo(peerStatus *peers.Status, id peer.ID) (*structs.Peer, error) { enr, err := peerStatus.ENR(id) if err != nil { if errors.Is(err, peerdata.ErrPeerUnknown) { @@ -263,7 +264,7 @@ func peerInfo(peerStatus *peers.Status, id peer.ID) (*Peer, error) { if eth.PeerDirection(direction) == eth.PeerDirection_UNKNOWN { return nil, nil } - p := &Peer{ + p := &structs.Peer{ PeerId: id.String(), State: strings.ToLower(eth.ConnectionState(connectionState).String()), Direction: strings.ToLower(eth.PeerDirection(direction).String()), diff --git a/beacon-chain/rpc/eth/node/handlers_peers_test.go b/beacon-chain/rpc/eth/node/handlers_peers_test.go index a1170170cc..f9b441447a 100644 --- a/beacon-chain/rpc/eth/node/handlers_peers_test.go +++ b/beacon-chain/rpc/eth/node/handlers_peers_test.go @@ -15,6 +15,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" libp2ptest "github.com/libp2p/go-libp2p/p2p/host/peerstore/test" ma "github.com/multiformats/go-multiaddr" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers" mockp2p "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" @@ -48,7 +49,7 @@ func TestGetPeer(t *testing.T) { s.GetPeer(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetPeerResponse{} + resp := &structs.GetPeerResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, rawId, resp.Data.PeerId) assert.Equal(t, p2pAddr, resp.Data.LastSeenP2PAddress) @@ -142,7 +143,7 @@ func TestGetPeers(t *testing.T) { s.GetPeers(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetPeersResponse{} + resp := &structs.GetPeersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) returnedPeer := resp.Data[0] @@ -226,7 +227,7 @@ func TestGetPeers(t *testing.T) { s.GetPeers(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetPeersResponse{} + resp := &structs.GetPeersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, len(tt.wantIds), len(resp.Data), "Wrong number of peers returned") for _, id := range tt.wantIds { @@ -257,7 +258,7 @@ func TestGetPeers_NoPeersReturnsEmptyArray(t *testing.T) { s.GetPeers(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetPeersResponse{} + resp := &structs.GetPeersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, 0, len(resp.Data)) } @@ -307,7 +308,7 @@ func TestGetPeerCount(t *testing.T) { writer.Body = &bytes.Buffer{} s.GetPeerCount(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetPeerCountResponse{} + resp := &structs.GetPeerCountResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "1", resp.Data.Connecting, "Wrong number of connecting peers") assert.Equal(t, "2", resp.Data.Connected, "Wrong number of connected peers") diff --git a/beacon-chain/rpc/eth/node/handlers_test.go b/beacon-chain/rpc/eth/node/handlers_test.go index c2f2999132..f473c97d32 100644 --- a/beacon-chain/rpc/eth/node/handlers_test.go +++ b/beacon-chain/rpc/eth/node/handlers_test.go @@ -14,6 +14,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" ma "github.com/multiformats/go-multiaddr" "github.com/prysmaticlabs/go-bitfield" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" mockp2p "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" @@ -59,7 +60,7 @@ func TestSyncStatus(t *testing.T) { s.GetSyncStatus(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SyncStatusResponse{} + resp := &structs.SyncStatusResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) assert.Equal(t, "100", resp.Data.HeadSlot) @@ -81,7 +82,7 @@ func TestGetVersion(t *testing.T) { s := &Server{} s.GetVersion(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetVersionResponse{} + resp := &structs.GetVersionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.StringContains(t, semVer, resp.Data.Version) assert.StringContains(t, os, resp.Data.Version) @@ -156,7 +157,7 @@ func TestGetIdentity(t *testing.T) { s.GetIdentity(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetIdentityResponse{} + resp := &structs.GetIdentityResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) expectedID := peer.ID("foo").String() assert.Equal(t, expectedID, resp.Data.PeerId) diff --git a/beacon-chain/rpc/eth/rewards/BUILD.bazel b/beacon-chain/rpc/eth/rewards/BUILD.bazel index fa5725436d..37483c31af 100644 --- a/beacon-chain/rpc/eth/rewards/BUILD.bazel +++ b/beacon-chain/rpc/eth/rewards/BUILD.bazel @@ -6,11 +6,11 @@ go_library( "handlers.go", "server.go", "service.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/blocks:go_default_library", @@ -38,6 +38,7 @@ go_test( srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/helpers:go_default_library", diff --git a/beacon-chain/rpc/eth/rewards/handlers.go b/beacon-chain/rpc/eth/rewards/handlers.go index e348a0577a..b0bab9c597 100644 --- a/beacon-chain/rpc/eth/rewards/handlers.go +++ b/beacon-chain/rpc/eth/rewards/handlers.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" @@ -52,7 +53,7 @@ func (s *Server) BlockRewards(w http.ResponseWriter, r *http.Request) { httputil.WriteError(w, httpError) return } - response := &BlockRewardsResponse{ + response := &structs.BlockRewardsResponse{ Data: blockRewards, ExecutionOptimistic: optimistic, Finalized: s.FinalizationFetcher.IsFinalized(ctx, blkRoot), @@ -91,8 +92,8 @@ func (s *Server) AttestationRewards(w http.ResponseWriter, r *http.Request) { return } - resp := &AttestationRewardsResponse{ - Data: AttestationRewards{ + resp := &structs.AttestationRewardsResponse{ + Data: structs.AttestationRewards{ IdealRewards: idealRewards, TotalRewards: totalRewards, }, @@ -174,14 +175,14 @@ func (s *Server) SyncCommitteeRewards(w http.ResponseWriter, r *http.Request) { return } - scRewards := make([]SyncCommitteeReward, len(valIndices)) + scRewards := make([]structs.SyncCommitteeReward, len(valIndices)) for i, valIdx := range valIndices { - scRewards[i] = SyncCommitteeReward{ + scRewards[i] = structs.SyncCommitteeReward{ ValidatorIndex: strconv.FormatUint(uint64(valIdx), 10), Reward: strconv.Itoa(rewards[i]), } } - response := &SyncCommitteeRewardsResponse{ + response := &structs.SyncCommitteeRewardsResponse{ Data: scRewards, ExecutionOptimistic: optimistic, Finalized: s.FinalizationFetcher.IsFinalized(r.Context(), blkRoot), @@ -257,11 +258,11 @@ func idealAttRewards( st state.BeaconState, bal *precompute.Balance, vals []*precompute.Validator, -) ([]IdealAttestationReward, bool) { +) ([]structs.IdealAttestationReward, bool) { idealValsCount := uint64(16) minIdealBalance := uint64(17) maxIdealBalance := minIdealBalance + idealValsCount - 1 - idealRewards := make([]IdealAttestationReward, 0, idealValsCount) + idealRewards := make([]structs.IdealAttestationReward, 0, idealValsCount) idealVals := make([]*precompute.Validator, 0, idealValsCount) increment := params.BeaconConfig().EffectiveBalanceIncrement for i := minIdealBalance; i <= maxIdealBalance; i++ { @@ -276,7 +277,7 @@ func idealAttRewards( IsPrevEpochTargetAttester: true, IsPrevEpochHeadAttester: true, }) - idealRewards = append(idealRewards, IdealAttestationReward{ + idealRewards = append(idealRewards, structs.IdealAttestationReward{ EffectiveBalance: strconv.FormatUint(effectiveBalance, 10), Inactivity: strconv.FormatUint(0, 10), }) @@ -316,10 +317,10 @@ func totalAttRewards( bal *precompute.Balance, vals []*precompute.Validator, valIndices []primitives.ValidatorIndex, -) ([]TotalAttestationReward, bool) { - totalRewards := make([]TotalAttestationReward, len(valIndices)) +) ([]structs.TotalAttestationReward, bool) { + totalRewards := make([]structs.TotalAttestationReward, len(valIndices)) for i, v := range valIndices { - totalRewards[i] = TotalAttestationReward{ValidatorIndex: strconv.FormatUint(uint64(v), 10)} + totalRewards[i] = structs.TotalAttestationReward{ValidatorIndex: strconv.FormatUint(uint64(v), 10)} } deltas, err := altair.AttestationsDelta(st, bal, vals) if err != nil { diff --git a/beacon-chain/rpc/eth/rewards/handlers_test.go b/beacon-chain/rpc/eth/rewards/handlers_test.go index 653716e52d..2fb535aab0 100644 --- a/beacon-chain/rpc/eth/rewards/handlers_test.go +++ b/beacon-chain/rpc/eth/rewards/handlers_test.go @@ -13,6 +13,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" @@ -236,7 +237,7 @@ func TestBlockRewards(t *testing.T) { s.BlockRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRewardsResponse{} + resp := &structs.BlockRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "12", resp.Data.ProposerIndex) assert.Equal(t, "125089490", resp.Data.Total) @@ -269,7 +270,7 @@ func TestBlockRewards(t *testing.T) { s.BlockRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRewardsResponse{} + resp := &structs.BlockRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "12", resp.Data.ProposerIndex) assert.Equal(t, "125089490", resp.Data.Total) @@ -302,7 +303,7 @@ func TestBlockRewards(t *testing.T) { s.BlockRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRewardsResponse{} + resp := &structs.BlockRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "12", resp.Data.ProposerIndex) assert.Equal(t, "125089490", resp.Data.Total) @@ -335,7 +336,7 @@ func TestBlockRewards(t *testing.T) { s.BlockRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &BlockRewardsResponse{} + resp := &structs.BlockRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "12", resp.Data.ProposerIndex) assert.Equal(t, "125089490", resp.Data.Total) @@ -404,7 +405,7 @@ func TestAttestationRewards(t *testing.T) { s.AttestationRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AttestationRewardsResponse{} + resp := &structs.AttestationRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 16, len(resp.Data.IdealRewards)) sum := uint64(0) @@ -433,7 +434,7 @@ func TestAttestationRewards(t *testing.T) { s.AttestationRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AttestationRewardsResponse{} + resp := &structs.AttestationRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data.TotalRewards)) sum := uint64(0) @@ -456,7 +457,7 @@ func TestAttestationRewards(t *testing.T) { s.AttestationRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AttestationRewardsResponse{} + resp := &structs.AttestationRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 64, len(resp.Data.TotalRewards)) sum := uint64(0) @@ -498,7 +499,7 @@ func TestAttestationRewards(t *testing.T) { s.AttestationRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AttestationRewardsResponse{} + resp := &structs.AttestationRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "0", resp.Data.TotalRewards[0].Head) assert.Equal(t, "-439299", resp.Data.TotalRewards[0].Source) @@ -536,7 +537,7 @@ func TestAttestationRewards(t *testing.T) { s.AttestationRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AttestationRewardsResponse{} + resp := &structs.AttestationRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, "-4768", resp.Data.TotalRewards[0].Inactivity) }) @@ -737,7 +738,7 @@ func TestSyncCommiteeRewards(t *testing.T) { s.SyncCommitteeRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SyncCommitteeRewardsResponse{} + resp := &structs.SyncCommitteeRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) sum := uint64(0) @@ -764,7 +765,7 @@ func TestSyncCommiteeRewards(t *testing.T) { s.SyncCommitteeRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SyncCommitteeRewardsResponse{} + resp := &structs.SyncCommitteeRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 512, len(resp.Data)) sum := 0 @@ -795,7 +796,7 @@ func TestSyncCommiteeRewards(t *testing.T) { s.SyncCommitteeRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SyncCommitteeRewardsResponse{} + resp := &structs.SyncCommitteeRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) sum := 0 @@ -826,7 +827,7 @@ func TestSyncCommiteeRewards(t *testing.T) { s.SyncCommitteeRewards(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &SyncCommitteeRewardsResponse{} + resp := &structs.SyncCommitteeRewardsResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 3, len(resp.Data)) sum := 0 diff --git a/beacon-chain/rpc/eth/rewards/service.go b/beacon-chain/rpc/eth/rewards/service.go index 511199490b..53bea5dca6 100644 --- a/beacon-chain/rpc/eth/rewards/service.go +++ b/beacon-chain/rpc/eth/rewards/service.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" coreblocks "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/validators" @@ -17,7 +18,7 @@ import ( // BlockRewardsFetcher is a interface that provides access to reward related responses type BlockRewardsFetcher interface { - GetBlockRewardsData(context.Context, interfaces.ReadOnlyBeaconBlock) (*BlockRewards, *httputil.DefaultJsonError) + GetBlockRewardsData(context.Context, interfaces.ReadOnlyBeaconBlock) (*structs.BlockRewards, *httputil.DefaultJsonError) GetStateForRewards(context.Context, interfaces.ReadOnlyBeaconBlock) (state.BeaconState, *httputil.DefaultJsonError) } @@ -28,7 +29,7 @@ type BlockRewardService struct { // GetBlockRewardsData returns the BlockRewards object which is used for the BlockRewardsResponse and ProduceBlockV3. // Rewards are denominated in Gwei. -func (rs *BlockRewardService) GetBlockRewardsData(ctx context.Context, blk interfaces.ReadOnlyBeaconBlock) (*BlockRewards, *httputil.DefaultJsonError) { +func (rs *BlockRewardService) GetBlockRewardsData(ctx context.Context, blk interfaces.ReadOnlyBeaconBlock) (*structs.BlockRewards, *httputil.DefaultJsonError) { if blk == nil || blk.IsNil() { return nil, &httputil.DefaultJsonError{ Message: consensusblocks.ErrNilBeaconBlock.Error(), @@ -107,7 +108,7 @@ func (rs *BlockRewardService) GetBlockRewardsData(ctx context.Context, blk inter } } - return &BlockRewards{ + return &structs.BlockRewards{ ProposerIndex: strconv.FormatUint(uint64(proposerIndex), 10), Total: strconv.FormatUint(proposerSlashingsBalance-initBalance+syncCommitteeReward, 10), Attestations: strconv.FormatUint(attBalance-initBalance, 10), diff --git a/beacon-chain/rpc/eth/rewards/testing/BUILD.bazel b/beacon-chain/rpc/eth/rewards/testing/BUILD.bazel index 5370f28f30..94cafdd226 100644 --- a/beacon-chain/rpc/eth/rewards/testing/BUILD.bazel +++ b/beacon-chain/rpc/eth/rewards/testing/BUILD.bazel @@ -6,7 +6,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards/testing", visibility = ["//visibility:public"], deps = [ - "//beacon-chain/rpc/eth/rewards:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/state:go_default_library", "//consensus-types/interfaces:go_default_library", "//network/httputil:go_default_library", diff --git a/beacon-chain/rpc/eth/rewards/testing/mock.go b/beacon-chain/rpc/eth/rewards/testing/mock.go index 3a53a461f3..b67dc7115e 100644 --- a/beacon-chain/rpc/eth/rewards/testing/mock.go +++ b/beacon-chain/rpc/eth/rewards/testing/mock.go @@ -3,19 +3,19 @@ package testing import ( "context" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" "github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces" "github.com/prysmaticlabs/prysm/v4/network/httputil" ) type MockBlockRewardFetcher struct { - Rewards *rewards.BlockRewards + Rewards *structs.BlockRewards Error *httputil.DefaultJsonError State state.BeaconState } -func (m *MockBlockRewardFetcher) GetBlockRewardsData(_ context.Context, _ interfaces.ReadOnlyBeaconBlock) (*rewards.BlockRewards, *httputil.DefaultJsonError) { +func (m *MockBlockRewardFetcher) GetBlockRewardsData(_ context.Context, _ interfaces.ReadOnlyBeaconBlock) (*structs.BlockRewards, *httputil.DefaultJsonError) { if m.Error != nil { return nil, m.Error } diff --git a/beacon-chain/rpc/eth/shared/BUILD.bazel b/beacon-chain/rpc/eth/shared/BUILD.bazel index 19f1180f52..795809ba8c 100644 --- a/beacon-chain/rpc/eth/shared/BUILD.bazel +++ b/beacon-chain/rpc/eth/shared/BUILD.bazel @@ -3,38 +3,21 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", srcs = [ - "conversions.go", - "conversions_block.go", - "conversions_state.go", "errors.go", "request.go", - "structs.go", - "structs_block.go", - "structs_state.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared", visibility = ["//visibility:public"], deps = [ - "//api/server:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/rpc/lookup:go_default_library", - "//beacon-chain/state:go_default_library", "//beacon-chain/sync:go_default_library", - "//config/fieldparams:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", - "//consensus-types/primitives:go_default_library", - "//consensus-types/validator:go_default_library", - "//container/slice:go_default_library", - "//encoding/bytesutil:go_default_library", - "//math:go_default_library", "//network/httputil:go_default_library", - "//proto/engine/v1:go_default_library", - "//proto/prysm/v1alpha1:go_default_library", - "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_gorilla_mux//:go_default_library", - "@com_github_pkg_errors//:go_default_library", ], ) diff --git a/beacon-chain/rpc/eth/shared/request.go b/beacon-chain/rpc/eth/shared/request.go index 45386e4e03..ea288e51db 100644 --- a/beacon-chain/rpc/eth/shared/request.go +++ b/beacon-chain/rpc/eth/shared/request.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v4/network/httputil" @@ -126,8 +127,8 @@ func IsSyncing( httputil.WriteError(w, errJson) return true } - syncDetails := &SyncDetailsContainer{ - Data: &SyncDetails{ + syncDetails := &structs.SyncDetailsContainer{ + Data: &structs.SyncDetails{ HeadSlot: strconv.FormatUint(uint64(headSlot), 10), SyncDistance: strconv.FormatUint(uint64(timeFetcher.CurrentSlot()-headSlot), 10), IsSyncing: true, diff --git a/beacon-chain/rpc/eth/validator/BUILD.bazel b/beacon-chain/rpc/eth/validator/BUILD.bazel index d817a3c10f..c4293a0ece 100644 --- a/beacon-chain/rpc/eth/validator/BUILD.bazel +++ b/beacon-chain/rpc/eth/validator/BUILD.bazel @@ -6,12 +6,12 @@ go_library( "handlers.go", "handlers_block.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator", visibility = ["//visibility:public"], deps = [ "//api:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/builder:go_default_library", "//beacon-chain/cache:go_default_library", @@ -59,6 +59,7 @@ go_test( embed = [":go_default_library"], deps = [ "//api:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/builder/testing:go_default_library", "//beacon-chain/cache:go_default_library", @@ -70,9 +71,7 @@ go_test( "//beacon-chain/operations/synccommittee:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/rpc/core:go_default_library", - "//beacon-chain/rpc/eth/rewards:go_default_library", "//beacon-chain/rpc/eth/rewards/testing:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/rpc/eth/shared/testing:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", "//beacon-chain/state:go_default_library", diff --git a/beacon-chain/rpc/eth/validator/handlers.go b/beacon-chain/rpc/eth/validator/handlers.go index b94fa289e6..d6f069048d 100644 --- a/beacon-chain/rpc/eth/validator/handlers.go +++ b/beacon-chain/rpc/eth/validator/handlers.go @@ -13,6 +13,7 @@ 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/builder" "github.com/prysmaticlabs/prysm/v4/beacon-chain/cache" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" @@ -76,18 +77,18 @@ func (s *Server) GetAggregateAttestation(w http.ResponseWriter, r *http.Request) return } - response := &AggregateAttestationResponse{ - Data: &shared.Attestation{ + response := &structs.AggregateAttestationResponse{ + Data: &structs.Attestation{ AggregationBits: hexutil.Encode(match.AggregationBits), - Data: &shared.AttestationData{ + Data: &structs.AttestationData{ Slot: strconv.FormatUint(uint64(match.Data.Slot), 10), CommitteeIndex: strconv.FormatUint(uint64(match.Data.CommitteeIndex), 10), BeaconBlockRoot: hexutil.Encode(match.Data.BeaconBlockRoot), - Source: &shared.Checkpoint{ + Source: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(match.Data.Source.Epoch), 10), Root: hexutil.Encode(match.Data.Source.Root), }, - Target: &shared.Checkpoint{ + Target: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(match.Data.Target.Epoch), 10), Root: hexutil.Encode(match.Data.Target.Root), }, @@ -117,7 +118,7 @@ func (s *Server) SubmitContributionAndProofs(w http.ResponseWriter, r *http.Requ ctx, span := trace.StartSpan(r.Context(), "validator.SubmitContributionAndProofs") defer span.End() - var req SubmitContributionAndProofsRequest + var req structs.SubmitContributionAndProofsRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -150,7 +151,7 @@ func (s *Server) SubmitAggregateAndProofs(w http.ResponseWriter, r *http.Request ctx, span := trace.StartSpan(r.Context(), "validator.SubmitAggregateAndProofs") defer span.End() - var req SubmitAggregateAndProofsRequest + var req structs.SubmitAggregateAndProofsRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -205,7 +206,7 @@ func (s *Server) SubmitSyncCommitteeSubscription(w http.ResponseWriter, r *http. return } - var req SubmitSyncCommitteeSubscriptionsRequest + var req structs.SubmitSyncCommitteeSubscriptionsRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -315,7 +316,7 @@ func (s *Server) SubmitBeaconCommitteeSubscription(w http.ResponseWriter, r *htt return } - var req SubmitBeaconCommitteeSubscriptionsRequest + var req structs.SubmitBeaconCommitteeSubscriptionsRequest err := json.NewDecoder(r.Body).Decode(&req.Data) switch { case err == io.EOF: @@ -421,16 +422,16 @@ func (s *Server) GetAttestationData(w http.ResponseWriter, r *http.Request) { return } - response := &GetAttestationDataResponse{ - Data: &shared.AttestationData{ + response := &structs.GetAttestationDataResponse{ + Data: &structs.AttestationData{ Slot: strconv.FormatUint(uint64(attestationData.Slot), 10), CommitteeIndex: strconv.FormatUint(uint64(attestationData.CommitteeIndex), 10), BeaconBlockRoot: hexutil.Encode(attestationData.BeaconBlockRoot), - Source: &shared.Checkpoint{ + Source: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(attestationData.Source.Epoch), 10), Root: hexutil.Encode(attestationData.Source.Root), }, - Target: &shared.Checkpoint{ + Target: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(attestationData.Target.Epoch), 10), Root: hexutil.Encode(attestationData.Target.Root), }, @@ -462,7 +463,7 @@ func (s *Server) ProduceSyncCommitteeContribution(w http.ResponseWriter, r *http if !ok { return } - response := &ProduceSyncCommitteeContributionResponse{ + response := &structs.ProduceSyncCommitteeContributionResponse{ Data: contribution, } httputil.WriteJson(w, response) @@ -475,7 +476,7 @@ func (s *Server) produceSyncCommitteeContribution( slot primitives.Slot, index uint64, blockRoot []byte, -) (*shared.SyncCommitteeContribution, bool) { +) (*structs.SyncCommitteeContribution, bool) { msgs, err := s.SyncCommitteePool.SyncCommitteeMessages(slot) if err != nil { httputil.HandleError(w, "Could not get sync subcommittee messages: "+err.Error(), http.StatusInternalServerError) @@ -499,7 +500,7 @@ func (s *Server) produceSyncCommitteeContribution( return nil, false } - return &shared.SyncCommitteeContribution{ + return &structs.SyncCommitteeContribution{ Slot: strconv.FormatUint(uint64(slot), 10), BeaconBlockRoot: hexutil.Encode(blockRoot), SubcommitteeIndex: strconv.FormatUint(index, 10), @@ -518,7 +519,7 @@ func (s *Server) RegisterValidator(w http.ResponseWriter, r *http.Request) { return } - var jsonRegistrations []*shared.SignedValidatorRegistration + var jsonRegistrations []*structs.SignedValidatorRegistration err := json.NewDecoder(r.Body).Decode(&jsonRegistrations) switch { case err == io.EOF: @@ -551,7 +552,7 @@ func (s *Server) RegisterValidator(w http.ResponseWriter, r *http.Request) { // PrepareBeaconProposer endpoint saves the fee recipient given a validator index, this is used when proposing a block. func (s *Server) PrepareBeaconProposer(w http.ResponseWriter, r *http.Request) { - var jsonFeeRecipients []*shared.FeeRecipient + var jsonFeeRecipients []*structs.FeeRecipient err := json.NewDecoder(r.Body).Decode(&jsonFeeRecipients) switch { case err == io.EOF: @@ -675,7 +676,7 @@ func (s *Server) GetAttesterDuties(w http.ResponseWriter, r *http.Request) { } committeesAtSlot := helpers.SlotCommitteeCount(activeValidatorCount) - duties := make([]*AttesterDuty, 0, len(requestedValIndices)) + duties := make([]*structs.AttesterDuty, 0, len(requestedValIndices)) for _, index := range requestedValIndices { pubkey := st.PubkeyAtIndex(index) var zeroPubkey [fieldparams.BLSPubkeyLength]byte @@ -696,7 +697,7 @@ func (s *Server) GetAttesterDuties(w http.ResponseWriter, r *http.Request) { break } } - duties = append(duties, &AttesterDuty{ + duties = append(duties, &structs.AttesterDuty{ Pubkey: hexutil.Encode(pubkey[:]), ValidatorIndex: strconv.FormatUint(uint64(index), 10), CommitteeIndex: strconv.FormatUint(uint64(committee.CommitteeIndex), 10), @@ -718,7 +719,7 @@ func (s *Server) GetAttesterDuties(w http.ResponseWriter, r *http.Request) { return } - response := &GetAttesterDutiesResponse{ + response := &structs.GetAttesterDutiesResponse{ DependentRoot: hexutil.Encode(dependentRoot), Data: duties, ExecutionOptimistic: isOptimistic, @@ -803,7 +804,7 @@ func (s *Server) GetProposerDuties(w http.ResponseWriter, r *http.Request) { return } - duties := make([]*ProposerDuty, 0) + duties := make([]*structs.ProposerDuty, 0) for index, proposalSlots := range proposals { val, err := st.ValidatorAtIndexReadOnly(index) if err != nil { @@ -813,7 +814,7 @@ func (s *Server) GetProposerDuties(w http.ResponseWriter, r *http.Request) { pubkey48 := val.PublicKey() pubkey := pubkey48[:] for _, slot := range proposalSlots { - duties = append(duties, &ProposerDuty{ + duties = append(duties, &structs.ProposerDuty{ Pubkey: hexutil.Encode(pubkey), ValidatorIndex: strconv.FormatUint(uint64(index), 10), Slot: strconv.FormatUint(uint64(slot), 10), @@ -835,7 +836,7 @@ func (s *Server) GetProposerDuties(w http.ResponseWriter, r *http.Request) { return } - resp := &GetProposerDutiesResponse{ + resp := &structs.GetProposerDutiesResponse{ DependentRoot: hexutil.Encode(dependentRoot), Data: duties, ExecutionOptimistic: isOptimistic, @@ -973,7 +974,7 @@ func (s *Server) GetSyncCommitteeDuties(w http.ResponseWriter, r *http.Request) return } - resp := &GetSyncCommitteeDutiesResponse{ + resp := &structs.GetSyncCommitteeDutiesResponse{ Data: duties, ExecutionOptimistic: isOptimistic, } @@ -1068,15 +1069,15 @@ func (s *Server) GetLiveness(w http.ResponseWriter, r *http.Request) { } } - resp := &GetLivenessResponse{ - Data: make([]*Liveness, len(requestedValIndices)), + resp := &structs.GetLivenessResponse{ + Data: make([]*structs.Liveness, len(requestedValIndices)), } for i, vi := range requestedValIndices { if vi >= primitives.ValidatorIndex(len(participation)) { httputil.HandleError(w, fmt.Sprintf("Validator index %d is invalid", vi), http.StatusBadRequest) return } - resp.Data[i] = &Liveness{ + resp.Data[i] = &structs.Liveness{ Index: strconv.FormatUint(uint64(vi), 10), IsLive: participation[vi] != 0, } @@ -1139,11 +1140,11 @@ func syncCommitteeDutiesAndVals( st state.BeaconState, requestedValIndices []primitives.ValidatorIndex, committeePubkeys map[[fieldparams.BLSPubkeyLength]byte][]string, -) ([]*SyncCommitteeDuty, []state.ReadOnlyValidator, error) { - duties := make([]*SyncCommitteeDuty, 0) +) ([]*structs.SyncCommitteeDuty, []state.ReadOnlyValidator, error) { + duties := make([]*structs.SyncCommitteeDuty, 0) vals := make([]state.ReadOnlyValidator, 0) for _, index := range requestedValIndices { - duty := &SyncCommitteeDuty{ + duty := &structs.SyncCommitteeDuty{ ValidatorIndex: strconv.FormatUint(uint64(index), 10), } valPubkey := st.PubkeyAtIndex(index) @@ -1166,7 +1167,7 @@ func syncCommitteeDutiesAndVals( return duties, vals, nil } -func sortProposerDuties(w http.ResponseWriter, duties []*ProposerDuty) bool { +func sortProposerDuties(w http.ResponseWriter, duties []*structs.ProposerDuty) bool { ok := true sort.Slice(duties, func(i, j int) bool { si, err := strconv.ParseUint(duties[i].Slot, 10, 64) diff --git a/beacon-chain/rpc/eth/validator/handlers_block.go b/beacon-chain/rpc/eth/validator/handlers_block.go index b71c2fbec6..c38e9bc9fa 100644 --- a/beacon-chain/rpc/eth/validator/handlers_block.go +++ b/beacon-chain/rpc/eth/validator/handlers_block.go @@ -10,6 +10,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" @@ -331,12 +332,12 @@ func handleProducePhase0V3( httputil.WriteSsz(w, sszResp, "phase0Block.ssz") return } - jsonBytes, err := json.Marshal(shared.BeaconBlockFromConsensus(blk.Phase0)) + jsonBytes, err := json.Marshal(structs.BeaconBlockFromConsensus(blk.Phase0)) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Phase0), ExecutionPayloadBlinded: false, ExecutionPayloadValue: payloadValue, // mev not available at this point @@ -361,12 +362,12 @@ func handleProduceAltairV3( httputil.WriteSsz(w, sszResp, "altairBlock.ssz") return } - jsonBytes, err := json.Marshal(shared.BeaconBlockAltairFromConsensus(blk.Altair)) + jsonBytes, err := json.Marshal(structs.BeaconBlockAltairFromConsensus(blk.Altair)) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Altair), ExecutionPayloadBlinded: false, ExecutionPayloadValue: executionPayloadValue, // mev not available at this point @@ -391,7 +392,7 @@ func handleProduceBellatrixV3( httputil.WriteSsz(w, sszResp, "bellatrixBlock.ssz") return } - block, err := shared.BeaconBlockBellatrixFromConsensus(blk.Bellatrix) + block, err := structs.BeaconBlockBellatrixFromConsensus(blk.Bellatrix) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -401,7 +402,7 @@ func handleProduceBellatrixV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Bellatrix), ExecutionPayloadBlinded: false, ExecutionPayloadValue: executionPayloadValue, // mev not available at this point @@ -426,7 +427,7 @@ func handleProduceBlindedBellatrixV3( httputil.WriteSsz(w, sszResp, "blindedBellatrixBlock.ssz") return } - block, err := shared.BlindedBeaconBlockBellatrixFromConsensus(blk.BlindedBellatrix) + block, err := structs.BlindedBeaconBlockBellatrixFromConsensus(blk.BlindedBellatrix) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -436,7 +437,7 @@ func handleProduceBlindedBellatrixV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Bellatrix), ExecutionPayloadBlinded: true, ExecutionPayloadValue: executionPayloadValue, @@ -461,7 +462,7 @@ func handleProduceBlindedCapellaV3( httputil.WriteSsz(w, sszResp, "blindedCapellaBlock.ssz") return } - block, err := shared.BlindedBeaconBlockCapellaFromConsensus(blk.BlindedCapella) + block, err := structs.BlindedBeaconBlockCapellaFromConsensus(blk.BlindedCapella) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -471,7 +472,7 @@ func handleProduceBlindedCapellaV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Capella), ExecutionPayloadBlinded: true, ExecutionPayloadValue: executionPayloadValue, @@ -496,7 +497,7 @@ func handleProduceCapellaV3( httputil.WriteSsz(w, sszResp, "capellaBlock.ssz") return } - block, err := shared.BeaconBlockCapellaFromConsensus(blk.Capella) + block, err := structs.BeaconBlockCapellaFromConsensus(blk.Capella) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -506,7 +507,7 @@ func handleProduceCapellaV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Capella), ExecutionPayloadBlinded: false, ExecutionPayloadValue: executionPayloadValue, // mev not available at this point @@ -531,7 +532,7 @@ func handleProduceBlindedDenebV3( httputil.WriteSsz(w, sszResp, "blindedDenebBlockContents.ssz") return } - blindedBlock, err := shared.BlindedBeaconBlockDenebFromConsensus(blk.BlindedDeneb) + blindedBlock, err := structs.BlindedBeaconBlockDenebFromConsensus(blk.BlindedDeneb) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -541,7 +542,7 @@ func handleProduceBlindedDenebV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Deneb), ExecutionPayloadBlinded: true, ExecutionPayloadValue: executionPayloadValue, @@ -567,7 +568,7 @@ func handleProduceDenebV3( return } - blockContents, err := shared.BeaconBlockContentsDenebFromConsensus(blk.Deneb) + blockContents, err := structs.BeaconBlockContentsDenebFromConsensus(blk.Deneb) if err != nil { httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return @@ -577,7 +578,7 @@ func handleProduceDenebV3( httputil.HandleError(w, err.Error(), http.StatusInternalServerError) return } - httputil.WriteJson(w, &ProduceBlockV3Response{ + httputil.WriteJson(w, &structs.ProduceBlockV3Response{ Version: version.String(version.Deneb), ExecutionPayloadBlinded: false, ExecutionPayloadValue: executionPayloadValue, // mev not available at this point diff --git a/beacon-chain/rpc/eth/validator/handlers_block_test.go b/beacon-chain/rpc/eth/validator/handlers_block_test.go index e687d599ab..040c9e1348 100644 --- a/beacon-chain/rpc/eth/validator/handlers_block_test.go +++ b/beacon-chain/rpc/eth/validator/handlers_block_test.go @@ -12,10 +12,9 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v4/api" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" blockchainTesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards" rewardtesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/rewards/testing" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" rpctesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared/testing" mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing" "github.com/prysmaticlabs/prysm/v4/network/httputil" @@ -35,10 +34,10 @@ func TestProduceBlockV2(t *testing.T) { require.NoError(t, err) chainService := &blockchainTesting.ChainService{} syncChecker := &mockSync.Sync{IsSyncing: false} - rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &rewards.BlockRewards{Total: "10"}} + rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &structs.BlockRewards{Total: "10"}} t.Run("Phase 0", func(t *testing.T) { - var block *shared.SignedBeaconBlock + var block *structs.SignedBeaconBlock err = json.Unmarshal([]byte(rpctesting.Phase0Block), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -70,7 +69,7 @@ func TestProduceBlockV2(t *testing.T) { require.Equal(t, "phase0", writer.Header().Get(api.VersionHeader)) }) t.Run("Altair", func(t *testing.T) { - var block *shared.SignedBeaconBlockAltair + var block *structs.SignedBeaconBlockAltair err = json.Unmarshal([]byte(rpctesting.AltairBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -103,7 +102,7 @@ func TestProduceBlockV2(t *testing.T) { require.Equal(t, "altair", writer.Header().Get(api.VersionHeader)) }) t.Run("Bellatrix", func(t *testing.T) { - var block *shared.SignedBeaconBlockBellatrix + var block *structs.SignedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BellatrixBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -140,7 +139,7 @@ func TestProduceBlockV2(t *testing.T) { require.Equal(t, "bellatrix", writer.Header().Get(api.VersionHeader)) }) t.Run("BlindedBellatrix", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockBellatrix + var block *structs.SignedBlindedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &block) require.NoError(t, err) @@ -172,7 +171,7 @@ func TestProduceBlockV2(t *testing.T) { assert.StringContains(t, "Prepared block is blinded", e.Message) }) t.Run("Capella", func(t *testing.T) { - var block *shared.SignedBeaconBlockCapella + var block *structs.SignedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.CapellaBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -209,7 +208,7 @@ func TestProduceBlockV2(t *testing.T) { require.Equal(t, "capella", writer.Header().Get(api.VersionHeader)) }) t.Run("Blinded Capella", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockCapella + var block *structs.SignedBlindedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &block) require.NoError(t, err) @@ -241,7 +240,7 @@ func TestProduceBlockV2(t *testing.T) { assert.StringContains(t, "Prepared block is blinded", e.Message) }) t.Run("Deneb", func(t *testing.T) { - var block *shared.SignedBeaconBlockContentsDeneb + var block *structs.SignedBeaconBlockContentsDeneb err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.ToUnsigned()) @@ -278,7 +277,7 @@ func TestProduceBlockV2(t *testing.T) { require.Equal(t, "deneb", writer.Header().Get(api.VersionHeader)) }) t.Run("Blinded Deneb", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockDeneb + var block *structs.SignedBlindedBeaconBlockDeneb err = json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block) require.NoError(t, err) @@ -375,10 +374,10 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.NoError(t, err) chainService := &blockchainTesting.ChainService{} syncChecker := &mockSync.Sync{IsSyncing: false} - rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &rewards.BlockRewards{Total: "10"}} + rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &structs.BlockRewards{Total: "10"}} t.Run("Phase 0", func(t *testing.T) { - var block *shared.SignedBeaconBlock + var block *structs.SignedBeaconBlock err = json.Unmarshal([]byte(rpctesting.Phase0Block), &block) require.NoError(t, err) @@ -413,7 +412,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.Equal(t, "phase0", writer.Header().Get(api.VersionHeader)) }) t.Run("Altair", func(t *testing.T) { - var block *shared.SignedBeaconBlockAltair + var block *structs.SignedBeaconBlockAltair err = json.Unmarshal([]byte(rpctesting.AltairBlock), &block) require.NoError(t, err) @@ -450,7 +449,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.Equal(t, "altair", writer.Header().Get(api.VersionHeader)) }) t.Run("Bellatrix", func(t *testing.T) { - var block *shared.SignedBeaconBlockBellatrix + var block *structs.SignedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BellatrixBlock), &block) require.NoError(t, err) @@ -487,7 +486,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.Equal(t, "bellatrix", writer.Header().Get(api.VersionHeader)) }) t.Run("BlindedBellatrix", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockBellatrix + var block *structs.SignedBlindedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &block) require.NoError(t, err) @@ -520,7 +519,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { assert.StringContains(t, "Prepared block is blinded", e.Message) }) t.Run("Capella", func(t *testing.T) { - var block *shared.SignedBeaconBlockCapella + var block *structs.SignedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.CapellaBlock), &block) require.NoError(t, err) @@ -557,7 +556,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.Equal(t, "capella", writer.Header().Get(api.VersionHeader)) }) t.Run("Blinded Capella", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockCapella + var block *structs.SignedBlindedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &block) require.NoError(t, err) @@ -593,7 +592,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { assert.StringContains(t, "Prepared block is blinded", e.Message) }) t.Run("Deneb", func(t *testing.T) { - var block *shared.SignedBeaconBlockContentsDeneb + var block *structs.SignedBeaconBlockContentsDeneb err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &block) require.NoError(t, err) @@ -630,7 +629,7 @@ func TestProduceBlockV2SSZ(t *testing.T) { require.Equal(t, "deneb", writer.Header().Get(api.VersionHeader)) }) t.Run("Blinded Deneb", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockDeneb + var block *structs.SignedBlindedBeaconBlockDeneb err = json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block) require.NoError(t, err) @@ -674,10 +673,10 @@ func TestProduceBlindedBlock(t *testing.T) { require.NoError(t, err) chainService := &blockchainTesting.ChainService{} syncChecker := &mockSync.Sync{IsSyncing: false} - rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &rewards.BlockRewards{Total: "10"}} + rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &structs.BlockRewards{Total: "10"}} t.Run("Phase 0", func(t *testing.T) { - var block *shared.SignedBeaconBlock + var block *structs.SignedBeaconBlock err = json.Unmarshal([]byte(rpctesting.Phase0Block), &block) require.NoError(t, err) @@ -707,7 +706,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.StringContains(t, "Prepared block is not blinded", e.Message) }) t.Run("Altair", func(t *testing.T) { - var block *shared.SignedBeaconBlockAltair + var block *structs.SignedBeaconBlockAltair err = json.Unmarshal([]byte(rpctesting.AltairBlock), &block) require.NoError(t, err) @@ -739,7 +738,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.StringContains(t, "Prepared block is not blinded", e.Message) }) t.Run("Bellatrix", func(t *testing.T) { - var block *shared.SignedBeaconBlockBellatrix + var block *structs.SignedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BellatrixBlock), &block) require.NoError(t, err) @@ -771,7 +770,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.StringContains(t, "Prepared block is not blinded", e.Message) }) t.Run("BlindedBellatrix", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockBellatrix + var block *structs.SignedBlindedBeaconBlockBellatrix err = json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -808,7 +807,7 @@ func TestProduceBlindedBlock(t *testing.T) { require.Equal(t, "bellatrix", writer.Header().Get(api.VersionHeader)) }) t.Run("Capella", func(t *testing.T) { - var block *shared.SignedBeaconBlockCapella + var block *structs.SignedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.CapellaBlock), &block) require.NoError(t, err) @@ -840,7 +839,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.StringContains(t, "Prepared block is not blinded", e.Message) }) t.Run("Blinded Capella", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockCapella + var block *structs.SignedBlindedBeaconBlockCapella err = json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -877,7 +876,7 @@ func TestProduceBlindedBlock(t *testing.T) { require.Equal(t, "capella", writer.Header().Get(api.VersionHeader)) }) t.Run("Deneb", func(t *testing.T) { - var block *shared.SignedBeaconBlockContentsDeneb + var block *structs.SignedBeaconBlockContentsDeneb err = json.Unmarshal([]byte(rpctesting.DenebBlockContents), &block) require.NoError(t, err) @@ -909,7 +908,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.StringContains(t, "Prepared block is not blinded", e.Message) }) t.Run("Blinded Deneb", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockDeneb + var block *structs.SignedBlindedBeaconBlockDeneb err = json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1011,10 +1010,10 @@ func TestProduceBlockV3(t *testing.T) { require.NoError(t, err) chainService := &blockchainTesting.ChainService{} syncChecker := &mockSync.Sync{IsSyncing: false} - rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &rewards.BlockRewards{Total: "10"}} + rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &structs.BlockRewards{Total: "10"}} t.Run("Phase 0", func(t *testing.T) { - var block *shared.SignedBeaconBlock + var block *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1047,7 +1046,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Altair", func(t *testing.T) { - var block *shared.SignedBeaconBlockAltair + var block *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &block) require.NoError(t, err) @@ -1083,7 +1082,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Bellatrix", func(t *testing.T) { - var block *shared.SignedBeaconBlockBellatrix + var block *structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1121,7 +1120,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("BlindedBellatrix", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockBellatrix + var block *structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1159,7 +1158,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Capella", func(t *testing.T) { - var block *shared.SignedBeaconBlockCapella + var block *structs.SignedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.CapellaBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1197,7 +1196,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Blinded Capella", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockCapella + var block *structs.SignedBlindedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1235,7 +1234,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Deneb", func(t *testing.T) { - var block *shared.SignedBeaconBlockContentsDeneb + var block *structs.SignedBeaconBlockContentsDeneb err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.ToUnsigned()) @@ -1273,7 +1272,7 @@ func TestProduceBlockV3(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Blinded Deneb", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockDeneb + var block *structs.SignedBlindedBeaconBlockDeneb err := json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block) require.NoError(t, err) jsonBytes, err := json.Marshal(block.Message) @@ -1375,10 +1374,10 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.NoError(t, err) chainService := &blockchainTesting.ChainService{} syncChecker := &mockSync.Sync{IsSyncing: false} - rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &rewards.BlockRewards{Total: "10"}} + rewardFetcher := &rewardtesting.MockBlockRewardFetcher{Rewards: &structs.BlockRewards{Total: "10"}} t.Run("Phase 0", func(t *testing.T) { - var block *shared.SignedBeaconBlock + var block *structs.SignedBeaconBlock err := json.Unmarshal([]byte(rpctesting.Phase0Block), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1414,7 +1413,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Altair", func(t *testing.T) { - var block *shared.SignedBeaconBlockAltair + var block *structs.SignedBeaconBlockAltair err := json.Unmarshal([]byte(rpctesting.AltairBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1452,7 +1451,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Bellatrix", func(t *testing.T) { - var block *shared.SignedBeaconBlockBellatrix + var block *structs.SignedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BellatrixBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1494,7 +1493,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("BlindedBellatrix", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockBellatrix + var block *structs.SignedBlindedBeaconBlockBellatrix err := json.Unmarshal([]byte(rpctesting.BlindedBellatrixBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1535,7 +1534,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Capella", func(t *testing.T) { - var block *shared.SignedBeaconBlockCapella + var block *structs.SignedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.CapellaBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1576,7 +1575,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Blinded Capella", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockCapella + var block *structs.SignedBlindedBeaconBlockCapella err := json.Unmarshal([]byte(rpctesting.BlindedCapellaBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1617,7 +1616,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Deneb", func(t *testing.T) { - var block *shared.SignedBeaconBlockContentsDeneb + var block *structs.SignedBeaconBlockContentsDeneb err := json.Unmarshal([]byte(rpctesting.DenebBlockContents), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) @@ -1658,7 +1657,7 @@ func TestProduceBlockV3SSZ(t *testing.T) { require.Equal(t, "10000000000", writer.Header().Get(api.ConsensusBlockValueHeader)) }) t.Run("Blinded Deneb", func(t *testing.T) { - var block *shared.SignedBlindedBeaconBlockDeneb + var block *structs.SignedBlindedBeaconBlockDeneb err := json.Unmarshal([]byte(rpctesting.BlindedDenebBlock), &block) require.NoError(t, err) v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl) diff --git a/beacon-chain/rpc/eth/validator/handlers_test.go b/beacon-chain/rpc/eth/validator/handlers_test.go index 50aca2d6d2..84d700b822 100644 --- a/beacon-chain/rpc/eth/validator/handlers_test.go +++ b/beacon-chain/rpc/eth/validator/handlers_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mockChain "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" builderTest "github.com/prysmaticlabs/prysm/v4/beacon-chain/builder/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/cache" @@ -26,7 +27,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/synccommittee" p2pmock "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/core" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/stategen" @@ -163,7 +163,7 @@ func TestGetAggregateAttestation(t *testing.T) { s.GetAggregateAttestation(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AggregateAttestationResponse{} + resp := &structs.AggregateAttestationResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -190,7 +190,7 @@ func TestGetAggregateAttestation(t *testing.T) { s.GetAggregateAttestation(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AggregateAttestationResponse{} + resp := &structs.AggregateAttestationResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -329,7 +329,7 @@ func TestGetAggregateAttestation_SameSlotAndRoot_ReturnMostAggregationBits(t *te s.GetAggregateAttestation(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &AggregateAttestationResponse{} + resp := &structs.AggregateAttestationResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) assert.DeepEqual(t, "0x03000001", resp.Data.AggregationBits) @@ -872,16 +872,16 @@ func TestGetAttestationData(t *testing.T) { s.GetAttestationData(writer, request) - expectedResponse := &GetAttestationDataResponse{ - Data: &shared.AttestationData{ + expectedResponse := &structs.GetAttestationDataResponse{ + Data: &structs.AttestationData{ Slot: strconv.FormatUint(uint64(slot), 10), BeaconBlockRoot: hexutil.Encode(blockRoot[:]), CommitteeIndex: strconv.FormatUint(0, 10), - Source: &shared.Checkpoint{ + Source: &structs.Checkpoint{ Epoch: strconv.FormatUint(2, 10), Root: hexutil.Encode(justifiedRoot[:]), }, - Target: &shared.Checkpoint{ + Target: &structs.Checkpoint{ Epoch: strconv.FormatUint(3, 10), Root: hexutil.Encode(blockRoot[:]), }, @@ -889,7 +889,7 @@ func TestGetAttestationData(t *testing.T) { } assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttestationDataResponse{} + resp := &structs.GetAttestationDataResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) assert.DeepEqual(t, expectedResponse, resp) @@ -1110,16 +1110,16 @@ func TestGetAttestationData(t *testing.T) { s.GetAttestationData(writer, request) - expectedResponse := &GetAttestationDataResponse{ - Data: &shared.AttestationData{ + expectedResponse := &structs.GetAttestationDataResponse{ + Data: &structs.AttestationData{ Slot: strconv.FormatUint(uint64(slot), 10), BeaconBlockRoot: hexutil.Encode(blockRoot[:]), CommitteeIndex: strconv.FormatUint(0, 10), - Source: &shared.Checkpoint{ + Source: &structs.Checkpoint{ Epoch: strconv.FormatUint(0, 10), Root: hexutil.Encode(justifiedRoot[:]), }, - Target: &shared.Checkpoint{ + Target: &structs.Checkpoint{ Epoch: strconv.FormatUint(0, 10), Root: hexutil.Encode(blockRoot[:]), }, @@ -1127,7 +1127,7 @@ func TestGetAttestationData(t *testing.T) { } assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttestationDataResponse{} + resp := &structs.GetAttestationDataResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) assert.DeepEqual(t, expectedResponse, resp) @@ -1197,16 +1197,16 @@ func TestGetAttestationData(t *testing.T) { s.GetAttestationData(writer, request) - expectedResponse := &GetAttestationDataResponse{ - Data: &shared.AttestationData{ + expectedResponse := &structs.GetAttestationDataResponse{ + Data: &structs.AttestationData{ Slot: strconv.FormatUint(uint64(slot), 10), BeaconBlockRoot: hexutil.Encode(blockRoot[:]), CommitteeIndex: strconv.FormatUint(0, 10), - Source: &shared.Checkpoint{ + Source: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(slots.ToEpoch(1500)), 10), Root: hexutil.Encode(justifiedBlockRoot[:]), }, - Target: &shared.Checkpoint{ + Target: &structs.Checkpoint{ Epoch: strconv.FormatUint(312, 10), Root: hexutil.Encode(blockRoot[:]), }, @@ -1214,7 +1214,7 @@ func TestGetAttestationData(t *testing.T) { } assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttestationDataResponse{} + resp := &structs.GetAttestationDataResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) assert.DeepEqual(t, expectedResponse, resp) @@ -1248,7 +1248,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) require.Equal(t, resp.Data.Slot, "1") @@ -1263,7 +1263,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusBadRequest, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.ErrorContains(t, "slot is required", errors.New(writer.Body.String())) }) @@ -1275,7 +1275,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusBadRequest, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.ErrorContains(t, "subcommittee_index is required", errors.New(writer.Body.String())) }) @@ -1287,7 +1287,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusBadRequest, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.ErrorContains(t, "Invalid Beacon Block Root: empty hex string", errors.New(writer.Body.String())) }) @@ -1299,7 +1299,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusBadRequest, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.ErrorContains(t, "Invalid Beacon Block Root: hex string without 0x prefix", errors.New(writer.Body.String())) }) @@ -1311,7 +1311,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &ProduceSyncCommitteeContributionResponse{} + resp := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp) require.NotNil(t, resp.Data) @@ -1330,7 +1330,7 @@ func TestProduceSyncCommitteeContribution(t *testing.T) { } server.ProduceSyncCommitteeContribution(writer, request) assert.Equal(t, http.StatusNotFound, writer.Code) - resp2 := &ProduceSyncCommitteeContributionResponse{} + resp2 := &structs.ProduceSyncCommitteeContributionResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp2)) require.ErrorContains(t, "No subcommittee messages found", errors.New(writer.Body.String())) }) @@ -1449,7 +1449,7 @@ func TestGetAttesterDuties(t *testing.T) { s.GetAttesterDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterDutiesResponse{} + resp := &structs.GetAttesterDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(genesisRoot[:]), resp.DependentRoot) require.Equal(t, 1, len(resp.Data)) @@ -1473,7 +1473,7 @@ func TestGetAttesterDuties(t *testing.T) { s.GetAttesterDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterDutiesResponse{} + resp := &structs.GetAttesterDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) }) @@ -1532,7 +1532,7 @@ func TestGetAttesterDuties(t *testing.T) { s.GetAttesterDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterDutiesResponse{} + resp := &structs.GetAttesterDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(genesisRoot[:]), resp.DependentRoot) require.Equal(t, 1, len(resp.Data)) @@ -1589,7 +1589,7 @@ func TestGetAttesterDuties(t *testing.T) { s.GetAttesterDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterDutiesResponse{} + resp := &structs.GetAttesterDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 0, len(resp.Data)) }) @@ -1627,7 +1627,7 @@ func TestGetAttesterDuties(t *testing.T) { s.GetAttesterDuties(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &GetAttesterDutiesResponse{} + resp := &structs.GetAttesterDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -1702,12 +1702,12 @@ func TestGetProposerDuties(t *testing.T) { s.GetProposerDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetProposerDutiesResponse{} + resp := &structs.GetProposerDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(genesisRoot[:]), resp.DependentRoot) assert.Equal(t, 31, len(resp.Data)) // We expect a proposer duty for slot 11. - var expectedDuty *ProposerDuty + var expectedDuty *structs.ProposerDuty for _, duty := range resp.Data { if duty.Slot == "11" { expectedDuty = duty @@ -1742,12 +1742,12 @@ func TestGetProposerDuties(t *testing.T) { s.GetProposerDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetProposerDutiesResponse{} + resp := &structs.GetProposerDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, hexutil.Encode(genesisRoot[:]), resp.DependentRoot) assert.Equal(t, 32, len(resp.Data)) // We expect a proposer duty for slot 43. - var expectedDuty *ProposerDuty + var expectedDuty *structs.ProposerDuty for _, duty := range resp.Data { if duty.Slot == "43" { expectedDuty = duty @@ -1828,7 +1828,7 @@ func TestGetProposerDuties(t *testing.T) { s.GetProposerDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetProposerDutiesResponse{} + resp := &structs.GetProposerDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -1906,7 +1906,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) duty := resp.Data[0] @@ -1929,7 +1929,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 2, len(resp.Data)) }) @@ -1988,7 +1988,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) assert.Equal(t, "1", resp.Data[0].ValidatorIndex) @@ -2004,7 +2004,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) duty := resp.Data[0] require.Equal(t, 2, len(duty.ValidatorSyncCommitteeIndices)) @@ -2037,7 +2037,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) duty := resp.Data[0] @@ -2094,7 +2094,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) duty := resp.Data[0] @@ -2114,7 +2114,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, 1, len(resp.Data)) duty := resp.Data[0] @@ -2190,7 +2190,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) { s.GetSyncCommitteeDuties(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetSyncCommitteeDutiesResponse{} + resp := &structs.GetSyncCommitteeDutiesResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) assert.Equal(t, true, resp.ExecutionOptimistic) }) @@ -2221,13 +2221,13 @@ func TestGetSyncCommitteeDuties(t *testing.T) { func TestPrepareBeaconProposer(t *testing.T) { tests := []struct { name string - request []*shared.FeeRecipient + request []*structs.FeeRecipient code int wantErr string }{ { name: "Happy Path", - request: []*shared.FeeRecipient{{ + request: []*structs.FeeRecipient{{ FeeRecipient: "0xb698D697092822185bF0311052215d5B5e1F3934", ValidatorIndex: "1", }, @@ -2237,7 +2237,7 @@ func TestPrepareBeaconProposer(t *testing.T) { }, { name: "invalid fee recipient length", - request: []*shared.FeeRecipient{{ + request: []*structs.FeeRecipient{{ FeeRecipient: "0xb698D697092822185bF0311052", ValidatorIndex: "1", }, @@ -2290,7 +2290,7 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { TrackedValidatorsCache: cache.NewTrackedValidatorsCache(), PayloadIDCache: cache.NewPayloadIDCache(), } - req := []*shared.FeeRecipient{{ + req := []*structs.FeeRecipient{{ FeeRecipient: hexutil.Encode(bytesutil.PadTo([]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}, fieldparams.FeeRecipientLength)), ValidatorIndex: "1", }} @@ -2319,7 +2319,7 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { // Same validator with different fee recipient hook.Reset() - req = []*shared.FeeRecipient{{ + req = []*structs.FeeRecipient{{ FeeRecipient: hexutil.Encode(bytesutil.PadTo([]byte{0x01, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}, fieldparams.FeeRecipientLength)), ValidatorIndex: "1", }} @@ -2335,7 +2335,7 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { // More than one validator hook.Reset() - req = []*shared.FeeRecipient{ + req = []*structs.FeeRecipient{ { FeeRecipient: hexutil.Encode(bytesutil.PadTo([]byte{0x01, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}, fieldparams.FeeRecipientLength)), ValidatorIndex: "1", @@ -2376,9 +2376,9 @@ func BenchmarkServer_PrepareBeaconProposer(b *testing.B) { PayloadIDCache: cache.NewPayloadIDCache(), } f := bytesutil.PadTo([]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}, fieldparams.FeeRecipientLength) - recipients := make([]*shared.FeeRecipient, 0) + recipients := make([]*structs.FeeRecipient, 0) for i := 0; i < 10000; i++ { - recipients = append(recipients, &shared.FeeRecipient{FeeRecipient: hexutil.Encode(f), ValidatorIndex: fmt.Sprint(i)}) + recipients = append(recipients, &structs.FeeRecipient{FeeRecipient: hexutil.Encode(f), ValidatorIndex: fmt.Sprint(i)}) } byt, err := json.Marshal(recipients) require.NoError(b, err) @@ -2436,7 +2436,7 @@ func TestGetLiveness(t *testing.T) { s.GetLiveness(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetLivenessResponse{} + resp := &structs.GetLivenessResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) data0 := resp.Data[0] @@ -2455,7 +2455,7 @@ func TestGetLiveness(t *testing.T) { s.GetLiveness(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetLivenessResponse{} + resp := &structs.GetLivenessResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) data0 := resp.Data[0] @@ -2474,7 +2474,7 @@ func TestGetLiveness(t *testing.T) { s.GetLiveness(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &GetLivenessResponse{} + resp := &structs.GetLivenessResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.NotNil(t, resp.Data) data0 := resp.Data[0] diff --git a/beacon-chain/rpc/prysm/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/beacon/BUILD.bazel index 859051ec9c..921567efad 100644 --- a/beacon-chain/rpc/prysm/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/beacon/BUILD.bazel @@ -5,11 +5,11 @@ go_library( srcs = [ "handlers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/beacon", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/db:go_default_library", diff --git a/beacon-chain/rpc/prysm/beacon/handlers.go b/beacon-chain/rpc/prysm/beacon/handlers.go index 831f484cec..180952beb6 100644 --- a/beacon-chain/rpc/prysm/beacon/handlers.go +++ b/beacon-chain/rpc/prysm/beacon/handlers.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common/hexutil" + "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/shared" "github.com/prysmaticlabs/prysm/v4/config/params" @@ -57,9 +58,9 @@ func (s *Server) GetWeakSubjectivity(w http.ResponseWriter, r *http.Request) { stateRoot := cb.Block().StateRoot() log.Printf("Weak subjectivity checkpoint reported as epoch=%d, block root=%#x, state root=%#x", wsEpoch, cbr, stateRoot) - resp := &GetWeakSubjectivityResponse{ - Data: &WeakSubjectivityData{ - WsCheckpoint: &shared.Checkpoint{ + resp := &structs.GetWeakSubjectivityResponse{ + Data: &structs.WeakSubjectivityData{ + WsCheckpoint: &structs.Checkpoint{ Epoch: strconv.FormatUint(uint64(wsEpoch), 10), Root: hexutil.Encode(cbr[:]), }, diff --git a/beacon-chain/rpc/prysm/beacon/structs.go b/beacon-chain/rpc/prysm/beacon/structs.go deleted file mode 100644 index 4f9b5f6bc9..0000000000 --- a/beacon-chain/rpc/prysm/beacon/structs.go +++ /dev/null @@ -1,12 +0,0 @@ -package beacon - -import "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" - -type GetWeakSubjectivityResponse struct { - Data *WeakSubjectivityData `json:"data"` -} - -type WeakSubjectivityData struct { - WsCheckpoint *shared.Checkpoint `json:"ws_checkpoint"` - StateRoot string `json:"state_root"` -} diff --git a/beacon-chain/rpc/prysm/node/BUILD.bazel b/beacon-chain/rpc/prysm/node/BUILD.bazel index c77cf937a9..ef143b6440 100644 --- a/beacon-chain/rpc/prysm/node/BUILD.bazel +++ b/beacon-chain/rpc/prysm/node/BUILD.bazel @@ -5,11 +5,11 @@ go_library( srcs = [ "handlers.go", "server.go", - "structs.go", ], importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/node", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", "//beacon-chain/execution:go_default_library", @@ -28,12 +28,10 @@ go_library( go_test( name = "go_default_test", - srcs = [ - "handlers_test.go", - "server_test.go", - ], + srcs = ["handlers_test.go"], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/p2p:go_default_library", "//beacon-chain/p2p/peers:go_default_library", "//beacon-chain/p2p/testing:go_default_library", diff --git a/beacon-chain/rpc/prysm/node/handlers.go b/beacon-chain/rpc/prysm/node/handlers.go index 1c6c25879b..552e198904 100644 --- a/beacon-chain/rpc/prysm/node/handlers.go +++ b/beacon-chain/rpc/prysm/node/handlers.go @@ -9,6 +9,7 @@ import ( corenet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers/peerdata" @@ -24,7 +25,7 @@ func (s *Server) ListTrustedPeer(w http.ResponseWriter, r *http.Request) { peerStatus := s.PeersFetcher.Peers() allIds := s.PeersFetcher.Peers().GetTrustedPeers() - allPeers := make([]*Peer, 0, len(allIds)) + allPeers := make([]*structs.Peer, 0, len(allIds)) for _, id := range allIds { p, err := httpPeerInfo(peerStatus, id) if err != nil { @@ -37,8 +38,8 @@ func (s *Server) ListTrustedPeer(w http.ResponseWriter, r *http.Request) { } // peers added into trusted set but never connected should also be listed if p == nil { - p = &Peer{ - PeerID: id.String(), + p = &structs.Peer{ + PeerId: id.String(), Enr: "", LastSeenP2PAddress: "", State: eth.ConnectionState(corenet.NotConnected).String(), @@ -47,7 +48,7 @@ func (s *Server) ListTrustedPeer(w http.ResponseWriter, r *http.Request) { } allPeers = append(allPeers, p) } - response := &PeersResponse{Peers: allPeers} + response := &structs.PeersResponse{Peers: allPeers} httputil.WriteJson(w, response) } @@ -65,7 +66,7 @@ func (s *Server) AddTrustedPeer(w http.ResponseWriter, r *http.Request) { httputil.WriteError(w, errJson) return } - var addrRequest *AddrRequest + var addrRequest *structs.AddrRequest err = json.Unmarshal(body, &addrRequest) if err != nil { errJson := &httputil.DefaultJsonError{ @@ -130,7 +131,7 @@ func (s *Server) RemoveTrustedPeer(w http.ResponseWriter, r *http.Request) { // httpPeerInfo does the same thing as peerInfo function in node.go but returns the // http peer response. -func httpPeerInfo(peerStatus *peers.Status, id peer.ID) (*Peer, error) { +func httpPeerInfo(peerStatus *peers.Status, id peer.ID) (*structs.Peer, error) { enr, err := peerStatus.ENR(id) if err != nil { if errors.Is(err, peerdata.ErrPeerUnknown) { @@ -171,8 +172,8 @@ func httpPeerInfo(peerStatus *peers.Status, id peer.ID) (*Peer, error) { } v1ConnState := eth.ConnectionState(connectionState).String() v1PeerDirection := eth.PeerDirection(direction).String() - p := Peer{ - PeerID: id.String(), + p := structs.Peer{ + PeerId: id.String(), State: v1ConnState, Direction: v1PeerDirection, } diff --git a/beacon-chain/rpc/prysm/node/handlers_test.go b/beacon-chain/rpc/prysm/node/handlers_test.go index 98d52b7072..f107d3193c 100644 --- a/beacon-chain/rpc/prysm/node/handlers_test.go +++ b/beacon-chain/rpc/prysm/node/handlers_test.go @@ -14,6 +14,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" libp2ptest "github.com/libp2p/go-libp2p/p2p/host/peerstore/test" ma "github.com/multiformats/go-multiaddr" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers" mockp2p "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" @@ -84,14 +85,14 @@ func TestListTrustedPeer(t *testing.T) { writer.Body = &bytes.Buffer{} s.ListTrustedPeer(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &PeersResponse{} + resp := &structs.PeersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) peers := resp.Peers // assert number of trusted peer is right assert.Equal(t, 9, len(peers)) for i := 0; i < 9; i++ { - pid, err := peer.Decode(peers[i].PeerID) + pid, err := peer.Decode(peers[i].PeerId) require.NoError(t, err) if pid == ids[8] { assert.Equal(t, "", peers[i].Enr) @@ -151,7 +152,7 @@ func TestListTrustedPeers_NoPeersReturnsEmptyArray(t *testing.T) { writer.Body = &bytes.Buffer{} s.ListTrustedPeer(writer, request) assert.Equal(t, http.StatusOK, writer.Code) - resp := &PeersResponse{} + resp := &structs.PeersResponse{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) peers := resp.Peers assert.Equal(t, 0, len(peers)) @@ -163,7 +164,7 @@ func TestAddTrustedPeer(t *testing.T) { s := Server{PeersFetcher: peerFetcher} url := "http://anything.is.fine" - addr := &AddrRequest{ + addr := &structs.AddrRequest{ Addr: "/ip4/127.0.0.1/tcp/30303/p2p/16Uiu2HAm1n583t4huDMMqEUUBuQs6bLts21mxCfX3tiqu9JfHvRJ", } addrJson, err := json.Marshal(addr) @@ -201,7 +202,7 @@ func TestAddTrustedPeer_BadAddress(t *testing.T) { s := Server{PeersFetcher: peerFetcher} url := "http://anything.is.fine" - addr := &AddrRequest{ + addr := &structs.AddrRequest{ Addr: "anything/but/not/an/address", } addrJson, err := json.Marshal(addr) diff --git a/beacon-chain/rpc/prysm/node/server_test.go b/beacon-chain/rpc/prysm/node/server_test.go deleted file mode 100644 index 2b4023a62f..0000000000 --- a/beacon-chain/rpc/prysm/node/server_test.go +++ /dev/null @@ -1 +0,0 @@ -package node diff --git a/beacon-chain/rpc/prysm/node/structs.go b/beacon-chain/rpc/prysm/node/structs.go deleted file mode 100644 index 7dbe3c8d46..0000000000 --- a/beacon-chain/rpc/prysm/node/structs.go +++ /dev/null @@ -1,17 +0,0 @@ -package node - -type AddrRequest struct { - Addr string `json:"addr"` -} - -type PeersResponse struct { - Peers []*Peer `json:"Peers"` -} - -type Peer struct { - PeerID string `json:"peer_id"` - Enr string `json:"enr"` - LastSeenP2PAddress string `json:"last_seen_p2p_address"` - State string `json:"state"` - Direction string `json:"direction"` -} diff --git a/beacon-chain/rpc/prysm/validator/BUILD.bazel b/beacon-chain/rpc/prysm/validator/BUILD.bazel index 3596803b8b..a67fb7dae6 100644 --- a/beacon-chain/rpc/prysm/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/validator/BUILD.bazel @@ -10,6 +10,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/validator", visibility = ["//visibility:public"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", "//beacon-chain/rpc/core:go_default_library", @@ -37,6 +38,7 @@ go_test( ], embed = [":go_default_library"], deps = [ + "//api/server/structs:go_default_library", "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/helpers:go_default_library", diff --git a/beacon-chain/rpc/prysm/validator/validator_count.go b/beacon-chain/rpc/prysm/validator/validator_count.go index 2482a93f30..57c12b7621 100644 --- a/beacon-chain/rpc/prysm/validator/validator_count.go +++ b/beacon-chain/rpc/prysm/validator/validator_count.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" statenative "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" @@ -20,17 +21,6 @@ import ( "go.opencensus.io/trace" ) -type CountResponse struct { - ExecutionOptimistic string `json:"execution_optimistic"` - Finalized string `json:"finalized"` - Data []*Count `json:"data"` -} - -type Count struct { - Status string `json:"status"` - Count string `json:"count"` -} - // GetValidatorCount is a HTTP handler that serves the GET /eth/v1/beacon/states/{state_id}/validator_count endpoint. // It returns the total validator count according to the given statuses provided as a query parameter. // @@ -126,7 +116,7 @@ func (s *Server) GetValidatorCount(w http.ResponseWriter, r *http.Request) { return } - valCountResponse := &CountResponse{ + valCountResponse := &structs.GetValidatorCountResponse{ ExecutionOptimistic: strconv.FormatBool(isOptimistic), Finalized: strconv.FormatBool(isFinalized), Data: valCount, @@ -136,7 +126,7 @@ func (s *Server) GetValidatorCount(w http.ResponseWriter, r *http.Request) { } // validatorCountByStatus returns a slice of validator count for each status in the given epoch. -func validatorCountByStatus(validators []*eth.Validator, statuses []validator.Status, epoch primitives.Epoch) ([]*Count, error) { +func validatorCountByStatus(validators []*eth.Validator, statuses []validator.Status, epoch primitives.Epoch) ([]*structs.ValidatorCount, error) { countByStatus := make(map[validator.Status]uint64) for _, val := range validators { readOnlyVal, err := statenative.NewValidator(val) @@ -159,9 +149,9 @@ func validatorCountByStatus(validators []*eth.Validator, statuses []validator.St } } - var resp []*Count + var resp []*structs.ValidatorCount for status, count := range countByStatus { - resp = append(resp, &Count{ + resp = append(resp, &structs.ValidatorCount{ Status: status.String(), Count: strconv.FormatUint(count, 10), }) diff --git a/beacon-chain/rpc/prysm/validator/validator_count_test.go b/beacon-chain/rpc/prysm/validator/validator_count_test.go index 30a74c7c17..ca5cd2bbae 100644 --- a/beacon-chain/rpc/prysm/validator/validator_count_test.go +++ b/beacon-chain/rpc/prysm/validator/validator_count_test.go @@ -12,6 +12,7 @@ import ( "strings" "testing" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/lookup" @@ -188,16 +189,16 @@ func TestGetValidatorCount(t *testing.T) { stateID string statuses []string currentEpoch int - expectedResponse CountResponse + expectedResponse structs.GetValidatorCountResponse }{ { name: "Head count active validators", stateID: "head", statuses: []string{"active"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active", Count: "13", @@ -209,10 +210,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count active ongoing validators", stateID: "head", statuses: []string{"active_ongoing"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active_ongoing", Count: "11", @@ -224,10 +225,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count active exiting validators", stateID: "head", statuses: []string{"active_exiting"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active_exiting", Count: "1", @@ -239,10 +240,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count active slashed validators", stateID: "head", statuses: []string{"active_slashed"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active_slashed", Count: "1", @@ -254,10 +255,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count pending validators", stateID: "head", statuses: []string{"pending"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "pending", Count: "6", @@ -269,10 +270,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count pending initialized validators", stateID: "head", statuses: []string{"pending_initialized"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "pending_initialized", Count: "1", @@ -284,10 +285,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count pending queued validators", stateID: "head", statuses: []string{"pending_queued"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "pending_queued", Count: "5", @@ -300,10 +301,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"exited"}, currentEpoch: 35, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "exited", Count: "6", @@ -316,10 +317,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"exited_slashed"}, currentEpoch: 35, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "exited_slashed", Count: "2", @@ -332,10 +333,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"exited_unslashed"}, currentEpoch: 35, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "exited_unslashed", Count: "4", @@ -348,10 +349,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"withdrawal"}, currentEpoch: 45, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "withdrawal", Count: "2", @@ -364,10 +365,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"withdrawal_possible"}, currentEpoch: 45, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "withdrawal_possible", Count: "1", @@ -380,10 +381,10 @@ func TestGetValidatorCount(t *testing.T) { stateID: "head", statuses: []string{"withdrawal_done"}, currentEpoch: 45, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "withdrawal_done", Count: "1", @@ -395,10 +396,10 @@ func TestGetValidatorCount(t *testing.T) { name: "Head count active and pending validators", stateID: "head", statuses: []string{"active", "pending"}, - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active", Count: "13", @@ -413,10 +414,10 @@ func TestGetValidatorCount(t *testing.T) { { name: "Head count of ALL validators", stateID: "head", - expectedResponse: CountResponse{ + expectedResponse: structs.GetValidatorCountResponse{ ExecutionOptimistic: "false", Finalized: "true", - Data: []*Count{ + Data: []*structs.ValidatorCount{ { Status: "active", Count: "13", @@ -482,7 +483,7 @@ func TestGetValidatorCount(t *testing.T) { body, err := io.ReadAll(resp.Body) require.NoError(t, err) - var count CountResponse + var count structs.GetValidatorCountResponse err = json.Unmarshal(body, &count) require.NoError(t, err) require.DeepEqual(t, test.expectedResponse, count) diff --git a/beacon-chain/rpc/prysm/validator/validator_performance.go b/beacon-chain/rpc/prysm/validator/validator_performance.go index b06c605742..dfd904c24c 100644 --- a/beacon-chain/rpc/prysm/validator/validator_performance.go +++ b/beacon-chain/rpc/prysm/validator/validator_performance.go @@ -4,36 +4,19 @@ import ( "encoding/json" "net/http" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/core" - "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/network/httputil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "go.opencensus.io/trace" ) -type PerformanceRequest struct { - PublicKeys [][]byte `json:"public_keys,omitempty"` - Indices []primitives.ValidatorIndex `json:"indices,omitempty"` -} - -type PerformanceResponse struct { - PublicKeys [][]byte `json:"public_keys,omitempty"` - CorrectlyVotedSource []bool `json:"correctly_voted_source,omitempty"` - CorrectlyVotedTarget []bool `json:"correctly_voted_target,omitempty"` - CorrectlyVotedHead []bool `json:"correctly_voted_head,omitempty"` - CurrentEffectiveBalances []uint64 `json:"current_effective_balances,omitempty"` - BalancesBeforeEpochTransition []uint64 `json:"balances_before_epoch_transition,omitempty"` - BalancesAfterEpochTransition []uint64 `json:"balances_after_epoch_transition,omitempty"` - MissingValidators [][]byte `json:"missing_validators,omitempty"` - InactivityScores []uint64 `json:"inactivity_scores,omitempty"` -} - // GetValidatorPerformance is an HTTP handler for GetValidatorPerformance. func (s *Server) GetValidatorPerformance(w http.ResponseWriter, r *http.Request) { ctx, span := trace.StartSpan(r.Context(), "validator.GetValidatorPerformance") defer span.End() - var req PerformanceRequest + var req structs.GetValidatorPerformanceRequest if r.Body != http.NoBody { if err := json.NewDecoder(r.Body).Decode(&req); err != nil { handleHTTPError(w, "Could not decode request body: "+err.Error(), http.StatusBadRequest) @@ -51,7 +34,7 @@ func (s *Server) GetValidatorPerformance(w http.ResponseWriter, r *http.Request) handleHTTPError(w, "Could not compute validator performance: "+err.Err.Error(), core.ErrorReasonToHTTP(err.Reason)) return } - response := &PerformanceResponse{ + response := &structs.GetValidatorPerformanceResponse{ PublicKeys: computed.PublicKeys, CorrectlyVotedSource: computed.CorrectlyVotedSource, CorrectlyVotedTarget: computed.CorrectlyVotedTarget, // In altair, when this is true then the attestation was definitely included. diff --git a/beacon-chain/rpc/prysm/validator/validator_performance_test.go b/beacon-chain/rpc/prysm/validator/validator_performance_test.go index e05cbf7d25..322ba88023 100644 --- a/beacon-chain/rpc/prysm/validator/validator_performance_test.go +++ b/beacon-chain/rpc/prysm/validator/validator_performance_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/prysmaticlabs/go-bitfield" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" @@ -67,7 +68,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, }, } - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -78,7 +79,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { MissingValidators: [][]byte{publicKeys[0][:]}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]}, } var buf bytes.Buffer @@ -98,7 +99,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) @@ -133,7 +134,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { require.NoError(t, err) extraBal := params.BeaconConfig().MaxEffectiveBalance + params.BeaconConfig().GweiPerEth - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -143,7 +144,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { BalancesAfterEpochTransition: []uint64{vp[1].AfterEpochTransitionBalance, vp[2].AfterEpochTransitionBalance}, MissingValidators: [][]byte{publicKeys[0][:]}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ Indices: []primitives.ValidatorIndex{2, 1, 0}, } var buf bytes.Buffer @@ -163,7 +164,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) @@ -198,7 +199,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { require.NoError(t, err) extraBal := params.BeaconConfig().MaxEffectiveBalance + params.BeaconConfig().GweiPerEth - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -208,7 +209,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { BalancesAfterEpochTransition: []uint64{vp[1].AfterEpochTransitionBalance, vp[2].AfterEpochTransitionBalance}, MissingValidators: [][]byte{publicKeys[0][:]}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:]}, Indices: []primitives.ValidatorIndex{1, 2}, } var buf bytes.Buffer @@ -228,7 +229,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) @@ -259,7 +260,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, }, } - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -270,7 +271,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { MissingValidators: [][]byte{publicKeys[0][:]}, InactivityScores: []uint64{0, 0}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]}, } var buf bytes.Buffer @@ -290,7 +291,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) @@ -321,7 +322,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, }, } - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -332,7 +333,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { MissingValidators: [][]byte{publicKeys[0][:]}, InactivityScores: []uint64{0, 0}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]}, } var buf bytes.Buffer @@ -352,7 +353,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) @@ -383,7 +384,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { SyncChecker: &mockSync.Sync{IsSyncing: false}, }, } - want := &PerformanceResponse{ + want := &structs.GetValidatorPerformanceResponse{ PublicKeys: [][]byte{publicKeys[1][:], publicKeys[2][:]}, CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance}, CorrectlyVotedSource: []bool{false, false}, @@ -394,7 +395,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { MissingValidators: [][]byte{publicKeys[0][:]}, InactivityScores: []uint64{0, 0}, } - request := &PerformanceRequest{ + request := &structs.GetValidatorPerformanceRequest{ PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]}, } var buf bytes.Buffer @@ -414,7 +415,7 @@ func TestServer_GetValidatorPerformance(t *testing.T) { body, err := io.ReadAll(rawResp.Body) require.NoError(t, err) - response := &PerformanceResponse{} + response := &structs.GetValidatorPerformanceResponse{} require.NoError(t, json.Unmarshal(body, response)) require.DeepEqual(t, want, response) }) diff --git a/cmd/prysmctl/validator/BUILD.bazel b/cmd/prysmctl/validator/BUILD.bazel index 777b0fd03f..719b5a9245 100644 --- a/cmd/prysmctl/validator/BUILD.bazel +++ b/cmd/prysmctl/validator/BUILD.bazel @@ -14,7 +14,7 @@ go_library( "//api/client:go_default_library", "//api/client/beacon:go_default_library", "//api/client/validator:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", + "//api/server/structs:go_default_library", "//cmd:go_default_library", "//cmd/validator/accounts:go_default_library", "//cmd/validator/flags:go_default_library", @@ -47,9 +47,7 @@ go_test( embed = [":go_default_library"], deps = [ "//api/server:go_default_library", - "//beacon-chain/rpc/eth/beacon:go_default_library", - "//beacon-chain/rpc/eth/config:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", + "//api/server/structs:go_default_library", "//config/params:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", diff --git a/cmd/prysmctl/validator/withdraw.go b/cmd/prysmctl/validator/withdraw.go index abadb571cf..ecc17a3ae7 100644 --- a/cmd/prysmctl/validator/withdraw.go +++ b/cmd/prysmctl/validator/withdraw.go @@ -14,7 +14,7 @@ import ( "github.com/logrusorgru/aurora" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api/client/beacon" - "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" log "github.com/sirupsen/logrus" @@ -40,8 +40,8 @@ func setWithdrawalAddresses(c *cli.Context) error { return callWithdrawalEndpoints(ctx, beaconNodeHost, setWithdrawalAddressJsons) } -func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*shared.SignedBLSToExecutionChange, error) { - setWithdrawalAddressJsons := make([]*shared.SignedBLSToExecutionChange, 0) +func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*structs.SignedBLSToExecutionChange, error) { + setWithdrawalAddressJsons := make([]*structs.SignedBLSToExecutionChange, 0) foundFilePaths, err := findWithdrawalFiles(c.String(PathFlag.Name)) if err != nil { return setWithdrawalAddressJsons, errors.Wrap(err, "failed to find withdrawal files") @@ -51,7 +51,7 @@ func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*shared.SignedBLSToExe if err != nil { return setWithdrawalAddressJsons, errors.Wrap(err, "failed to open file") } - var to []*shared.SignedBLSToExecutionChange + var to []*structs.SignedBLSToExecutionChange if err := json.Unmarshal(b, &to); err != nil { log.Warnf("provided file: %s, is not a list of signed withdrawal messages. Error:%s", foundFilePath, err.Error()) continue @@ -67,8 +67,8 @@ func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*shared.SignedBLSToExe if len(obj.Signature) == fieldparams.BLSSignatureLength*2 { to[i].Signature = fmt.Sprintf("0x%s", obj.Signature) } - setWithdrawalAddressJsons = append(setWithdrawalAddressJsons, &shared.SignedBLSToExecutionChange{ - Message: &shared.BLSToExecutionChange{ + setWithdrawalAddressJsons = append(setWithdrawalAddressJsons, &structs.SignedBLSToExecutionChange{ + Message: &structs.BLSToExecutionChange{ ValidatorIndex: to[i].Message.ValidatorIndex, FromBLSPubkey: to[i].Message.FromBLSPubkey, ToExecutionAddress: to[i].Message.ToExecutionAddress, @@ -83,7 +83,7 @@ func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*shared.SignedBLSToExe return setWithdrawalAddressJsons, nil } -func callWithdrawalEndpoints(ctx context.Context, host string, request []*shared.SignedBLSToExecutionChange) error { +func callWithdrawalEndpoints(ctx context.Context, host string, request []*structs.SignedBLSToExecutionChange) error { client, err := beacon.NewClient(host) if err != nil { return err @@ -123,7 +123,7 @@ func callWithdrawalEndpoints(ctx context.Context, host string, request []*shared return checkIfWithdrawsAreInPool(ctx, client, request) } -func checkIfWithdrawsAreInPool(ctx context.Context, client *beacon.Client, request []*shared.SignedBLSToExecutionChange) error { +func checkIfWithdrawsAreInPool(ctx context.Context, client *beacon.Client, request []*structs.SignedBLSToExecutionChange) error { log.Info("Verifying requested withdrawal messages known to node...") poolResponse, err := client.GetBLStoExecutionChanges(ctx) if err != nil { diff --git a/cmd/prysmctl/validator/withdraw_test.go b/cmd/prysmctl/validator/withdraw_test.go index b0cdbf4035..3bc3063a8d 100644 --- a/cmd/prysmctl/validator/withdraw_test.go +++ b/cmd/prysmctl/validator/withdraw_test.go @@ -13,9 +13,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/beacon" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/config" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -32,16 +30,16 @@ func getHappyPathTestServer(file string, t *testing.T) *httptest.Server { if r.RequestURI == "/eth/v1/beacon/pool/bls_to_execution_changes" { b, err := os.ReadFile(filepath.Clean(file)) require.NoError(t, err) - var to []*shared.SignedBLSToExecutionChange + var to []*structs.SignedBLSToExecutionChange err = json.Unmarshal(b, &to) require.NoError(t, err) - err = json.NewEncoder(w).Encode(&beacon.BLSToExecutionChangesPoolResponse{ + err = json.NewEncoder(w).Encode(&structs.BLSToExecutionChangesPoolResponse{ Data: to, }) require.NoError(t, err) } else if r.RequestURI == "/eth/v1/beacon/states/head/fork" { - err := json.NewEncoder(w).Encode(&beacon.GetStateForkResponse{ - Data: &shared.Fork{ + err := json.NewEncoder(w).Encode(&structs.GetStateForkResponse{ + Data: &structs.Fork{ PreviousVersion: hexutil.Encode(params.BeaconConfig().CapellaForkVersion), CurrentVersion: hexutil.Encode(params.BeaconConfig().CapellaForkVersion), Epoch: "1350", @@ -53,7 +51,7 @@ func getHappyPathTestServer(file string, t *testing.T) *httptest.Server { } else if r.RequestURI == "/eth/v1/config/spec" { m := make(map[string]string) m["CAPELLA_FORK_EPOCH"] = "1350" - err := json.NewEncoder(w).Encode(&config.GetSpecResponse{ + err := json.NewEncoder(w).Encode(&structs.GetSpecResponse{ Data: m, }) require.NoError(t, err) @@ -231,8 +229,8 @@ func TestCallWithdrawalEndpoint_Errors(t *testing.T) { if r.RequestURI == "/eth/v1/beacon/states/head/fork" { w.WriteHeader(200) w.Header().Set("Content-Type", "application/json") - err := json.NewEncoder(w).Encode(&beacon.GetStateForkResponse{ - Data: &shared.Fork{ + err := json.NewEncoder(w).Encode(&structs.GetStateForkResponse{ + Data: &structs.Fork{ PreviousVersion: hexutil.Encode(params.BeaconConfig().CapellaForkVersion), CurrentVersion: hexutil.Encode(params.BeaconConfig().CapellaForkVersion), Epoch: fmt.Sprintf("%d", params.BeaconConfig().CapellaForkEpoch), @@ -246,7 +244,7 @@ func TestCallWithdrawalEndpoint_Errors(t *testing.T) { w.Header().Set("Content-Type", "application/json") m := make(map[string]string) m["CAPELLA_FORK_EPOCH"] = "1350" - err := json.NewEncoder(w).Encode(&config.GetSpecResponse{ + err := json.NewEncoder(w).Encode(&structs.GetSpecResponse{ Data: m, }) require.NoError(t, err) @@ -289,8 +287,8 @@ func TestCallWithdrawalEndpoint_ForkBeforeCapella(t *testing.T) { w.Header().Set("Content-Type", "application/json") if r.RequestURI == "/eth/v1/beacon/states/head/fork" { - err := json.NewEncoder(w).Encode(&beacon.GetStateForkResponse{ - Data: &shared.Fork{ + err := json.NewEncoder(w).Encode(&structs.GetStateForkResponse{ + Data: &structs.Fork{ PreviousVersion: hexutil.Encode(params.BeaconConfig().BellatrixForkVersion), CurrentVersion: hexutil.Encode(params.BeaconConfig().BellatrixForkVersion), Epoch: "1000", @@ -302,7 +300,7 @@ func TestCallWithdrawalEndpoint_ForkBeforeCapella(t *testing.T) { } else if r.RequestURI == "/eth/v1/config/spec" { m := make(map[string]string) m["CAPELLA_FORK_EPOCH"] = "1350" - err := json.NewEncoder(w).Encode(&config.GetSpecResponse{ + err := json.NewEncoder(w).Encode(&structs.GetSpecResponse{ Data: m, }) require.NoError(t, err) @@ -339,10 +337,10 @@ func TestVerifyWithdrawal_Multiple(t *testing.T) { if r.Method == http.MethodGet { b, err := os.ReadFile(filepath.Clean(file)) require.NoError(t, err) - var to []*shared.SignedBLSToExecutionChange + var to []*structs.SignedBLSToExecutionChange err = json.Unmarshal(b, &to) require.NoError(t, err) - err = json.NewEncoder(w).Encode(&beacon.BLSToExecutionChangesPoolResponse{ + err = json.NewEncoder(w).Encode(&structs.BLSToExecutionChangesPoolResponse{ Data: to, }) require.NoError(t, err) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index e220ae14b2..2fe7dd634e 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -23,13 +23,11 @@ go_library( visibility = ["//testing/endtoend:__subpackages__"], deps = [ "//api/client/beacon:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/signing:go_default_library", "//beacon-chain/p2p:go_default_library", - "//beacon-chain/rpc/eth/beacon:go_default_library", - "//beacon-chain/rpc/eth/debug:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//beacon-chain/state:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", diff --git a/testing/endtoend/evaluators/beaconapi/BUILD.bazel b/testing/endtoend/evaluators/beaconapi/BUILD.bazel index 896be24afd..e3cfa1012e 100644 --- a/testing/endtoend/evaluators/beaconapi/BUILD.bazel +++ b/testing/endtoend/evaluators/beaconapi/BUILD.bazel @@ -13,11 +13,7 @@ go_library( visibility = ["//testing/endtoend:__subpackages__"], 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/debug:go_default_library", - "//beacon-chain/rpc/eth/node:go_default_library", - "//beacon-chain/rpc/eth/validator:go_default_library", + "//api/server/structs:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", "//proto/prysm/v1alpha1:go_default_library", diff --git a/testing/endtoend/evaluators/beaconapi/requests.go b/testing/endtoend/evaluators/beaconapi/requests.go index 9fbfeedb07..fc66b0ca52 100644 --- a/testing/endtoend/evaluators/beaconapi/requests.go +++ b/testing/endtoend/evaluators/beaconapi/requests.go @@ -5,57 +5,53 @@ import ( "strings" "github.com/pkg/errors" - "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/debug" - "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/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" ) var requests = map[string]endpoint{ - "/beacon/genesis": newMetadata[beacon.GetGenesisResponse](v1PathTemplate), - "/beacon/states/{param1}/root": newMetadata[beacon.GetStateRootResponse](v1PathTemplate, + "/beacon/genesis": newMetadata[structs.GetGenesisResponse](v1PathTemplate), + "/beacon/states/{param1}/root": newMetadata[structs.GetStateRootResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/fork": newMetadata[beacon.GetStateForkResponse](v1PathTemplate, + "/beacon/states/{param1}/fork": newMetadata[structs.GetStateForkResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/finality_checkpoints": newMetadata[beacon.GetFinalityCheckpointsResponse](v1PathTemplate, + "/beacon/states/{param1}/finality_checkpoints": newMetadata[structs.GetFinalityCheckpointsResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), // we want to test comma-separated query params - "/beacon/states/{param1}/validators?id=0,1": newMetadata[beacon.GetValidatorsResponse](v1PathTemplate, + "/beacon/states/{param1}/validators?id=0,1": newMetadata[structs.GetValidatorsResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/validators/{param2}": newMetadata[beacon.GetValidatorResponse](v1PathTemplate, + "/beacon/states/{param1}/validators/{param2}": newMetadata[structs.GetValidatorResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head", "0"} })), - "/beacon/states/{param1}/validator_balances?id=0,1": newMetadata[beacon.GetValidatorBalancesResponse](v1PathTemplate, + "/beacon/states/{param1}/validator_balances?id=0,1": newMetadata[structs.GetValidatorBalancesResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/committees?index=0": newMetadata[beacon.GetCommitteesResponse](v1PathTemplate, + "/beacon/states/{param1}/committees?index=0": newMetadata[structs.GetCommitteesResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/sync_committees": newMetadata[beacon.GetSyncCommitteeResponse](v1PathTemplate, + "/beacon/states/{param1}/sync_committees": newMetadata[structs.GetSyncCommitteeResponse](v1PathTemplate, withStart(params.BeaconConfig().AltairForkEpoch), withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/states/{param1}/randao": newMetadata[beacon.GetRandaoResponse](v1PathTemplate, + "/beacon/states/{param1}/randao": newMetadata[structs.GetRandaoResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/headers": newMetadata[beacon.GetBlockHeadersResponse](v1PathTemplate), - "/beacon/headers/{param1}": newMetadata[beacon.GetBlockHeaderResponse](v1PathTemplate, + "/beacon/headers": newMetadata[structs.GetBlockHeadersResponse](v1PathTemplate), + "/beacon/headers/{param1}": newMetadata[structs.GetBlockHeaderResponse](v1PathTemplate, withParams(func(e primitives.Epoch) []string { slot := uint64(0) if e > 0 { @@ -63,88 +59,88 @@ var requests = map[string]endpoint{ } return []string{fmt.Sprintf("%v", slot)} })), - "/beacon/blocks/{param1}": newMetadata[beacon.GetBlockV2Response](v2PathTemplate, + "/beacon/blocks/{param1}": newMetadata[structs.GetBlockV2Response](v2PathTemplate, withSsz(), withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/blocks/{param1}/root": newMetadata[beacon.BlockRootResponse](v1PathTemplate, + "/beacon/blocks/{param1}/root": newMetadata[structs.BlockRootResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/blocks/{param1}/attestations": newMetadata[beacon.GetBlockAttestationsResponse](v1PathTemplate, + "/beacon/blocks/{param1}/attestations": newMetadata[structs.GetBlockAttestationsResponse](v1PathTemplate, withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/blinded_blocks/{param1}": newMetadata[beacon.GetBlockV2Response](v1PathTemplate, + "/beacon/blinded_blocks/{param1}": newMetadata[structs.GetBlockV2Response](v1PathTemplate, withSsz(), withParams(func(_ primitives.Epoch) []string { return []string{"head"} })), - "/beacon/pool/attestations": newMetadata[beacon.ListAttestationsResponse](v1PathTemplate, + "/beacon/pool/attestations": newMetadata[structs.ListAttestationsResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*beacon.ListAttestationsResponse) + pResp, ok := p.(*structs.ListAttestationsResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.ListAttestationsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.ListAttestationsResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/beacon/pool/attester_slashings": newMetadata[beacon.GetAttesterSlashingsResponse](v1PathTemplate, + "/beacon/pool/attester_slashings": newMetadata[structs.GetAttesterSlashingsResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*beacon.GetAttesterSlashingsResponse) + pResp, ok := p.(*structs.GetAttesterSlashingsResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.GetAttesterSlashingsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetAttesterSlashingsResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/beacon/pool/proposer_slashings": newMetadata[beacon.GetProposerSlashingsResponse](v1PathTemplate, + "/beacon/pool/proposer_slashings": newMetadata[structs.GetProposerSlashingsResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*beacon.GetProposerSlashingsResponse) + pResp, ok := p.(*structs.GetProposerSlashingsResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.GetProposerSlashingsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetProposerSlashingsResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/beacon/pool/voluntary_exits": newMetadata[beacon.ListVoluntaryExitsResponse](v1PathTemplate, + "/beacon/pool/voluntary_exits": newMetadata[structs.ListVoluntaryExitsResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*beacon.ListVoluntaryExitsResponse) + pResp, ok := p.(*structs.ListVoluntaryExitsResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.ListVoluntaryExitsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.ListVoluntaryExitsResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/beacon/pool/bls_to_execution_changes": newMetadata[beacon.BLSToExecutionChangesPoolResponse](v1PathTemplate, + "/beacon/pool/bls_to_execution_changes": newMetadata[structs.BLSToExecutionChangesPoolResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*beacon.BLSToExecutionChangesPoolResponse) + pResp, ok := p.(*structs.BLSToExecutionChangesPoolResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.BLSToExecutionChangesPoolResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.BLSToExecutionChangesPoolResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/config/fork_schedule": newMetadata[config.GetForkScheduleResponse](v1PathTemplate, + "/config/fork_schedule": newMetadata[structs.GetForkScheduleResponse](v1PathTemplate, withCustomEval(func(p interface{}, lh interface{}) error { - pResp, ok := p.(*config.GetForkScheduleResponse) + pResp, ok := p.(*structs.GetForkScheduleResponse) if !ok { - return fmt.Errorf(msgWrongJson, &config.GetForkScheduleResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetForkScheduleResponse{}, p) } - lhResp, ok := lh.(*config.GetForkScheduleResponse) + lhResp, ok := lh.(*structs.GetForkScheduleResponse) if !ok { - return fmt.Errorf(msgWrongJson, &config.GetForkScheduleResponse{}, lh) + return fmt.Errorf(msgWrongJson, &structs.GetForkScheduleResponse{}, lh) } if pResp.Data == nil { return errEmptyPrysmData @@ -165,50 +161,50 @@ var requests = map[string]endpoint{ } return compareJSON(pResp, lhResp) })), - "/config/deposit_contract": newMetadata[config.GetDepositContractResponse](v1PathTemplate), - "/debug/beacon/heads": newMetadata[debug.GetForkChoiceHeadsV2Response](v2PathTemplate), - "/node/identity": newMetadata[node.GetIdentityResponse](v1PathTemplate, + "/config/deposit_contract": newMetadata[structs.GetDepositContractResponse](v1PathTemplate), + "/debug/beacon/heads": newMetadata[structs.GetForkChoiceHeadsV2Response](v2PathTemplate), + "/node/identity": newMetadata[structs.GetIdentityResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*node.GetIdentityResponse) + pResp, ok := p.(*structs.GetIdentityResponse) if !ok { - return fmt.Errorf(msgWrongJson, &node.GetIdentityResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetIdentityResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/node/peers": newMetadata[node.GetPeersResponse](v1PathTemplate, + "/node/peers": newMetadata[structs.GetPeersResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*node.GetPeersResponse) + pResp, ok := p.(*structs.GetPeersResponse) if !ok { - return fmt.Errorf(msgWrongJson, &node.GetPeersResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetPeersResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/node/peer_count": newMetadata[node.GetPeerCountResponse](v1PathTemplate, + "/node/peer_count": newMetadata[structs.GetPeerCountResponse](v1PathTemplate, withCustomEval(func(p interface{}, _ interface{}) error { - pResp, ok := p.(*node.GetPeerCountResponse) + pResp, ok := p.(*structs.GetPeerCountResponse) if !ok { - return fmt.Errorf(msgWrongJson, &node.GetPeerCountResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetPeerCountResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData } return nil })), - "/node/version": newMetadata[node.GetVersionResponse](v1PathTemplate, + "/node/version": newMetadata[structs.GetVersionResponse](v1PathTemplate, withCustomEval(func(p interface{}, lh interface{}) error { - pResp, ok := p.(*node.GetVersionResponse) + pResp, ok := p.(*structs.GetVersionResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.ListAttestationsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.ListAttestationsResponse{}, p) } - lhResp, ok := lh.(*node.GetVersionResponse) + lhResp, ok := lh.(*structs.GetVersionResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.ListAttestationsResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.ListAttestationsResponse{}, p) } if pResp.Data == nil { return errEmptyPrysmData @@ -224,19 +220,19 @@ var requests = map[string]endpoint{ } return nil })), - "/node/syncing": newMetadata[node.SyncStatusResponse](v1PathTemplate), - "/validator/duties/proposer/{param1}": newMetadata[validator.GetProposerDutiesResponse](v1PathTemplate, + "/node/syncing": newMetadata[structs.SyncStatusResponse](v1PathTemplate), + "/validator/duties/proposer/{param1}": newMetadata[structs.GetProposerDutiesResponse](v1PathTemplate, withParams(func(e primitives.Epoch) []string { return []string{fmt.Sprintf("%v", e)} }), withCustomEval(func(p interface{}, lh interface{}) error { - pResp, ok := p.(*validator.GetProposerDutiesResponse) + pResp, ok := p.(*structs.GetProposerDutiesResponse) if !ok { - return fmt.Errorf(msgWrongJson, &validator.GetProposerDutiesResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetProposerDutiesResponse{}, p) } - lhResp, ok := lh.(*validator.GetProposerDutiesResponse) + lhResp, ok := lh.(*structs.GetProposerDutiesResponse) if !ok { - return fmt.Errorf(msgWrongJson, &validator.GetProposerDutiesResponse{}, lh) + return fmt.Errorf(msgWrongJson, &structs.GetProposerDutiesResponse{}, lh) } if pResp.Data == nil { return errEmptyPrysmData @@ -251,7 +247,7 @@ var requests = map[string]endpoint{ } return compareJSON(pResp, lhResp) })), - "/validator/duties/attester/{param1}": newMetadata[validator.GetAttesterDutiesResponse](v1PathTemplate, + "/validator/duties/attester/{param1}": newMetadata[structs.GetAttesterDutiesResponse](v1PathTemplate, withParams(func(e primitives.Epoch) []string { //ask for a future epoch to test this case return []string{fmt.Sprintf("%v", e+1)} @@ -264,13 +260,13 @@ var requests = map[string]endpoint{ return validatorIndices }()), withCustomEval(func(p interface{}, lh interface{}) error { - pResp, ok := p.(*validator.GetAttesterDutiesResponse) + pResp, ok := p.(*structs.GetAttesterDutiesResponse) if !ok { - return fmt.Errorf(msgWrongJson, &validator.GetAttesterDutiesResponse{}, p) + return fmt.Errorf(msgWrongJson, &structs.GetAttesterDutiesResponse{}, p) } - lhResp, ok := lh.(*validator.GetAttesterDutiesResponse) + lhResp, ok := lh.(*structs.GetAttesterDutiesResponse) if !ok { - return fmt.Errorf(msgWrongJson, &validator.GetAttesterDutiesResponse{}, lh) + return fmt.Errorf(msgWrongJson, &structs.GetAttesterDutiesResponse{}, lh) } if pResp.Data == nil { return errEmptyPrysmData diff --git a/testing/endtoend/evaluators/beaconapi/verify.go b/testing/endtoend/evaluators/beaconapi/verify.go index d91db8f33d..b72a58da8e 100644 --- a/testing/endtoend/evaluators/beaconapi/verify.go +++ b/testing/endtoend/evaluators/beaconapi/verify.go @@ -10,8 +10,7 @@ import ( "time" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon" - "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" @@ -45,7 +44,7 @@ func verify(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) error { } func run(nodeIdx int) error { - genesisResp := &beacon.GetGenesisResponse{} + genesisResp := &structs.GetGenesisResponse{} if err := doJSONGetRequest(v1PathTemplate, "/beacon/genesis", nodeIdx, genesisResp); err != nil { return errors.Wrap(err, "error getting genesis data") } @@ -135,14 +134,14 @@ func postEvaluation(requests map[string]endpoint, epoch primitives.Epoch) error // verify that dependent root of proposer duties matches block header blockHeaderData := requests["/beacon/headers/{param1}"] - header, ok := blockHeaderData.getPResp().(*beacon.GetBlockHeaderResponse) + header, ok := blockHeaderData.getPResp().(*structs.GetBlockHeaderResponse) if !ok { - return fmt.Errorf(msgWrongJson, &beacon.GetBlockHeaderResponse{}, blockHeaderData.getPResp()) + return fmt.Errorf(msgWrongJson, &structs.GetBlockHeaderResponse{}, blockHeaderData.getPResp()) } dutiesData := requests["/validator/duties/proposer/{param1}"] - duties, ok := dutiesData.getPResp().(*validator.GetProposerDutiesResponse) + duties, ok := dutiesData.getPResp().(*structs.GetProposerDutiesResponse) if !ok { - return fmt.Errorf(msgWrongJson, &validator.GetProposerDutiesResponse{}, dutiesData.getPResp()) + return fmt.Errorf(msgWrongJson, &structs.GetProposerDutiesResponse{}, dutiesData.getPResp()) } if header.Data.Root != duties.DependentRoot { return fmt.Errorf("header root %s does not match duties root %s ", header.Data.Root, duties.DependentRoot) diff --git a/testing/endtoend/evaluators/execution_engine.go b/testing/endtoend/evaluators/execution_engine.go index 13a57aef3b..d33ad1b09d 100644 --- a/testing/endtoend/evaluators/execution_engine.go +++ b/testing/endtoend/evaluators/execution_engine.go @@ -7,8 +7,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/shared" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/network/httputil" "github.com/prysmaticlabs/prysm/v4/runtime/version" @@ -29,7 +28,7 @@ var OptimisticSyncEnabled = types.Evaluator{ func optimisticSyncEnabled(_ *types.EvaluationContext, conns ...*grpc.ClientConn) error { for nodeIndex := range conns { path := fmt.Sprintf("http://localhost:%d/eth/v1/beacon/blinded_blocks/head", params.TestParams.Ports.PrysmBeaconNodeGatewayPort+nodeIndex) - resp := beacon.GetBlockV2Response{} + resp := structs.GetBlockV2Response{} httpResp, err := http.Get(path) // #nosec G107 -- path can't be constant because it depends on port param and node index if err != nil { return err @@ -55,7 +54,7 @@ func optimisticSyncEnabled(_ *types.EvaluationContext, conns ...*grpc.ClientConn } for i := startSlot; i <= primitives.Slot(headSlot); i++ { path = fmt.Sprintf("http://localhost:%d/eth/v1/beacon/blinded_blocks/%d", params.TestParams.Ports.PrysmBeaconNodeGatewayPort+nodeIndex, i) - resp = beacon.GetBlockV2Response{} + resp = structs.GetBlockV2Response{} httpResp, err = http.Get(path) // #nosec G107 -- path can't be constant because it depends on port param and node index if err != nil { return err @@ -82,12 +81,12 @@ func optimisticSyncEnabled(_ *types.EvaluationContext, conns ...*grpc.ClientConn return nil } -func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) { +func retrieveHeadSlot(resp *structs.GetBlockV2Response) (uint64, error) { var headSlot uint64 var err error switch resp.Version { case version.String(version.Phase0): - b := &shared.BeaconBlock{} + b := &structs.BeaconBlock{} if err := json.Unmarshal(resp.Data.Message, b); err != nil { return 0, err } @@ -96,7 +95,7 @@ func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) { return 0, err } case version.String(version.Altair): - b := &shared.BeaconBlockAltair{} + b := &structs.BeaconBlockAltair{} if err := json.Unmarshal(resp.Data.Message, b); err != nil { return 0, err } @@ -105,7 +104,7 @@ func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) { return 0, err } case version.String(version.Bellatrix): - b := &shared.BeaconBlockBellatrix{} + b := &structs.BeaconBlockBellatrix{} if err := json.Unmarshal(resp.Data.Message, b); err != nil { return 0, err } @@ -114,7 +113,7 @@ func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) { return 0, err } case version.String(version.Capella): - b := &shared.BeaconBlockCapella{} + b := &structs.BeaconBlockCapella{} if err := json.Unmarshal(resp.Data.Message, b); err != nil { return 0, err } @@ -123,7 +122,7 @@ func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) { return 0, err } case version.String(version.Deneb): - b := &shared.BeaconBlockDeneb{} + b := &structs.BeaconBlockDeneb{} if err := json.Unmarshal(resp.Data.Message, b); err != nil { return 0, err } diff --git a/testing/endtoend/evaluators/operations.go b/testing/endtoend/evaluators/operations.go index 3b6e55edb9..c7b16a078d 100644 --- a/testing/endtoend/evaluators/operations.go +++ b/testing/endtoend/evaluators/operations.go @@ -10,9 +10,9 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api/client/beacon" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" corehelpers "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" @@ -586,7 +586,7 @@ func submitWithdrawal(ec *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) if err != nil { return err } - changes := make([]*shared.SignedBLSToExecutionChange, 0) + changes := make([]*structs.SignedBLSToExecutionChange, 0) // Only send half the number of changes each time, to allow us to test // at the fork boundary. wantedChanges := numOfExits / 2 @@ -620,8 +620,8 @@ func submitWithdrawal(ec *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) } signature := privKeys[idx].Sign(sigRoot[:]).Marshal() - changes = append(changes, &shared.SignedBLSToExecutionChange{ - Message: shared.BLSChangeFromConsensus(message), + changes = append(changes, &structs.SignedBLSToExecutionChange{ + Message: structs.BLSChangeFromConsensus(message), Signature: hexutil.Encode(signature), }) } diff --git a/testing/endtoend/evaluators/validator.go b/testing/endtoend/evaluators/validator.go index 167aa3e3ff..27e1e55a1c 100644 --- a/testing/endtoend/evaluators/validator.go +++ b/testing/endtoend/evaluators/validator.go @@ -8,9 +8,8 @@ import ( "strconv" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/debug" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces" @@ -135,7 +134,7 @@ func validatorsParticipating(_ *types.EvaluationContext, conns ...*grpc.ClientCo } if partRate < expected { path := fmt.Sprintf("http://localhost:%d/eth/v2/debug/beacon/states/head", e2eparams.TestParams.Ports.PrysmBeaconNodeGatewayPort) - resp := debug.GetBeaconStateV2Response{} + resp := structs.GetBeaconStateV2Response{} httpResp, err := http.Get(path) // #nosec G107 -- path can't be constant because it depends on port param if err != nil { return err @@ -156,19 +155,19 @@ func validatorsParticipating(_ *types.EvaluationContext, conns ...*grpc.ClientCo case version.String(version.Phase0): // Do Nothing case version.String(version.Altair): - st := &shared.BeaconStateAltair{} + st := &structs.BeaconStateAltair{} if err = json.Unmarshal(resp.Data, st); err != nil { return err } respPrevEpochParticipation = st.PreviousEpochParticipation case version.String(version.Bellatrix): - st := &shared.BeaconStateBellatrix{} + st := &structs.BeaconStateBellatrix{} if err = json.Unmarshal(resp.Data, st); err != nil { return err } respPrevEpochParticipation = st.PreviousEpochParticipation case version.String(version.Capella): - st := &shared.BeaconStateCapella{} + st := &structs.BeaconStateCapella{} if err = json.Unmarshal(resp.Data, st); err != nil { return err } diff --git a/testing/middleware/builder/BUILD.bazel b/testing/middleware/builder/BUILD.bazel index 9d973321e6..33fa6fdedb 100644 --- a/testing/middleware/builder/BUILD.bazel +++ b/testing/middleware/builder/BUILD.bazel @@ -10,8 +10,8 @@ go_library( visibility = ["//visibility:public"], deps = [ "//api/client/builder:go_default_library", + "//api/server/structs:go_default_library", "//beacon-chain/core/signing:go_default_library", - "//beacon-chain/rpc/eth/shared:go_default_library", "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", diff --git a/testing/middleware/builder/builder.go b/testing/middleware/builder/builder.go index adfecf3e49..8d9a499355 100644 --- a/testing/middleware/builder/builder.go +++ b/testing/middleware/builder/builder.go @@ -24,8 +24,8 @@ import ( "github.com/ethereum/go-ethereum/trie" gMux "github.com/gorilla/mux" builderAPI "github.com/prysmaticlabs/prysm/v4/api/client/builder" + "github.com/prysmaticlabs/prysm/v4/api/server/structs" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces" @@ -285,7 +285,7 @@ func (p *Builder) isBuilderCall(req *http.Request) bool { } func (p *Builder) registerValidators(w http.ResponseWriter, req *http.Request) { - var registrations []shared.SignedValidatorRegistration + var registrations []structs.SignedValidatorRegistration if err := json.NewDecoder(req.Body).Decode(®istrations); err != nil { http.Error(w, "invalid request", http.StatusBadRequest) return diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index 212b0a72f4..4a7bcfec7c 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -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", diff --git a/validator/accounts/accounts_exit_test.go b/validator/accounts/accounts_exit_test.go index c6d91fbeca..5c0efd3f30 100644 --- a/validator/accounts/accounts_exit_test.go +++ b/validator/accounts/accounts_exit_test.go @@ -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) diff --git a/validator/client/beacon-api/BUILD.bazel b/validator/client/beacon-api/BUILD.bazel index fad6d0ea3b..34e4234d47 100644 --- a/validator/client/beacon-api/BUILD.bazel +++ b/validator/client/beacon-api/BUILD.bazel @@ -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", diff --git a/validator/client/beacon-api/activation_test.go b/validator/client/beacon-api/activation_test.go index dd1b8fb637..8aea9ded87 100644 --- a/validator/client/beacon-api/activation_test.go +++ b/validator/client/beacon-api/activation_test.go @@ -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) diff --git a/validator/client/beacon-api/attestation_data.go b/validator/client/beacon-api/attestation_data.go index 3af3b0f3fe..65780e63cb 100644 --- a/validator/client/beacon-api/attestation_data.go +++ b/validator/client/beacon-api/attestation_data.go @@ -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 diff --git a/validator/client/beacon-api/attestation_data_test.go b/validator/client/beacon-api/attestation_data_test.go index 0249595659..b164746833 100644 --- a/validator/client/beacon-api/attestation_data_test.go +++ b/validator/client/beacon-api/attestation_data_test.go @@ -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", }, diff --git a/validator/client/beacon-api/beacon_api_beacon_chain_client.go b/validator/client/beacon-api/beacon_api_beacon_chain_client.go index 1ae5987857..11097fd1c1 100644 --- a/validator/client/beacon-api/beacon_api_beacon_chain_client.go +++ b/validator/client/beacon-api/beacon_api_beacon_chain_client.go @@ -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 } diff --git a/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go b/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go index b3d0dbbd67..7ba6c58901 100644 --- a/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go +++ b/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go @@ -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 := ðpb.ValidatorPerformanceResponse{} jsonRestHandler := mock.NewMockJsonRestHandler(ctrl) jsonRestHandler.EXPECT().Post( diff --git a/validator/client/beacon-api/beacon_api_helpers.go b/validator/client/beacon-api/beacon_api_helpers.go index aa78a18eb7..91669340a6 100644 --- a/validator/client/beacon-api/beacon_api_helpers.go +++ b/validator/client/beacon-api/beacon_api_helpers.go @@ -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 diff --git a/validator/client/beacon-api/beacon_api_helpers_test.go b/validator/client/beacon-api/beacon_api_helpers_test.go index dd0ec636b5..51d0c08bf9 100644 --- a/validator/client/beacon-api/beacon_api_helpers_test.go +++ b/validator/client/beacon-api/beacon_api_helpers_test.go @@ -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() diff --git a/validator/client/beacon-api/beacon_api_node_client.go b/validator/client/beacon-api/beacon_api_node_client.go index 230848791f..410b32e6e6 100644 --- a/validator/client/beacon-api/beacon_api_node_client.go +++ b/validator/client/beacon-api/beacon_api_node_client.go @@ -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 } diff --git a/validator/client/beacon-api/beacon_api_node_client_test.go b/validator/client/beacon-api/beacon_api_node_client_test.go index b5c69fe21b..d5894ec54e 100644 --- a/validator/client/beacon-api/beacon_api_node_client_test.go +++ b/validator/client/beacon-api/beacon_api_node_client_test.go @@ -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, diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index a57647fa58..e2957bbe12 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -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) diff --git a/validator/client/beacon-api/beacon_block_converter.go b/validator/client/beacon-api/beacon_block_converter.go index 4f51af0fda..57b1750339 100644 --- a/validator/client/beacon-api/beacon_block_converter.go +++ b/validator/client/beacon-api/beacon_block_converter.go @@ -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, diff --git a/validator/client/beacon-api/beacon_block_converter_test.go b/validator/client/beacon-api/beacon_block_converter_test.go index 66b0f9d3e6..d41fda823f 100644 --- a/validator/client/beacon-api/beacon_block_converter_test.go +++ b/validator/client/beacon-api/beacon_block_converter_test.go @@ -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 diff --git a/validator/client/beacon-api/beacon_block_json_helpers.go b/validator/client/beacon-api/beacon_block_json_helpers.go index ce314ecd4e..c484be32a3 100644 --- a/validator/client/beacon-api/beacon_block_json_helpers.go +++ b/validator/client/beacon-api/beacon_block_json_helpers.go @@ -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), diff --git a/validator/client/beacon-api/beacon_block_json_helpers_test.go b/validator/client/beacon-api/beacon_block_json_helpers_test.go index 3ea53dbb22..0e62b1ec18 100644 --- a/validator/client/beacon-api/beacon_block_json_helpers_test.go +++ b/validator/client/beacon-api/beacon_block_json_helpers_test.go @@ -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", diff --git a/validator/client/beacon-api/beacon_block_proto_helpers.go b/validator/client/beacon-api/beacon_block_proto_helpers.go index e5e6cfb210..512120835b 100644 --- a/validator/client/beacon-api/beacon_block_proto_helpers.go +++ b/validator/client/beacon-api/beacon_block_proto_helpers.go @@ -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 { diff --git a/validator/client/beacon-api/beacon_block_proto_helpers_test.go b/validator/client/beacon-api/beacon_block_proto_helpers_test.go index 1af5b2ce02..d66eb905a4 100644 --- a/validator/client/beacon-api/beacon_block_proto_helpers_test.go +++ b/validator/client/beacon-api/beacon_block_proto_helpers_test.go @@ -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}), diff --git a/validator/client/beacon-api/domain_data_test.go b/validator/client/beacon-api/domain_data_test.go index dc4332cda4..4095c83701 100644 --- a/validator/client/beacon-api/domain_data_test.go +++ b/validator/client/beacon-api/domain_data_test.go @@ -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) diff --git a/validator/client/beacon-api/doppelganger_test.go b/validator/client/beacon-api/doppelganger_test.go index 08d2dc64a1..8de1832253 100644 --- a/validator/client/beacon-api/doppelganger_test.go +++ b/validator/client/beacon-api/doppelganger_test.go @@ -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) diff --git a/validator/client/beacon-api/duties.go b/validator/client/beacon-api/duties.go index c4078bd461..43de74ad89 100644 --- a/validator/client/beacon-api/duties.go +++ b/validator/client/beacon-api/duties.go @@ -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), diff --git a/validator/client/beacon-api/duties_test.go b/validator/client/beacon-api/duties_test.go index 3aae06cdde..6a825b1116 100644 --- a/validator/client/beacon-api/duties_test.go +++ b/validator/client/beacon-api/duties_test.go @@ -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), diff --git a/validator/client/beacon-api/genesis.go b/validator/client/beacon-api/genesis.go index dcc819a127..b331cb9ff6 100644 --- a/validator/client/beacon-api/genesis.go +++ b/validator/client/beacon-api/genesis.go @@ -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 } diff --git a/validator/client/beacon-api/genesis_test.go b/validator/client/beacon-api/genesis_test.go index da7122d2f0..a778a316d4 100644 --- a/validator/client/beacon-api/genesis_test.go +++ b/validator/client/beacon-api/genesis_test.go @@ -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} diff --git a/validator/client/beacon-api/get_beacon_block.go b/validator/client/beacon-api/get_beacon_block.go index 5726894fbd..d10600dc7a 100644 --- a/validator/client/beacon-api/get_beacon_block.go +++ b/validator/client/beacon-api/get_beacon_block.go @@ -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") } diff --git a/validator/client/beacon-api/get_beacon_block_test.go b/validator/client/beacon-api/get_beacon_block_test.go index 79e2a1e1e3..d9c2064f56 100644 --- a/validator/client/beacon-api/get_beacon_block_test.go +++ b/validator/client/beacon-api/get_beacon_block_test.go @@ -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) diff --git a/validator/client/beacon-api/index_test.go b/validator/client/beacon-api/index_test.go index 8ec1f09230..23c0459906 100644 --- a/validator/client/beacon-api/index_test.go +++ b/validator/client/beacon-api/index_test.go @@ -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( diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index a94d481890..3dfaa0c09f 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -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) } diff --git a/validator/client/beacon-api/mock/BUILD.bazel b/validator/client/beacon-api/mock/BUILD.bazel index 696ad18a1f..41e5ec048f 100644 --- a/validator/client/beacon-api/mock/BUILD.bazel +++ b/validator/client/beacon-api/mock/BUILD.bazel @@ -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", diff --git a/validator/client/beacon-api/mock/beacon_block_converter_mock.go b/validator/client/beacon-api/mock/beacon_block_converter_mock.go index 07ee9d9254..b75196b274 100644 --- a/validator/client/beacon-api/mock/beacon_block_converter_mock.go +++ b/validator/client/beacon-api/mock/beacon_block_converter_mock.go @@ -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) diff --git a/validator/client/beacon-api/mock/duties_mock.go b/validator/client/beacon-api/mock/duties_mock.go index 3d8fc86dc8..303d632a16 100644 --- a/validator/client/beacon-api/mock/duties_mock.go +++ b/validator/client/beacon-api/mock/duties_mock.go @@ -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 } diff --git a/validator/client/beacon-api/mock/genesis_mock.go b/validator/client/beacon-api/mock/genesis_mock.go index caa7aa74d3..a0e0aad1d2 100644 --- a/validator/client/beacon-api/mock/genesis_mock.go +++ b/validator/client/beacon-api/mock/genesis_mock.go @@ -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 } diff --git a/validator/client/beacon-api/mock/state_validators_mock.go b/validator/client/beacon-api/mock/state_validators_mock.go index 92d2ea6506..39fd360c9d 100644 --- a/validator/client/beacon-api/mock/state_validators_mock.go +++ b/validator/client/beacon-api/mock/state_validators_mock.go @@ -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 } diff --git a/validator/client/beacon-api/prepare_beacon_proposer.go b/validator/client/beacon-api/prepare_beacon_proposer.go index f068b41116..bfbe360b27 100644 --- a/validator/client/beacon-api/prepare_beacon_proposer.go +++ b/validator/client/beacon-api/prepare_beacon_proposer.go @@ -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), } diff --git a/validator/client/beacon-api/prepare_beacon_proposer_test.go b/validator/client/beacon-api/prepare_beacon_proposer_test.go index 9a5da617a6..5668f067fe 100644 --- a/validator/client/beacon-api/prepare_beacon_proposer_test.go +++ b/validator/client/beacon-api/prepare_beacon_proposer_test.go @@ -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, diff --git a/validator/client/beacon-api/propose_beacon_block.go b/validator/client/beacon-api/propose_beacon_block.go index fd48d72ca9..6a3bf1e1c2 100644 --- a/validator/client/beacon-api/propose_beacon_block.go +++ b/validator/client/beacon-api/propose_beacon_block.go @@ -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), diff --git a/validator/client/beacon-api/propose_beacon_block_altair_test.go b/validator/client/beacon-api/propose_beacon_block_altair_test.go index a939da7178..cfe99be58a 100644 --- a/validator/client/beacon-api/propose_beacon_block_altair_test.go +++ b/validator/client/beacon-api/propose_beacon_block_altair_test.go @@ -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 := ðpb.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), }, diff --git a/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go b/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go index 8163d22c7d..efc4ecdae9 100644 --- a/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go +++ b/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go @@ -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 := ðpb.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), diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go index 1c0b9d4a44..4f50dcce4b 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go @@ -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 := ðpb.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), diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go index 086d1e3d56..9172bce75b 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go @@ -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 := ðpb.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), diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go index 692cda8638..04573eecd0 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go @@ -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() diff --git a/validator/client/beacon-api/propose_beacon_block_capella_test.go b/validator/client/beacon-api/propose_beacon_block_capella_test.go index 48bee2a87d..d183a7fc37 100644 --- a/validator/client/beacon-api/propose_beacon_block_capella_test.go +++ b/validator/client/beacon-api/propose_beacon_block_capella_test.go @@ -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 := ðpb.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), diff --git a/validator/client/beacon-api/propose_beacon_block_deneb_test.go b/validator/client/beacon-api/propose_beacon_block_deneb_test.go index 57eeffff48..58704a542d 100644 --- a/validator/client/beacon-api/propose_beacon_block_deneb_test.go +++ b/validator/client/beacon-api/propose_beacon_block_deneb_test.go @@ -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() diff --git a/validator/client/beacon-api/propose_beacon_block_phase0_test.go b/validator/client/beacon-api/propose_beacon_block_phase0_test.go index b5f492bff4..53b72caf91 100644 --- a/validator/client/beacon-api/propose_beacon_block_phase0_test.go +++ b/validator/client/beacon-api/propose_beacon_block_phase0_test.go @@ -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 := ðpb.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), diff --git a/validator/client/beacon-api/propose_exit.go b/validator/client/beacon-api/propose_exit.go index e1c247ae14..c6901144ad 100644 --- a/validator/client/beacon-api/propose_exit.go +++ b/validator/client/beacon-api/propose_exit.go @@ -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), }, diff --git a/validator/client/beacon-api/propose_exit_test.go b/validator/client/beacon-api/propose_exit_test.go index 96626b9934..96b54bb9ab 100644 --- a/validator/client/beacon-api/propose_exit_test.go +++ b/validator/client/beacon-api/propose_exit_test.go @@ -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", }, diff --git a/validator/client/beacon-api/prysm_beacon_chain_client.go b/validator/client/beacon-api/prysm_beacon_chain_client.go index c822767467..cb5f0c397c 100644 --- a/validator/client/beacon-api/prysm_beacon_chain_client.go +++ b/validator/client/beacon-api/prysm_beacon_chain_client.go @@ -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 } diff --git a/validator/client/beacon-api/registration.go b/validator/client/beacon-api/registration.go index bb1d3717fd..e4b83d6c3c 100644 --- a/validator/client/beacon-api/registration.go +++ b/validator/client/beacon-api/registration.go @@ -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) diff --git a/validator/client/beacon-api/registration_test.go b/validator/client/beacon-api/registration_test.go index 28cbb7ac3f..e1d703e971 100644 --- a/validator/client/beacon-api/registration_test.go +++ b/validator/client/beacon-api/registration_test.go @@ -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", diff --git a/validator/client/beacon-api/state_validators.go b/validator/client/beacon-api/state_validators.go index 165ca0e40c..9a19ad267b 100644 --- a/validator/client/beacon-api/state_validators.go +++ b/validator/client/beacon-api/state_validators.go @@ -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 } diff --git a/validator/client/beacon-api/state_validators_test.go b/validator/client/beacon-api/state_validators_test.go index 066ecd03a4..faacd41965 100644 --- a/validator/client/beacon-api/state_validators_test.go +++ b/validator/client/beacon-api/state_validators_test.go @@ -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) diff --git a/validator/client/beacon-api/status_test.go b/validator/client/beacon-api/status_test.go index 3ed593bc88..53e833aae2 100644 --- a/validator/client/beacon-api/status_test.go +++ b/validator/client/beacon-api/status_test.go @@ -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", diff --git a/validator/client/beacon-api/stream_blocks.go b/validator/client/beacon-api/stream_blocks.go index 2d6d453aec..79c511095b 100644 --- a/validator/client/beacon-api/stream_blocks.go +++ b/validator/client/beacon-api/stream_blocks.go @@ -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") } diff --git a/validator/client/beacon-api/stream_blocks_test.go b/validator/client/beacon-api/stream_blocks_test.go index a8e6dec6ab..0971f6c0b7 100644 --- a/validator/client/beacon-api/stream_blocks_test.go +++ b/validator/client/beacon-api/stream_blocks_test.go @@ -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" diff --git a/validator/client/beacon-api/submit_aggregate_selection_proof.go b/validator/client/beacon-api/submit_aggregate_selection_proof.go index 41ce86d4bf..56c780397a 100644 --- a/validator/client/beacon-api/submit_aggregate_selection_proof.go +++ b/validator/client/beacon-api/submit_aggregate_selection_proof.go @@ -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 } diff --git a/validator/client/beacon-api/submit_aggregate_selection_proof_test.go b/validator/client/beacon-api/submit_aggregate_selection_proof_test.go index 010709fe32..c4d712e320 100644 --- a/validator/client/beacon-api/submit_aggregate_selection_proof_test.go +++ b/validator/client/beacon-api/submit_aggregate_selection_proof_test.go @@ -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( diff --git a/validator/client/beacon-api/submit_signed_aggregate_proof.go b/validator/client/beacon-api/submit_signed_aggregate_proof.go index 85a8d61774..5b9a83605b 100644 --- a/validator/client/beacon-api/submit_signed_aggregate_proof.go +++ b/validator/client/beacon-api/submit_signed_aggregate_proof.go @@ -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") } diff --git a/validator/client/beacon-api/submit_signed_aggregate_proof_test.go b/validator/client/beacon-api/submit_signed_aggregate_proof_test.go index 3049c1a79f..9efc7793ab 100644 --- a/validator/client/beacon-api/submit_signed_aggregate_proof_test.go +++ b/validator/client/beacon-api/submit_signed_aggregate_proof_test.go @@ -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() diff --git a/validator/client/beacon-api/submit_signed_contribution_and_proof.go b/validator/client/beacon-api/submit_signed_contribution_and_proof.go index 061a09a423..5427bd3811 100644 --- a/validator/client/beacon-api/submit_signed_contribution_and_proof.go +++ b/validator/client/beacon-api/submit_signed_contribution_and_proof.go @@ -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), diff --git a/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go b/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go index b47191d8aa..a2c02d3e79 100644 --- a/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go +++ b/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go @@ -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", diff --git a/validator/client/beacon-api/subscribe_committee_subnets.go b/validator/client/beacon-api/subscribe_committee_subnets.go index 0f8391cef5..d676297f19 100644 --- a/validator/client/beacon-api/subscribe_committee_subnets.go +++ b/validator/client/beacon-api/subscribe_committee_subnets.go @@ -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), diff --git a/validator/client/beacon-api/subscribe_committee_subnets_test.go b/validator/client/beacon-api/subscribe_committee_subnets_test.go index ca50277cb2..0340de7e53 100644 --- a/validator/client/beacon-api/subscribe_committee_subnets_test.go +++ b/validator/client/beacon-api/subscribe_committee_subnets_test.go @@ -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) } diff --git a/validator/client/beacon-api/sync_committee.go b/validator/client/beacon-api/sync_committee.go index fac04a0d52..c7fc609ce3 100644 --- a/validator/client/beacon-api/sync_committee.go +++ b/validator/client/beacon-api/sync_committee.go @@ -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 ðpb.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") } diff --git a/validator/client/beacon-api/sync_committee_test.go b/validator/client/beacon-api/sync_committee_test.go index bb8a9e3304..f602ee9405 100644 --- a/validator/client/beacon-api/sync_committee_test.go +++ b/validator/client/beacon-api/sync_committee_test.go @@ -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( diff --git a/validator/client/beacon-api/test-helpers/BUILD.bazel b/validator/client/beacon-api/test-helpers/BUILD.bazel index 142fbd19c5..e97da0f9fa 100644 --- a/validator/client/beacon-api/test-helpers/BUILD.bazel +++ b/validator/client/beacon-api/test-helpers/BUILD.bazel @@ -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", diff --git a/validator/client/beacon-api/test-helpers/altair_beacon_block_test_helpers.go b/validator/client/beacon-api/test-helpers/altair_beacon_block_test_helpers.go index c19183c32b..07e1a9e0f4 100644 --- a/validator/client/beacon-api/test-helpers/altair_beacon_block_test_helpers.go +++ b/validator/client/beacon-api/test-helpers/altair_beacon_block_test_helpers.go @@ -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), }, diff --git a/validator/client/beacon-api/test-helpers/bellatrix_beacon_block_test_helpers.go b/validator/client/beacon-api/test-helpers/bellatrix_beacon_block_test_helpers.go index bd73e27589..1189b67279 100644 --- a/validator/client/beacon-api/test-helpers/bellatrix_beacon_block_test_helpers.go +++ b/validator/client/beacon-api/test-helpers/bellatrix_beacon_block_test_helpers.go @@ -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), diff --git a/validator/client/beacon-api/test-helpers/capella_beacon_block_test_helpers.go b/validator/client/beacon-api/test-helpers/capella_beacon_block_test_helpers.go index f8d62897b1..003796b926 100644 --- a/validator/client/beacon-api/test-helpers/capella_beacon_block_test_helpers.go +++ b/validator/client/beacon-api/test-helpers/capella_beacon_block_test_helpers.go @@ -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), diff --git a/validator/client/beacon-api/test-helpers/deneb_beacon_block_test_helpers.go b/validator/client/beacon-api/test-helpers/deneb_beacon_block_test_helpers.go index 2d91274a6b..30ffaa53bd 100644 --- a/validator/client/beacon-api/test-helpers/deneb_beacon_block_test_helpers.go +++ b/validator/client/beacon-api/test-helpers/deneb_beacon_block_test_helpers.go @@ -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), diff --git a/validator/client/beacon-api/test-helpers/phase0_beacon_block_test_helpers.go b/validator/client/beacon-api/test-helpers/phase0_beacon_block_test_helpers.go index 2bfb597183..1845f2bdbc 100644 --- a/validator/client/beacon-api/test-helpers/phase0_beacon_block_test_helpers.go +++ b/validator/client/beacon-api/test-helpers/phase0_beacon_block_test_helpers.go @@ -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", }, diff --git a/validator/client/beacon-api/validator_count_test.go b/validator/client/beacon-api/validator_count_test.go index 821be792fa..60a321de3d 100644 --- a/validator/client/beacon-api/validator_count_test.go +++ b/validator/client/beacon-api/validator_count_test.go @@ -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", diff --git a/validator/client/beacon-api/wait_for_chain_start_test.go b/validator/client/beacon-api/wait_for_chain_start_test.go index 31dc341b8f..160001cd40 100644 --- a/validator/client/beacon-api/wait_for_chain_start_test.go +++ b/validator/client/beacon-api/wait_for_chain_start_test.go @@ -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", }, diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index 45b2f120c7..2bb209560f 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -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", diff --git a/validator/rpc/handlers_keymanager.go b/validator/rpc/handlers_keymanager.go index 89094d35ef..37a2a3352b 100644 --- a/validator/rpc/handlers_keymanager.go +++ b/validator/rpc/handlers_keymanager.go @@ -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), }, diff --git a/validator/rpc/structs.go b/validator/rpc/structs.go index 0cd834bcce..d02433f913 100644 --- a/validator/rpc/structs.go +++ b/validator/rpc/structs.go @@ -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