Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix perfsprint linter #619

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.6

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

- name: Lint
run: make lint
Expand Down
14 changes: 7 additions & 7 deletions beaconclient/prod_beacon_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type PayloadAttributes struct {
}

func (c *ProdBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData) {
eventsURL := fmt.Sprintf("%s/eth/v1/events?topics=head", c.beaconURI)
eventsURL := c.beaconURI + "/eth/v1/events?topics=head"
log := c.log.WithField("url", eventsURL)
log.Info("subscribing to head events")

Expand All @@ -109,7 +109,7 @@ func (c *ProdBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData) {
}

func (c *ProdBeaconInstance) SubscribeToPayloadAttributesEvents(payloadAttributesC chan PayloadAttributesEvent) {
eventsURL := fmt.Sprintf("%s/eth/v1/events?topics=payload_attributes", c.beaconURI)
eventsURL := c.beaconURI + "/eth/v1/events?topics=payload_attributes"
log := c.log.WithField("url", eventsURL)
log.Info("subscribing to payload_attributes events")

Expand Down Expand Up @@ -235,7 +235,7 @@ type GetHeaderResponseMessage struct {

// GetHeader returns the latest header - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockHeader
func (c *ProdBeaconInstance) GetHeader() (*GetHeaderResponse, error) {
uri := fmt.Sprintf("%s/eth/v1/beacon/headers/head", c.beaconURI)
uri := c.beaconURI + "/eth/v1/beacon/headers/head"
resp := new(GetHeaderResponse)
_, err := fetchBeacon(http.MethodGet, uri, nil, resp, nil, http.Header{}, false)
return resp, err
Expand All @@ -260,7 +260,7 @@ func (c *ProdBeaconInstance) GetPublishURI() string {
func (c *ProdBeaconInstance) PublishBlock(block *common.VersionedSignedProposal, broadcastMode BroadcastMode) (code int, err error) {
var uri string
if c.ffUseV1PublishBlockEndpoint {
uri = fmt.Sprintf("%s/eth/v1/beacon/blocks", c.beaconPublishURI)
uri = c.beaconPublishURI + "/eth/v1/beacon/blocks"
} else {
uri = fmt.Sprintf("%s/eth/v2/beacon/blocks?broadcast_validation=%s", c.beaconPublishURI, broadcastMode)
}
Expand Down Expand Up @@ -311,7 +311,7 @@ type GetGenesisResponseData struct {

// GetGenesis returns the genesis info - https://ethereum.github.io/beacon-APIs/#/Beacon/getGenesis
func (c *ProdBeaconInstance) GetGenesis() (*GetGenesisResponse, error) {
uri := fmt.Sprintf("%s/eth/v1/beacon/genesis", c.beaconURI)
uri := c.beaconURI + "/eth/v1/beacon/genesis"
resp := new(GetGenesisResponse)
_, err := fetchBeacon(http.MethodGet, uri, nil, resp, nil, http.Header{}, false)
return resp, err
Expand All @@ -328,7 +328,7 @@ type GetSpecResponse struct {

// GetSpec - https://ethereum.github.io/beacon-APIs/#/Config/getSpec
func (c *ProdBeaconInstance) GetSpec() (spec *GetSpecResponse, err error) {
uri := fmt.Sprintf("%s/eth/v1/config/spec", c.beaconURI)
uri := c.beaconURI + "/eth/v1/config/spec"
resp := new(GetSpecResponse)
_, err = fetchBeacon(http.MethodGet, uri, nil, resp, nil, http.Header{}, false)
return resp, err
Expand All @@ -344,7 +344,7 @@ type GetForkScheduleResponse struct {

// GetForkSchedule - https://ethereum.github.io/beacon-APIs/#/Config/getForkSchedule
func (c *ProdBeaconInstance) GetForkSchedule() (spec *GetForkScheduleResponse, err error) {
uri := fmt.Sprintf("%s/eth/v1/config/fork_schedule", c.beaconURI)
uri := c.beaconURI + "/eth/v1/config/fork_schedule"
resp := new(GetForkScheduleResponse)
_, err = fetchBeacon(http.MethodGet, uri, nil, resp, nil, http.Header{}, false)
return resp, err
Expand Down
9 changes: 4 additions & 5 deletions common/ssz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package common
import (
"bytes"
"encoding/json"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -36,7 +35,7 @@ func TestSSZBuilderSubmission(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
// json matches marshalled SSZ
jsonBytes := LoadGzippedBytes(t, fmt.Sprintf("%s.json.gz", testCase.filepath))
jsonBytes := LoadGzippedBytes(t, testCase.filepath+".json.gz")

submitBlockData := new(VersionedSubmitBlockRequest)
err := json.Unmarshal(jsonBytes, &submitBlockData)
Expand All @@ -46,7 +45,7 @@ func TestSSZBuilderSubmission(t *testing.T) {
marshalledSszBytes, err := submitBlockData.MarshalSSZ()
require.NoError(t, err)

sszBytes := LoadGzippedBytes(t, fmt.Sprintf("%s.ssz.gz", testCase.filepath))
sszBytes := LoadGzippedBytes(t, testCase.filepath+".ssz.gz")
require.Equal(t, sszBytes, marshalledSszBytes)

htr, err := submitBlockData.HashTreeRoot()
Expand Down Expand Up @@ -91,7 +90,7 @@ func TestSSZGetHeaderResponse(t *testing.T) {
// json -> marshalled ssz -> matches expected ssz
payload := new(builderSpec.VersionedSignedBuilderBid)

jsonBytes, err := os.ReadFile(fmt.Sprintf("%s.json", testCase.filepath))
jsonBytes, err := os.ReadFile(testCase.filepath + ".json")
require.NoError(t, err)

err = json.Unmarshal(jsonBytes, &payload)
Expand All @@ -109,7 +108,7 @@ func TestSSZGetHeaderResponse(t *testing.T) {
require.Fail(t, "unknown version")
}

sszExpectedBytes, err := os.ReadFile(fmt.Sprintf("%s.ssz", testCase.filepath))
sszExpectedBytes, err := os.ReadFile(testCase.filepath + ".ssz")
require.NoError(t, err)
require.Equal(t, sszExpectedBytes, ssz)

Expand Down
4 changes: 2 additions & 2 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package database

import (
"database/sql"
"fmt"
"errors"
"os"
"strconv"
"testing"
Expand Down Expand Up @@ -46,7 +46,7 @@ var (
RedisUpdate: 45,
Total: 46,
}
errFoo = fmt.Errorf("fake simulation error")
errFoo = errors.New("fake simulation error")
)

func createValidatorRegistration(pubKey string) ValidatorRegistrationEntry {
Expand Down
12 changes: 6 additions & 6 deletions services/api/optimistic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"context"
"encoding/json"
"fmt"
"errors"
"math/big"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -39,7 +39,7 @@ const (

var (
feeRecipient = bellatrix.ExecutionAddress{0x02}
errFake = fmt.Errorf("foo error")
errFake = errors.New("foo error")
)

func getTestBidTrace(pubkey phase0.BLSPubKey, value, slot uint64) *common.BidTraceV2WithBlobFields {
Expand Down Expand Up @@ -166,12 +166,12 @@ func TestSimulateBlock(t *testing.T) {
{
description: "block_already_known_capella",
version: spec.DataVersionCapella,
simulationError: fmt.Errorf(ErrBlockAlreadyKnown), //nolint:goerr113
simulationError: errors.New(ErrBlockAlreadyKnown), //nolint:goerr113
},
{
description: "missing_trie_node_capella",
version: spec.DataVersionCapella,
simulationError: fmt.Errorf(ErrMissingTrieNode + "23e21f94cd97b3b27ae5c758277639dd387a6e3da5923c5485f24ec6c71e16b8 (path ) <nil>"), //nolint:goerr113
simulationError: errors.New(ErrMissingTrieNode + "23e21f94cd97b3b27ae5c758277639dd387a6e3da5923c5485f24ec6c71e16b8 (path ) <nil>"), //nolint:goerr113
},
{
description: "success_deneb",
Expand All @@ -186,12 +186,12 @@ func TestSimulateBlock(t *testing.T) {
{
description: "block_already_known_deneb",
version: spec.DataVersionDeneb,
simulationError: fmt.Errorf(ErrBlockAlreadyKnown), //nolint:goerr113
simulationError: errors.New(ErrBlockAlreadyKnown), //nolint:goerr113
},
{
description: "missing_trie_node_deneb",
version: spec.DataVersionDeneb,
simulationError: fmt.Errorf(ErrMissingTrieNode + "23e21f94cd97b3b27ae5c758277639dd387a6e3da5923c5485f24ec6c71e16b8 (path ) <nil>"), //nolint:goerr113
simulationError: errors.New(ErrMissingTrieNode + "23e21f94cd97b3b27ae5c758277639dd387a6e3da5923c5485f24ec6c71e16b8 (path ) <nil>"), //nolint:goerr113
},
}
for _, tc := range cases {
Expand Down
2 changes: 1 addition & 1 deletion services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ func (api *RelayAPI) handleRegisterValidator(w http.ResponseWriter, req *http.Re
if api.ffRegValContinueOnInvalidSig {
return
} else {
handleError(regLog, http.StatusBadRequest, fmt.Sprintf("failed to verify validator signature for %s", signedValidatorRegistration.Message.Pubkey.String()))
handleError(regLog, http.StatusBadRequest, fmt.Sprintf("failed to verify validator signature for %s", signedValidatorRegistration.Message.Pubkey.String())) //nolint:perfsprint
return
}
}
Expand Down
Loading