Skip to content

Commit

Permalink
Add gofumpt to lint checks (flashbots#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored and screwyprof committed Feb 3, 2023
1 parent 7da77aa commit 3d34efd
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test-race:

.PHONY: lint
lint:
gofumpt -d -extra .
revive -set_exit_status ./...
go vet ./...
staticcheck ./...
Expand Down
3 changes: 1 addition & 2 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func Main() {
log.Logger.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})

}

if *logDebug {
Expand Down Expand Up @@ -156,7 +155,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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/test-cli/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/test-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/test-cli/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/test-cli/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions server/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
7 changes: 4 additions & 3 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3d34efd

Please sign in to comment.