Skip to content

Commit

Permalink
Merge pull request #3563 from nspcc-dev/go-1.21
Browse files Browse the repository at this point in the history
Go 1.21
  • Loading branch information
AnnaShaleva authored Aug 30, 2024
2 parents dc6c195 + 8bececb commit ff979e7
Show file tree
Hide file tree
Showing 138 changed files with 815 additions and 1,138 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'

- name: Build CLI
run: make build
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'

- name: Login to DockerHub
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'
cache: true

- name: Write coverage profile
Expand All @@ -156,24 +156,24 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-12, macos-14]
go_versions: [ '1.20', '1.21', '1.22' ]
go_versions: [ '1.21', '1.22', '1.23' ]
exclude:
# Only latest Go version for Windows and MacOS.
- os: windows-2022
go_versions: '1.20'
- os: windows-2022
go_versions: '1.21'
- os: macos-12
go_versions: '1.20'
- os: windows-2022
go_versions: '1.22'
- os: macos-12
go_versions: '1.21'
- os: macos-14
go_versions: '1.20'
- os: macos-12
go_versions: '1.22'
- os: macos-14
go_versions: '1.21'
- os: macos-14
go_versions: '1.22'
# Exclude latest Go version for Ubuntu as Coverage uses it.
- os: ubuntu-22.04
go_versions: '1.22'
go_versions: '1.23'
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ linters:
- decorder
- durationcheck
- errorlint
- exportloopref
- copyloopvar
- gofmt
- misspell
- predeclared
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Builder image
# Keep go version in sync with Build GA job.
FROM golang:1.22-alpine as builder
FROM golang:1.23-alpine as builder

# Display go version for information purposes.
RUN go version
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.wsc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Builder image
# Keep go version in sync with Build GA job.
FROM golang:1.22.0-windowsservercore-ltsc2022 as builder
FROM golang:1.23.0-windowsservercore-ltsc2022 as builder

COPY . /neo-go

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REPONAME = "neo-go"
NETMODE ?= "privnet"
BINARY=neo-go
BINARY_PATH=./bin/$(BINARY)$(shell go env GOEXE)
GO_VERSION ?= 1.20
GO_VERSION ?= 1.23
DESTDIR = ""
SYSCONFIGDIR = "/etc"
BINDIR = "/usr/bin"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ NeoGo, `:latest` points to the latest release) or build yourself.

### Building

Building NeoGo requires Go 1.20+ and `make`:
Building NeoGo requires Go 1.21+ and `make`:

```
make
Expand Down
19 changes: 12 additions & 7 deletions cli/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package query

import (
"bytes"
"cmp"
"encoding/base64"
"fmt"
"sort"
"slices"
"strconv"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -192,14 +193,18 @@ func queryCandidates(ctx *cli.Context) error {
return cli.Exit(err, 1)
}

sort.Slice(vals, func(i, j int) bool {
if vals[i].Active != vals[j].Active {
return vals[i].Active
slices.SortFunc(vals, func(a, b result.Candidate) int {
if a.Active && !b.Active {
return 1
}
if vals[i].Votes != vals[j].Votes {
return vals[i].Votes > vals[j].Votes
if !a.Active && b.Active {
return -1
}
return vals[i].PublicKey.Cmp(&vals[j].PublicKey) == -1
res := cmp.Compare(a.Votes, b.Votes)
if res != 0 {
return res
}
return a.PublicKey.Cmp(&b.PublicKey)
})
var res []byte
res = fmt.Appendf(res, "Key\tVotes\tCommittee\tConsensus\n")
Expand Down
19 changes: 8 additions & 11 deletions cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/signal"
"slices"
"syscall"
"time"

Expand Down Expand Up @@ -36,19 +37,17 @@ import (
func NewCommands() []*cli.Command {
cfgFlags := []cli.Flag{options.Config, options.ConfigFile, options.RelativePath}
cfgFlags = append(cfgFlags, options.Network...)
var cfgWithCountFlags = make([]cli.Flag, len(cfgFlags))
copy(cfgWithCountFlags, cfgFlags)
cfgFlags = append(cfgFlags, options.Debug)

var cfgWithCountFlags = slices.Clone(cfgFlags)
cfgFlags = append(cfgFlags, options.Debug)
cfgWithCountFlags = append(cfgWithCountFlags,
&cli.UintFlag{
Name: "count",
Aliases: []string{"c"},
Usage: "Number of blocks to be processed (default or 0: all chain)",
},
)
var cfgCountOutFlags = make([]cli.Flag, len(cfgWithCountFlags))
copy(cfgCountOutFlags, cfgWithCountFlags)
var cfgCountOutFlags = slices.Clone(cfgWithCountFlags)
cfgCountOutFlags = append(cfgCountOutFlags,
&cli.UintFlag{
Name: "start",
Expand All @@ -61,8 +60,7 @@ func NewCommands() []*cli.Command {
Usage: "Output file (stdout if not given)",
},
)
var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags))
copy(cfgCountInFlags, cfgWithCountFlags)
var cfgCountInFlags = slices.Clone(cfgWithCountFlags)
cfgCountInFlags = append(cfgCountInFlags,
&cli.StringFlag{
Name: "in",
Expand All @@ -79,13 +77,12 @@ func NewCommands() []*cli.Command {
Usage: "Use if dump is incremental",
},
)
var cfgHeightFlags = make([]cli.Flag, len(cfgFlags)+1)
copy(cfgHeightFlags, cfgFlags)
cfgHeightFlags[len(cfgHeightFlags)-1] = &cli.UintFlag{
var cfgHeightFlags = slices.Clone(cfgFlags)
cfgHeightFlags = append(cfgHeightFlags, &cli.UintFlag{
Name: "height",
Usage: "Height of the state to reset DB to",
Required: true,
}
})
return []*cli.Command{
{
Name: "node",
Expand Down
2 changes: 1 addition & 1 deletion cli/smartcontract/smart_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func initSmartContract(ctx *cli.Context) error {

gm := []byte("module " + contractName + `
go 1.20
go 1.21
require (
github.com/nspcc-dev/neo-go/pkg/interop ` + ver + `
Expand Down
4 changes: 2 additions & 2 deletions cli/util/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func cancelTx(ctx *cli.Context) error {
if err != nil {
return err
}
if mainTx != nil && t.NetworkFee < mainTx.NetworkFee+1 {
t.NetworkFee = mainTx.NetworkFee + 1
if mainTx != nil {
t.NetworkFee = max(t.NetworkFee, mainTx.NetworkFee+1)
}
t.NetworkFee += int64(flags.Fixed8FromContext(ctx, "gas"))
if mainTx != nil {
Expand Down
6 changes: 4 additions & 2 deletions cli/vm/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"math/big"
"os"
"slices"
"strconv"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -41,7 +42,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/util/slice"
"github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -1456,7 +1456,9 @@ func Parse(args []string) (string, error) {
}
buf = fmt.Appendf(buf, "Hex to String\t%s\n", fmt.Sprintf("%q", string(rawStr)))
buf = fmt.Appendf(buf, "Hex to Integer\t%s\n", bigint.FromBytes(rawStr))
buf = fmt.Appendf(buf, "Swap Endianness\t%s\n", hex.EncodeToString(slice.CopyReverse(rawStr)))
var clonedStr = slices.Clone(rawStr)
slices.Reverse(clonedStr)
buf = fmt.Appendf(buf, "Swap Endianness\t%s\n", hex.EncodeToString(clonedStr))
}
if addr, err := address.StringToUint160(arg); err == nil {
buf = fmt.Appendf(buf, "Address to BE ScriptHash\t%s\n", addr)
Expand Down
2 changes: 1 addition & 1 deletion cli/vm/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ require (
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0
)
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../pkg/interop") + `
go 1.20`)
go 1.21`)
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
return filename
}
Expand Down
8 changes: 4 additions & 4 deletions cli/wallet/nep11.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"slices"
"strconv"

"github.com/nspcc-dev/neo-go/cli/cmdargs"
Expand Down Expand Up @@ -39,12 +40,11 @@ func newNEP11Commands() []*cli.Command {
Usage: "Hex-encoded token ID",
}

balanceFlags := make([]cli.Flag, len(baseBalanceFlags))
copy(balanceFlags, baseBalanceFlags)
balanceFlags := slices.Clone(baseBalanceFlags)
balanceFlags = append(balanceFlags, tokenID)
balanceFlags = append(balanceFlags, options.RPC...)
transferFlags := make([]cli.Flag, len(baseTransferFlags))
copy(transferFlags, baseTransferFlags)

transferFlags := slices.Clone(baseTransferFlags)
transferFlags = append(transferFlags, tokenID)
transferFlags = append(transferFlags, options.RPC...)
return []*cli.Command{
Expand Down
8 changes: 4 additions & 4 deletions cli/wallet/nep17.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/big"
"slices"
"strings"

"github.com/nspcc-dev/neo-go/cli/cmdargs"
Expand Down Expand Up @@ -91,11 +92,10 @@ var (
)

func newNEP17Commands() []*cli.Command {
balanceFlags := make([]cli.Flag, len(baseBalanceFlags))
copy(balanceFlags, baseBalanceFlags)
balanceFlags := slices.Clone(baseBalanceFlags)
balanceFlags = append(balanceFlags, options.RPC...)
transferFlags := make([]cli.Flag, len(baseTransferFlags))
copy(transferFlags, baseTransferFlags)

transferFlags := slices.Clone(baseTransferFlags)
transferFlags = append(transferFlags, options.RPC...)
return []*cli.Command{
{
Expand Down
8 changes: 3 additions & 5 deletions cli/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"math/big"
"os"
"slices"
"strings"

"github.com/nspcc-dev/neo-go/cli/cmdargs"
Expand Down Expand Up @@ -512,16 +513,13 @@ func exportKeys(ctx *cli.Context) error {

var wifs []string

loop:
for _, a := range wall.Accounts {
if addr != "" && a.Address != addr {
continue
}

for i := range wifs {
if a.EncryptedWIF == wifs[i] {
continue loop
}
if slices.Contains(wifs, a.EncryptedWIF) {
continue
}

wifs = append(wifs, a.EncryptedWIF)
Expand Down
2 changes: 1 addition & 1 deletion examples/engine/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nspcc-dev/neo-go/examples/engine

go 1.20
go 1.21

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240727093519-1a48f1ce43ec
2 changes: 1 addition & 1 deletion examples/events/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nspcc-dev/neo-go/examples/events

go 1.20
go 1.21

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240727093519-1a48f1ce43ec
2 changes: 1 addition & 1 deletion examples/iterator/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nspcc-dev/neo-go/examples/iterator

go 1.20
go 1.21

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240727093519-1a48f1ce43ec
2 changes: 1 addition & 1 deletion examples/nft-d/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nspcc-dev/neo-go/examples/nft

go 1.20
go 1.21

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240727093519-1a48f1ce43ec
2 changes: 1 addition & 1 deletion examples/nft-nd-nns/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nspcc-dev/neo-go/examples/nft-nd-nns

go 1.20
go 1.21

require (
github.com/nspcc-dev/neo-go v0.102.1-0.20231020181554-d89c8801d689
Expand Down
Loading

0 comments on commit ff979e7

Please sign in to comment.