Skip to content

Commit

Permalink
Merge branch 'develop' into electra
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Jan 13, 2025
2 parents 285a77d + c574ad2 commit 76b1e91
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 31 deletions.
30 changes: 30 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# General settings
BOOST_LISTEN_ADDR=localhost:18550 # Listen address for mev-boost server

# Logging and debugging settings
LOG_JSON=false # Set to true to log in JSON format instead of text
DEBUG=false # Set to true to enable debug mode (shorthand for '--loglevel debug')
LOG_LEVEL=info # Log level: trace, debug, info, warn/warning, error, fatal, panic
LOG_SERVICE_TAG= # Optional: add a 'service=...' tag to all log messages
DISABLE_LOG_VERSION=false # Set to true to disable logging the version

# Genesis settings
GENESIS_FORK_VERSION= # Custom genesis fork version (optional)
GENESIS_TIMESTAMP=-1 # Custom genesis timestamp (in unix seconds)
MAINNET=true # Set to true to use Mainnet
SEPOLIA=false # Set to true to use Sepolia network
HOLESKY=false # Set to true to use Holesky network

# Relay settings
RELAYS= # Relay URLs: single entry or comma-separated list (scheme://pubkey@host)
RELAY_MONITORS= # Relay monitor URLs: single entry or comma-separated list (scheme://host)
MIN_BID_ETH=0 # Minimum bid to accept from a relay (in ETH)
RELAY_STARTUP_CHECK=false # Set to true to check relay status on startup and on status API call

# Relay timeout settings (in ms)
RELAY_TIMEOUT_MS_GETHEADER=950 # Timeout for getHeader requests to the relay (in ms)
RELAY_TIMEOUT_MS_GETPAYLOAD=4000 # Timeout for getPayload requests to the relay (in ms)
RELAY_TIMEOUT_MS_REGVAL=3000 # Timeout for registerValidator requests (in ms)

# Retry settings
REQUEST_MAX_RETRIES=5 # Maximum number of retries for a relay get payload request
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
run: go install mvdan.cc/gofumpt@v0.6.0

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
run: go install honnef.co/go/tools/cmd/staticcheck@v0.5.1

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2

- name: Lint
run: make lint
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
.vscode/
/README.internal.md
/validator_data.json
/build/
/build/

# Environemnt variable files
.env*
!.env.example

20 changes: 9 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ linters:
- gocritic
- godot
- godox
- gomnd
- lll
- mnd
- nlreturn
- nonamedreturns
- nosnakecase
- paralleltest
- testpackage
- varnamelen
Expand All @@ -40,20 +39,19 @@ linters:
- contextcheck
- rowserrcheck
- sqlclosecheck
- structcheck
- wastedassign

#
# Disabled because deprecated:
#
- deadcode
- exhaustivestruct
- golint
- ifshort
- interfacer
- maligned
- scopelint
- varcheck
- copyloopvar

#
# Disabled due to versioning:
#
- intrange
- exportloopref


linters-settings:
gofumpt:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test-cli is a utility to run through all the proposer requests against mev-boost

Mergemock is fully integrated: /~https://github.com/protolambda/mergemock

Make sure you've setup and built mergemock first, refer to its [README](/~https://github.com/flashbots/mergemock#quick-start) but here's a quick setup guide:
Make sure you've setup and built mergemock first, refer to its [README](/~https://github.com/protolambda/mergemock/blob/master/README.md) but here's a quick setup guide:

```bash
git clone /~https://github.com/protolambda/mergemock.git
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func setupGenesis(cmd *cli.Command) (string, uint64) {
)

switch {
case cmd.Bool(customGenesisForkFlag.Name):
case cmd.IsSet(customGenesisForkFlag.Name):
genesisForkVersion = cmd.String(customGenesisForkFlag.Name)
case cmd.Bool(sepoliaFlag.Name):
genesisForkVersion = genesisForkVersionSepolia
Expand Down
2 changes: 1 addition & 1 deletion server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (m *BoostService) handleRoot(w http.ResponseWriter, _ *http.Request) {
// handleStatus sends calls to the status endpoint of every relay.
// It returns OK if at least one returned OK, and returns error otherwise.
func (m *BoostService) handleStatus(w http.ResponseWriter, _ *http.Request) {
w.Header().Set(HeaderKeyVersion, config.Version)
w.Header().Set(HeaderKeyVersion, config.Version) //nolint:canonicalheader // we use a non-canonical header

Check failure on line 235 in server/service.go

View workflow job for this annotation

GitHub Actions / Lint

directive `//nolint:canonicalheader // we use a non-canonical header` is unused for linter "canonicalheader" (nolintlint)
if !m.relayCheck || m.CheckRelays() > 0 {
m.respondOK(w, nilResponse)
} else {
Expand Down
22 changes: 11 additions & 11 deletions server/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TestStatus(t *testing.T) {
rr := backend.request(t, http.MethodGet, path, nil)

require.Equal(t, http.StatusOK, rr.Code)
require.Greater(t, len(rr.Header().Get("X-MEVBoost-Version")), 0) //nolint:testifylint
require.NotEmpty(t, rr.Header().Get("X-MEVBoost-Version")) //nolint:canonicalheader // we use a non-canonical header

Check failure on line 245 in server/service_test.go

View workflow job for this annotation

GitHub Actions / Lint

directive `//nolint:canonicalheader // we use a non-canonical header` is unused for linter "canonicalheader" (nolintlint)
require.Equal(t, 1, backend.relays[0].GetRequestCount(path))
})

Expand All @@ -254,7 +254,7 @@ func TestStatus(t *testing.T) {
rr := backend.request(t, http.MethodGet, path, nil)

require.Equal(t, http.StatusServiceUnavailable, rr.Code)
require.Greater(t, len(rr.Header().Get("X-MEVBoost-Version")), 0) //nolint:testifylint
require.NotEmpty(t, rr.Header().Get("X-MEVBoost-Version")) //nolint:canonicalheader // we use a non-canonical header

Check failure on line 257 in server/service_test.go

View workflow job for this annotation

GitHub Actions / Lint

directive `//nolint:canonicalheader // we use a non-canonical header` is unused for linter "canonicalheader" (nolintlint)
require.Equal(t, 0, backend.relays[0].GetRequestCount(path))
})
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestRegisterValidator(t *testing.T) {
w.WriteHeader(http.StatusBadRequest)
})
rr = backend.request(t, http.MethodPost, path, payload)
require.Equal(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadGateway, rr.Code)
require.Equal(t, 3, backend.relays[0].GetRequestCount(path))
require.Equal(t, 3, backend.relays[1].GetRequestCount(path))
Expand All @@ -319,7 +319,7 @@ func TestRegisterValidator(t *testing.T) {
// Now make the relay return slowly, mev-boost should return an error
backend.relays[0].ResponseDelay = 180 * time.Millisecond
rr = backend.request(t, http.MethodPost, path, payload)
require.Equal(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadGateway, rr.Code)
require.Equal(t, 2, backend.relays[0].GetRequestCount(path))
})
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestGetHeader(t *testing.T) {

backend := newTestBackend(t, 1, time.Second)
rr := backend.request(t, http.MethodGet, invalidSlotPath, nil)
require.Equal(t, `{"code":400,"message":"invalid slot"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":400,"message":"invalid slot"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadRequest, rr.Code, rr.Body.String())
require.Equal(t, 0, backend.relays[0].GetRequestCount(path))
})
Expand All @@ -444,7 +444,7 @@ func TestGetHeader(t *testing.T) {

backend := newTestBackend(t, 1, time.Second)
rr := backend.request(t, http.MethodGet, invalidPubkeyPath, nil)
require.Equal(t, `{"code":400,"message":"invalid pubkey"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":400,"message":"invalid pubkey"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadRequest, rr.Code, rr.Body.String())
require.Equal(t, 0, backend.relays[0].GetRequestCount(path))
})
Expand All @@ -454,7 +454,7 @@ func TestGetHeader(t *testing.T) {

backend := newTestBackend(t, 1, time.Second)
rr := backend.request(t, http.MethodGet, invalidSlotPath, nil)
require.Equal(t, `{"code":400,"message":"invalid hash"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":400,"message":"invalid hash"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadRequest, rr.Code, rr.Body.String())
require.Equal(t, 0, backend.relays[0].GetRequestCount(path))
})
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestGetPayload(t *testing.T) {
rr = backend.request(t, http.MethodPost, path, payload)
require.Equal(t, 1, backend.relays[0].GetRequestCount(path))
require.Equal(t, 1, backend.relays[1].GetRequestCount(path))
require.Equal(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadGateway, rr.Code, rr.Body.String())
})

Expand All @@ -718,7 +718,7 @@ func TestGetPayload(t *testing.T) {
} else {
w.WriteHeader(http.StatusInternalServerError)
_, err := w.Write([]byte(`{"code":500,"message":"internal server error"}`))
require.NoError(t, err)
require.NoError(t, err, "failed to write error response") //nolint:testifylint // if we fail here the test is compromised
}
count++
})
Expand All @@ -740,12 +740,12 @@ func TestGetPayload(t *testing.T) {
} else {
w.WriteHeader(http.StatusInternalServerError)
_, err := w.Write([]byte(`{"code":500,"message":"internal server error"}`))
require.NoError(t, err)
require.NoError(t, err, "failed to write error response") //nolint:testifylint // if we fail here the test is compromised
}
})
rr := backend.request(t, http.MethodPost, path, payload)
require.Equal(t, 5, backend.relays[0].GetRequestCount(path))
require.Equal(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.JSONEq(t, `{"code":502,"message":"no successful relay response"}`+"\n", rr.Body.String())
require.Equal(t, http.StatusBadGateway, rr.Code, rr.Body.String())
})
}
Expand Down
6 changes: 3 additions & 3 deletions server/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestSendHTTPRequestUserAgent(t *testing.T) {
customUA := "test-user-agent"
expectedUA := fmt.Sprintf("mev-boost/%s %s", config.Version, customUA)
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
require.Equal(t, expectedUA, r.Header.Get("User-Agent"))
require.Equal(t, expectedUA, r.Header.Get("User-Agent")) //nolint:testifylint // if we fail here the test has failed
done <- true
}))
code, err := SendHTTPRequest(context.Background(), *http.DefaultClient, http.MethodGet, ts.URL, UserAgent(customUA), nil, nil, nil)
Expand All @@ -58,7 +58,7 @@ func TestSendHTTPRequestUserAgent(t *testing.T) {
// Test without custom UA
expectedUA = fmt.Sprintf("mev-boost/%s", config.Version)
ts = httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
require.Equal(t, expectedUA, r.Header.Get("User-Agent"))
require.Equal(t, expectedUA, r.Header.Get("User-Agent")) //nolint:testifylint // if we fail here the test has failed
done <- true
}))
code, err = SendHTTPRequest(context.Background(), *http.DefaultClient, http.MethodGet, ts.URL, "", nil, nil, nil)
Expand All @@ -77,7 +77,7 @@ func TestSendHTTPRequestGzip(t *testing.T) {
require.NoError(t, zw.Close())

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "gzip", r.Header.Get("Accept-Encoding"))
require.Equal(t, "gzip", r.Header.Get("Accept-Encoding")) //nolint:testifylint // if this fails the test is invalid
w.Header().Set("Content-Encoding", "gzip")
_, _ = w.Write(buf.Bytes())
}))
Expand Down

0 comments on commit 76b1e91

Please sign in to comment.