From 96ae86d5144378e29cc2cb186621f610931e39e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ber=C4=8Di=C4=8D?= Date: Tue, 17 Sep 2024 11:25:08 +0200 Subject: [PATCH] Bump Go to 1.23.2 and golangci-lint to 1.61.0 --- .changelog/5854.internal.md | 1 + .github/workflows/ci-lint.yml | 2 +- .github/workflows/ci-reproducibility.yml | 2 +- .github/workflows/release-dev.yml | 2 +- .github/workflows/release.yml | 2 +- docker/oasis-core-dev/Dockerfile | 4 ++-- docs/development-setup/prerequisites.md | 10 +++++----- go/.golangci.yml | 17 ++++++++--------- go/common/args.go | 6 ++++-- go/common/grpc/auth/auth_tls.go | 3 +-- go/common/grpc/auth/auth_tls_pubkeys.go | 5 ++--- .../cometbft/apps/roothash/transactions.go | 1 - go/go.mod | 2 +- .../scenario/e2e/runtime/keymanager_client.go | 4 ++-- go/p2p/rpc/client.go | 2 -- go/runtime/host/loadbalance/loadbalance.go | 7 ------- go/storage/mkvs/debug.go | 2 +- tests/upgrade/post/go.mod | 2 +- 18 files changed, 32 insertions(+), 42 deletions(-) create mode 100644 .changelog/5854.internal.md diff --git a/.changelog/5854.internal.md b/.changelog/5854.internal.md new file mode 100644 index 00000000000..bf73f1678eb --- /dev/null +++ b/.changelog/5854.internal.md @@ -0,0 +1 @@ +Bump Go to 1.23.2 and golangci-lint to 1.61.0 diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 7b11f2a4231..f8516c46e0a 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -46,7 +46,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.22.2" + go-version: "1.23.2" - name: Set up Rust run: rustup show - name: Install dependencies diff --git a/.github/workflows/ci-reproducibility.yml b/.github/workflows/ci-reproducibility.yml index 9cfa24b087e..3c884d6b502 100644 --- a/.github/workflows/ci-reproducibility.yml +++ b/.github/workflows/ci-reproducibility.yml @@ -39,7 +39,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.22.2" + go-version: "1.23.2" - name: Set up Rust working-directory: build${{ matrix.build_number }} run: rustup show diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index e38dfaa74ad..13908b77fc1 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -35,7 +35,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.22.2" + go-version: "1.23.2" - name: Set up Rust run: rustup show - name: Install Oasis Node prerequisites diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c56644353e8..e240e9752ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.22.2" + go-version: "1.23.2" - name: Set up Rust run: rustup show diff --git a/docker/oasis-core-dev/Dockerfile b/docker/oasis-core-dev/Dockerfile index b3a046ba008..a85a2f0a14a 100644 --- a/docker/oasis-core-dev/Dockerfile +++ b/docker/oasis-core-dev/Dockerfile @@ -1,12 +1,12 @@ FROM ubuntu:22.04 # Package versions. -ARG GO_VERSION=1.22.2 +ARG GO_VERSION=1.23.2 ARG GO_NANCY_VERSION=1.0.33 ARG GO_NANCY_CHECKSUM=a4bf5290d41b095c04f941ed5380674770c79d59735e33b1bd07a5cd5fbb135d ARG GO_PROTOC_VERSION=3.6.1 ARG GO_PROTOC_GEN_GO_VERSION=1.21.0 -ARG GOLANGCILINT_VERSION=1.56.1 +ARG GOLANGCILINT_VERSION=1.61.0 ARG GOCOVMERGE_VERSION=b5bfa59ec0adc420475f97f89b58045c721d761c ARG GOFUMPT_VERSION=v0.6.0 ARG GOIMPORTS_VERSION=v0.18.0 diff --git a/docs/development-setup/prerequisites.md b/docs/development-setup/prerequisites.md index deda88abd08..1aec66ce1a9 100644 --- a/docs/development-setup/prerequisites.md +++ b/docs/development-setup/prerequisites.md @@ -40,7 +40,7 @@ Core: ``` -* [Go] (at least version 1.22.2). +* [Go] (at least version 1.23.2). If your distribution provides a new-enough version of Go, just use that. @@ -52,18 +52,18 @@ Core: * [ensure `$GOPATH/bin` is in your `PATH`]( https://tip.golang.org/doc/code.html#GOPATH), * [install the desired version of Go]( - https://golang.org/doc/install#extra_versions), e.g. 1.22.2, with: + https://golang.org/doc/install#extra_versions), e.g. 1.23.2, with: ``` - go install golang.org/dl/go1.22.2@latest - go1.22.2 download + go install golang.org/dl/go1.23.2@latest + go1.23.2 download ``` * instruct the build system to use this particular version of Go by setting the `OASIS_GO` environment variable in your `~/.bashrc`: ``` - export OASIS_GO=go1.22.2 + export OASIS_GO=go1.23.2 ``` * [Rust]. diff --git a/go/.golangci.yml b/go/.golangci.yml index 5bdeabb5940..fd37df97999 100644 --- a/go/.golangci.yml +++ b/go/.golangci.yml @@ -10,8 +10,9 @@ linters-settings: # https://github.com/securego/gosec#available-rules - G402 - G404 + - G115 # Integer conversion with overflow check; many false positives govet: - check-shadowing: true + shadow: true # Enable once suggested fixes are shown: https://github.com/golangci/golangci-lint/issues/2134 #enable: # - fieldalignment @@ -57,10 +58,9 @@ linters: disable-all: true enable: - bodyclose + - copyloopvar - depguard - errcheck - - exportloopref - - gas - goconst - gocyclo - gofumpt @@ -70,7 +70,6 @@ linters: - gosimple - govet - ineffassign - - megacheck - misspell - revive - rowserrcheck @@ -80,11 +79,6 @@ linters: - unused run: - skip-dirs: - # golang-ci-lint requires that files compile for certain linters - # to run, and Go plugins do not compile unless `-buildmode=plugin` - # is set, which linters do not do. - - oasis-test-runner/scenario/pluginsigner/example_signer_plugin exclude-use-default: false @@ -93,3 +87,8 @@ issues: - EXC0014 # un-exclude revive `exported` which warns about incorrect comments on exported items. exclude: - context-as-argument # revive + exclude-dirs: + # golang-ci-lint requires that files compile for certain linters + # to run, and Go plugins do not compile unless `-buildmode=plugin` + # is set, which linters do not do. + - oasis-test-runner/scenario/pluginsigner/example_signer_plugin diff --git a/go/common/args.go b/go/common/args.go index a9dd5858ef4..1cfc7d6d6e6 100644 --- a/go/common/args.go +++ b/go/common/args.go @@ -15,10 +15,12 @@ func TrimArgs(osArgs []string) []string { panic("TrimArgs called with an empty argument list") } + args := []string{osArgs[0]} + for i, w := range osArgs { if w == argSeparator { - return append([]string{osArgs[0]}, osArgs[i+1:]...) + return append(args, osArgs[i+1:]...) } } - return osArgs[0:1] + return args } diff --git a/go/common/grpc/auth/auth_tls.go b/go/common/grpc/auth/auth_tls.go index 54f962bee2d..70a71f824b4 100644 --- a/go/common/grpc/auth/auth_tls.go +++ b/go/common/grpc/auth/auth_tls.go @@ -3,7 +3,6 @@ package auth import ( "context" "crypto/x509" - "fmt" "sync" "google.golang.org/grpc/codes" @@ -34,7 +33,7 @@ func (auth *PeerCertAuthenticator) AuthFunc(ctx context.Context, _ interface{}) return status.Errorf(codes.PermissionDenied, "grpc: unexpected peer authentication credentials") } if nPeerCerts := len(tlsAuth.State.PeerCertificates); nPeerCerts != 1 { - return status.Errorf(codes.PermissionDenied, fmt.Sprintf("grpc: unexpected number of peer certificates: %d", nPeerCerts)) + return status.Errorf(codes.PermissionDenied, "grpc: unexpected number of peer certificates: %d", nPeerCerts) } peerCert := tlsAuth.State.PeerCertificates[0] subject := accessctl.SubjectFromX509Certificate(peerCert) diff --git a/go/common/grpc/auth/auth_tls_pubkeys.go b/go/common/grpc/auth/auth_tls_pubkeys.go index 5744932ed2e..f121ad0261b 100644 --- a/go/common/grpc/auth/auth_tls_pubkeys.go +++ b/go/common/grpc/auth/auth_tls_pubkeys.go @@ -2,7 +2,6 @@ package auth import ( "context" - "fmt" "sync" "google.golang.org/grpc/codes" @@ -35,7 +34,7 @@ func (auth *PeerPubkeyAuthenticator) AuthFunc(ctx context.Context, _ interface{} return status.Errorf(codes.PermissionDenied, "grpc: unexpected peer authentication credentials") } if nPeerCerts := len(tlsAuth.State.PeerCertificates); nPeerCerts != 1 { - return status.Errorf(codes.PermissionDenied, fmt.Sprintf("grpc: unexpected number of peer certificates: %d", nPeerCerts)) + return status.Errorf(codes.PermissionDenied, "grpc: unexpected number of peer certificates: %d", nPeerCerts) } peerCertRaw := tlsAuth.State.PeerCertificates[0].Raw @@ -46,7 +45,7 @@ func (auth *PeerPubkeyAuthenticator) AuthFunc(ctx context.Context, _ interface{} Keys: auth.whitelist, }) if err != nil { - return status.Errorf(codes.PermissionDenied, err.Error()) + return status.Errorf(codes.PermissionDenied, "%s", err.Error()) } return nil diff --git a/go/consensus/cometbft/apps/roothash/transactions.go b/go/consensus/cometbft/apps/roothash/transactions.go index a01267c4013..524f06619ba 100644 --- a/go/consensus/cometbft/apps/roothash/transactions.go +++ b/go/consensus/cometbft/apps/roothash/transactions.go @@ -49,7 +49,6 @@ func (app *rootHashApplication) executorCommit( if ctx.IsCheckOnly() { // Notify subscribers about observed commitments. for _, ec := range cc.Commits { - ec := ec app.ecn.DeliverExecutorCommitment(cc.ID, &ec) } return nil diff --git a/go/go.mod b/go/go.mod index ebdcb7dde26..c139e3dd35e 100644 --- a/go/go.mod +++ b/go/go.mod @@ -214,4 +214,4 @@ require ( lukechampine.com/blake3 v1.3.0 // indirect ) -go 1.22.2 +go 1.23.2 diff --git a/go/oasis-test-runner/scenario/e2e/runtime/keymanager_client.go b/go/oasis-test-runner/scenario/e2e/runtime/keymanager_client.go index ba05a6e4558..cf68e7087b4 100644 --- a/go/oasis-test-runner/scenario/e2e/runtime/keymanager_client.go +++ b/go/oasis-test-runner/scenario/e2e/runtime/keymanager_client.go @@ -115,7 +115,7 @@ func (c *keyManagerRPCClient) fetchPublicKey(ctx context.Context, generation uin if msg == fmt.Sprintf("master secret generation %d not found", generation) { return nil, nil } - return nil, fmt.Errorf(msg) + return nil, fmt.Errorf("%s", msg) } var key secrets.SignedPublicKey @@ -160,7 +160,7 @@ func (c *keyManagerRPCClient) fetchEphemeralPublicKey(ctx context.Context, epoch if msg == fmt.Sprintf("ephemeral secret for epoch %d not found", epoch) { return nil, nil } - return nil, fmt.Errorf(msg) + return nil, fmt.Errorf("%s", msg) } var key secrets.SignedPublicKey diff --git a/go/p2p/rpc/client.go b/go/p2p/rpc/client.go index e270c360612..0e415adc519 100644 --- a/go/p2p/rpc/client.go +++ b/go/p2p/rpc/client.go @@ -392,8 +392,6 @@ func (c *client) CallMulti( resultCh := make(chan result, len(peers)) for _, peer := range peers { - peer := peer // Make sure goroutine below operates on the right instance. - pool.Submit(func() { // Abort early in case we are done. select { diff --git a/go/runtime/host/loadbalance/loadbalance.go b/go/runtime/host/loadbalance/loadbalance.go index 6bb1db2901f..bbee436f36b 100644 --- a/go/runtime/host/loadbalance/loadbalance.go +++ b/go/runtime/host/loadbalance/loadbalance.go @@ -90,8 +90,6 @@ func (lb *lbRuntime) Call(ctx context.Context, body *protocol.Body) (*protocol.B } resCh := make(chan *result) for _, rt := range lb.instances { - rt := rt // Make sure goroutine below operates on the right instance. - go func() { rsp, err := rt.Call(ctx, body) resCh <- &result{ @@ -167,9 +165,6 @@ func (lb *lbRuntime) WatchEvents() (<-chan *host.Event, pubsub.ClosableSubscript func (lb *lbRuntime) Start() { lb.startOnce.Do(func() { for idx, rt := range lb.instances { - idx := idx - rt := rt // Make sure goroutine below operates on the right instance. - // Subscribe to runtime events before starting runtime to make sure we don't miss the // started event. evCh, sub := rt.WatchEvents() @@ -227,8 +222,6 @@ func (lb *lbRuntime) Abort(ctx context.Context, force bool) error { // We don't know which instance to abort, so we abort all instances. errCh := make(chan error) for _, rt := range lb.instances { - rt := rt // Make sure goroutine below operates on the right instance. - go func() { errCh <- rt.Abort(ctx, force) }() diff --git a/go/storage/mkvs/debug.go b/go/storage/mkvs/debug.go index eb448a1bccd..e6f954c7046 100644 --- a/go/storage/mkvs/debug.go +++ b/go/storage/mkvs/debug.go @@ -46,6 +46,6 @@ func (t *tree) doDumpLocal(ctx context.Context, w io.Writer, ptr *node.Pointer, fmt.Fprintf(w, "%s- %s -> %v [%v/%s]", prefix, n.Key, value, n.Clean, n.Hash) default: - fmt.Fprintf(w, prefix+"") + fmt.Fprintf(w, "%s", prefix+"") } } diff --git a/tests/upgrade/post/go.mod b/tests/upgrade/post/go.mod index 84f81a5794b..572f0f75874 100644 --- a/tests/upgrade/post/go.mod +++ b/tests/upgrade/post/go.mod @@ -1,6 +1,6 @@ module github.com/oasisprotocol/oasis-core/test-upgrade -go 1.22.2 +go 1.23.2 replace ( github.com/cometbft/cometbft => github.com/oasisprotocol/cometbft v0.37.2-oasis1