Expose structs from API Middleware (#11547)

This commit is contained in:
Radosław Kapka
2022-10-07 17:45:26 +02:00
committed by GitHub
parent 6bea17cb54
commit eb49404a75
9 changed files with 613 additions and 613 deletions

View File

@@ -29,13 +29,13 @@ var priorityRegex = regexp.MustCompile(`q=(\d+(?:\.\d+)?)`)
type sszConfig struct {
fileName string
responseJson sszResponse
responseJson SszResponse
}
func handleGetBeaconStateSSZ(m *apimiddleware.ApiProxyMiddleware, endpoint apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
config := sszConfig{
fileName: "beacon_state.ssz",
responseJson: &sszResponseJson{},
responseJson: &SszResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -43,7 +43,7 @@ func handleGetBeaconStateSSZ(m *apimiddleware.ApiProxyMiddleware, endpoint apimi
func handleGetBeaconBlockSSZ(m *apimiddleware.ApiProxyMiddleware, endpoint apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
config := sszConfig{
fileName: "beacon_block.ssz",
responseJson: &sszResponseJson{},
responseJson: &SszResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -51,7 +51,7 @@ func handleGetBeaconBlockSSZ(m *apimiddleware.ApiProxyMiddleware, endpoint apimi
func handleGetBeaconStateSSZV2(m *apimiddleware.ApiProxyMiddleware, endpoint apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
config := sszConfig{
fileName: "beacon_state.ssz",
responseJson: &versionedSSZResponseJson{},
responseJson: &VersionedSSZResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -59,7 +59,7 @@ func handleGetBeaconStateSSZV2(m *apimiddleware.ApiProxyMiddleware, endpoint api
func handleGetBeaconBlockSSZV2(m *apimiddleware.ApiProxyMiddleware, endpoint apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
config := sszConfig{
fileName: "beacon_block.ssz",
responseJson: &versionedSSZResponseJson{},
responseJson: &VersionedSSZResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -80,7 +80,7 @@ func handleSubmitBlindedBlockSSZ(
func handleProduceBlockSSZ(m *apimiddleware.ApiProxyMiddleware, endpoint apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
config := sszConfig{
fileName: "produce_beacon_block.ssz",
responseJson: &versionedSSZResponseJson{},
responseJson: &VersionedSSZResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -93,7 +93,7 @@ func handleProduceBlindedBlockSSZ(
) (handled bool) {
config := sszConfig{
fileName: "produce_blinded_beacon_block.ssz",
responseJson: &versionedSSZResponseJson{},
responseJson: &VersionedSSZResponseJson{},
}
return handleGetSSZ(m, endpoint, w, req, config)
}
@@ -275,7 +275,7 @@ func preparePostedSSZData(req *http.Request) apimiddleware.ErrorJson {
if err != nil {
return apimiddleware.InternalServerErrorWithMessage(err, "could not read body")
}
j := sszRequestJson{Data: base64.StdEncoding.EncodeToString(buf)}
j := SszRequestJson{Data: base64.StdEncoding.EncodeToString(buf)}
data, err := json.Marshal(j)
if err != nil {
return apimiddleware.InternalServerErrorWithMessage(err, "could not prepare POST data")
@@ -286,7 +286,7 @@ func preparePostedSSZData(req *http.Request) apimiddleware.ErrorJson {
return nil
}
func serializeMiddlewareResponseIntoSSZ(respJson sszResponse) (version string, ssz []byte, errJson apimiddleware.ErrorJson) {
func serializeMiddlewareResponseIntoSSZ(respJson SszResponse) (version string, ssz []byte, errJson apimiddleware.ErrorJson) {
// Serialize the SSZ part of the deserialized value.
data, err := base64.StdEncoding.DecodeString(respJson.SSZData())
if err != nil {
@@ -363,16 +363,16 @@ func receiveEvents(eventChan <-chan *sse.Event, w http.ResponseWriter, req *http
switch string(msg.Event) {
case events.HeadTopic:
data = &eventHeadJson{}
data = &EventHeadJson{}
case events.BlockTopic:
data = &receivedBlockDataJson{}
data = &ReceivedBlockDataJson{}
case events.AttestationTopic:
data = &attestationJson{}
data = &AttestationJson{}
// Data received in the event does not fit the expected event stream output.
// We extract the underlying attestation from event data
// and assign the attestation back to event data for further processing.
eventData := &aggregatedAttReceivedDataJson{}
eventData := &AggregatedAttReceivedDataJson{}
if err := json.Unmarshal(msg.Data, eventData); err != nil {
return apimiddleware.InternalServerError(err)
}
@@ -382,15 +382,15 @@ func receiveEvents(eventChan <-chan *sse.Event, w http.ResponseWriter, req *http
}
msg.Data = attData
case events.VoluntaryExitTopic:
data = &signedVoluntaryExitJson{}
data = &SignedVoluntaryExitJson{}
case events.FinalizedCheckpointTopic:
data = &eventFinalizedCheckpointJson{}
data = &EventFinalizedCheckpointJson{}
case events.ChainReorgTopic:
data = &eventChainReorgJson{}
data = &EventChainReorgJson{}
case events.SyncCommitteeContributionTopic:
data = &signedContributionAndProofJson{}
data = &SignedContributionAndProofJson{}
case "error":
data = &eventErrorJson{}
data = &EventErrorJson{}
default:
return &apimiddleware.DefaultErrorJson{
Message: fmt.Sprintf("Event type '%s' not supported", string(msg.Event)),

View File

@@ -252,7 +252,7 @@ func TestReceiveEvents(t *testing.T) {
go func() {
base64Val := "Zm9v"
data := &eventFinalizedCheckpointJson{
data := &EventFinalizedCheckpointJson{
Block: base64Val,
State: base64Val,
Epoch: "1",
@@ -301,7 +301,7 @@ func TestReceiveEvents_TrailingSpace(t *testing.T) {
go func() {
base64Val := "Zm9v"
data := &eventFinalizedCheckpointJson{
data := &EventFinalizedCheckpointJson{
Block: base64Val,
State: base64Val,
Epoch: "1",
@@ -327,7 +327,7 @@ data: {"block":"0x666f6f","state":"0x666f6f","epoch":"1","execution_optimistic":
func TestWriteEvent(t *testing.T) {
base64Val := "Zm9v"
data := &eventFinalizedCheckpointJson{
data := &EventFinalizedCheckpointJson{
Block: base64Val,
State: base64Val,
Epoch: "1",
@@ -341,7 +341,7 @@ func TestWriteEvent(t *testing.T) {
w := httptest.NewRecorder()
w.Body = &bytes.Buffer{}
errJson := writeEvent(msg, w, &eventFinalizedCheckpointJson{})
errJson := writeEvent(msg, w, &EventFinalizedCheckpointJson{})
require.Equal(t, true, errJson == nil)
written := w.Body.String()
assert.Equal(t, "event: test_event\ndata: {\"block\":\"0x666f6f\",\"state\":\"0x666f6f\",\"epoch\":\"1\",\"execution_optimistic\":false}\n\n", written)

View File

@@ -25,14 +25,14 @@ func wrapFeeRecipientsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*feeRecipientsRequestJSON); !ok {
if _, ok := endpoint.PostRequest.(*FeeRecipientsRequestJSON); !ok {
return true, nil
}
recipients := make([]*feeRecipientJson, 0)
recipients := make([]*FeeRecipientJson, 0)
if err := json.NewDecoder(req.Body).Decode(&recipients); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &feeRecipientsRequestJSON{Recipients: recipients}
j := &FeeRecipientsRequestJSON{Recipients: recipients}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -48,14 +48,14 @@ func wrapSignedValidatorRegistrationsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*signedValidatorRegistrationsRequestJson); !ok {
if _, ok := endpoint.PostRequest.(*SignedValidatorRegistrationsRequestJson); !ok {
return true, nil
}
registrations := make([]*signedValidatorRegistrationJson, 0)
registrations := make([]*SignedValidatorRegistrationJson, 0)
if err := json.NewDecoder(req.Body).Decode(&registrations); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &signedValidatorRegistrationsRequestJson{Registrations: registrations}
j := &SignedValidatorRegistrationsRequestJson{Registrations: registrations}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -71,12 +71,12 @@ func wrapAttestationsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitAttestationRequestJson); ok {
atts := make([]*attestationJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitAttestationRequestJson); ok {
atts := make([]*AttestationJson, 0)
if err := json.NewDecoder(req.Body).Decode(&atts); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitAttestationRequestJson{Data: atts}
j := &SubmitAttestationRequestJson{Data: atts}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -93,12 +93,12 @@ func wrapValidatorIndicesArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*dutiesRequestJson); ok {
if _, ok := endpoint.PostRequest.(*DutiesRequestJson); ok {
indices := make([]string, 0)
if err := json.NewDecoder(req.Body).Decode(&indices); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &dutiesRequestJson{Index: indices}
j := &DutiesRequestJson{Index: indices}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -115,12 +115,12 @@ func wrapSignedAggregateAndProofArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitAggregateAndProofsRequestJson); ok {
data := make([]*signedAggregateAttestationAndProofJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitAggregateAndProofsRequestJson); ok {
data := make([]*SignedAggregateAttestationAndProofJson, 0)
if err := json.NewDecoder(req.Body).Decode(&data); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitAggregateAndProofsRequestJson{Data: data}
j := &SubmitAggregateAndProofsRequestJson{Data: data}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -137,12 +137,12 @@ func wrapBeaconCommitteeSubscriptionsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitBeaconCommitteeSubscriptionsRequestJson); ok {
data := make([]*beaconCommitteeSubscribeJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitBeaconCommitteeSubscriptionsRequestJson); ok {
data := make([]*BeaconCommitteeSubscribeJson, 0)
if err := json.NewDecoder(req.Body).Decode(&data); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitBeaconCommitteeSubscriptionsRequestJson{Data: data}
j := &SubmitBeaconCommitteeSubscriptionsRequestJson{Data: data}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -159,12 +159,12 @@ func wrapSyncCommitteeSubscriptionsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitSyncCommitteeSubscriptionRequestJson); ok {
data := make([]*syncCommitteeSubscriptionJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitSyncCommitteeSubscriptionRequestJson); ok {
data := make([]*SyncCommitteeSubscriptionJson, 0)
if err := json.NewDecoder(req.Body).Decode(&data); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitSyncCommitteeSubscriptionRequestJson{Data: data}
j := &SubmitSyncCommitteeSubscriptionRequestJson{Data: data}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -181,12 +181,12 @@ func wrapSyncCommitteeSignaturesArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitSyncCommitteeSignaturesRequestJson); ok {
data := make([]*syncCommitteeMessageJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitSyncCommitteeSignaturesRequestJson); ok {
data := make([]*SyncCommitteeMessageJson, 0)
if err := json.NewDecoder(req.Body).Decode(&data); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitSyncCommitteeSignaturesRequestJson{Data: data}
j := &SubmitSyncCommitteeSignaturesRequestJson{Data: data}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -203,12 +203,12 @@ func wrapSignedContributionAndProofsArray(
_ http.ResponseWriter,
req *http.Request,
) (apimiddleware.RunDefault, apimiddleware.ErrorJson) {
if _, ok := endpoint.PostRequest.(*submitContributionAndProofsRequestJson); ok {
data := make([]*signedContributionAndProofJson, 0)
if _, ok := endpoint.PostRequest.(*SubmitContributionAndProofsRequestJson); ok {
data := make([]*SignedContributionAndProofJson, 0)
if err := json.NewDecoder(req.Body).Decode(&data); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not decode body")
}
j := &submitContributionAndProofsRequestJson{Data: data}
j := &SubmitContributionAndProofsRequestJson{Data: data}
b, err := json.Marshal(j)
if err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal wrapped body")
@@ -219,22 +219,22 @@ func wrapSignedContributionAndProofsArray(
}
type phase0PublishBlockRequestJson struct {
Phase0Block *beaconBlockJson `json:"phase0_block"`
Phase0Block *BeaconBlockJson `json:"phase0_block"`
Signature string `json:"signature" hex:"true"`
}
type altairPublishBlockRequestJson struct {
AltairBlock *beaconBlockAltairJson `json:"altair_block"`
AltairBlock *BeaconBlockAltairJson `json:"altair_block"`
Signature string `json:"signature" hex:"true"`
}
type bellatrixPublishBlockRequestJson struct {
BellatrixBlock *beaconBlockBellatrixJson `json:"bellatrix_block"`
BellatrixBlock *BeaconBlockBellatrixJson `json:"bellatrix_block"`
Signature string `json:"signature" hex:"true"`
}
type bellatrixPublishBlindedBlockRequestJson struct {
BellatrixBlock *blindedBeaconBlockBellatrixJson `json:"bellatrix_block"`
BellatrixBlock *BlindedBeaconBlockBellatrixJson `json:"bellatrix_block"`
Signature string `json:"signature" hex:"true"`
}
@@ -266,11 +266,11 @@ func setInitialPublishBlockPostRequest(endpoint *apimiddleware.Endpoint,
}
currentEpoch := slots.ToEpoch(types.Slot(slot))
if currentEpoch < params.BeaconConfig().AltairForkEpoch {
endpoint.PostRequest = &signedBeaconBlockContainerJson{}
endpoint.PostRequest = &SignedBeaconBlockContainerJson{}
} else if currentEpoch < params.BeaconConfig().BellatrixForkEpoch {
endpoint.PostRequest = &signedBeaconBlockAltairContainerJson{}
endpoint.PostRequest = &SignedBeaconBlockAltairContainerJson{}
} else {
endpoint.PostRequest = &signedBeaconBlockBellatrixContainerJson{}
endpoint.PostRequest = &SignedBeaconBlockBellatrixContainerJson{}
}
req.Body = io.NopCloser(bytes.NewBuffer(buf))
return true, nil
@@ -281,7 +281,7 @@ func setInitialPublishBlockPostRequest(endpoint *apimiddleware.Endpoint,
// We do a simple conversion depending on the type of endpoint.PostRequest
// (which was filled out previously in setInitialPublishBlockPostRequest).
func preparePublishedBlock(endpoint *apimiddleware.Endpoint, _ http.ResponseWriter, _ *http.Request) apimiddleware.ErrorJson {
if block, ok := endpoint.PostRequest.(*signedBeaconBlockContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBeaconBlockContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &phase0PublishBlockRequestJson{
Phase0Block: block.Message,
@@ -290,7 +290,7 @@ func preparePublishedBlock(endpoint *apimiddleware.Endpoint, _ http.ResponseWrit
endpoint.PostRequest = actualPostReq
return nil
}
if block, ok := endpoint.PostRequest.(*signedBeaconBlockAltairContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBeaconBlockAltairContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &altairPublishBlockRequestJson{
AltairBlock: block.Message,
@@ -299,7 +299,7 @@ func preparePublishedBlock(endpoint *apimiddleware.Endpoint, _ http.ResponseWrit
endpoint.PostRequest = actualPostReq
return nil
}
if block, ok := endpoint.PostRequest.(*signedBeaconBlockBellatrixContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBeaconBlockBellatrixContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &bellatrixPublishBlockRequestJson{
BellatrixBlock: block.Message,
@@ -339,11 +339,11 @@ func setInitialPublishBlindedBlockPostRequest(endpoint *apimiddleware.Endpoint,
}
currentEpoch := slots.ToEpoch(types.Slot(slot))
if currentEpoch < params.BeaconConfig().AltairForkEpoch {
endpoint.PostRequest = &signedBeaconBlockContainerJson{}
endpoint.PostRequest = &SignedBeaconBlockContainerJson{}
} else if currentEpoch < params.BeaconConfig().BellatrixForkEpoch {
endpoint.PostRequest = &signedBeaconBlockAltairContainerJson{}
endpoint.PostRequest = &SignedBeaconBlockAltairContainerJson{}
} else {
endpoint.PostRequest = &signedBlindedBeaconBlockBellatrixContainerJson{}
endpoint.PostRequest = &SignedBlindedBeaconBlockBellatrixContainerJson{}
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(buf))
return true, nil
@@ -354,7 +354,7 @@ func setInitialPublishBlindedBlockPostRequest(endpoint *apimiddleware.Endpoint,
// We do a simple conversion depending on the type of endpoint.PostRequest
// (which was filled out previously in setInitialPublishBlockPostRequest).
func preparePublishedBlindedBlock(endpoint *apimiddleware.Endpoint, _ http.ResponseWriter, _ *http.Request) apimiddleware.ErrorJson {
if block, ok := endpoint.PostRequest.(*signedBeaconBlockContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBeaconBlockContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &phase0PublishBlockRequestJson{
Phase0Block: block.Message,
@@ -363,7 +363,7 @@ func preparePublishedBlindedBlock(endpoint *apimiddleware.Endpoint, _ http.Respo
endpoint.PostRequest = actualPostReq
return nil
}
if block, ok := endpoint.PostRequest.(*signedBeaconBlockAltairContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBeaconBlockAltairContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &altairPublishBlockRequestJson{
AltairBlock: block.Message,
@@ -372,7 +372,7 @@ func preparePublishedBlindedBlock(endpoint *apimiddleware.Endpoint, _ http.Respo
endpoint.PostRequest = actualPostReq
return nil
}
if block, ok := endpoint.PostRequest.(*signedBlindedBeaconBlockBellatrixContainerJson); ok {
if block, ok := endpoint.PostRequest.(*SignedBlindedBeaconBlockBellatrixContainerJson); ok {
// Prepare post request that can be properly decoded on gRPC side.
actualPostReq := &bellatrixPublishBlindedBlockRequestJson{
BellatrixBlock: block.Message,
@@ -404,12 +404,12 @@ func prepareValidatorAggregates(body []byte, responseContainer interface{}) (api
if err := json.Unmarshal(body, tempContainer); err != nil {
return false, apimiddleware.InternalServerErrorWithMessage(err, "could not unmarshal response into temp container")
}
container, ok := responseContainer.(*syncCommitteesResponseJson)
container, ok := responseContainer.(*SyncCommitteesResponseJson)
if !ok {
return false, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
}
container.Data = &syncCommitteeValidatorsJson{}
container.Data = &SyncCommitteeValidatorsJson{}
container.Data.Validators = tempContainer.Data.Validators
container.Data.ValidatorAggregates = make([][]string, len(tempContainer.Data.ValidatorAggregates))
for i, srcValAgg := range tempContainer.Data.ValidatorAggregates {
@@ -423,24 +423,24 @@ func prepareValidatorAggregates(body []byte, responseContainer interface{}) (api
type phase0BlockResponseJson struct {
Version string `json:"version"`
Data *signedBeaconBlockContainerJson `json:"data"`
Data *SignedBeaconBlockContainerJson `json:"data"`
ExecutionOptimistic bool `json:"execution_optimistic"`
}
type altairBlockResponseJson struct {
Version string `json:"version"`
Data *signedBeaconBlockAltairContainerJson `json:"data"`
Data *SignedBeaconBlockAltairContainerJson `json:"data"`
ExecutionOptimistic bool `json:"execution_optimistic"`
}
type bellatrixBlockResponseJson struct {
Version string `json:"version"`
Data *signedBeaconBlockBellatrixContainerJson `json:"data"`
Data *SignedBeaconBlockBellatrixContainerJson `json:"data"`
ExecutionOptimistic bool `json:"execution_optimistic"`
}
func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
respContainer, ok := response.(*blockV2ResponseJson)
respContainer, ok := response.(*BlockV2ResponseJson)
if !ok {
return false, nil, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
}
@@ -450,7 +450,7 @@ func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, a
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_PHASE0.String())):
actualRespContainer = &phase0BlockResponseJson{
Version: respContainer.Version,
Data: &signedBeaconBlockContainerJson{
Data: &SignedBeaconBlockContainerJson{
Message: respContainer.Data.Phase0Block,
Signature: respContainer.Data.Signature,
},
@@ -459,7 +459,7 @@ func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, a
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_ALTAIR.String())):
actualRespContainer = &altairBlockResponseJson{
Version: respContainer.Version,
Data: &signedBeaconBlockAltairContainerJson{
Data: &SignedBeaconBlockAltairContainerJson{
Message: respContainer.Data.AltairBlock,
Signature: respContainer.Data.Signature,
},
@@ -468,7 +468,7 @@ func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, a
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_BELLATRIX.String())):
actualRespContainer = &bellatrixBlockResponseJson{
Version: respContainer.Version,
Data: &signedBeaconBlockBellatrixContainerJson{
Data: &SignedBeaconBlockBellatrixContainerJson{
Message: respContainer.Data.BellatrixBlock,
Signature: respContainer.Data.Signature,
},
@@ -487,21 +487,21 @@ func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, a
type phase0StateResponseJson struct {
Version string `json:"version"`
Data *beaconStateJson `json:"data"`
Data *BeaconStateJson `json:"data"`
}
type altairStateResponseJson struct {
Version string `json:"version"`
Data *beaconStateAltairJson `json:"data"`
Data *BeaconStateAltairJson `json:"data"`
}
type bellatrixStateResponseJson struct {
Version string `json:"version"`
Data *beaconStateBellatrixJson `json:"data"`
Data *BeaconStateBellatrixJson `json:"data"`
}
func serializeV2State(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
respContainer, ok := response.(*beaconStateV2ResponseJson)
respContainer, ok := response.(*BeaconStateV2ResponseJson)
if !ok {
return false, nil, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
}
@@ -536,26 +536,26 @@ func serializeV2State(response interface{}) (apimiddleware.RunDefault, []byte, a
type phase0ProduceBlockResponseJson struct {
Version string `json:"version"`
Data *beaconBlockJson `json:"data"`
Data *BeaconBlockJson `json:"data"`
}
type altairProduceBlockResponseJson struct {
Version string `json:"version"`
Data *beaconBlockAltairJson `json:"data"`
Data *BeaconBlockAltairJson `json:"data"`
}
type bellatrixProduceBlockResponseJson struct {
Version string `json:"version"`
Data *beaconBlockBellatrixJson `json:"data"`
Data *BeaconBlockBellatrixJson `json:"data"`
}
type bellatrixProduceBlindedBlockResponseJson struct {
Version string `json:"version"`
Data *blindedBeaconBlockBellatrixJson `json:"data"`
Data *BlindedBeaconBlockBellatrixJson `json:"data"`
}
func serializeProducedV2Block(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
respContainer, ok := response.(*produceBlockResponseV2Json)
respContainer, ok := response.(*ProduceBlockResponseV2Json)
if !ok {
return false, nil, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
}
@@ -589,7 +589,7 @@ func serializeProducedV2Block(response interface{}) (apimiddleware.RunDefault, [
}
func serializeProducedBlindedBlock(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
respContainer, ok := response.(*produceBlindedBlockResponseJson)
respContainer, ok := response.(*ProduceBlindedBlockResponseJson)
if !ok {
return false, nil, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
}

View File

@@ -22,9 +22,9 @@ import (
func TestWrapAttestationArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitAttestationRequestJson{},
PostRequest: &SubmitAttestationRequestJson{},
}
unwrappedAtts := []*attestationJson{{AggregationBits: "1010"}}
unwrappedAtts := []*AttestationJson{{AggregationBits: "1010"}}
unwrappedAttsJson, err := json.Marshal(unwrappedAtts)
require.NoError(t, err)
@@ -36,7 +36,7 @@ func TestWrapAttestationArray(t *testing.T) {
runDefault, errJson := wrapAttestationsArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedAtts := &submitAttestationRequestJson{}
wrappedAtts := &SubmitAttestationRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedAtts))
require.Equal(t, 1, len(wrappedAtts.Data), "wrong number of wrapped items")
assert.Equal(t, "1010", wrappedAtts.Data[0].AggregationBits)
@@ -44,7 +44,7 @@ func TestWrapAttestationArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitAttestationRequestJson{},
PostRequest: &SubmitAttestationRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -62,7 +62,7 @@ func TestWrapAttestationArray(t *testing.T) {
func TestWrapValidatorIndicesArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &dutiesRequestJson{},
PostRequest: &DutiesRequestJson{},
}
unwrappedIndices := []string{"1", "2"}
unwrappedIndicesJson, err := json.Marshal(unwrappedIndices)
@@ -76,7 +76,7 @@ func TestWrapValidatorIndicesArray(t *testing.T) {
runDefault, errJson := wrapValidatorIndicesArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedIndices := &dutiesRequestJson{}
wrappedIndices := &DutiesRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedIndices))
require.Equal(t, 2, len(wrappedIndices.Index), "wrong number of wrapped items")
assert.Equal(t, "1", wrappedIndices.Index[0])
@@ -85,7 +85,7 @@ func TestWrapValidatorIndicesArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &dutiesRequestJson{},
PostRequest: &DutiesRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -103,9 +103,9 @@ func TestWrapValidatorIndicesArray(t *testing.T) {
func TestWrapSignedAggregateAndProofArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitAggregateAndProofsRequestJson{},
PostRequest: &SubmitAggregateAndProofsRequestJson{},
}
unwrappedAggs := []*signedAggregateAttestationAndProofJson{{Signature: "sig"}}
unwrappedAggs := []*SignedAggregateAttestationAndProofJson{{Signature: "sig"}}
unwrappedAggsJson, err := json.Marshal(unwrappedAggs)
require.NoError(t, err)
@@ -117,7 +117,7 @@ func TestWrapSignedAggregateAndProofArray(t *testing.T) {
runDefault, errJson := wrapSignedAggregateAndProofArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedAggs := &submitAggregateAndProofsRequestJson{}
wrappedAggs := &SubmitAggregateAndProofsRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedAggs))
require.Equal(t, 1, len(wrappedAggs.Data), "wrong number of wrapped items")
assert.Equal(t, "sig", wrappedAggs.Data[0].Signature)
@@ -125,7 +125,7 @@ func TestWrapSignedAggregateAndProofArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitAggregateAndProofsRequestJson{},
PostRequest: &SubmitAggregateAndProofsRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -143,9 +143,9 @@ func TestWrapSignedAggregateAndProofArray(t *testing.T) {
func TestWrapBeaconCommitteeSubscriptionsArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitBeaconCommitteeSubscriptionsRequestJson{},
PostRequest: &SubmitBeaconCommitteeSubscriptionsRequestJson{},
}
unwrappedSubs := []*beaconCommitteeSubscribeJson{{
unwrappedSubs := []*BeaconCommitteeSubscribeJson{{
ValidatorIndex: "1",
CommitteeIndex: "1",
CommitteesAtSlot: "1",
@@ -163,7 +163,7 @@ func TestWrapBeaconCommitteeSubscriptionsArray(t *testing.T) {
runDefault, errJson := wrapBeaconCommitteeSubscriptionsArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedSubs := &submitBeaconCommitteeSubscriptionsRequestJson{}
wrappedSubs := &SubmitBeaconCommitteeSubscriptionsRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedSubs))
require.Equal(t, 1, len(wrappedSubs.Data), "wrong number of wrapped items")
assert.Equal(t, "1", wrappedSubs.Data[0].ValidatorIndex)
@@ -175,7 +175,7 @@ func TestWrapBeaconCommitteeSubscriptionsArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitBeaconCommitteeSubscriptionsRequestJson{},
PostRequest: &SubmitBeaconCommitteeSubscriptionsRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -193,9 +193,9 @@ func TestWrapBeaconCommitteeSubscriptionsArray(t *testing.T) {
func TestWrapSyncCommitteeSubscriptionsArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitSyncCommitteeSubscriptionRequestJson{},
PostRequest: &SubmitSyncCommitteeSubscriptionRequestJson{},
}
unwrappedSubs := []*syncCommitteeSubscriptionJson{
unwrappedSubs := []*SyncCommitteeSubscriptionJson{
{
ValidatorIndex: "1",
SyncCommitteeIndices: []string{"1", "2"},
@@ -218,7 +218,7 @@ func TestWrapSyncCommitteeSubscriptionsArray(t *testing.T) {
runDefault, errJson := wrapSyncCommitteeSubscriptionsArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedSubs := &submitSyncCommitteeSubscriptionRequestJson{}
wrappedSubs := &SubmitSyncCommitteeSubscriptionRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedSubs))
require.Equal(t, 2, len(wrappedSubs.Data), "wrong number of wrapped items")
assert.Equal(t, "1", wrappedSubs.Data[0].ValidatorIndex)
@@ -230,7 +230,7 @@ func TestWrapSyncCommitteeSubscriptionsArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitSyncCommitteeSubscriptionRequestJson{},
PostRequest: &SubmitSyncCommitteeSubscriptionRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -248,9 +248,9 @@ func TestWrapSyncCommitteeSubscriptionsArray(t *testing.T) {
func TestWrapSyncCommitteeSignaturesArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitSyncCommitteeSignaturesRequestJson{},
PostRequest: &SubmitSyncCommitteeSignaturesRequestJson{},
}
unwrappedSigs := []*syncCommitteeMessageJson{{
unwrappedSigs := []*SyncCommitteeMessageJson{{
Slot: "1",
BeaconBlockRoot: "root",
ValidatorIndex: "1",
@@ -267,7 +267,7 @@ func TestWrapSyncCommitteeSignaturesArray(t *testing.T) {
runDefault, errJson := wrapSyncCommitteeSignaturesArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrappedSigs := &submitSyncCommitteeSignaturesRequestJson{}
wrappedSigs := &SubmitSyncCommitteeSignaturesRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrappedSigs))
require.Equal(t, 1, len(wrappedSigs.Data), "wrong number of wrapped items")
assert.Equal(t, "1", wrappedSigs.Data[0].Slot)
@@ -278,7 +278,7 @@ func TestWrapSyncCommitteeSignaturesArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitSyncCommitteeSignaturesRequestJson{},
PostRequest: &SubmitSyncCommitteeSignaturesRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -296,13 +296,13 @@ func TestWrapSyncCommitteeSignaturesArray(t *testing.T) {
func TestWrapSignedContributionAndProofsArray(t *testing.T) {
t.Run("ok", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitContributionAndProofsRequestJson{},
PostRequest: &SubmitContributionAndProofsRequestJson{},
}
unwrapped := []*signedContributionAndProofJson{
unwrapped := []*SignedContributionAndProofJson{
{
Message: &contributionAndProofJson{
Message: &ContributionAndProofJson{
AggregatorIndex: "1",
Contribution: &syncCommitteeContributionJson{
Contribution: &SyncCommitteeContributionJson{
Slot: "1",
BeaconBlockRoot: "root",
SubcommitteeIndex: "1",
@@ -314,7 +314,7 @@ func TestWrapSignedContributionAndProofsArray(t *testing.T) {
Signature: "sig",
},
{
Message: &contributionAndProofJson{},
Message: &ContributionAndProofJson{},
Signature: "sig",
},
}
@@ -329,7 +329,7 @@ func TestWrapSignedContributionAndProofsArray(t *testing.T) {
runDefault, errJson := wrapSignedContributionAndProofsArray(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
wrapped := &submitContributionAndProofsRequestJson{}
wrapped := &SubmitContributionAndProofsRequestJson{}
require.NoError(t, json.NewDecoder(request.Body).Decode(wrapped))
require.Equal(t, 2, len(wrapped.Data), "wrong number of wrapped items")
assert.Equal(t, "sig", wrapped.Data[0].Signature)
@@ -347,7 +347,7 @@ func TestWrapSignedContributionAndProofsArray(t *testing.T) {
t.Run("invalid_body", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &submitContributionAndProofsRequestJson{},
PostRequest: &SubmitContributionAndProofsRequestJson{},
}
var body bytes.Buffer
_, err := body.Write([]byte("invalid"))
@@ -385,7 +385,7 @@ func TestSetInitialPublishBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBeaconBlockContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBeaconBlockContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
t.Run("Altair", func(t *testing.T) {
slot, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
@@ -400,7 +400,7 @@ func TestSetInitialPublishBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBeaconBlockAltairContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBeaconBlockAltairContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
t.Run("Bellatrix", func(t *testing.T) {
slot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
@@ -415,16 +415,16 @@ func TestSetInitialPublishBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBeaconBlockBellatrixContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBeaconBlockBellatrixContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
}
func TestPreparePublishedBlock(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBeaconBlockContainerJson{
Message: &beaconBlockJson{
Body: &beaconBlockBodyJson{},
PostRequest: &SignedBeaconBlockContainerJson{
Message: &BeaconBlockJson{
Body: &BeaconBlockBodyJson{},
},
},
}
@@ -436,9 +436,9 @@ func TestPreparePublishedBlock(t *testing.T) {
t.Run("Altair", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBeaconBlockAltairContainerJson{
Message: &beaconBlockAltairJson{
Body: &beaconBlockBodyAltairJson{},
PostRequest: &SignedBeaconBlockAltairContainerJson{
Message: &BeaconBlockAltairJson{
Body: &BeaconBlockBodyAltairJson{},
},
},
}
@@ -450,9 +450,9 @@ func TestPreparePublishedBlock(t *testing.T) {
t.Run("Bellatrix", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBeaconBlockBellatrixContainerJson{
Message: &beaconBlockBellatrixJson{
Body: &beaconBlockBodyBellatrixJson{},
PostRequest: &SignedBeaconBlockBellatrixContainerJson{
Message: &BeaconBlockBellatrixJson{
Body: &BeaconBlockBodyBellatrixJson{},
},
},
}
@@ -491,7 +491,7 @@ func TestSetInitialPublishBlindedBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlindedBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBeaconBlockContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBeaconBlockContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
t.Run("Altair", func(t *testing.T) {
slot, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
@@ -506,7 +506,7 @@ func TestSetInitialPublishBlindedBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlindedBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBeaconBlockAltairContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBeaconBlockAltairContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
t.Run("Bellatrix", func(t *testing.T) {
slot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
@@ -521,16 +521,16 @@ func TestSetInitialPublishBlindedBlockPostRequest(t *testing.T) {
runDefault, errJson := setInitialPublishBlindedBlockPostRequest(endpoint, nil, request)
require.Equal(t, true, errJson == nil)
assert.Equal(t, apimiddleware.RunDefault(true), runDefault)
assert.Equal(t, reflect.TypeOf(signedBlindedBeaconBlockBellatrixContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
assert.Equal(t, reflect.TypeOf(SignedBlindedBeaconBlockBellatrixContainerJson{}).Name(), reflect.Indirect(reflect.ValueOf(endpoint.PostRequest)).Type().Name())
})
}
func TestPreparePublishedBlindedBlock(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBeaconBlockContainerJson{
Message: &beaconBlockJson{
Body: &beaconBlockBodyJson{},
PostRequest: &SignedBeaconBlockContainerJson{
Message: &BeaconBlockJson{
Body: &BeaconBlockBodyJson{},
},
},
}
@@ -542,9 +542,9 @@ func TestPreparePublishedBlindedBlock(t *testing.T) {
t.Run("Altair", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBeaconBlockAltairContainerJson{
Message: &beaconBlockAltairJson{
Body: &beaconBlockBodyAltairJson{},
PostRequest: &SignedBeaconBlockAltairContainerJson{
Message: &BeaconBlockAltairJson{
Body: &BeaconBlockBodyAltairJson{},
},
},
}
@@ -556,9 +556,9 @@ func TestPreparePublishedBlindedBlock(t *testing.T) {
t.Run("Bellatrix", func(t *testing.T) {
endpoint := &apimiddleware.Endpoint{
PostRequest: &signedBlindedBeaconBlockBellatrixContainerJson{
Message: &blindedBeaconBlockBellatrixJson{
Body: &blindedBeaconBlockBodyBellatrixJson{},
PostRequest: &SignedBlindedBeaconBlockBellatrixContainerJson{
Message: &BlindedBeaconBlockBellatrixJson{
Body: &BlindedBeaconBlockBodyBellatrixJson{},
},
},
}
@@ -591,7 +591,7 @@ func TestPrepareValidatorAggregates(t *testing.T) {
bodyJson, err := json.Marshal(body)
require.NoError(t, err)
container := &syncCommitteesResponseJson{}
container := &SyncCommitteesResponseJson{}
runDefault, errJson := prepareValidatorAggregates(bodyJson, container)
require.Equal(t, nil, errJson)
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
@@ -601,15 +601,15 @@ func TestPrepareValidatorAggregates(t *testing.T) {
func TestSerializeV2Block(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
response := &blockV2ResponseJson{
response := &BlockV2ResponseJson{
Version: ethpbv2.Version_PHASE0.String(),
Data: &signedBeaconBlockContainerV2Json{
Phase0Block: &beaconBlockJson{
Data: &SignedBeaconBlockContainerV2Json{
Phase0Block: &BeaconBlockJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyJson{},
Body: &BeaconBlockBodyJson{},
},
Signature: "sig",
},
@@ -633,15 +633,15 @@ func TestSerializeV2Block(t *testing.T) {
})
t.Run("Altair", func(t *testing.T) {
response := &blockV2ResponseJson{
response := &BlockV2ResponseJson{
Version: ethpbv2.Version_ALTAIR.String(),
Data: &signedBeaconBlockContainerV2Json{
AltairBlock: &beaconBlockAltairJson{
Data: &SignedBeaconBlockContainerV2Json{
AltairBlock: &BeaconBlockAltairJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyAltairJson{},
Body: &BeaconBlockBodyAltairJson{},
},
Signature: "sig",
},
@@ -665,15 +665,15 @@ func TestSerializeV2Block(t *testing.T) {
})
t.Run("Bellatrix", func(t *testing.T) {
response := &blockV2ResponseJson{
response := &BlockV2ResponseJson{
Version: ethpbv2.Version_BELLATRIX.String(),
Data: &signedBeaconBlockContainerV2Json{
BellatrixBlock: &beaconBlockBellatrixJson{
Data: &SignedBeaconBlockContainerV2Json{
BellatrixBlock: &BeaconBlockBellatrixJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyBellatrixJson{},
Body: &BeaconBlockBodyBellatrixJson{},
},
Signature: "sig",
},
@@ -706,7 +706,7 @@ func TestSerializeV2Block(t *testing.T) {
})
t.Run("unsupported block version", func(t *testing.T) {
response := &blockV2ResponseJson{
response := &BlockV2ResponseJson{
Version: "unsupported",
}
runDefault, j, errJson := serializeV2Block(response)
@@ -719,10 +719,10 @@ func TestSerializeV2Block(t *testing.T) {
func TestSerializeV2State(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
response := &beaconStateV2ResponseJson{
response := &BeaconStateV2ResponseJson{
Version: ethpbv2.Version_PHASE0.String(),
Data: &beaconStateContainerV2Json{
Phase0State: &beaconStateJson{},
Data: &BeaconStateContainerV2Json{
Phase0State: &BeaconStateJson{},
AltairState: nil,
},
}
@@ -734,11 +734,11 @@ func TestSerializeV2State(t *testing.T) {
})
t.Run("Altair", func(t *testing.T) {
response := &beaconStateV2ResponseJson{
response := &BeaconStateV2ResponseJson{
Version: ethpbv2.Version_ALTAIR.String(),
Data: &beaconStateContainerV2Json{
Data: &BeaconStateContainerV2Json{
Phase0State: nil,
AltairState: &beaconStateAltairJson{},
AltairState: &BeaconStateAltairJson{},
},
}
runDefault, j, errJson := serializeV2State(response)
@@ -749,11 +749,11 @@ func TestSerializeV2State(t *testing.T) {
})
t.Run("Bellatrix", func(t *testing.T) {
response := &beaconStateV2ResponseJson{
response := &BeaconStateV2ResponseJson{
Version: ethpbv2.Version_BELLATRIX.String(),
Data: &beaconStateContainerV2Json{
Data: &BeaconStateContainerV2Json{
Phase0State: nil,
BellatrixState: &beaconStateBellatrixJson{},
BellatrixState: &BeaconStateBellatrixJson{},
},
}
runDefault, j, errJson := serializeV2State(response)
@@ -772,7 +772,7 @@ func TestSerializeV2State(t *testing.T) {
})
t.Run("unsupported state version", func(t *testing.T) {
response := &beaconStateV2ResponseJson{
response := &BeaconStateV2ResponseJson{
Version: "unsupported",
}
runDefault, j, errJson := serializeV2State(response)
@@ -785,15 +785,15 @@ func TestSerializeV2State(t *testing.T) {
func TestSerializeProducedV2Block(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
response := &produceBlockResponseV2Json{
response := &ProduceBlockResponseV2Json{
Version: ethpbv2.Version_PHASE0.String(),
Data: &beaconBlockContainerV2Json{
Phase0Block: &beaconBlockJson{
Data: &BeaconBlockContainerV2Json{
Phase0Block: &BeaconBlockJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyJson{},
Body: &BeaconBlockBodyJson{},
},
},
}
@@ -814,15 +814,15 @@ func TestSerializeProducedV2Block(t *testing.T) {
})
t.Run("Altair", func(t *testing.T) {
response := &produceBlockResponseV2Json{
response := &ProduceBlockResponseV2Json{
Version: ethpbv2.Version_ALTAIR.String(),
Data: &beaconBlockContainerV2Json{
AltairBlock: &beaconBlockAltairJson{
Data: &BeaconBlockContainerV2Json{
AltairBlock: &BeaconBlockAltairJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyAltairJson{},
Body: &BeaconBlockBodyAltairJson{},
},
},
}
@@ -843,15 +843,15 @@ func TestSerializeProducedV2Block(t *testing.T) {
})
t.Run("Bellatrix", func(t *testing.T) {
response := &produceBlockResponseV2Json{
response := &ProduceBlockResponseV2Json{
Version: ethpbv2.Version_BELLATRIX.String(),
Data: &beaconBlockContainerV2Json{
BellatrixBlock: &beaconBlockBellatrixJson{
Data: &BeaconBlockContainerV2Json{
BellatrixBlock: &BeaconBlockBellatrixJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyBellatrixJson{},
Body: &BeaconBlockBodyBellatrixJson{},
},
},
}
@@ -881,7 +881,7 @@ func TestSerializeProducedV2Block(t *testing.T) {
})
t.Run("unsupported block version", func(t *testing.T) {
response := &produceBlockResponseV2Json{
response := &ProduceBlockResponseV2Json{
Version: "unsupported",
}
runDefault, j, errJson := serializeProducedV2Block(response)
@@ -894,15 +894,15 @@ func TestSerializeProducedV2Block(t *testing.T) {
func TestSerializeProduceBlindedBlock(t *testing.T) {
t.Run("Phase 0", func(t *testing.T) {
response := &produceBlindedBlockResponseJson{
response := &ProduceBlindedBlockResponseJson{
Version: ethpbv2.Version_PHASE0.String(),
Data: &blindedBeaconBlockContainerJson{
Phase0Block: &beaconBlockJson{
Data: &BlindedBeaconBlockContainerJson{
Phase0Block: &BeaconBlockJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyJson{},
Body: &BeaconBlockBodyJson{},
},
AltairBlock: nil,
},
@@ -924,15 +924,15 @@ func TestSerializeProduceBlindedBlock(t *testing.T) {
})
t.Run("Altair", func(t *testing.T) {
response := &produceBlindedBlockResponseJson{
response := &ProduceBlindedBlockResponseJson{
Version: ethpbv2.Version_ALTAIR.String(),
Data: &blindedBeaconBlockContainerJson{
AltairBlock: &beaconBlockAltairJson{
Data: &BlindedBeaconBlockContainerJson{
AltairBlock: &BeaconBlockAltairJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &beaconBlockBodyAltairJson{},
Body: &BeaconBlockBodyAltairJson{},
},
},
}
@@ -953,15 +953,15 @@ func TestSerializeProduceBlindedBlock(t *testing.T) {
})
t.Run("Bellatrix", func(t *testing.T) {
response := &produceBlindedBlockResponseJson{
response := &ProduceBlindedBlockResponseJson{
Version: ethpbv2.Version_BELLATRIX.String(),
Data: &blindedBeaconBlockContainerJson{
BellatrixBlock: &blindedBeaconBlockBellatrixJson{
Data: &BlindedBeaconBlockContainerJson{
BellatrixBlock: &BlindedBeaconBlockBellatrixJson{
Slot: "1",
ProposerIndex: "1",
ParentRoot: "root",
StateRoot: "root",
Body: &blindedBeaconBlockBodyBellatrixJson{},
Body: &BlindedBeaconBlockBodyBellatrixJson{},
},
},
}
@@ -991,7 +991,7 @@ func TestSerializeProduceBlindedBlock(t *testing.T) {
})
t.Run("unsupported block version", func(t *testing.T) {
response := &produceBlockResponseV2Json{
response := &ProduceBlockResponseV2Json{
Version: "unsupported",
}
runDefault, j, errJson := serializeProducedV2Block(response)

View File

@@ -78,35 +78,35 @@ func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, er
endpoint := apimiddleware.DefaultEndpoint()
switch path {
case "/eth/v1/beacon/genesis":
endpoint.GetResponse = &genesisResponseJson{}
endpoint.GetResponse = &GenesisResponseJson{}
case "/eth/v1/beacon/states/{state_id}/root":
endpoint.GetResponse = &stateRootResponseJson{}
endpoint.GetResponse = &StateRootResponseJson{}
case "/eth/v1/beacon/states/{state_id}/fork":
endpoint.GetResponse = &stateForkResponseJson{}
endpoint.GetResponse = &StateForkResponseJson{}
case "/eth/v1/beacon/states/{state_id}/finality_checkpoints":
endpoint.GetResponse = &stateFinalityCheckpointResponseJson{}
endpoint.GetResponse = &StateFinalityCheckpointResponseJson{}
case "/eth/v1/beacon/states/{state_id}/validators":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "id", Hex: true}, {Name: "status", Enum: true}}
endpoint.GetResponse = &stateValidatorsResponseJson{}
endpoint.GetResponse = &StateValidatorsResponseJson{}
case "/eth/v1/beacon/states/{state_id}/validators/{validator_id}":
endpoint.GetResponse = &stateValidatorResponseJson{}
endpoint.GetResponse = &StateValidatorResponseJson{}
case "/eth/v1/beacon/states/{state_id}/validator_balances":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "id", Hex: true}}
endpoint.GetResponse = &validatorBalancesResponseJson{}
endpoint.GetResponse = &ValidatorBalancesResponseJson{}
case "/eth/v1/beacon/states/{state_id}/committees":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "epoch"}, {Name: "index"}, {Name: "slot"}}
endpoint.GetResponse = &stateCommitteesResponseJson{}
endpoint.GetResponse = &StateCommitteesResponseJson{}
case "/eth/v1/beacon/states/{state_id}/sync_committees":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "epoch"}}
endpoint.GetResponse = &syncCommitteesResponseJson{}
endpoint.GetResponse = &SyncCommitteesResponseJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeGrpcResponseBodyIntoContainer: prepareValidatorAggregates,
}
case "/eth/v1/beacon/headers":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "slot"}, {Name: "parent_root", Hex: true}}
endpoint.GetResponse = &blockHeadersResponseJson{}
endpoint.GetResponse = &BlockHeadersResponseJson{}
case "/eth/v1/beacon/headers/{block_id}":
endpoint.GetResponse = &blockHeaderResponseJson{}
endpoint.GetResponse = &BlockHeaderResponseJson{}
case "/eth/v1/beacon/blocks":
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: setInitialPublishBlockPostRequest,
@@ -120,108 +120,108 @@ func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, er
}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleSubmitBlindedBlockSSZ}
case "/eth/v1/beacon/blocks/{block_id}":
endpoint.GetResponse = &blockResponseJson{}
endpoint.GetResponse = &BlockResponseJson{}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleGetBeaconBlockSSZ}
case "/eth/v2/beacon/blocks/{block_id}":
endpoint.GetResponse = &blockV2ResponseJson{}
endpoint.GetResponse = &BlockV2ResponseJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreSerializeMiddlewareResponseIntoJson: serializeV2Block,
}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleGetBeaconBlockSSZV2}
case "/eth/v1/beacon/blocks/{block_id}/root":
endpoint.GetResponse = &blockRootResponseJson{}
endpoint.GetResponse = &BlockRootResponseJson{}
case "/eth/v1/beacon/blocks/{block_id}/attestations":
endpoint.GetResponse = &blockAttestationsResponseJson{}
endpoint.GetResponse = &BlockAttestationsResponseJson{}
case "/eth/v1/beacon/pool/attestations":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "slot"}, {Name: "committee_index"}}
endpoint.GetResponse = &attestationsPoolResponseJson{}
endpoint.PostRequest = &submitAttestationRequestJson{}
endpoint.Err = &indexedVerificationFailureErrorJson{}
endpoint.GetResponse = &AttestationsPoolResponseJson{}
endpoint.PostRequest = &SubmitAttestationRequestJson{}
endpoint.Err = &IndexedVerificationFailureErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapAttestationsArray,
}
case "/eth/v1/beacon/pool/attester_slashings":
endpoint.PostRequest = &attesterSlashingJson{}
endpoint.GetResponse = &attesterSlashingsPoolResponseJson{}
endpoint.PostRequest = &AttesterSlashingJson{}
endpoint.GetResponse = &AttesterSlashingsPoolResponseJson{}
case "/eth/v1/beacon/pool/proposer_slashings":
endpoint.PostRequest = &proposerSlashingJson{}
endpoint.GetResponse = &proposerSlashingsPoolResponseJson{}
endpoint.PostRequest = &ProposerSlashingJson{}
endpoint.GetResponse = &ProposerSlashingsPoolResponseJson{}
case "/eth/v1/beacon/pool/voluntary_exits":
endpoint.PostRequest = &signedVoluntaryExitJson{}
endpoint.GetResponse = &voluntaryExitsPoolResponseJson{}
endpoint.PostRequest = &SignedVoluntaryExitJson{}
endpoint.GetResponse = &VoluntaryExitsPoolResponseJson{}
case "/eth/v1/beacon/pool/sync_committees":
endpoint.PostRequest = &submitSyncCommitteeSignaturesRequestJson{}
endpoint.Err = &indexedVerificationFailureErrorJson{}
endpoint.PostRequest = &SubmitSyncCommitteeSignaturesRequestJson{}
endpoint.Err = &IndexedVerificationFailureErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapSyncCommitteeSignaturesArray,
}
case "/eth/v1/beacon/weak_subjectivity":
endpoint.GetResponse = &WeakSubjectivityResponse{}
case "/eth/v1/node/identity":
endpoint.GetResponse = &identityResponseJson{}
endpoint.GetResponse = &IdentityResponseJson{}
case "/eth/v1/node/peers":
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "state", Enum: true}, {Name: "direction", Enum: true}}
endpoint.GetResponse = &peersResponseJson{}
endpoint.GetResponse = &PeersResponseJson{}
case "/eth/v1/node/peers/{peer_id}":
endpoint.RequestURLLiterals = []string{"peer_id"}
endpoint.GetResponse = &peerResponseJson{}
endpoint.GetResponse = &PeerResponseJson{}
case "/eth/v1/node/peer_count":
endpoint.GetResponse = &peerCountResponseJson{}
endpoint.GetResponse = &PeerCountResponseJson{}
case "/eth/v1/node/version":
endpoint.GetResponse = &versionResponseJson{}
endpoint.GetResponse = &VersionResponseJson{}
case "/eth/v1/node/syncing":
endpoint.GetResponse = &syncingResponseJson{}
endpoint.GetResponse = &SyncingResponseJson{}
case "/eth/v1/node/health":
// Use default endpoint
case "/eth/v1/debug/beacon/states/{state_id}":
endpoint.GetResponse = &beaconStateResponseJson{}
endpoint.GetResponse = &BeaconStateResponseJson{}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleGetBeaconStateSSZ}
case "/eth/v2/debug/beacon/states/{state_id}":
endpoint.GetResponse = &beaconStateV2ResponseJson{}
endpoint.GetResponse = &BeaconStateV2ResponseJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreSerializeMiddlewareResponseIntoJson: serializeV2State,
}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleGetBeaconStateSSZV2}
case "/eth/v1/debug/beacon/heads":
endpoint.GetResponse = &forkChoiceHeadsResponseJson{}
endpoint.GetResponse = &ForkChoiceHeadsResponseJson{}
case "/eth/v2/debug/beacon/heads":
endpoint.GetResponse = &v2ForkChoiceHeadsResponseJson{}
endpoint.GetResponse = &V2ForkChoiceHeadsResponseJson{}
case "/eth/v1/debug/beacon/forkchoice":
endpoint.GetResponse = &forkchoiceResponse{}
endpoint.GetResponse = &ForkchoiceResponse{}
case "/eth/v1/config/fork_schedule":
endpoint.GetResponse = &forkScheduleResponseJson{}
endpoint.GetResponse = &ForkScheduleResponseJson{}
case "/eth/v1/config/deposit_contract":
endpoint.GetResponse = &depositContractResponseJson{}
endpoint.GetResponse = &DepositContractResponseJson{}
case "/eth/v1/config/spec":
endpoint.GetResponse = &specResponseJson{}
endpoint.GetResponse = &SpecResponseJson{}
case "/eth/v1/events":
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleEvents}
case "/eth/v1/validator/duties/attester/{epoch}":
endpoint.PostRequest = &dutiesRequestJson{}
endpoint.PostResponse = &attesterDutiesResponseJson{}
endpoint.PostRequest = &DutiesRequestJson{}
endpoint.PostResponse = &AttesterDutiesResponseJson{}
endpoint.RequestURLLiterals = []string{"epoch"}
endpoint.Err = &nodeSyncDetailsErrorJson{}
endpoint.Err = &NodeSyncDetailsErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapValidatorIndicesArray,
}
case "/eth/v1/validator/duties/proposer/{epoch}":
endpoint.GetResponse = &proposerDutiesResponseJson{}
endpoint.GetResponse = &ProposerDutiesResponseJson{}
endpoint.RequestURLLiterals = []string{"epoch"}
endpoint.Err = &nodeSyncDetailsErrorJson{}
endpoint.Err = &NodeSyncDetailsErrorJson{}
case "/eth/v1/validator/duties/sync/{epoch}":
endpoint.PostRequest = &dutiesRequestJson{}
endpoint.PostResponse = &syncCommitteeDutiesResponseJson{}
endpoint.PostRequest = &DutiesRequestJson{}
endpoint.PostResponse = &SyncCommitteeDutiesResponseJson{}
endpoint.RequestURLLiterals = []string{"epoch"}
endpoint.Err = &nodeSyncDetailsErrorJson{}
endpoint.Err = &NodeSyncDetailsErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapValidatorIndicesArray,
}
case "/eth/v1/validator/blocks/{slot}":
endpoint.GetResponse = &produceBlockResponseJson{}
endpoint.GetResponse = &ProduceBlockResponseJson{}
endpoint.RequestURLLiterals = []string{"slot"}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "randao_reveal", Hex: true}, {Name: "graffiti", Hex: true}}
case "/eth/v2/validator/blocks/{slot}":
endpoint.GetResponse = &produceBlockResponseV2Json{}
endpoint.GetResponse = &ProduceBlockResponseV2Json{}
endpoint.RequestURLLiterals = []string{"slot"}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "randao_reveal", Hex: true}, {Name: "graffiti", Hex: true}}
endpoint.Hooks = apimiddleware.HookCollection{
@@ -229,7 +229,7 @@ func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, er
}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleProduceBlockSSZ}
case "/eth/v1/validator/blinded_blocks/{slot}":
endpoint.GetResponse = &produceBlindedBlockResponseJson{}
endpoint.GetResponse = &ProduceBlindedBlockResponseJson{}
endpoint.RequestURLLiterals = []string{"slot"}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "randao_reveal", Hex: true}, {Name: "graffiti", Hex: true}}
endpoint.Hooks = apimiddleware.HookCollection{
@@ -237,43 +237,43 @@ func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, er
}
endpoint.CustomHandlers = []apimiddleware.CustomHandler{handleProduceBlindedBlockSSZ}
case "/eth/v1/validator/attestation_data":
endpoint.GetResponse = &produceAttestationDataResponseJson{}
endpoint.GetResponse = &ProduceAttestationDataResponseJson{}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "slot"}, {Name: "committee_index"}}
case "/eth/v1/validator/aggregate_attestation":
endpoint.GetResponse = &aggregateAttestationResponseJson{}
endpoint.GetResponse = &AggregateAttestationResponseJson{}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "attestation_data_root", Hex: true}, {Name: "slot"}}
case "/eth/v1/validator/beacon_committee_subscriptions":
endpoint.PostRequest = &submitBeaconCommitteeSubscriptionsRequestJson{}
endpoint.Err = &nodeSyncDetailsErrorJson{}
endpoint.PostRequest = &SubmitBeaconCommitteeSubscriptionsRequestJson{}
endpoint.Err = &NodeSyncDetailsErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapBeaconCommitteeSubscriptionsArray,
}
case "/eth/v1/validator/sync_committee_subscriptions":
endpoint.PostRequest = &submitSyncCommitteeSubscriptionRequestJson{}
endpoint.Err = &nodeSyncDetailsErrorJson{}
endpoint.PostRequest = &SubmitSyncCommitteeSubscriptionRequestJson{}
endpoint.Err = &NodeSyncDetailsErrorJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapSyncCommitteeSubscriptionsArray,
}
case "/eth/v1/validator/aggregate_and_proofs":
endpoint.PostRequest = &submitAggregateAndProofsRequestJson{}
endpoint.PostRequest = &SubmitAggregateAndProofsRequestJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapSignedAggregateAndProofArray,
}
case "/eth/v1/validator/sync_committee_contribution":
endpoint.GetResponse = &produceSyncCommitteeContributionResponseJson{}
endpoint.GetResponse = &ProduceSyncCommitteeContributionResponseJson{}
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "slot"}, {Name: "subcommittee_index"}, {Name: "beacon_block_root", Hex: true}}
case "/eth/v1/validator/contribution_and_proofs":
endpoint.PostRequest = &submitContributionAndProofsRequestJson{}
endpoint.PostRequest = &SubmitContributionAndProofsRequestJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapSignedContributionAndProofsArray,
}
case "/eth/v1/validator/prepare_beacon_proposer":
endpoint.PostRequest = &feeRecipientsRequestJSON{}
endpoint.PostRequest = &FeeRecipientsRequestJSON{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapFeeRecipientsArray,
}
case "/eth/v1/validator/register_validator":
endpoint.PostRequest = &signedValidatorRegistrationsRequestJson{}
endpoint.PostRequest = &SignedValidatorRegistrationsRequestJson{}
endpoint.Hooks = apimiddleware.HookCollection{
OnPreDeserializeRequestBodyIntoContainer: wrapSignedValidatorRegistrationsArray,
}

File diff suppressed because it is too large Load Diff