Skip to content

chore: update go to 1.24 #1046

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
merged 2 commits into from
Apr 14, 2025
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 .github/workflows/go-mod-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false

- name: go mod tidy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false
- name: Run Gosec
id: gosec-run
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false

- name: Check `builtins` directory
Expand All @@ -31,7 +31,7 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.64.5
version: v1.64.8
# use the default if on main branch, otherwise use the pull request config
args: --timeout=30m --config=.golangci.yml
only-new-issues: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
unit_tests:
strategy:
matrix:
go-version: [1.23.x]
go-version: [1.24.x]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- go-version: 1.21.x
os: ubuntu-latest
- go-version: 1.22.x
os: ubuntu-latest
- go-version: 1.24.x
- go-version: 1.23.x
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Make all
run: make all
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build thor in a stock Go builder container
FROM golang:1.23-alpine3.21 AS builder
FROM golang:1.24-alpine3.21 AS builder

RUN apk add --no-cache make gcc musl-dev linux-headers git
WORKDIR /go/thor
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ dep:| go_version_check

go_version_check:
@if test $(MAJOR) -lt 1; then \
echo "Go 1.23 or higher required"; \
echo "Go 1.24 or higher required"; \
exit 1; \
else \
if test $(MAJOR) -eq 1 -a $(MINOR) -lt 22; then \
echo "Go 1.23 or higher required"; \
echo "Go 1.24 or higher required"; \
exit 1; \
fi \
fi
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vechain/thor/v2

go 1.23
go 1.24

require (
github.com/beevik/ntp v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions log/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ var sink []byte
func BenchmarkPrettyInt64Logfmt(b *testing.B) {
buf := make([]byte, 100)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
sink = appendInt64(buf, rand.Int64()) //#nosec G404
}
}

func BenchmarkPrettyUint64Logfmt(b *testing.B) {
buf := make([]byte, 100)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
sink = appendUint64(buf, rand.Uint64(), false) //#nosec G404
}
}
14 changes: 7 additions & 7 deletions log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func TestJSONHandler(t *testing.T) {

func BenchmarkTraceLogging(b *testing.B) {
SetDefault(NewLogger(NewTerminalHandler(os.Stderr, true)))
b.ResetTimer()
for i := 0; i < b.N; i++ {

for i := 0; b.Loop(); i++ {
Trace("a message", "v", i)
}
}
Expand Down Expand Up @@ -102,8 +102,8 @@ func benchmarkLogger(b *testing.B, l Logger) {
err = errors.New("oh nooes it's crap")
)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {

for i := 0; b.Loop(); i++ {
l.Info("This is a message",
"foo", int16(i),
"bytes", bb,
Expand Down Expand Up @@ -165,18 +165,18 @@ const termTimeFormat = "01-02|15:04:05.000"
func BenchmarkAppendFormat(b *testing.B) {
var now = time.Now()
b.Run("fmt time.Format", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
fmt.Fprintf(io.Discard, "%s", now.Format(termTimeFormat))
}
})
b.Run("time.AppendFormat", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
now.AppendFormat(nil, termTimeFormat)
}
})
var buf = new(bytes.Buffer)
b.Run("time.Custom", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
writeTimeTermFormat(buf, now)
buf.Reset()
}
Expand Down
11 changes: 5 additions & 6 deletions logdb/logdb_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func BenchmarkFakeDB_NewestBlockID(t *testing.B) {
t.ResetTimer()
for _, tt := range tests {
t.Run(tt.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
want, err := tt.prepare()
require.NoError(t, err)

Expand Down Expand Up @@ -139,7 +139,7 @@ func BenchmarkFakeDB_WriteBlocks(t *testing.B) {
t.ResetTimer()
for _, tt := range tests {
t.Run(tt.name, func(b *testing.B) {
for i := 0; i < t.N; i++ {
for t.Loop() {
tt.writeFunc(b)
}
})
Expand All @@ -158,8 +158,7 @@ func BenchmarkTestDB_HasBlockID(b *testing.B) {
require.NoError(b, err)
require.GreaterOrEqual(b, len(events), 500_000, "there should be more than 500k events in the db")

b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
for _, event := range events {
has, err := db.HasBlockID(event.BlockID)
require.NoError(b, err)
Expand Down Expand Up @@ -203,7 +202,7 @@ func BenchmarkTestDB_FilterEvents(b *testing.B) {
for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err = db.FilterEvents(context.Background(), tt.arg)
if err != nil {
b.Fatal(err)
Expand Down Expand Up @@ -242,7 +241,7 @@ func BenchmarkTestDB_FilterTransfers(b *testing.B) {
for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err = db.FilterTransfers(context.Background(), tt.arg)
if err != nil {
b.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions muxdb/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Benchmark_cacheNodeBlob(b *testing.B) {
)
rand.Read(blob)

for i := 0; i < b.N; i++ {
for b.Loop() {
cache.AddNodeBlob(&keyBuf, name, path, trie.Version{}, blob, true)
got := cache.GetNodeBlob(&keyBuf, name, path, trie.Version{}, false)
if !bytes.Equal(got, blob) {
Expand All @@ -86,7 +86,7 @@ func Benchmark_cacheRootNode(b *testing.B) {

rn := tr.RootNode()

for i := 0; i < b.N; i++ {
for b.Loop() {
cache.AddRootNode(name, rn)
got := cache.GetRootNode(name, trie.Version{})
if got != rn {
Expand Down
8 changes: 4 additions & 4 deletions thor/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func BenchmarkHash(b *testing.B) {

k := sha3.NewLegacyKeccak256().(keccakState)
var b32 thor.Bytes32
for i := 0; i < b.N; i++ {
for b.Loop() {
k.Write(data)
k.Read(b32[:])
k.Reset()
}
})

b.Run("blake2b", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
thor.Blake2b(data)
}
})
Expand All @@ -47,13 +47,13 @@ func BenchmarkBlake2b(b *testing.B) {
data := make([]byte, 100)
rand.New(rand.NewSource(1)).Read(data) //#nosec G404
b.Run("Blake2b", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
thor.Blake2b(data).Bytes()
}
})

b.Run("BlakeFn", func(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
thor.Blake2bFn(func(w io.Writer) {
w.Write(data)
})
Expand Down
2 changes: 1 addition & 1 deletion tracers/tracers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type traceTest struct {

type callTest struct {
traceTest
Calls callFrame `json:"calls,omitempty"`
Calls callFrame `json:"calls"`
}

type diffState struct {
Expand Down
2 changes: 1 addition & 1 deletion trie/derive_root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func BenchmarkDeriveRoot(b *testing.B) {
n: 100,
content: make([]byte, 32),
}
for i := 0; i < b.N; i++ {
for b.Loop() {
DeriveRoot(&list)
}
}
10 changes: 5 additions & 5 deletions trie/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,36 @@ func TestHexKeybytes(t *testing.T) {

func BenchmarkHexToCompact(b *testing.B) {
testBytes := []byte{0, 15, 1, 12, 11, 8, 16 /*term*/}
for i := 0; i < b.N; i++ {
for b.Loop() {
hexToCompact(testBytes)
}
}

func BenchmarkAppendHexToCompact(b *testing.B) {
testBytes := []byte{0, 15, 1, 12, 11, 8, 16 /*term*/}
var buf []byte
for i := 0; i < b.N; i++ {
for b.Loop() {
buf = appendHexToCompact(buf[:0], testBytes)
}
}

func BenchmarkCompactToHex(b *testing.B) {
testBytes := []byte{0, 15, 1, 12, 11, 8, 16 /*term*/}
for i := 0; i < b.N; i++ {
for b.Loop() {
compactToHex(testBytes)
}
}

func BenchmarkKeybytesToHex(b *testing.B) {
testBytes := []byte{7, 6, 6, 5, 7, 2, 6, 2, 16}
for i := 0; i < b.N; i++ {
for b.Loop() {
keybytesToHex(testBytes)
}
}

func BenchmarkHexToKeybytes(b *testing.B) {
testBytes := []byte{7, 6, 6, 5, 7, 2, 6, 2, 16}
for i := 0; i < b.N; i++ {
for b.Loop() {
hexToKeybytes(testBytes)
}
}
8 changes: 4 additions & 4 deletions trie/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func benchmarkEncodeFullNode(b *testing.B, consensus, skipHash bool) {
for i := range 16 {
f.children[i] = &refNode{hash: datagen.RandomHash().Bytes()}
}
for i := 0; i < b.N; i++ {
for b.Loop() {
if consensus {
buf = f.encodeConsensus(buf[:0])
} else {
Expand All @@ -50,7 +50,7 @@ func benchmarkEncodeShortNode(b *testing.B, consensus bool) {
buf []byte
)

for i := 0; i < b.N; i++ {
for b.Loop() {
if consensus {
buf = s.encodeConsensus(buf[:0])
} else {
Expand Down Expand Up @@ -85,7 +85,7 @@ func benchmarkDecodeFullNode(b *testing.B, skipHash bool) {
f.children[i] = &refNode{hash: datagen.RandomHash().Bytes()}
}
enc := f.encode(nil, skipHash)
for i := 0; i < b.N; i++ {
for b.Loop() {
mustDecodeNode(nil, enc, 0)
}
}
Expand All @@ -105,7 +105,7 @@ func BenchmarkDecodeShortNode(b *testing.B) {
}

enc := s.encode(nil, false)
for i := 0; i < b.N; i++ {
for b.Loop() {
mustDecodeNode(nil, enc, 0)
}
}
Expand Down
5 changes: 2 additions & 3 deletions trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ func benchGet(b *testing.B, commit bool) {
trie.Commit(db, root.Ver, false)
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
trie.Get(k)
}
b.StopTimer()
Expand All @@ -484,7 +483,7 @@ func benchGet(b *testing.B, commit bool) {
func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie {
trie := new(Trie)
k := make([]byte, 32)
for i := 0; i < b.N; i++ {
for i := 0; b.Loop(); i++ {
e.PutUint64(k, uint64(i))
trie.Update(k, k, nil)
}
Expand Down
2 changes: 1 addition & 1 deletion tx/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func BenchmarkTxMining(b *testing.B) {
signer := thor.BytesToAddress([]byte("acc1"))
maxWork := &big.Int{}
eval := tx.EvaluateWork(signer)
for i := 0; i < b.N; i++ {
for i := 0; b.Loop(); i++ {
work := eval(uint64(i))
if work.Cmp(maxWork) > 0 {
maxWork = work
Expand Down
Loading
Loading