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

go: Bump go to 1.21.0 #5356

Merged
merged 11 commits into from
Aug 28, 2023
Merged
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .buildkite/go/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ pushd go
popd

pushd tests/upgrade
make all
OASIS_GO=go1.20.2 make all
peternose marked this conversation as resolved.
Show resolved Hide resolved
popd
8 changes: 5 additions & 3 deletions .buildkite/go/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pushd go
make lint
popd

pushd tests/upgrade
make lint
popd
# Lint doesn't work.
# See: https://github.com/lucas-clemente/quic-go/wiki/quic-go-and-Go-versions
#pushd tests/upgrade
# make lint
#popd
5 changes: 0 additions & 5 deletions .buildkite/scripts/test_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
# https://buildkite.com/docs/pipelines/writing-build-scripts
set -euxo pipefail

# Install Go version needed to build the stable branch.
# See: https://github.com/lucas-clemente/quic-go/wiki/quic-go-and-Go-versions
go install golang.org/dl/go1.19.10@latest
go1.19.10 download

# Branches to test.
pre_upgrade_git_branch="stable/22.2.x"
post_upgrade_git_branch="master"
Expand Down
1 change: 1 addition & 0 deletions .changelog/5356.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go: Bump go to 1.21.0
6 changes: 3 additions & 3 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ jobs:
# e.g. "Merge 3e621938d65caaa67f8e35d145335d889d470fc8 into 19a39b2f66cd7a165082d1486b2f1eb36ec2354a".
ref: ${{ github.event.pull_request.head.sha }}
# Fetch all history so gitlint can check the relevant commits.
fetch-depth: '0'
fetch-depth: "0"
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: "3.x"
- name: Set up Node.js 12
uses: actions/setup-node@v3
with:
node-version: "12.x"
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
go-version: "1.21.x"
- name: Set up Rust
run: rustup show
- name: Install dependencies
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-reproducibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ env:
JEMALLOC_CHECKSUM: 34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6

jobs:

build-code:
# NOTE: This name appears in GitHub's Checks API.
name: build
Expand All @@ -40,7 +39,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
go-version: "1.21.x"
- name: Set up Rust
working-directory: build${{ matrix.build_number }}
run: rustup show
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
JEMALLOC_CHECKSUM: 34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6

jobs:

prepare-dev-release:
runs-on: ubuntu-22.04
steps:
Expand All @@ -36,7 +35,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
go-version: "1.21.x"
- name: Set up Rust
run: rustup show
- name: Install Oasis Node prerequisites
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
# Pattern that roughly matches Oasis Core's version tags.
# For more details on GitHub Actions' pattern match syntax, see:
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags.
- 'v[0-9]+.[0-9]+*'
- "v[0-9]+.[0-9]+*"

# Global environment variables.
env:
Expand All @@ -21,7 +21,6 @@ env:
JEMALLOC_CHECKSUM: 34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6

jobs:

prepare-release:
runs-on: ubuntu-22.04
steps:
Expand All @@ -39,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
go-version: "1.21.x"

- name: Set up Rust
run: rustup show
Expand Down
6 changes: 6 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ define ENSURE_GIT_VERSION_EQUALS_PUNCH_VERSION =
fi
endef

# Golangci-lint binary to use for all Golangci-lint commands.
export OASIS_GOLANGCI_LINT ?= golangci-lint

# Golangci-lint command prefix to use in all Golangci-lint commands.
GOLANGCI_LINT := env -u GOPATH $(OASIS_GOLANGCI_LINT)

# Go binary to use for all Go commands.
export OASIS_GO ?= go

Expand Down
15 changes: 11 additions & 4 deletions docker/oasis-core-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
FROM ubuntu:22.04

# Package versions.
ARG GO_VERSION=1.20.2
ARG GO_VERSION=1.21.0
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.51.2
ARG GOLANGCILINT_VERSION=1.54.2
ARG GOCOVMERGE_VERSION=b5bfa59ec0adc420475f97f89b58045c721d761c
ARG GOFUMPT_VERSION=v0.4.0
ARG GOIMPORTS_VERSION=v0.7.0
ARG GOFUMPT_VERSION=v0.5.0
ARG GOIMPORTS_VERSION=v0.12.0
ARG RUST_NIGHTLY_VERSION=2023-01-16
ARG JEMALLOC_VERSION=5.2.1
ARG JEMALLOC_CHECKSUM=34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6

# Legacy package versions (upgrade tests).
ARG LEGACY_GO_VERSION=1.20.2

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qq && apt-get upgrade -qq && apt-get install -qq \
Expand Down Expand Up @@ -57,6 +60,10 @@ RUN curl "https://sh.rustup.rs" -sfo rustup.sh && \
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
rm go${GO_VERSION}.linux-amd64.tar.gz && \
# Install legacy Go version.
go install golang.org/dl/go${LEGACY_GO_VERSION}@latest && \
go${LEGACY_GO_VERSION} download && \
# Prepare folder for binaries.
mkdir -p /go/bin && \
# Install a specific version of protoc-gen-go.
go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GO_PROTOC_GEN_GO_VERSION} && \
Expand Down
16 changes: 8 additions & 8 deletions docs/development-setup/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Core:
```
<!-- markdownlint-enable line-length -->

* [Go] (at least version 1.20.2).
* [Go] (at least version 1.21.0).

If your distribution provides a new-enough version of Go, just use that.

Expand All @@ -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.20.2, with:
https://golang.org/doc/install#extra_versions), e.g. 1.21.0, with:

```
go install golang.org/dl/go1.20.2@latest
go1.20.2 download
go install golang.org/dl/go1.21.0@latest
go1.21.0 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.20.2
export OASIS_GO=go1.21.0
```

* [Rust].
Expand Down Expand Up @@ -137,8 +137,8 @@ Core:
Download and install it with:

```
${OASIS_GO:-go} install mvdan.cc/gofumpt@v0.4.0
${OASIS_GO:-go} install golang.org/x/tools/cmd/goimports@v0.7.0
${OASIS_GO:-go} install mvdan.cc/gofumpt@v0.5.0
${OASIS_GO:-go} install golang.org/x/tools/cmd/goimports@v0.12.0
```

* (**OPTIONAL**) [golangci-lint].
Expand All @@ -151,7 +151,7 @@ Core:
```
curl -sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b $(${OASIS_GO:-go} env GOPATH)/bin v1.51.2
| sh -s -- -b $(${OASIS_GO:-go} env GOPATH)/bin v1.54.2
```

* (**OPTIONAL**) [protoc-gen-go].
Expand Down
36 changes: 36 additions & 0 deletions go/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,42 @@ linters-settings:
# Enable once suggested fixes are shown: https://github.com/golangci/golangci-lint/issues/2134
#enable:
# - fieldalignment
depguard:
rules:
main:
files:
- $all
allow:
- $gostd
- github.com/a8m/envsubst
- github.com/btcsuite/btcutil
- github.com/cenkalti/backoff/v4
- github.com/cometbft/cometbft
- github.com/cosmos/gogoproto/proto
- github.com/dgraph-io/badger/v3
- github.com/eapache/channels
- github.com/fxamacker/cbor/v2
- github.com/gammazero/deque
- github.com/go-kit/log
- github.com/goki/go-difflib
- github.com/golang/protobu
- github.com/golang/snappy
- github.com/google/btree
- github.com/hashicorp/go-hclog
- github.com/hashicorp/go-plugin
- github.com/hpcloud/tail
- github.com/ipfs/go-log/v2
- github.com/libp2p/go-libp2p
- github.com/multiformats/go-multiaddr
- github.com/oasisprotocol
- github.com/olekukonko/tablewriter
- github.com/powerman/rpc-codec
- github.com/prometheus
- github.com/seccomp/libseccomp-golang
- github.com/spf13
- github.com/stretchr
- github.com/tidwall/btree
- github.com/tyler-smith/go-bip39

linters:
disable-all: true
Expand Down
2 changes: 1 addition & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fmt:
# Lint.
lint:
@$(ECHO) "$(CYAN)*** Running Go linters...$(OFF)"
@env -u GOPATH golangci-lint run --timeout 4m
@$(GOLANGCI_LINT) run --timeout 4m

lint-mod-tidy:
@$(ECHO) "$(CYAN)*** Checking go mod tidy...$(OFF)"
Expand Down
8 changes: 4 additions & 4 deletions go/beacon/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var (

func handlerGetBaseEpoch(
srv interface{},
ctx context.Context, //nolint: revive
dec func(interface{}) error,
ctx context.Context,
_ func(interface{}) error,
interceptor grpc.UnaryServerInterceptor,
) (interface{}, error) {
if interceptor == nil {
Expand Down Expand Up @@ -126,7 +126,7 @@ func handlerGetEpoch(

func handlerGetFutureEpoch(
srv interface{},
ctx context.Context, //nolint: revive
ctx context.Context,
dec func(interface{}) error,
interceptor grpc.UnaryServerInterceptor,
) (interface{}, error) {
Expand Down Expand Up @@ -370,7 +370,7 @@ func (c *beaconClient) WatchEpochs(ctx context.Context) (<-chan EpochTime, pubsu
return ch, sub, nil
}

func (c *beaconClient) WatchLatestEpoch(ctx context.Context) (<-chan EpochTime, pubsub.ClosableSubscription, error) {
func (c *beaconClient) WatchLatestEpoch(context.Context) (<-chan EpochTime, pubsub.ClosableSubscription, error) {
// The only thing that uses this is the registration worker, and it
// is not over gRPC.
return nil, nil, fmt.Errorf("beacon: gRPC method not implemented")
Expand Down
2 changes: 1 addition & 1 deletion go/common/crypto/mathrand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type rngAdapter struct {
off int
}

func (a *rngAdapter) Seed(seed int64) {
func (a *rngAdapter) Seed(int64) {
panic("mathrand: Seed is not supported")
}

Expand Down
9 changes: 3 additions & 6 deletions go/common/crypto/signature/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,8 @@ func (s *Signature) UnmarshalPEM(data []byte) error {
if blk.Type != sigPEMType {
return fmt.Errorf("signature: expected different PEM block (expected: %s got: %s)", sigPEMType, blk.Type)
}
if err := s.Signature.UnmarshalBinary(blk.Bytes); err != nil {
return err
}

return nil
return s.Signature.UnmarshalBinary(blk.Bytes)
}

// Signed is a signed blob.
Expand Down Expand Up @@ -463,7 +460,7 @@ type PrettySigned struct {

// PrettyPrint writes a pretty-printed representation of the type
// to the given writer.
func (p PrettySigned) PrettyPrint(ctx context.Context, prefix string, w io.Writer) {
func (p PrettySigned) PrettyPrint(_ context.Context, prefix string, w io.Writer) {
data, err := json.MarshalIndent(p, prefix, " ")
if err != nil {
fmt.Fprintf(w, "%s<error: %s>\n", prefix, err)
Expand Down Expand Up @@ -579,7 +576,7 @@ type PrettyMultiSigned struct {

// PrettyPrint writes a pretty-printed representation of the type to the
// given writer.
func (p PrettyMultiSigned) PrettyPrint(ctx context.Context, prefix string, w io.Writer) {
func (p PrettyMultiSigned) PrettyPrint(_ context.Context, prefix string, w io.Writer) {
data, err := json.MarshalIndent(p, prefix, " ")
if err != nil {
fmt.Fprintf(w, "%s<error: %s>\n", prefix, err)
Expand Down
4 changes: 2 additions & 2 deletions go/common/crypto/signature/signers/memory/memory_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewFactory() signature.SignerFactory {
}

// EnsureRole is a no-op for testing expedience.
func (fac *Factory) EnsureRole(role signature.SignerRole) error {
func (fac *Factory) EnsureRole(signature.SignerRole) error {
return nil
}

Expand All @@ -67,7 +67,7 @@ func (fac *Factory) Generate(role signature.SignerRole, rng io.Reader) (signatur
}

// Load will return an error, as the factory does not support persistence.
func (fac *Factory) Load(role signature.SignerRole) (signature.Signer, error) {
func (fac *Factory) Load(signature.SignerRole) (signature.Signer, error) {
return nil, signature.ErrNotExist
}

Expand Down
6 changes: 3 additions & 3 deletions go/common/crypto/signature/signers/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (wf *wrapperFactory) EnsureRole(role signature.SignerRole) error {
return nil
}

func (wf *wrapperFactory) Generate(role signature.SignerRole, _rng io.Reader) (signature.Signer, error) {
func (wf *wrapperFactory) Generate(role signature.SignerRole, _ io.Reader) (signature.Signer, error) {
if role == signature.SignerVRF {
return nil, signature.ErrVRFNotSupported
}
Expand Down Expand Up @@ -271,13 +271,13 @@ type signerPlugin struct {
impl Signer
}

func (p *signerPlugin) Server(_broker *plugin.MuxBroker) (interface{}, error) {
func (p *signerPlugin) Server(*plugin.MuxBroker) (interface{}, error) {
return &rpcServer{
impl: p.impl,
}, nil
}

func (signerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
func (signerPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
return &rpcClient{
client: c,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions go/common/crypto/signature/signers/plugin/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type RPCContextSignArgs struct {
Message []byte
}

func (m *rpcServer) Initialize(args *RPCInitArgs, resp *interface{}) error {
func (m *rpcServer) Initialize(args *RPCInitArgs, _ *interface{}) error {
return m.impl.Initialize(args.Config, args.Roles...)
}

func (m *rpcServer) Load(args *RPCLoadArgs, resp *interface{}) error {
func (m *rpcServer) Load(args *RPCLoadArgs, _ *interface{}) error {
return m.impl.Load(args.Role, args.MustGenerate)
}

Expand Down
Loading
Loading