From d5465415d0691d780cf2ca1854718a7d1ab9df61 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 26 Oct 2025 12:39:11 -0400 Subject: [PATCH 1/4] Bump go.mod versions to 1.25 --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index dbe45d0..1e42f05 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/attestantio/dirk -go 1.22.0 +go 1.25 -toolchain go1.22.4 +toolchain go1.25.3 require ( github.com/attestantio/go-eth2-client v0.21.11 From 45c8929cfda24a2cbbd0831e99496a0d8db68ce8 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 26 Oct 2025 13:21:28 -0400 Subject: [PATCH 2/4] Bump versions outside go.mod --- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/release.yml | 6 +++--- .github/workflows/test.yml | 2 +- Dockerfile | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a8a2615..3d86e88 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: - 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 b2e11cd..625f3b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: uses: actions/setup-go@v3 with: cache: false - go-version: '^1.22' + go-version: '^1.25' - name: Check out repository into the Go module directory uses: actions/checkout@v4 @@ -123,7 +123,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: '^1.22' + go-version: '^1.25' - name: Check out repository into the Go module directory uses: actions/checkout@v4 @@ -169,7 +169,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: '^1.22' + go-version: '^1.25' - name: Check out repository into the Go module directory uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db2ef35..efb419d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: '^1.22' + go-version: '^1.25' - uses: actions/checkout@v4 - uses: n8maninger/action-golang-test@v1 with: diff --git a/Dockerfile b/Dockerfile index 80174c6..dfa6dfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-bookworm as builder +FROM golang:1.25-bookworm as builder WORKDIR /app From eb4bd352dfae9b03fa6951e730e9464b9741e77f Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 26 Oct 2025 13:21:52 -0400 Subject: [PATCH 3/4] Migrate .golangci.yml to v2 config file format --- .golangci.yml | 178 +++++++++++++++++--------------------------------- 1 file changed, 60 insertions(+), 118 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 701dd4f..40e765b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,126 +1,15 @@ -# This file contains all available configuration options -# with their default values (in comments). -# -# 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$" - -# Options for analysis running. +version: "2" run: - # The default concurrency value is the number of available CPU. - # concurrency: 4 - - # Timeout for analysis, e.g. 30s, 5m. - # Default: 1m - timeout: 10m - - # Exit code when at least one issue was found. - # Default: 1 - # issues-exit-code: 2 - - # Include test files or not. - # Default: true - tests: false - - # List of build tags, all linters use it. - # Default: []. - # build-tags: - # - mytag - - # Which dirs to skip: issues from them won't be reported. - # Can use regexp here: `generated.*`, regexp is applied on full path. - # Default value is empty list, - # but default dirs are skipped independently of this option's value (see skip-dirs-use-default). - # "/" will be replaced by current OS file path separator to properly work on Windows. - # skip-dirs: - # - autogenerated_by_my_lib - - # Enables skipping of directories: - # - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - # Default: true - # skip-dirs-use-default: false - - # If set we pass it to "go list -mod={option}". From "go help modules": - # If invoked with -mod=readonly, the go command is disallowed from the implicit - # automatic updating of go.mod described above. Instead, it fails when any changes - # to go.mod are needed. This setting is most useful to check that go.mod does - # not need updates, such as in a continuous integration and testing system. - # If invoked with -mod=vendor, the go command assumes that the vendor - # directory holds the correct copies of dependencies and ignores - # the dependency descriptions in go.mod. - # - # Allowed values: readonly|vendor|mod - # By default, it isn't set. modules-download-mode: readonly - - # Allow multiple parallel golangci-lint instances running. - # If false (default) - golangci-lint acquires file lock on start. + tests: false allow-parallel-runners: true - - # 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.19' - - -# output configuration options + timeout: 10m output: formats: - - format: colored-line-number + text: path: stderr - -# All available settings of specific linters. -linters-settings: - lll: - line-length: 132 - - nlreturn: - # Allow two-line blocks without requiring a newline - block-size: 3 - - stylecheck: - checks: [ "all", "-ST1000" ] - - 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 }} Attestant Limited. - 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. - linters: - # Enable all available linters. - # Default: false - enable-all: true - # Disable specific linter - # https://golangci-lint.run/usage/linters/#disabled-by-default + default: all disable: - cyclop - depguard @@ -129,7 +18,6 @@ linters: - exhaustruct - forcetypeassert - funlen - - gci - gochecknoglobals - gocognit - goconst @@ -138,7 +26,61 @@ linters: - mnd - nlreturn - perfsprint - - tenv - varnamelen - wrapcheck - wsl + settings: + goheader: + values: + regexp: + YEARS: (20\d\d - 20\d\d|20\d\d, 20\d\d|20\d\d) + template: |- + Copyright © {{ YEARS }} Attestant Limited. + 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. + lll: + line-length: 132 + nlreturn: + block-size: 3 + staticcheck: + checks: + - all + - -ST1000 + tagliatelle: + case: + rules: + json: snake + yaml: snake + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - .*_ssz\.go$ + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - .*_ssz\.go$ + - third_party$ + - builtin$ + - examples$ From cf4c435b792082331193b8d458d374ecb2ba49bf Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 26 Oct 2025 13:33:25 -0400 Subject: [PATCH 4/4] Fix some lints, ignore others --- .golangci.yml | 3 ++ .../grpc/handlers/accountmanager/handler.go | 1 + services/api/grpc/handlers/lister/handler.go | 1 + .../api/grpc/handlers/receiver/handler.go | 1 + services/api/grpc/handlers/signer/handler.go | 1 + .../grpc/handlers/walletmanager/handler.go | 1 + services/api/grpc/service.go | 9 ++-- testing/logger/capture.go | 42 +++++++++---------- 8 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 40e765b..a16096b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,10 +25,13 @@ linters: - lll - mnd - nlreturn + - noinlineerr - perfsprint + - revive - varnamelen - wrapcheck - wsl + - wsl_v5 settings: goheader: values: diff --git a/services/api/grpc/handlers/accountmanager/handler.go b/services/api/grpc/handlers/accountmanager/handler.go index 964edbd..782d452 100644 --- a/services/api/grpc/handlers/accountmanager/handler.go +++ b/services/api/grpc/handlers/accountmanager/handler.go @@ -27,6 +27,7 @@ import ( // Handler is the account manager handler. type Handler struct { pb.UnimplementedAccountManagerServer + accountManager accountmanager.Service process process.Service } diff --git a/services/api/grpc/handlers/lister/handler.go b/services/api/grpc/handlers/lister/handler.go index 3b503b2..533a40a 100644 --- a/services/api/grpc/handlers/lister/handler.go +++ b/services/api/grpc/handlers/lister/handler.go @@ -26,6 +26,7 @@ import ( // Handler is the lister handler. type Handler struct { pb.UnimplementedListerServer + lister lister.Service } diff --git a/services/api/grpc/handlers/receiver/handler.go b/services/api/grpc/handlers/receiver/handler.go index 805e5b9..d5d9e7d 100644 --- a/services/api/grpc/handlers/receiver/handler.go +++ b/services/api/grpc/handlers/receiver/handler.go @@ -27,6 +27,7 @@ import ( // Handler is the receiver handler, receiving requests in the distributed key generation process. type Handler struct { pb.UnimplementedDKGServer + process process.Service peers peers.Service } diff --git a/services/api/grpc/handlers/signer/handler.go b/services/api/grpc/handlers/signer/handler.go index 76ba62f..2f52d90 100644 --- a/services/api/grpc/handlers/signer/handler.go +++ b/services/api/grpc/handlers/signer/handler.go @@ -26,6 +26,7 @@ import ( // Handler is the signer handler, allowing access to signer functions through grpc. type Handler struct { pb.UnimplementedSignerServer + signer signer.Service } diff --git a/services/api/grpc/handlers/walletmanager/handler.go b/services/api/grpc/handlers/walletmanager/handler.go index 59ae476..42c8f5f 100644 --- a/services/api/grpc/handlers/walletmanager/handler.go +++ b/services/api/grpc/handlers/walletmanager/handler.go @@ -26,6 +26,7 @@ import ( // Handler is the handler for GRPC requests to the wallet manager. type Handler struct { pb.UnimplementedWalletManagerServer + walletManager walletmanager.Service } diff --git a/services/api/grpc/service.go b/services/api/grpc/service.go index 8ca8bcd..99301e1 100644 --- a/services/api/grpc/service.go +++ b/services/api/grpc/service.go @@ -118,7 +118,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) { } pb.RegisterDKGServer(s.grpcServer, receiverHandler) - err = s.serve(parameters.listenAddress) + err = s.serve(ctx, parameters.listenAddress) if err != nil { return nil, errors.Wrap(err, "failed to start API server") } @@ -177,15 +177,16 @@ func (s *Service) createServer(name string, certPEMBlock []byte, keyPEMBlock []b } // Serve serves the GRPC server. -func (s *Service) serve(listenAddress string) error { - conn, err := net.Listen("tcp", listenAddress) +func (s *Service) serve(ctx context.Context, listenAddress string) error { + var lc net.ListenConfig + listener, err := lc.Listen(ctx, "tcp", listenAddress) if err != nil { return err } log.Info().Str("address", listenAddress).Msg("Listening") go func() { - if err := s.grpcServer.Serve(conn); err != nil { + if err := s.grpcServer.Serve(listener); err != nil { log.Error().Err(err).Msg("Could not start GRPC server") } }() diff --git a/testing/logger/capture.go b/testing/logger/capture.go index b9cd22c..e528cb1 100644 --- a/testing/logger/capture.go +++ b/testing/logger/capture.go @@ -29,6 +29,17 @@ type LogCapture struct { entries []map[string]any } +// NewLogCapture captures logs for querying. +// Logs are created in JSON format and without timestamps. +func NewLogCapture() *LogCapture { + c := &LogCapture{ + entries: make([]map[string]any, 0), + } + logger := zerolog.New(c) + zerologger.Logger = logger + return c +} + // Write captures an individual log message. func (c *LogCapture) Write(p []byte) (int, error) { entry := make(map[string]any) @@ -42,17 +53,6 @@ func (c *LogCapture) Write(p []byte) (int, error) { return len(p), nil } -// NewLogCapture captures logs for querying. -// Logs are created in JSON format and without timestamps. -func NewLogCapture() *LogCapture { - c := &LogCapture{ - entries: make([]map[string]any, 0), - } - logger := zerolog.New(c) - zerologger.Logger = logger - return c -} - // AssertHasEntry checks if there is a log entry with the given string. func (c *LogCapture) AssertHasEntry(t *testing.T, msg string) { t.Helper() @@ -83,6 +83,16 @@ func (c *LogCapture) HasLog(fields map[string]any) bool { return matched } +// Entries returns all captures log entries. +func (c *LogCapture) Entries() []map[string]any { + return c.entries +} + +// ClearEntries removes all existing log entries. +func (c *LogCapture) ClearEntries() { + c.entries = make([]map[string]any, 0) +} + // hasField returns true if the entry has a matching field. func (*LogCapture) hasField(entry map[string]any, key string, value any) bool { for entryKey, entryValue := range entry { @@ -125,13 +135,3 @@ func (*LogCapture) hasField(entry map[string]any, key string, value any) bool { return false } - -// Entries returns all captures log entries. -func (c *LogCapture) Entries() []map[string]any { - return c.entries -} - -// ClearEntries removes all existing log entries. -func (c *LogCapture) ClearEntries() { - c.entries = make([]map[string]any, 0) -}