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
5 changes: 4 additions & 1 deletion api/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ go_library(
],
importpath = "github.com/OffchainLabs/prysm/v6/api/client",
visibility = ["//visibility:public"],
deps = ["@com_github_pkg_errors//:go_default_library"],
deps = [
"//api:go_default_library",
"@com_github_pkg_errors//:go_default_library",
],
)

go_test(
Expand Down
1 change: 1 addition & 0 deletions api/client/beacon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
importpath = "github.com/OffchainLabs/prysm/v6/api/client/beacon",
visibility = ["//visibility:public"],
deps = [
"//api:go_default_library",
"//api/client:go_default_library",
"//api/server:go_default_library",
"//api/server/structs:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion api/client/beacon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"regexp"
"strconv"

"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/client"
"github.com/OffchainLabs/prysm/v6/api/server"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
Expand Down Expand Up @@ -273,7 +274,7 @@ func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*stru
if err != nil {
return errors.Wrap(err, "invalid format, failed to create new POST request object")
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set(api.ContentTypeHeader, api.JsonMediaType)
resp, err := c.Do(req)
if err != nil {
return err
Expand Down
36 changes: 18 additions & 18 deletions api/client/builder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *Client) do(ctx context.Context, method string, path string, body io.Rea
if err != nil {
return
}
req.Header.Add("User-Agent", version.BuildData())
req.Header.Add(api.UserAgentHeader, version.BuildData())
for _, o := range opts {
o(req)
}
Expand Down Expand Up @@ -232,11 +232,11 @@ func (c *Client) GetHeader(ctx context.Context, slot primitives.Slot, parentHash
var getOpts reqOption
if c.sszEnabled {
getOpts = func(r *http.Request) {
r.Header.Set("Accept", api.OctetStreamMediaType)
r.Header.Set(api.AcceptHeader, api.OctetStreamMediaType)
}
} else {
getOpts = func(r *http.Request) {
r.Header.Set("Accept", api.JsonMediaType)
r.Header.Set(api.AcceptHeader, api.JsonMediaType)
}
}
data, header, err := c.do(ctx, http.MethodGet, path, nil, http.StatusOK, getOpts)
Expand All @@ -259,8 +259,8 @@ func (c *Client) GetHeader(ctx context.Context, slot primitives.Slot, parentHash

func (c *Client) parseHeaderResponse(data []byte, header http.Header, slot primitives.Slot) (SignedBid, error) {
var versionHeader string
if c.sszEnabled || header.Get(api.VersionHeader) != "" {
versionHeader = header.Get(api.VersionHeader)
if c.sszEnabled || header.Get(api.EthConsensusVersionHeader) != "" {
versionHeader = header.Get(api.EthConsensusVersionHeader)
} else {
// If we don't have a version header, attempt to parse JSON for version
v := &VersionResponse{}
Expand Down Expand Up @@ -390,8 +390,8 @@ func (c *Client) RegisterValidator(ctx context.Context, svr []*ethpb.SignedValid
)
if c.sszEnabled {
postOpts = func(r *http.Request) {
r.Header.Set("Content-Type", api.OctetStreamMediaType)
r.Header.Set("Accept", api.OctetStreamMediaType)
r.Header.Set(api.ContentTypeHeader, api.OctetStreamMediaType)
r.Header.Set(api.AcceptHeader, api.OctetStreamMediaType)
}
body, err = sszValidatorRegisterRequest(svr)
if err != nil {
Expand All @@ -401,8 +401,8 @@ func (c *Client) RegisterValidator(ctx context.Context, svr []*ethpb.SignedValid
}
} else {
postOpts = func(r *http.Request) {
r.Header.Set("Content-Type", api.JsonMediaType)
r.Header.Set("Accept", api.JsonMediaType)
r.Header.Set(api.ContentTypeHeader, api.JsonMediaType)
r.Header.Set(api.AcceptHeader, api.JsonMediaType)
}
body, err = jsonValidatorRegisterRequest(svr)
if err != nil {
Expand Down Expand Up @@ -446,7 +446,7 @@ func sszValidatorRegisterRequest(svr []*ethpb.SignedValidatorRegistrationV1) ([]
return ssz, nil
}

var errResponseVersionMismatch = errors.New("builder API response uses a different version than requested in " + api.VersionHeader + " header")
var errResponseVersionMismatch = errors.New("builder API response uses a different version than requested in " + api.EthConsensusVersionHeader + " header")

func getVersionsBlockToPayload(blockVersion int) (int, error) {
if blockVersion >= version.Fulu {
Expand Down Expand Up @@ -525,7 +525,7 @@ func (c *Client) SubmitBlindedBlockPostFulu(ctx context.Context, sb interfaces.R
func (c *Client) checkBlockVersion(respBytes []byte, header http.Header) (int, error) {
var versionHeader string
if c.sszEnabled {
versionHeader = strings.ToLower(header.Get(api.VersionHeader))
versionHeader = strings.ToLower(header.Get(api.EthConsensusVersionHeader))
} else {
// fallback to JSON-based version extraction
v := &VersionResponse{}
Expand Down Expand Up @@ -555,9 +555,9 @@ func (c *Client) buildBlindedBlockRequest(sb interfaces.ReadOnlySignedBeaconBloc
return nil, nil, errors.Wrap(err, "could not marshal SSZ for blinded block")
}
opt := func(r *http.Request) {
r.Header.Set(api.VersionHeader, version.String(sb.Version()))
r.Header.Set("Content-Type", api.OctetStreamMediaType)
r.Header.Set("Accept", api.OctetStreamMediaType)
r.Header.Set(api.EthConsensusVersionHeader, version.String(sb.Version()))
r.Header.Set(api.ContentTypeHeader, api.OctetStreamMediaType)
r.Header.Set(api.AcceptHeader, api.OctetStreamMediaType)
}
return body, opt, nil
}
Expand All @@ -571,9 +571,9 @@ func (c *Client) buildBlindedBlockRequest(sb interfaces.ReadOnlySignedBeaconBloc
return nil, nil, errors.Wrap(err, "error marshaling blinded block to JSON")
}
opt := func(r *http.Request) {
r.Header.Set(api.VersionHeader, version.String(sb.Version()))
r.Header.Set("Content-Type", api.JsonMediaType)
r.Header.Set("Accept", api.JsonMediaType)
r.Header.Set(api.EthConsensusVersionHeader, version.String(sb.Version()))
r.Header.Set(api.ContentTypeHeader, api.JsonMediaType)
r.Header.Set(api.AcceptHeader, api.JsonMediaType)
}
return body, opt, nil
}
Expand Down Expand Up @@ -676,7 +676,7 @@ func (c *Client) parseBlindedBlockResponseJSON(
// happy path, and an error with information about the server response body for a non-200 response.
func (c *Client) Status(ctx context.Context) error {
getOpts := func(r *http.Request) {
r.Header.Set("Accept", api.JsonMediaType)
r.Header.Set(api.AcceptHeader, api.JsonMediaType)
}
_, _, err := c.do(ctx, http.MethodGet, getStatus, nil, http.StatusOK, getOpts)
return err
Expand Down
Loading
Loading