Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions beaconclient/mock_beacon_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ func (c *MockBeaconInstance) GetSpec() (spec *GetSpecResponse, err error) {
return nil, nil
}

func (c *MockBeaconInstance) GetSpecRaw() (map[string]interface{}, error) {
return map[string]interface{}{
"SECONDS_PER_SLOT": "12",
"SLOTS_PER_EPOCH": "32",
}, nil
}

func (c *MockBeaconInstance) GetForkSchedule() (spec *GetForkScheduleResponse, err error) {
return nil, nil
}
Expand Down
7 changes: 7 additions & 0 deletions beaconclient/mock_multi_beacon_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ func (*MockMultiBeaconClient) GetSpec() (spec *GetSpecResponse, err error) {
return nil, nil
}

func (*MockMultiBeaconClient) GetSpecRaw() (map[string]interface{}, error) {
return map[string]interface{}{
"SECONDS_PER_SLOT": "12",
"SLOTS_PER_EPOCH": "32",
}, nil
}

func (*MockMultiBeaconClient) GetForkSchedule() (spec *GetForkScheduleResponse, err error) {
resp := &GetForkScheduleResponse{
Data: []struct {
Expand Down
19 changes: 19 additions & 0 deletions beaconclient/multi_beacon_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type IMultiBeaconClient interface {
PublishBlock(block *common.VersionedSignedProposal) (code int, err error)
GetGenesis() (*GetGenesisResponse, error)
GetSpec() (spec *GetSpecResponse, err error)
GetSpecRaw() (map[string]interface{}, error)
GetForkSchedule() (spec *GetForkScheduleResponse, err error)
GetRandao(slot uint64) (spec *GetRandaoResponse, err error)
GetWithdrawals(slot uint64) (spec *GetWithdrawalsResponse, err error)
Expand All @@ -59,6 +60,7 @@ type IBeaconInstance interface {
PublishBlock(block *common.VersionedSignedProposal, broadcastMode BroadcastMode) (code int, err error)
GetGenesis() (*GetGenesisResponse, error)
GetSpec() (spec *GetSpecResponse, err error)
GetSpecRaw() (map[string]interface{}, error)
GetForkSchedule() (spec *GetForkScheduleResponse, err error)
GetRandao(slot uint64) (spec *GetRandaoResponse, err error)
GetWithdrawals(slot uint64) (spec *GetWithdrawalsResponse, err error)
Expand Down Expand Up @@ -349,6 +351,23 @@ func (c *MultiBeaconClient) GetSpec() (spec *GetSpecResponse, err error) {
return nil, err
}

// GetSpecRaw returns the complete beacon spec as raw JSON
func (c *MultiBeaconClient) GetSpecRaw() (map[string]interface{}, error) {
clients := c.beaconInstancesByLastResponse()
for _, client := range clients {
log := c.log.WithField("uri", client.GetURI())
if spec, err := client.GetSpecRaw(); err != nil {
log.WithError(err).Warn("failed to get spec as raw JSON")
continue
} else {
return spec, nil
}
}

c.log.Error("failed to get spec as raw JSON on any CL node")
return nil, ErrBeaconNodesUnavailable
}

// GetForkSchedule - https://ethereum.github.io/beacon-APIs/#/Config/getForkSchedule
func (c *MultiBeaconClient) GetForkSchedule() (spec *GetForkScheduleResponse, err error) {
clients := c.beaconInstancesByLastResponse()
Expand Down
8 changes: 8 additions & 0 deletions beaconclient/prod_beacon_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ func (c *ProdBeaconInstance) GetSpec() (spec *GetSpecResponse, err error) {
return resp, err
}

// GetSpecRaw fetches the complete beacon spec configuration as raw JSON
func (c *ProdBeaconInstance) GetSpecRaw() (map[string]interface{}, error) {
uri := c.beaconURI + "/eth/v1/config/spec"
var rawSpec map[string]interface{}
_, err := fetchBeacon(http.MethodGet, uri, nil, &rawSpec, nil, http.Header{}, false)
return rawSpec, err
}

type GetForkScheduleResponse struct {
Data []struct {
PreviousVersion string `json:"previous_version"`
Expand Down
2 changes: 1 addition & 1 deletion common/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint25
}
}

getHeaderResponse, err = BuildGetHeaderResponse(payload, &relaySk, &relayPk, domain)
getHeaderResponse, err = BuildGetHeaderResponse(payload, &relaySk, &relayPk, domain, nil)
require.NoError(t, err)

getPayloadResponse, err = BuildGetPayloadResponse(payload)
Expand Down
Loading