Skip to content

Commit 03526b7

Browse files
committed
aggressive lint
1 parent 10042c8 commit 03526b7

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

.golangci.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
linters:
2-
enable-all: false
2+
enable-all: true
33
disable:
44
- cyclop
55
- forbidigo
@@ -28,6 +28,9 @@ linters:
2828
- exhaustruct
2929
- depguard
3030
- err113
31+
- gocognit
32+
- nakedret
33+
- tagliatelle
3134

3235
#
3336
# Disabled because of generics:
@@ -55,11 +58,6 @@ linters-settings:
5558
excludes:
5659
- G108
5760

58-
tagliatelle:
59-
case:
60-
rules:
61-
json: snake
62-
6361
gofumpt:
6462
extra-rules: true
6563

cmd/receiver-proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var flags []cli.Flag = []cli.Flag{
5353
&cli.StringFlag{
5454
Name: "builder-confighub-endpoint",
5555
Value: "http://127.0.0.1:14892",
56-
Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)",
56+
Usage: "address of the builder config hub enpoint (directly or using the cvm-proxy)",
5757
EnvVars: []string{"BUILDER_CONFIGHUB_ENDPOINT"},
5858
},
5959
&cli.StringFlag{

cmd/sender-proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var flags []cli.Flag = []cli.Flag{
2828
&cli.StringFlag{
2929
Name: "builder-confighub-endpoint",
3030
Value: "http://127.0.0.1:14892",
31-
Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)",
31+
Usage: "address of the builder config hub enpoint (directly or using the cvm-proxy)",
3232
EnvVars: []string{"BUILDER_CONFIGHUB_ENDPOINT"},
3333
},
3434
&cli.StringFlag{

proxy/archive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ type ArchiveQueue struct {
3939
}
4040

4141
func (aq *ArchiveQueue) Run() {
42-
var workers []*archiveQueueWorker
4342
workerCount := 1
4443
if aq.workerCount > 0 {
4544
workerCount = aq.workerCount
4645
}
46+
workers := make([]*archiveQueueWorker, 0, workerCount)
4747
workersQueue := make(chan *ParsedRequest, ArchiveWorkerQueueSize)
48-
for w := 0; w < workerCount; w++ {
48+
for w := range workerCount {
4949
worker := &archiveQueueWorker{
5050
log: aq.log.With(slog.Int("worker", w)),
5151
archiveClient: aq.archiveClient,

proxy/confighub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (b *BuilderConfigHub) Builders(internal bool) (result []ConfighubBuilder, e
7474
} else {
7575
url += "/api/l1-builder/v1/builders"
7676
}
77-
resp, err = http.Get(url)
77+
resp, err = http.Get(url) //nolint:gosec
7878
if err != nil {
7979
return
8080
}

proxy/receiver_proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func NewReceiverProxy(config ReceiverProxyConfig) (*ReceiverProxy, error) {
134134

135135
prx.CertHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
136136
w.Header().Add("Content-Type", "application/octet-stream")
137-
_, err := w.Write([]byte(prx.PublicCertPEM))
137+
_, err := w.Write(prx.PublicCertPEM)
138138
if err != nil {
139139
prx.Log.Warn("Failed to serve certificate", slog.Any("error", err))
140140
}

proxy/receiver_proxy_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,28 @@ func StartTestOrderflowProxy(name string) (*OrderflowProxyTestSetup, error) {
7777
localBuilderServer := ServeHTTPRequestToChan(localBuilderRequests)
7878

7979
proxy := createProxy(localBuilderServer.URL, name)
80-
publicProxyServer := &http.Server{
80+
publicProxyServer := &http.Server{ //nolint:gosec
8181
Handler: proxy.PublicHandler,
8282
TLSConfig: proxy.TLSConfig(),
8383
}
84-
publicListener, err := net.Listen("tcp", ":0")
84+
publicListener, err := net.Listen("tcp", ":0") //nolint:gosec
8585
if err != nil {
8686
return nil, err
8787
}
88-
go publicProxyServer.ServeTLS(publicListener, "", "") //nolint: errcheck
89-
publicServerEndpoint := fmt.Sprintf("https://localhost:%d", publicListener.Addr().(*net.TCPAddr).Port)
90-
ip := fmt.Sprintf("127.0.0.1:%d", publicListener.Addr().(*net.TCPAddr).Port)
88+
go publicProxyServer.ServeTLS(publicListener, "", "") //nolint: errcheck
89+
publicServerEndpoint := fmt.Sprintf("https://localhost:%d", publicListener.Addr().(*net.TCPAddr).Port) //nolint:forcetypeassert
90+
ip := fmt.Sprintf("127.0.0.1:%d", publicListener.Addr().(*net.TCPAddr).Port) //nolint:forcetypeassert
9191

92-
localProxyServer := &http.Server{
92+
localProxyServer := &http.Server{ //nolint:gosec
9393
Handler: proxy.LocalHandler,
9494
TLSConfig: proxy.TLSConfig(),
9595
}
96-
localListener, err := net.Listen("tcp", ":0")
96+
localListener, err := net.Listen("tcp", ":0") //nolint:gosec
9797
if err != nil {
9898
return nil, err
9999
}
100-
go localProxyServer.ServeTLS(localListener, "", "") //nolint:errcheck
101-
localServerEndpoint := fmt.Sprintf("https://localhost:%d", localListener.Addr().(*net.TCPAddr).Port)
100+
go localProxyServer.ServeTLS(localListener, "", "") //nolint:errcheck
101+
localServerEndpoint := fmt.Sprintf("https://localhost:%d", localListener.Addr().(*net.TCPAddr).Port) //nolint:forcetypeassert
102102

103103
certProxyServer := httptest.NewServer(proxy.CertHandler)
104104

@@ -160,7 +160,7 @@ func TestMain(m *testing.M) {
160160
archiveServer = ServeHTTPRequestToChan(archiveServerRequests)
161161
defer archiveServer.Close()
162162

163-
for i := 0; i < 3; i++ {
163+
for i := range 3 {
164164
proxy, err := StartTestOrderflowProxy(fmt.Sprintf("proxy:%d", i))
165165
proxies = append(proxies, proxy)
166166
if err != nil {
@@ -233,6 +233,7 @@ func expectNoRequest(t *testing.T, ch chan *RequestData) {
233233
}
234234

235235
func proxiesUpdatePeers(t *testing.T) {
236+
t.Helper()
236237
for _, instance := range proxies {
237238
err := instance.proxy.RequestNewPeers()
238239
require.NoError(t, err)

proxy/sharing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (sq *ShareQueue) Run() {
6464
if sq.localBuilder != nil {
6565
builderPeer := newShareQueuePeer("local-builder", sq.localBuilder)
6666
localBuilder = &builderPeer
67-
for worker := 0; worker < workersPerPeer; worker += 1 {
67+
for worker := range workersPerPeer {
6868
go sq.proxyRequests(localBuilder, worker)
6969
}
7070
defer localBuilder.Close()
@@ -108,7 +108,7 @@ func (sq *ShareQueue) Run() {
108108
sq.log.Info("Created client for peer", slog.String("peer", info.Name), slog.String("name", sq.name))
109109
newPeer := newShareQueuePeer(info.Name, client)
110110
peers = append(peers, newPeer)
111-
for worker := 0; worker < workersPerPeer; worker += 1 {
111+
for worker := range workersPerPeer {
112112
go sq.proxyRequests(&newPeer, worker)
113113
}
114114
}
@@ -155,7 +155,7 @@ func (sq *ShareQueue) proxyRequests(peer *shareQueuePeer, worker int) {
155155
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
156156
resp, err := peer.client.Call(ctx, method, data)
157157
cancel()
158-
timeShareQueuePeerRPCDuration(peer.name, int64(time.Since(start).Milliseconds()))
158+
timeShareQueuePeerRPCDuration(peer.name, time.Since(start).Milliseconds())
159159
if err != nil {
160160
logger.Warn("Error while proxying request", slog.Any("error", err))
161161
incShareQueuePeerRPCErrors(peer.name)

proxy/utils.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"errors"
8-
"fmt"
8+
"net"
99
"net/http"
1010
"strings"
1111
"sync"
@@ -16,7 +16,7 @@ import (
1616
"github.com/flashbots/go-utils/signature"
1717
)
1818

19-
var DefaultOrderflowProxyPublicPort = 5544
19+
var DefaultOrderflowProxyPublicPort = "5544"
2020

2121
var errCertificate = errors.New("failed to add certificate to pool")
2222

@@ -27,7 +27,8 @@ func createTransportForSelfSignedCert(certPEM []byte) (*http.Transport, error) {
2727
}
2828
return &http.Transport{
2929
TLSClientConfig: &tls.Config{
30-
RootCAs: certPool,
30+
RootCAs: certPool,
31+
MinVersion: tls.VersionTLS12,
3132
},
3233
}, nil
3334
}
@@ -41,7 +42,7 @@ func HTTPClientWithMaxConnections(maxOpenConnections int) *http.Client {
4142
}
4243
}
4344

44-
func RPCClientWithCertAndSigner(endpoint string, certPEM []byte, signer *signature.Signer, maxOpenConnections int) (rpcclient.RPCClient, error) {
45+
func RPCClientWithCertAndSigner(endpoint string, certPEM []byte, signer *signature.Signer, maxOpenConnections int) (rpcclient.RPCClient, error) { //nolint:ireturn
4546
transport, err := createTransportForSelfSignedCert(certPEM)
4647
if err != nil {
4748
return nil, err
@@ -59,9 +60,9 @@ func RPCClientWithCertAndSigner(endpoint string, certPEM []byte, signer *signatu
5960

6061
func OrderflowProxyURLFromIP(ip string) string {
6162
if strings.Contains(ip, ":") {
62-
return fmt.Sprintf("https://%s", ip)
63+
return "https://" + ip
6364
} else {
64-
return fmt.Sprintf("https://%s:%d", ip, DefaultOrderflowProxyPublicPort)
65+
return "https://" + net.JoinHostPort(ip, DefaultOrderflowProxyPublicPort)
6566
}
6667
}
6768

0 commit comments

Comments
 (0)