From e42adde0b235c51e9f44d6eb1c21501266050733 Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Wed, 28 Feb 2024 09:09:58 +0100 Subject: [PATCH] update to go v1.22 --- .github/workflows/lint.yml | 2 +- .github/workflows/release.yaml | 4 ++-- .github/workflows/tests.yml | 2 +- .golangci.yml | 1 + Dockerfile | 2 +- Makefile | 1 + cmd/test-cli/main.go | 1 - go.mod | 2 +- server/errors.go | 6 +++--- server/service_test.go | 10 +++++----- server/utils_test.go | 4 ++-- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c77a1426..7fe49694 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: ^1.21.0 + go-version: ^1.22.0 id: go - name: Ensure go mod tidy runs without changes diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9a84b323..959e65c1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -71,7 +71,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: ^1.21 + go-version: ^1.22 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3 with: @@ -101,7 +101,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: ^1.21 + go-version: ^1.22 - name: Make directories run: | mkdir -p ./build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c6ed73c..5d69e5db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: ^1.21 + go-version: ^1.22 id: go - name: Checkout sources diff --git a/.golangci.yml b/.golangci.yml index 52baf613..074ca1ca 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,6 +31,7 @@ linters: - ireturn - noctx - tagliatelle + - perfsprint # # Disabled because of generics: diff --git a/Dockerfile b/Dockerfile index c2487cee..32477fb6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM golang:1.21 as builder +FROM golang:1.22 as builder ARG VERSION WORKDIR /build diff --git a/Makefile b/Makefile index a5ccd47e..06fc69fe 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ v: .PHONY: build build: + @go version CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o mev-boost .PHONY: build-testcli diff --git a/cmd/test-cli/main.go b/cmd/test-cli/main.go index f9ec4f58..e249af91 100644 --- a/cmd/test-cli/main.go +++ b/cmd/test-cli/main.go @@ -36,7 +36,6 @@ func doRegisterValidator(v validatorPrivateData, boostEndpoint string, builderSi log.WithError(err).Fatal("Could not prepare registration message") } _, err = server.SendHTTPRequest(context.TODO(), *http.DefaultClient, http.MethodPost, boostEndpoint+"/eth/v1/builder/validators", "test-cli", nil, message, nil) - if err != nil { log.WithError(err).Fatal("Validator registration not successful") } diff --git a/go.mod b/go.mod index f6d36d87..d01f0998 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/flashbots/mev-boost -go 1.21 +go 1.22 require ( github.com/ethereum/go-ethereum v1.13.10 diff --git a/server/errors.go b/server/errors.go index 7a75a9e5..a9757b38 100644 --- a/server/errors.go +++ b/server/errors.go @@ -1,9 +1,9 @@ package server -import "fmt" +import "errors" // ErrMissingRelayPubkey is returned if a new RelayEntry URL has no public key. -var ErrMissingRelayPubkey = fmt.Errorf("missing relay public key") +var ErrMissingRelayPubkey = errors.New("missing relay public key") // ErrPointAtInfinityPubkey is returned if a new RelayEntry URL has an all-zero public key. -var ErrPointAtInfinityPubkey = fmt.Errorf("relay public key cannot be the point-at-infinity") +var ErrPointAtInfinityPubkey = errors.New("relay public key cannot be the point-at-infinity") diff --git a/server/service_test.go b/server/service_test.go index 72bcfade..33b2438e 100644 --- a/server/service_test.go +++ b/server/service_test.go @@ -207,7 +207,7 @@ func TestWebserverMaxHeaderSize(t *testing.T) { backend.boost.listenAddr = addr go func() { err := backend.boost.StartHTTPServer() - require.NoError(t, err) + require.NoError(t, err) //nolint:testifylint }() time.Sleep(time.Millisecond * 100) path := "http://" + addr + "?" + strings.Repeat("abc", 4000) // path with characters of size over 4kb @@ -275,7 +275,7 @@ func TestRegisterValidator(t *testing.T) { require.Equal(t, 1, backend.relays[1].GetRequestCount(path)) // Now make one relay return an error - backend.relays[0].overrideHandleRegisterValidator(func(w http.ResponseWriter, r *http.Request) { + backend.relays[0].overrideHandleRegisterValidator(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusBadRequest) }) rr = backend.request(t, http.MethodPost, path, payload) @@ -284,7 +284,7 @@ func TestRegisterValidator(t *testing.T) { require.Equal(t, 2, backend.relays[1].GetRequestCount(path)) // Now make both relays return an error - which should cause the request to fail - backend.relays[1].overrideHandleRegisterValidator(func(w http.ResponseWriter, r *http.Request) { + backend.relays[1].overrideHandleRegisterValidator(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusBadRequest) }) rr = backend.request(t, http.MethodPost, path, payload) @@ -688,7 +688,7 @@ func TestGetPayload(t *testing.T) { backend := newTestBackend(t, 1, 2*time.Second) count := 0 - backend.relays[0].handlerOverrideGetPayload = func(w http.ResponseWriter, r *http.Request) { + backend.relays[0].handlerOverrideGetPayload = func(w http.ResponseWriter, _ *http.Request) { if count > 0 { // success response on the second attempt backend.relays[0].defaultHandleGetPayload(w) @@ -709,7 +709,7 @@ func TestGetPayload(t *testing.T) { count := 0 maxRetries := 5 - backend.relays[0].handlerOverrideGetPayload = func(w http.ResponseWriter, r *http.Request) { + backend.relays[0].handlerOverrideGetPayload = func(w http.ResponseWriter, _ *http.Request) { count++ if count > maxRetries { // success response after max retry attempts diff --git a/server/utils_test.go b/server/utils_test.go index 636eaa3c..3ae76f68 100644 --- a/server/utils_test.go +++ b/server/utils_test.go @@ -46,7 +46,7 @@ func TestSendHTTPRequestUserAgent(t *testing.T) { // Test with custom UA customUA := "test-user-agent" expectedUA := fmt.Sprintf("mev-boost/%s %s", config.Version, customUA) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { require.Equal(t, expectedUA, r.Header.Get("User-Agent")) done <- true })) @@ -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(w http.ResponseWriter, r *http.Request) { + ts = httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { require.Equal(t, expectedUA, r.Header.Get("User-Agent")) done <- true }))