From cc574e013e6cb28bb6a827e53a1296ab515031cc Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Thu, 15 Feb 2024 15:24:50 +0100 Subject: [PATCH] Go 1.22 --- .github/workflows/checks.yml | 10 +++++----- .golangci.yaml | 1 + collector/node_conn_bloxroute.go | 2 +- collector/node_conn_eden.go | 2 +- common/common_test.go | 2 +- common/txsfile.go | 5 ++--- common/txsummary.go | 15 ++++++++------- common/types.go | 4 ++-- go.mod | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a5a293a..6075791 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.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: Check out code into the Go module directory @@ -30,20 +30,20 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: ^1.21 + go-version: ^1.22 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 - name: Install gofumpt - run: go install mvdan.cc/gofumpt@v0.4.0 + run: go install mvdan.cc/gofumpt@v0.6.0 - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.2 + 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.54.2 + run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1 - name: Lint run: make lint diff --git a/.golangci.yaml b/.golangci.yaml index 16587ab..b4b34c9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -28,6 +28,7 @@ linters: - varcheck - depguard - exhaustruct + - perfsprint # # Disabled because of generics: diff --git a/collector/node_conn_bloxroute.go b/collector/node_conn_bloxroute.go index 234eafe..65f8d5b 100644 --- a/collector/node_conn_bloxroute.go +++ b/collector/node_conn_bloxroute.go @@ -131,7 +131,7 @@ func (nc *BlxNodeConnection) connect() { // fmt.Println("got message", string(nextNotification)) var txMsg common.BlxRawTxMsg - err = json.Unmarshal(nextNotification, &txMsg) + err = json.Unmarshal(nextNotification, &txMsg) //nolint:musttag if err != nil { nc.log.Errorw("failed to unmarshal message", "error", err) continue diff --git a/collector/node_conn_eden.go b/collector/node_conn_eden.go index 249ff16..63388fe 100644 --- a/collector/node_conn_eden.go +++ b/collector/node_conn_eden.go @@ -129,7 +129,7 @@ func (nc *EdenNodeConnection) connect() { // fmt.Println("got message", string(nextNotification)) var txMsg common.EdenRawTxMsg - err = json.Unmarshal(nextNotification, &txMsg) + err = json.Unmarshal(nextNotification, &txMsg) //nolint:musttag if err != nil { nc.log.Errorw("failed to unmarshal message", "error", err) continue diff --git a/common/common_test.go b/common/common_test.go index 16d7431..8e79ea9 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -100,7 +100,7 @@ func TestParquet(t *testing.T) { pr.ReadStop() fr.Close() - require.Equal(t, 1, len(entries)) + require.Len(t, entries, 1) tx := entries[0] require.Equal(t, summary.Timestamp, tx.Timestamp) diff --git a/common/txsfile.go b/common/txsfile.go index 92a03fb..ba5bdc5 100644 --- a/common/txsfile.go +++ b/common/txsfile.go @@ -4,7 +4,6 @@ import ( "archive/zip" "bufio" "errors" - "fmt" "io" "os" "strconv" @@ -184,8 +183,8 @@ func ParseTx(timestampMs int64, rawTxHex string) (TxSummaryEntry, *types.Transac From: strings.ToLower(from.Hex()), To: strings.ToLower(to), Value: tx.Value().String(), - Nonce: fmt.Sprint(tx.Nonce()), - Gas: fmt.Sprint(tx.Gas()), + Nonce: strconv.FormatUint(tx.Nonce(), 10), + Gas: strconv.FormatUint(tx.Gas(), 10), GasPrice: tx.GasPrice().String(), GasTipCap: tx.GasTipCap().String(), GasFeeCap: tx.GasFeeCap().String(), diff --git a/common/txsummary.go b/common/txsummary.go index 78a53b7..9573373 100644 --- a/common/txsummary.go +++ b/common/txsummary.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math" + "strconv" "strings" "github.com/ethereum/go-ethereum/common" @@ -110,23 +111,23 @@ func (t *TxSummaryEntry) WasIncludedBeforeReceived() bool { func (t *TxSummaryEntry) ToCSVRow() []string { return []string{ - fmt.Sprint(t.Timestamp), + strconv.FormatInt(t.Timestamp, 10), t.Hash, t.ChainID, t.From, t.To, t.Value, - fmt.Sprint(t.Nonce), - fmt.Sprint(t.Gas), + t.Nonce, + t.Gas, t.GasPrice, t.GasTipCap, t.GasFeeCap, - fmt.Sprint(t.DataSize), + strconv.FormatInt(t.DataSize, 10), t.Data4Bytes, strings.Join(t.Sources, " "), - fmt.Sprint(t.IncludedAtBlockHeight), - fmt.Sprint(t.IncludedBlockTimestamp), - fmt.Sprint(t.InclusionDelayMs), + strconv.FormatInt(t.IncludedAtBlockHeight, 10), + strconv.FormatInt(t.IncludedBlockTimestamp, 10), + strconv.FormatInt(t.InclusionDelayMs, 10), } } diff --git a/common/types.go b/common/types.go index 143c4b6..198cad7 100644 --- a/common/types.go +++ b/common/types.go @@ -4,7 +4,7 @@ import ( "strings" ) -type BlxRawTxMsg struct { //nolint:musttag +type BlxRawTxMsg struct { Params struct { Result struct { RawTx string @@ -12,7 +12,7 @@ type BlxRawTxMsg struct { //nolint:musttag } } -type EdenRawTxMsg struct { //nolint:musttag +type EdenRawTxMsg struct { Params struct { Result struct { RLP string diff --git a/go.mod b/go.mod index a3beb28..adf0e54 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/flashbots/mempool-dumpster -go 1.21 +go 1.22 require ( github.com/HdrHistogram/hdrhistogram-go v1.1.2