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

[Merged by Bors] - Update to go 1.21 #4865

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ 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.21'

# output configuration options
output:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8

FROM golang:1.20 as builder
FROM golang:1.21 as builder
RUN set -ex \
&& apt-get update --fix-missing \
&& apt-get install -qy --no-install-recommends \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ all: install build
install:
git lfs install
go mod download
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.53.3
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2
go install github.com/spacemeshos/go-scale/scalegen@v1.1.10
go install go.uber.org/mock/mockgen@v0.2.0
go install gotest.tools/gotestsum@v1.10.0
go install honnef.co/go/tools/cmd/staticcheck@v0.4.3
go install gotest.tools/gotestsum@v1.10.1
go install honnef.co/go/tools/cmd/staticcheck@v0.4.5
.PHONY: install

build: go-spacemesh get-profiler
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Since the project uses Go Modules it is best to place the code **outside** your

Building is supported on OS X, Linux, FreeBSD, and Windows.

Install [Go 1.20 or later](https://golang.org/dl/) for your platform, if you haven't already.
Install [Go 1.21 or later](https://golang.org/dl/) for your platform, if you haven't already.

On Windows you need to install `make` via [msys2](https://www.msys2.org/), [MingGW-w64](http://mingw-w64.org/doku.php) or [mingw](https://chocolatey.org/packages/mingw)

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ clone_folder: c:\gopath\src\github.com\spacemeshos\go-spacemesh\
environment:
GOPATH: c:\gopath

stack: go 1.20
stack: go 1.21

before_build:
- choco install make
Expand Down
2 changes: 1 addition & 1 deletion beacon/beacon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func TestBeacon_BeaconsWithDatabase(t *testing.T) {
// clear out the in-memory map
// the database should still give us values
pd.mu.Lock()
pd.beacons = make(map[types.EpochID]types.Beacon)
clear(pd.beacons)
pd.mu.Unlock()

got, err = pd.GetBeacon(epoch3)
Expand Down
2 changes: 1 addition & 1 deletion blocks/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (g *Generator) run() error {
out.Layer,
log.Int("num_proposals", len(out.Proposals)),
)
maxLayer = types.MaxLayer(maxLayer, out.Layer)
maxLayer = max(maxLayer, out.Layer)
_, err := g.processHareOutput(out)
if err != nil {
if errors.Is(err, errNodeHasBadMeshHash) {
Expand Down
3 changes: 1 addition & 2 deletions blocks/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/seehuhn/mt19937"

"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/common/util"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/events"
"github.com/spacemeshos/go-spacemesh/log"
Expand Down Expand Up @@ -207,7 +206,7 @@ func toUint64Slice(b []byte) []uint64 {
l := len(b)
var s []uint64
for i := 0; i < l; i += numByte {
s = append(s, binary.LittleEndian.Uint64(b[i:util.Min(l, i+numByte)]))
s = append(s, binary.LittleEndian.Uint64(b[i:min(l, i+numByte)]))
}
return s
}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 as builder
FROM golang:1.21 as builder

WORKDIR /src

Expand Down
2 changes: 1 addition & 1 deletion common/types/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (b Beacon) String() string { return b.Hex() }
func (b Beacon) ShortString() string {
str := b.Hex()
l := len(str)
return Shorten(str[util.Min(2, l):], 10)
return Shorten(str[min(2, l):], 10)
}

// Bytes gets the byte representation of the underlying hash.
Expand Down
6 changes: 3 additions & 3 deletions common/types/hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (h Hash20) String() string {
// ShortString returns a the first 5 characters of the hash, for logging purposes.
func (h Hash20) ShortString() string {
l := len(h.Hex())
return Shorten(h.Hex()[util.Min(2, l):], 10)
return Shorten(h.Hex()[min(2, l):], 10)
}

// Format implements fmt.Formatter, forcing the byte slice to be formatted as is,
Expand Down Expand Up @@ -200,13 +200,13 @@ func (h Hash32) String() string {
// ShortString returns the first 5 characters of the hash, for logging purposes.
func (h Hash32) ShortString() string {
l := len(h.Hex())
return Shorten(h.Hex()[util.Min(2, l):], 10)
return Shorten(h.Hex()[min(2, l):], 10)
}

// Shorten shortens a string to a specified length.
func Shorten(s string, maxlen int) string {
l := len(s)
return s[:util.Min(maxlen, l)]
return s[:min(maxlen, l)]
}

// Format implements fmt.Formatter, forcing the byte slice to be formatted as is,
Expand Down
20 changes: 0 additions & 20 deletions common/types/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,23 +248,3 @@ func NewLayer(layerIndex LayerID) *Layer {
blocks: make([]*Block, 0, 3),
}
}

// MinLayer returns minimal nonzero layer.
func MinLayer(i, j LayerID) LayerID {
if i == 0 {
return j
} else if j == 0 {
return i
} else if i < j {
return i
}
return j
}

// MaxLayer returns max layer.
func MaxLayer(i, j LayerID) LayerID {
if i > j {
return i
}
return j
}
11 changes: 0 additions & 11 deletions common/util/compare.go

This file was deleted.

8 changes: 5 additions & 3 deletions common/util/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@
}

func mapError(err error) error {
if err, ok := err.(*strconv.NumError); ok {
switch err.Err {
var numErr *strconv.NumError
if errors.As(err, &numErr) {
switch numErr.Err {

Check warning on line 162 in common/util/json.go

View check run for this annotation

Codecov / codecov/patch

common/util/json.go#L162

Added line #L162 was not covered by tests
case strconv.ErrRange:
return ErrUint64Range
case strconv.ErrSyntax:
return ErrSyntax
}
}
if _, ok := err.(hex.InvalidByteError); ok {
var syntaxErr hex.InvalidByteError
if errors.As(err, &syntaxErr) {
return ErrSyntax
}
if errors.Is(err, hex.ErrLength) {
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/spacemeshos/go-spacemesh

go 1.20
go 1.21

require (
cloud.google.com/go/storage v1.32.0
github.com/ALTree/bigfloat v0.2.0
github.com/benbjohnson/clock v1.3.5
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230531032220-a757362a12e1
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230824072557-45fdbaea2552
github.com/cosmos/btcutil v1.0.5
github.com/go-llsqlite/llsqlite v0.0.0-20230612031458-a9e271fe723a
github.com/gofrs/flock v0.8.1
Expand All @@ -20,15 +20,15 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.6
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/libp2p/go-libp2p v0.30.0
github.com/libp2p/go-libp2p v0.31.0
github.com/libp2p/go-libp2p-kad-dht v0.25.1
github.com/libp2p/go-libp2p-pubsub v0.9.3
github.com/libp2p/go-libp2p-record v0.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/multiformats/go-multiaddr v0.11.0
github.com/multiformats/go-varint v0.0.7
github.com/natefinch/atomic v1.0.1
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/common v0.44.0
github.com/pyroscope-io/pyroscope v0.37.2
Expand Down Expand Up @@ -56,9 +56,9 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.58.0
google.golang.org/protobuf v1.31.0
k8s.io/api v0.26.3
k8s.io/api v0.26.7
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.26.3
k8s.io/client-go v0.26.7
sigs.k8s.io/controller-runtime v0.14.6
)

Expand Down Expand Up @@ -176,8 +176,8 @@ require (
github.com/prometheus/procfs v0.11.1 // indirect
github.com/pyroscope-io/dotnetdiag v1.2.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.2 // indirect
github.com/quic-go/quic-go v0.38.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
github.com/quic-go/quic-go v0.38.1 // indirect
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
Expand Down Expand Up @@ -220,8 +220,8 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/apiextensions-apiserver v0.26.7 // indirect
k8s.io/component-base v0.26.7 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
Expand Down
Loading