Skip to content

Commit

Permalink
Remove allBidsWereJSON logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Feb 17, 2025
1 parent 14442d1 commit 1fcd5ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
17 changes: 0 additions & 17 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,6 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
proposerPreferredContentType = MediaTypeJSON
}

// If every relay returned the bid in JSON, that means that none
// of them support SSZ and this would always require extra conversions.
// In this situation, if the proposer still accepts JSON, respond to the
// getHeader in JSON so the proposer sends the getPayload request in JSON.
allBidsWereJSON := true
for _, relay := range result.relays {
if relay.SupportsSSZ {
log.Debug("there is a relay that supports SSZ")
allBidsWereJSON = false
break
}
}
if proposerPreferredContentType != MediaTypeJSON && allBidsWereJSON && parsedProposerAcceptContentTypes.Accepts(MediaTypeJSON) {
log.Debug("overriding the response content type to be JSON")
proposerPreferredContentType = MediaTypeJSON
}

// Respond appropriately
if proposerPreferredContentType == MediaTypeJSON {
log.Debug("responding with JSON")
Expand Down
8 changes: 4 additions & 4 deletions server/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func TestGetHeader(t *testing.T) {
require.Equal(t, MediaTypeOctetStream, rr.Header().Get(HeaderContentType))
})

t.Run("One relay returns JSON, mev-boost returns JSON", func(t *testing.T) {
t.Run("One relay returns JSON, mev-boost returns preferred SSZ", func(t *testing.T) {
header := make(http.Header)
header.Set(HeaderEthConsensusVersion, "deneb")
header.Set(HeaderAccept, "application/octet-stream;q=1.0,application/json;q=0.9")
Expand All @@ -370,10 +370,10 @@ func TestGetHeader(t *testing.T) {
rr := backend.request(t, http.MethodGet, path, header, nil)
require.Equal(t, http.StatusOK, rr.Code, rr.Body.String())
require.Equal(t, 1, backend.relays[0].GetRequestCount(path))
require.Equal(t, MediaTypeJSON, rr.Header().Get(HeaderContentType)) //nolint:testifylint
require.Equal(t, MediaTypeOctetStream, rr.Header().Get(HeaderContentType)) //nolint:testifylint

Check failure on line 373 in server/service_test.go

View workflow job for this annotation

GitHub Actions / Lint

directive `//nolint:testifylint` is unused for linter "testifylint" (nolintlint)
})

t.Run("Two relays return JSON, mev-boost returns JSON", func(t *testing.T) {
t.Run("Two relays return JSON, mev-boost returns preferred SSZ", func(t *testing.T) {
header := make(http.Header)
header.Set(HeaderEthConsensusVersion, "deneb")
header.Set(HeaderAccept, "application/octet-stream;q=1.0,application/json;q=0.9")
Expand All @@ -385,7 +385,7 @@ func TestGetHeader(t *testing.T) {
require.Equal(t, http.StatusOK, rr.Code, rr.Body.String())
require.Equal(t, 1, backend.relays[0].GetRequestCount(path))
require.Equal(t, 1, backend.relays[1].GetRequestCount(path))
require.Equal(t, MediaTypeJSON, rr.Header().Get(HeaderContentType)) //nolint:testifylint
require.Equal(t, MediaTypeOctetStream, rr.Header().Get(HeaderContentType)) //nolint:testifylint

Check failure on line 388 in server/service_test.go

View workflow job for this annotation

GitHub Actions / Lint

directive `//nolint:testifylint` is unused for linter "testifylint" (nolintlint)
})

t.Run("Accepts both with Q values", func(t *testing.T) {
Expand Down

0 comments on commit 1fcd5ff

Please sign in to comment.