Skip to content

Commit

Permalink
Try #4865:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Sep 5, 2023
2 parents cb695b1 + c97a69a commit 4209c0f
Show file tree
Hide file tree
Showing 35 changed files with 155 additions and 201 deletions.
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
8 changes: 4 additions & 4 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 github.com/golang/mock/mockgen
go install gotest.tools/gotestsum@v1.10.0
go install honnef.co/go/tools/cmd/staticcheck@v0.4.3
go install github.com/golang/mock/mockgen@v1.6.0
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 {
g.logger.With().Error("failed to process hare output",
Expand Down
7 changes: 0 additions & 7 deletions blocks/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ func Test_HandleBlockData(t *testing.T) {
assert.NoError(t, th.HandleSyncedBlock(context.TODO(), block.ID().AsHash32(), peer, data))
}

func max(i, j int) int {
if i > j {
return i
}
return j
}

func TestValidateRewards(t *testing.T) {
for _, tc := range []struct {
desc string
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 decodeNibble(in byte) uint64 {
}

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 {
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
33 changes: 16 additions & 17 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 @@ -21,15 +21,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.29.2
github.com/libp2p/go-libp2p v0.31.0
github.com/libp2p/go-libp2p-kad-dht v0.25.0
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.10.1
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 All @@ -51,14 +51,14 @@ require (
github.com/zeebo/blake3 v0.2.3
go.uber.org/atomic v1.11.0
go.uber.org/zap v1.25.0
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/sync v0.3.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.57.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 @@ -99,7 +99,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
Expand Down Expand Up @@ -136,7 +136,7 @@ require (
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/libp2p/go-nat v0.2.0 // indirect
github.com/libp2p/go-netroute v0.2.1 // indirect
github.com/libp2p/go-reuseport v0.3.0 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -163,7 +163,7 @@ require (
github.com/nullstyle/go-xdr v0.0.0-20180726165426-f4c839f75077 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
Expand All @@ -174,9 +174,8 @@ require (
github.com/prometheus/procfs v0.10.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-19 v0.3.3 // indirect
github.com/quic-go/qtls-go1-20 v0.2.3 // indirect
github.com/quic-go/quic-go v0.36.4 // 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 @@ -206,7 +205,7 @@ require (
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
Expand All @@ -219,8 +218,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

0 comments on commit 4209c0f

Please sign in to comment.