From a3e955107482cf62952a9edd36cc7309d52991a2 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Mon, 24 Nov 2025 15:17:47 +0000 Subject: [PATCH 1/3] Update dependencies. --- go.mod | 4 ++-- go.sum | 4 ++++ main.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4442e79..37143cc 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.5 github.com/rs/zerolog v1.33.0 - github.com/sasha-s/go-deadlock v0.3.5 + github.com/sasha-s/go-deadlock v0.3.6 github.com/shopspring/decimal v1.4.0 github.com/spf13/pflag v1.0.6 github.com/spf13/viper v1.19.0 @@ -73,7 +73,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect - github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc // indirect + github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect github.com/pk910/dynamic-ssz v0.0.5 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.1 // indirect diff --git a/go.sum b/go.sum index 1c664c7..7e3e084 100644 --- a/go.sum +++ b/go.sum @@ -327,6 +327,8 @@ github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xl github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc h1:Xz/LkK9AJRY5QTkA1uE1faB8yeqRFjeKgwDtI13ogcY= github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe h1:vHpqOnPlnkba8iSxU4j/CvDSS9J4+F4473esQsYLGoE= +github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pk910/dynamic-ssz v0.0.5 h1:VP9heGYUwzlpyhk28P2nCAzhvGsePJOOOO5vQMDh2qQ= github.com/pk910/dynamic-ssz v0.0.5/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -364,6 +366,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= +github.com/sasha-s/go-deadlock v0.3.6 h1:TR7sfOnZ7x00tWPfD397Peodt57KzMDo+9Ae9rMiUmw= +github.com/sasha-s/go-deadlock v0.3.6/go.mod h1:CUqNyyvMxTyjFqDT7MRg9mb4Dv/btmGTqSR+rky/UXo= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= diff --git a/main.go b/main.go index bf68026..dce6da8 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,7 @@ import ( ) // ReleaseVersion is the release version for the code. -var ReleaseVersion = "0.4.5" +var ReleaseVersion = "0.5.0" func main() { os.Exit(main2()) From b517102580e3ff2e62380200f72b83e685fc73c2 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Mon, 24 Nov 2025 15:26:52 +0000 Subject: [PATCH 2/3] Update comptrollerd. --- .github/workflows/golangci-lint.yml | 4 +- .github/workflows/release.yml | 6 +- .golangci.yml | 194 +++++++++--------- go.mod | 4 +- main.go | 1 - metrics.go | 1 - services/blockpayments/standard/handler.go | 2 +- services/blockpayments/standard/service.go | 1 - services/comptrollerdb/filters.go | 4 - .../comptrollerdb/postgresql/alternatebids.go | 1 - .../comptrollerdb/postgresql/deliveredbids.go | 1 - .../comptrollerdb/postgresql/receivedbids.go | 1 - services/comptrollerdb/postgresql/upgrader.go | 36 ---- services/relays/standard/metrics.go | 1 - services/scheduler/standard/service.go | 2 - util/scatter.go | 2 +- 16 files changed, 107 insertions(+), 154 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 57bdc46..eff5029 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -12,12 +12,12 @@ permissions: jobs: golangci: name: lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/setup-go@v5 with: cache: false - go-version: '^1.22' + go-version: '^1.25' - uses: actions/checkout@v4 - name: golangci-lint uses: golangci/golangci-lint-action@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57461d3..1f65368 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ on: jobs: # Set variables that will be available to all builds. env_vars: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 outputs: release_version: ${{ steps.release_version.outputs.release_version }} binary: ${{ steps.binary.outputs.binary }} @@ -25,7 +25,7 @@ jobs: # Create a github release to hold the assets once built. create_release: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: env_vars outputs: upload_url: ${{ steps.release_action.outputs.upload_url }} @@ -40,7 +40,7 @@ jobs: # Build and pack the binaries for linux. build_linux: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [create_release, env_vars] steps: - name: Set up Go diff --git a/.golangci.yml b/.golangci.yml index 6448aae..1a4aa95 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,15 +4,7 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. -issues: - # Which files to exclude: they will be analyzed, but issues from them won't be reported. - # There is no need to include all autogenerated files, - # we confidently recognize autogenerated files. - # If it's not, please let us know. - # "/" will be replaced by current OS file path separator to properly work on Windows. - # Default: [] - exclude-files: - - ".*_ssz\\.go$" +version: "2" # Options for analysis running. run: @@ -69,96 +61,21 @@ run: # Define the Go version limit. # Mainly related to generics support since go1.18. # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18 - # go: '1.20' + # go: '1.19' # output configuration options -# output: - # Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions - # - # Multiple can be specified by separating them by comma, output can be provided - # for each of them by separating format name and path by colon symbol. - # Output path can be either `stdout`, `stderr` or path to the file to write to. - # Example: "checkstyle:report.json,colored-line-number" - # - # Default: colored-line-number - # format: json - - # Print lines of code with issue. - # Default: true - # print-issued-lines: false - - # Print linter name in the end of issue text. - # Default: true - # print-linter-name: false - - # Make issues output unique by line. - # Default: true - # uniq-by-line: false - - # Add a prefix to the output file references. - # Default is no prefix. - # path-prefix: "" - - # Sort results by: filepath, line and column. - # sort-results: true - - -# All available settings of specific linters. -linters-settings: - gosec: - excludes: - # Flags for potentially-unsafe casting of ints, but generates a lot of false positives. - - 'G115' - - lll: - line-length: 132 - - nlreturn: - block-size: 3 - - revive: - ignore-generated-header: false - severity: error - confidence: 0.8 - enable-all-rules: true - rules: - - name: add-constant - disabled: true - - name: cyclomatic - disabled: true - - name: cognitive-complexity - disabled: true - - name: confusing-results - - name: function-length - disabled: true - - name: line-length-limit - arguments: [132] - - name: max-public-structs - disabled: true - - name: package-comments - disabled: true - - name: struct-tag - arguments: ["json,allowempty"] - - name: unhandled-error - arguments: - - "fmt.Fprint" - - "fmt.Fprintf" - - stylecheck: - checks: [ "all", "-ST1000" ] - - tagliatelle: - case: - # use-field-name: true - rules: - json: snake - yaml: snake +output: + formats: + text: + path: stderr + colors: true + print-issued-lines: true linters: # Enable all available linters. # Default: false - enable-all: true + default: all # Disable specific linter # https://golangci-lint.run/usage/linters/#disabled-by-default disable: @@ -169,18 +86,103 @@ linters: - exhaustive - exhaustruct - forcetypeassert + - funcorder - funlen - - gci - gochecknoglobals - - gochecknoinits - gocognit - goconst + - godoclint + - iface - ireturn - lll - - maintidx + - modernize - mnd - - musttag + - nestif + - nilnil + - nlreturn + - noinlineerr - perfsprint + - promlinter - varnamelen - wrapcheck - wsl + exclusions: + paths: + - ".*_ssz\\.go$" + settings: + godot: + scope: all + period: true + capital: false + + gosec: + excludes: + - G115 # This generates a lot of false positives, recheck once https://github.com/securego/gosec/issues/1212 is closed + + errcheck: + exclude-functions: + - fmt.Fprintf + + lll: + line-length: 132 + + nlreturn: + # Allow two-line blocks without requiring a newline + block-size: 3 + + tagliatelle: + case: + # use-field-name: true + rules: + json: snake + yaml: snake + + goheader: + values: + regexp: + YEARS: '(20\d\d - 20\d\d|20\d\d, 20\d\d|20\d\d)' + template: |- + Copyright © {{ YEARS }} Weald Technology Trading. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + revive: + rules: + - name: package-comments + severity: warning + disabled: true + exclude: [ "" ] + + wsl_v5: + disable: + - assign + - branch + - decl + - defer + - expr + - for + - go + - if + - inc-dec + - label + - range + - return + - select + - send + - switch + - type-switch + - append + - assign-exclusive + - assign-expr + - err + - leading-whitespace + - trailing-whitespace \ No newline at end of file diff --git a/go.mod b/go.mod index 37143cc..c7847a3 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/wealdtech/comptrollerd -go 1.23.0 +go 1.25.0 -toolchain go1.24.5 +toolchain go1.25.3 require ( github.com/attestantio/go-eth2-client v0.27.1 diff --git a/main.go b/main.go index dce6da8..69afc7b 100644 --- a/main.go +++ b/main.go @@ -405,7 +405,6 @@ func startBids( func runCommands(_ context.Context) { if viper.GetBool("version") { fmt.Fprintf(os.Stdout, "%s\n", ReleaseVersion) - //nolint:revive os.Exit(0) } } diff --git a/metrics.go b/metrics.go index 4ce8fe1..37ce57f 100644 --- a/metrics.go +++ b/metrics.go @@ -88,7 +88,6 @@ func setRelease(_ context.Context, version string) { releaseMetric.WithLabelValues(version).Set(1) } -//nolint:revive func setReady(_ context.Context, ready bool) { if readyMetric == nil { return diff --git a/services/blockpayments/standard/handler.go b/services/blockpayments/standard/handler.go index a142fa7..88cad5a 100644 --- a/services/blockpayments/standard/handler.go +++ b/services/blockpayments/standard/handler.go @@ -255,7 +255,6 @@ func (s *Service) checkUnderpaidBid(ctx context.Context, return nil } -//nolint:revive func (s *Service) calcBuilderRewards(ctx context.Context, block *execdb.Block, txs []*execdb.Transaction, @@ -511,6 +510,7 @@ func (s *Service) deliveredBidOfSlot(ctx context.Context, deliveredBid := deliveredBids[0] if e := log.Trace(); e.Enabled() { + //nolint:musttag rawJSON, err := json.Marshal(deliveredBid) if err == nil { e.RawJSON("delivered_bid", rawJSON).Msg("Obtained delivered bid") diff --git a/services/blockpayments/standard/service.go b/services/blockpayments/standard/service.go index 79abd94..e44f653 100644 --- a/services/blockpayments/standard/service.go +++ b/services/blockpayments/standard/service.go @@ -77,7 +77,6 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) { if err := s.onReplaySlot(ctx, phase0.Slot(parameters.replaySlot)); err != nil { return nil, err } - //nolint:revive os.Exit(0) } diff --git a/services/comptrollerdb/filters.go b/services/comptrollerdb/filters.go index 96fc24c..1dc0137 100644 --- a/services/comptrollerdb/filters.go +++ b/services/comptrollerdb/filters.go @@ -83,10 +83,6 @@ type BlockPaymentFilter struct { // ToSlot is the latest slot to which to fetch results. // If nil then there is no latest slot. ToSlot *uint32 - - // FeeRecipients are the fee recipients of the rewards. - // If nil then there is no fee recipient filter. - // FeeRecipients [][]byte } // ValidatorRegistrationFilter defines a filter for fetching validator registrations. diff --git a/services/comptrollerdb/postgresql/alternatebids.go b/services/comptrollerdb/postgresql/alternatebids.go index ff4eba0..48c6b3e 100644 --- a/services/comptrollerdb/postgresql/alternatebids.go +++ b/services/comptrollerdb/postgresql/alternatebids.go @@ -110,7 +110,6 @@ FROM t_alternate_bids`) queryVals = append(queryVals, filter.BestRelays) _, _ = queryBuilder.WriteString(fmt.Sprintf(` %s f_best_relay = ANY($%d)`, wherestr, len(queryVals))) - // wherestr = " AND" } switch filter.Order { diff --git a/services/comptrollerdb/postgresql/deliveredbids.go b/services/comptrollerdb/postgresql/deliveredbids.go index e2148bf..411217d 100644 --- a/services/comptrollerdb/postgresql/deliveredbids.go +++ b/services/comptrollerdb/postgresql/deliveredbids.go @@ -137,7 +137,6 @@ FROM t_delivered_bids`) queryVals = append(queryVals, filter.BlockHashes) _, _ = queryBuilder.WriteString(fmt.Sprintf(` %s f_block_hash = ANY($%d)`, wherestr, len(queryVals))) - // wherestr = " AND" } switch filter.Order { diff --git a/services/comptrollerdb/postgresql/receivedbids.go b/services/comptrollerdb/postgresql/receivedbids.go index 86e3e4f..157cfec 100644 --- a/services/comptrollerdb/postgresql/receivedbids.go +++ b/services/comptrollerdb/postgresql/receivedbids.go @@ -138,7 +138,6 @@ FROM t_received_bids`) queryVals = append(queryVals, filter.BlockHashes) _, _ = queryBuilder.WriteString(fmt.Sprintf(` %s f_block_hash = ANY($%d)`, wherestr, len(queryVals))) - // wherestr = " AND" } switch filter.Order { diff --git a/services/comptrollerdb/postgresql/upgrader.go b/services/comptrollerdb/postgresql/upgrader.go index f68705c..f1da44a 100644 --- a/services/comptrollerdb/postgresql/upgrader.go +++ b/services/comptrollerdb/postgresql/upgrader.go @@ -90,42 +90,6 @@ func (s *Service) Upgrade(ctx context.Context) error { return nil } -// // columnExists returns true if the given column exists in the given table. -// func (s *Service) columnExists(ctx context.Context, tableName string, columnName string) (bool, error) { -// tx := s.tx(ctx) -// if tx == nil { -// ctx, cancel, err := s.BeginTx(ctx) -// if err != nil { -// return false, errors.Wrap(err, "failed to begin transaction") -// } -// tx = s.tx(ctx) -// defer cancel() -// } -// -// query := fmt.Sprintf(`SELECT true -// FROM pg_attribute -// WHERE attrelid = '%s'::regclass -// AND attname = '%s' -// AND NOT attisdropped`, tableName, columnName) -// -// rows, err := tx.Query(ctx, query) -// if err != nil { -// return false, err -// } -// defer rows.Close() -// -// found := false -// if rows.Next() { -// err = rows.Scan( -// &found, -// ) -// if err != nil { -// return false, errors.Wrap(err, "failed to scan row") -// } -// } -// return found, nil -// } - // tableExists returns true if the given table exists. func (s *Service) tableExists(ctx context.Context, tableName string) (bool, error) { tx := s.tx(ctx) diff --git a/services/relays/standard/metrics.go b/services/relays/standard/metrics.go index bfdcc14..d7bfd9c 100644 --- a/services/relays/standard/metrics.go +++ b/services/relays/standard/metrics.go @@ -74,7 +74,6 @@ func monitorRegistrationsProcessed(relay string) { } } -//nolint:revive func monitorRelayActive(relay string, active bool) { if relayActive != nil { if active { diff --git a/services/scheduler/standard/service.go b/services/scheduler/standard/service.go index 8bbf66c..b528acb 100644 --- a/services/scheduler/standard/service.go +++ b/services/scheduler/standard/service.go @@ -370,8 +370,6 @@ func finaliseJob(job *job) { } // runJob runs the given job. -// -//nolint:revive func (*Service) runJob(_ context.Context, job *job) error { job.stateLock.Lock() if job.active.Load() { diff --git a/util/scatter.go b/util/scatter.go index 4311567..ca5dea1 100644 --- a/util/scatter.go +++ b/util/scatter.go @@ -63,7 +63,7 @@ func Scatter(inputLen int, concurrency int, work func(int, int, *sync.RWMutex) ( }(offset, entries) } - // Collect results from workers + // Collect results from workers. results := make([]*ScatterResult, workers) var err error for i := range workers { From be9122e59d71a2bcf2d01afec9926d0054344e78 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Mon, 24 Nov 2025 15:37:09 +0000 Subject: [PATCH 3/3] Lint. --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index eff5029..3b32a5e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -20,7 +20,7 @@ jobs: go-version: '^1.25' - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: version: 'latest' args: '--timeout=60m'