From 2204da61349a6c475d2b1f19996e1197488f3e83 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Fri, 23 Sep 2022 09:06:15 -0500 Subject: [PATCH] Add gofumpt to lint checks --- Makefile | 1 + cli/main.go | 3 +-- cmd/test-cli/beacon.go | 2 +- cmd/test-cli/main.go | 7 +++---- cmd/test-cli/requests.go | 2 +- cmd/test-cli/validator.go | 2 +- server/errors.go | 6 ++---- server/service.go | 7 ++++--- server/service_test.go | 2 +- server/utils.go | 4 ++-- 10 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 4aac3f28..fdcc24f1 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ test-race: .PHONY: lint lint: + gofumpt -d -extra . revive -set_exit_status ./... go vet ./... staticcheck ./... diff --git a/cli/main.go b/cli/main.go index c11e0477..0f4a7bc9 100644 --- a/cli/main.go +++ b/cli/main.go @@ -77,7 +77,6 @@ func Main() { log.Logger.SetFormatter(&logrus.TextFormatter{ FullTimestamp: true, }) - } if *logDebug { @@ -150,7 +149,7 @@ func Main() { log.Fatal(server.StartHTTPServer()) } -func getEnv(key string, defaultValue string) string { +func getEnv(key, defaultValue string) string { if value, ok := os.LookupEnv(key); ok { return value } diff --git a/cmd/test-cli/beacon.go b/cmd/test-cli/beacon.go index 9b211cb5..e96490ca 100644 --- a/cmd/test-cli/beacon.go +++ b/cmd/test-cli/beacon.go @@ -20,7 +20,7 @@ type beaconBlockData struct { BlockHash common.Hash } -func createBeacon(isMergemock bool, beaconEndpoint string, engineEndpoint string) Beacon { +func createBeacon(isMergemock bool, beaconEndpoint, engineEndpoint string) Beacon { if isMergemock { return &MergemockBeacon{engineEndpoint} } diff --git a/cmd/test-cli/main.go b/cmd/test-cli/main.go index 91ff2ab1..ff4f484a 100644 --- a/cmd/test-cli/main.go +++ b/cmd/test-cli/main.go @@ -10,9 +10,8 @@ import ( "github.com/ethereum/go-ethereum/common" boostTypes "github.com/flashbots/go-boost-utils/types" - "github.com/sirupsen/logrus" - "github.com/flashbots/mev-boost/server" + "github.com/sirupsen/logrus" ) var log = logrus.WithField("service", "cmd/test-cli") @@ -88,7 +87,7 @@ func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon return getHeaderResp } -func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beacon, engineEndpoint string, builderSigningDomain boostTypes.Domain, proposerSigningDomain boostTypes.Domain) { +func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beacon, engineEndpoint string, builderSigningDomain, proposerSigningDomain boostTypes.Domain) { header := doGetHeader(v, boostEndpoint, beaconNode, engineEndpoint, builderSigningDomain) blindedBeaconBlock := boostTypes.BlindedBeaconBlock{ @@ -244,7 +243,7 @@ func main() { } } -func getEnv(key string, defaultValue string) string { +func getEnv(key, defaultValue string) string { if value, ok := os.LookupEnv(key); ok { return value } diff --git a/cmd/test-cli/requests.go b/cmd/test-cli/requests.go index fe8a4baf..b151860a 100644 --- a/cmd/test-cli/requests.go +++ b/cmd/test-cli/requests.go @@ -21,7 +21,7 @@ type jsonrpcMessage struct { Result json.RawMessage `json:"result,omitempty"` } -func sendJSONRequest(endpoint string, payload any, dst any) error { +func sendJSONRequest(endpoint string, payload, dst any) error { payloadBytes, err := json.Marshal(payload) if err != nil { return err diff --git a/cmd/test-cli/validator.go b/cmd/test-cli/validator.go index 9dd0fc16..c432bde8 100644 --- a/cmd/test-cli/validator.go +++ b/cmd/test-cli/validator.go @@ -22,7 +22,7 @@ func (v *validatorPrivateData) SaveValidator(filePath string) error { if err != nil { return err } - return os.WriteFile(filePath, validatorData, 0644) + return os.WriteFile(filePath, validatorData, 0o644) } func mustLoadValidator(filePath string) validatorPrivateData { diff --git a/server/errors.go b/server/errors.go index b3ff008e..41740c62 100644 --- a/server/errors.go +++ b/server/errors.go @@ -2,7 +2,5 @@ package server import "fmt" -var ( - // ErrMissingRelayPubkey is returned if a new RelayEntry URL has no public key - ErrMissingRelayPubkey = fmt.Errorf("missing relay public key") -) +// ErrMissingRelayPubkey is returned if a new RelayEntry URL has no public key +var ErrMissingRelayPubkey = fmt.Errorf("missing relay public key") diff --git a/server/service.go b/server/service.go index a1a08f05..dd321091 100644 --- a/server/service.go +++ b/server/service.go @@ -31,8 +31,10 @@ var ( errServerAlreadyRunning = errors.New("server already running") ) -var nilHash = types.Hash{} -var nilResponse = struct{}{} +var ( + nilHash = types.Hash{} + nilResponse = struct{}{} +) type httpErrorResp struct { Code int `json:"code"` @@ -486,7 +488,6 @@ func (m *BoostService) handleGetPayload(w http.ResponseWriter, req *http.Request responsePayload := new(types.GetPayloadResponse) _, err := SendHTTPRequest(requestCtx, m.httpClientGetPayload, http.MethodPost, url, ua, payload, responsePayload) - if err != nil { log.WithError(err).Error("error making request to relay") return diff --git a/server/service_test.go b/server/service_test.go index 7c4778c5..84b9c059 100644 --- a/server/service_test.go +++ b/server/service_test.go @@ -53,7 +53,7 @@ func newTestBackend(t *testing.T, numRelays int, relayTimeout time.Duration) *te return &backend } -func (be *testBackend) request(t *testing.T, method string, path string, payload any) *httptest.ResponseRecorder { +func (be *testBackend) request(t *testing.T, method, path string, payload any) *httptest.ResponseRecorder { var req *http.Request var err error diff --git a/server/utils.go b/server/utils.go index 1e204840..4dc7e927 100644 --- a/server/utils.go +++ b/server/utils.go @@ -25,7 +25,7 @@ type UserAgent string type BlockHashHex string // SendHTTPRequest - prepare and send HTTP request, marshaling the payload if any, and decoding the response if dst is set -func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, userAgent UserAgent, payload any, dst any) (code int, err error) { +func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, userAgent UserAgent, payload, dst any) (code int, err error) { var req *http.Request if payload == nil { @@ -81,7 +81,7 @@ func SendHTTPRequest(ctx context.Context, client http.Client, method, url string } // ComputeDomain computes the signing domain -func ComputeDomain(domainType types.DomainType, forkVersionHex string, genesisValidatorsRootHex string) (domain types.Domain, err error) { +func ComputeDomain(domainType types.DomainType, forkVersionHex, genesisValidatorsRootHex string) (domain types.Domain, err error) { genesisValidatorsRoot := types.Root(common.HexToHash(genesisValidatorsRootHex)) forkVersionBytes, err := hexutil.Decode(forkVersionHex) if err != nil || len(forkVersionBytes) > 4 {