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

upd/Bump minimal go version up to 1.19 #2485

Merged
merged 3 commits into from
Sep 19, 2023
Merged
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 .docker/Dockerfile.adm
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
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.cli
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
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.ir
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
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage
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
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage-testnet
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
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18.x', '1.19.x', '1.20' ]
go: [ '1.19.x', '1.20.x', '1.21' ]
steps:
- name: Setup go
uses: actions/setup-go@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changelog for NeoFS Node
### Removed

### Updated
- Update minimal supported Go version up to v1.19 (#2485)

### Updating from v0.38.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8
HUB_IMAGE ?= nspccdev/neofs
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"

GO_VERSION ?= 1.20
GO_VERSION ?= 1.21
LINT_VERSION ?= 1.54.0
ARCH = amd64

Expand Down
31 changes: 16 additions & 15 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/signal"
"path/filepath"
"sync"
"sync/atomic"
atomicstd "sync/atomic"
"syscall"
"time"
Expand Down Expand Up @@ -68,7 +69,6 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/version"
"github.com/panjf2000/ants/v2"
"go.etcd.io/bbolt"
"go.uber.org/atomic"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc"
Expand Down Expand Up @@ -248,7 +248,7 @@ type internals struct {
closers []func()

apiVersion version.Version
healthStatus *atomic.Int32
healthStatus atomic.Int32
// is node under maintenance
isMaintenance atomic.Bool
}
Expand Down Expand Up @@ -405,8 +405,8 @@ type cfgNetmap struct {
state *networkState

needBootstrap bool
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
startEpoch uint64 // epoch number when application is started
reBoostrapTurnedOff atomic.Bool // managed by control service in runtime
startEpoch uint64 // epoch number when application is started
}

type cfgNodeInfo struct {
Expand Down Expand Up @@ -505,13 +505,13 @@ func initCfg(appCfg *config.Config) *cfg {
fatalOnErr(err)

c.internals = internals{
ctx: context.Background(),
appCfg: appCfg,
internalErr: make(chan error, 10), // We only need one error, but we can have multiple senders.
wg: new(sync.WaitGroup),
apiVersion: version.Current(),
healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)),
ctx: context.Background(),
appCfg: appCfg,
internalErr: make(chan error, 10), // We only need one error, but we can have multiple senders.
wg: new(sync.WaitGroup),
apiVersion: version.Current(),
}
c.internals.healthStatus.Store(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED))

c.internals.logLevel, err = zap.ParseAtomicLevel(c.LoggerCfg.level)
fatalOnErr(err)
Expand Down Expand Up @@ -550,11 +550,10 @@ func initCfg(appCfg *config.Config) *cfg {
workerPool: containerWorkerPool,
}
c.cfgNetmap = cfgNetmap{
scriptHash: contractsconfig.Netmap(appCfg),
state: netState,
workerPool: netmapWorkerPool,
needBootstrap: !relayOnly,
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
scriptHash: contractsconfig.Netmap(appCfg),
state: netState,
workerPool: netmapWorkerPool,
needBootstrap: !relayOnly,
}
c.cfgGRPC = cfgGRPC{
maxChunkSize: maxChunkSize,
Expand All @@ -572,6 +571,8 @@ func initCfg(appCfg *config.Config) *cfg {
workerPool: reputationWorkerPool,
}

c.cfgNetmap.reBoostrapTurnedOff.Store(nodeconfig.Relay(appCfg))

c.ownerIDFromKey = user.ResolveFromECDSAPublicKey(key.PrivateKey.PublicKey)

if metricsconfig.Enabled(c.appCfg) {
Expand Down
5 changes: 2 additions & 3 deletions cmd/neofs-node/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"sync/atomic"

netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
Expand All @@ -17,13 +18,12 @@ import (
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/version"
"go.uber.org/atomic"
"go.uber.org/zap"
)

// primary solution of local network state dump.
type networkState struct {
epoch *atomic.Uint64
epoch atomic.Uint64

controlNetStatus atomic.Value // control.NetmapStatus

Expand All @@ -37,7 +37,6 @@ func newNetworkState() *networkState {
nmStatus.Store(control.NetmapStatus_STATUS_UNDEFINED)

return &networkState{
epoch: atomic.NewUint64(0),
controlNetStatus: nmStatus,
}
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nspcc-dev/neofs-node

go 1.18
go 1.19

require (
github.com/cheggaaa/pb v1.0.29
Expand Down Expand Up @@ -30,7 +30,6 @@ require (
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.4
go.etcd.io/bbolt v1.3.7
go.uber.org/atomic v1.10.0
go.uber.org/zap v1.24.0
golang.org/x/sys v0.11.0
golang.org/x/term v0.11.0
Expand Down Expand Up @@ -92,6 +91,7 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/twmb/murmur3 v1.1.5 // indirect
github.com/urfave/cli v1.22.5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net"
"sync/atomic"

"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
Expand Down Expand Up @@ -52,7 +53,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/util/state"
"github.com/panjf2000/ants/v2"
"github.com/spf13/viper"
"go.uber.org/atomic"
"go.uber.org/zap"
"google.golang.org/grpc"
)
Expand Down
7 changes: 1 addition & 6 deletions pkg/innerring/processors/governance/process_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ func (gp *Processor) processAlphabetSync(txHash util.Uint256) {
}

// 4. Update NeoFS contract in the mainnet.
epoch := gp.epochState.EpochCounter()

buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, epoch)

id := append([]byte(alphabetUpdateIDPrefix), buf...)
id := binary.LittleEndian.AppendUint64([]byte(alphabetUpdateIDPrefix), gp.epochState.EpochCounter())

prm := neofscontract.AlphabetUpdatePrm{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobovnicza/blobovnicza.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package blobovnicza
import (
"io/fs"
"os"
"sync/atomic"
"time"

"go.etcd.io/bbolt"
"go.uber.org/atomic"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobovnicza/sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (b *Blobovnicza) incSize(sz uint64) {
}

func (b *Blobovnicza) decSize(sz uint64) {
b.filled.Sub(sz)
b.filled.Add(^(sz - 1))
}

func (b *Blobovnicza) full() bool {
Expand Down
6 changes: 3 additions & 3 deletions pkg/local_object_storage/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package engine
import (
"errors"
"sync"
"sync/atomic"

"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
"github.com/nspcc-dev/neofs-node/pkg/util"
"go.uber.org/atomic"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -126,7 +126,7 @@ func (e *StorageEngine) reportShardErrorBackground(id string, msg string, err er
return
}

errCount := sh.errorCount.Inc()
errCount := sh.errorCount.Add(1)
e.reportShardErrorWithFlags(sh.Shard, errCount, false, msg, err)
}

Expand All @@ -144,7 +144,7 @@ func (e *StorageEngine) reportShardError(
return
}

errCount := sh.errorCount.Inc()
errCount := sh.errorCount.Add(1)
e.reportShardErrorWithFlags(sh.Shard, errCount, true, msg, err, fields...)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"sync/atomic"
"testing"

"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/nspcc-dev/tzhash/tz"
"github.com/panjf2000/ants/v2"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -86,7 +86,7 @@ func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine {
}

engine.shards[s.ID().String()] = shardWrapper{
errorCount: atomic.NewUint32(0),
errorCount: new(atomic.Uint32),
Shard: s,
}
engine.shardPools[s.ID().String()] = pool
Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/engine/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package engine

import (
"fmt"
"sync/atomic"

"github.com/google/uuid"
"github.com/nspcc-dev/hrw"
Expand All @@ -10,7 +11,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/panjf2000/ants/v2"
"go.uber.org/atomic"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -128,7 +128,7 @@ func (e *StorageEngine) addShard(sh *shard.Shard) error {
}

e.shards[strID] = shardWrapper{
errorCount: atomic.NewUint32(0),
errorCount: new(atomic.Uint32),
Shard: sh,
}

Expand Down
12 changes: 7 additions & 5 deletions pkg/local_object_storage/metabase/put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package meta_test
import (
"runtime"
"strconv"
"sync/atomic"
"testing"
"time"

Expand All @@ -13,7 +14,6 @@ import (
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
)

func prepareObjects(t testing.TB, n int) []*objectSDK.Object {
Expand Down Expand Up @@ -47,13 +47,14 @@ func BenchmarkPut(b *testing.B) {
// Ensure the benchmark is bound by CPU and not waiting batch-delay time.
b.SetParallelism(1)

index := atomic.NewInt64(-1)
index := new(atomic.Int64)
index.Store(-1)
objs := prepareObjects(b, b.N)
b.ResetTimer()
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if err := metaPut(db, objs[index.Inc()], nil); err != nil {
if err := metaPut(db, objs[index.Add(1)], nil); err != nil {
b.Fatal(err)
}
}
Expand All @@ -63,12 +64,13 @@ func BenchmarkPut(b *testing.B) {
db := newDB(b,
meta.WithMaxBatchDelay(time.Millisecond*10),
meta.WithMaxBatchSize(1))
index := atomic.NewInt64(-1)
index := new(atomic.Int64)
index.Store(-1)
objs := prepareObjects(b, b.N)
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if err := metaPut(db, objs[index.Inc()], nil); err != nil {
if err := metaPut(db, objs[index.Add(1)], nil); err != nil {
b.Fatal(err)
}
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/local_object_storage/pilorama/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,8 @@ func internalKey(key []byte, k, v string, parent, node Node) []byte {
key = append(key, byte(l), byte(l>>8))
key = append(key, v...)

var raw [8]byte
binary.LittleEndian.PutUint64(raw[:], parent)
key = append(key, raw[:]...)
key = binary.LittleEndian.AppendUint64(key, parent)
key = binary.LittleEndian.AppendUint64(key, node)

binary.LittleEndian.PutUint64(raw[:], node)
key = append(key, raw[:]...)
return key
}
Loading
Loading