From 870d8eb397dcb1ab17961f8e8607b7e8848f2b8f Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 27 Feb 2026 11:54:40 +0300 Subject: [PATCH 1/5] go.mod: upgrade to Go 1.25+, use 1.26 for builds Close #152. Signed-off-by: Anna Shaleva --- .github/workflows/go.yml | 10 +++++----- CHANGELOG.md | 2 +- go.mod | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 40a67824..862d9040 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,17 +20,17 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go: [ '1.24', '1.25'] + go: [ '1.25', '1.26'] os: [ubuntu-latest, windows-latest, macos-latest] exclude: # Only latest Go version for Windows and MacOS. - os: windows-latest - go: '1.24' + go: '1.25' - os: macos-latest - go: '1.24' + go: '1.25' # Exclude latest Go version for Ubuntu as Coverage uses it. - os: ubuntu-latest - go: '1.25' + go: '1.26' steps: - name: Setup go @@ -52,7 +52,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.25 + go-version: 1.26 - name: Check out uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a8717d..063395ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ New features: Behaviour changes: Improvements: - * minimum required Go version is 1.24 (#144) + * minimum required Go version is 1.25 (#144, #156) Bugs fixed: diff --git a/go.mod b/go.mod index e3d5cf0e..33180733 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/nspcc-dev/dbft -go 1.24 +go 1.25 require ( github.com/stretchr/testify v1.11.1 From c6b0b369799ae7b341215b866a5cc122a5a327fa Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 27 Feb 2026 12:01:58 +0300 Subject: [PATCH 2/5] *: convert worker groups to wg.Go() use where possible Available since Go 1.25. Signed-off-by: Anna Shaleva --- internal/simulation/main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/simulation/main.go b/internal/simulation/main.go index 4625144c..9025217d 100644 --- a/internal/simulation/main.go +++ b/internal/simulation/main.go @@ -68,14 +68,10 @@ func main() { defer cancel() wg := new(sync.WaitGroup) - wg.Add(len(nodes)) - for i := range nodes { - go func(i int) { - defer wg.Done() - + wg.Go(func() { nodes[i].Run(ctx) - }(i) + }) } wg.Wait() From 9f437e413d10c203d5bce6392a16cafdd313173b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 27 Feb 2026 12:04:38 +0300 Subject: [PATCH 3/5] go.mod: upgrade dependencies Signed-off-by: Anna Shaleva --- CHANGELOG.md | 1 + go.mod | 4 ++-- go.sum | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 063395ae..9b26e7da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Behaviour changes: Improvements: * minimum required Go version is 1.25 (#144, #156) + * `go.uber.org/zap` dependency upgrade from v1.27.0 to v1.27.1 (#156) Bugs fixed: diff --git a/go.mod b/go.mod index 33180733..c1ce46b3 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.25 require ( github.com/stretchr/testify v1.11.1 - go.uber.org/zap v1.27.0 + go.uber.org/zap v1.27.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.uber.org/multierr v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 92630fbd..2118601b 100644 --- a/go.sum +++ b/go.sum @@ -6,10 +6,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 1492f73258a90d035895a85c914607cf1a0f9fd3 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 27 Feb 2026 12:30:39 +0300 Subject: [PATCH 4/5] consensus: remove unused arg from fillRandom Should be a part of 07e2e263. Signed-off-by: Anna Shaleva --- internal/consensus/message_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/consensus/message_test.go b/internal/consensus/message_test.go index f4bad7c2..ff149cd2 100644 --- a/internal/consensus/message_test.go +++ b/internal/consensus/message_test.go @@ -42,7 +42,7 @@ func TestPayload_EncodeDecode(t *testing.T) { t.Run("Commit", func(t *testing.T) { var cc commit - fillRandom(t, cc.signature[:]) + fillRandom(cc.signature[:]) m := generateMessage(dbft.CommitType, &cc) testEncodeDecode(t, m, new(Payload)) @@ -146,7 +146,7 @@ func TestCompact_EncodeDecode(t *testing.T) { ValidatorIndex: 10, ViewNumber: 77, } - fillRandom(t, p.Signature[:]) + fillRandom(p.Signature[:]) testEncodeDecode(t, p, new(commitCompact)) }) @@ -201,6 +201,6 @@ func testMarshalUnmarshal(t *testing.T, expected, actual *Payload) { require.Equal(t, expected.Hash(), actual.Hash()) } -func fillRandom(t *testing.T, arr []byte) { +func fillRandom(arr []byte) { _, _ = rand.Read(arr) } From e944d6910338b9ef6fed7c90dbfc91f2a3c5b924 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 27 Feb 2026 12:37:55 +0300 Subject: [PATCH 5/5] timer: migrate TestTimer_Reset to synctest Before (1sec 108ms): ``` === RUN TestTimer_Reset --- PASS: TestTimer_Reset (1.10s) ``` After (4ms): ``` === RUN TestTimer_Reset --- PASS: TestTimer_Reset (0.00s) ``` Signed-off-by: Anna Shaleva --- timer/timer_test.go | 48 +++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/timer/timer_test.go b/timer/timer_test.go index 6b3c8b68..8635ee79 100644 --- a/timer/timer_test.go +++ b/timer/timer_test.go @@ -2,37 +2,47 @@ package timer import ( "testing" + "testing/synctest" "time" "github.com/stretchr/testify/require" ) func TestTimer_Reset(t *testing.T) { - tt := New() + synctest.Test(t, func(t *testing.T) { + tt := New() - tt.Reset(1, 2, time.Millisecond*100) - time.Sleep(time.Millisecond * 200) - shouldReceive(t, tt, 1, 2, "no value in timer") + tt.Reset(1, 2, time.Millisecond*100) + time.Sleep(time.Millisecond * 200) + synctest.Wait() + shouldReceive(t, tt, 1, 2, "no value in timer") - tt.Reset(1, 2, time.Second) - tt.Reset(2, 3, 0) - shouldReceive(t, tt, 2, 3, "no value in timer after reset(0)") + tt.Reset(1, 2, time.Second) + tt.Reset(2, 3, 0) + synctest.Wait() + shouldReceive(t, tt, 2, 3, "no value in timer after reset(0)") - tt.Reset(1, 2, time.Millisecond*100) - time.Sleep(time.Millisecond * 200) - tt.Reset(1, 3, time.Millisecond*100) - time.Sleep(time.Millisecond * 200) - shouldReceive(t, tt, 1, 3, "invalid value after reset") + tt.Reset(1, 2, time.Millisecond*100) + time.Sleep(time.Millisecond * 200) + synctest.Wait() + tt.Reset(1, 3, time.Millisecond*100) + time.Sleep(time.Millisecond * 200) + synctest.Wait() + shouldReceive(t, tt, 1, 3, "invalid value after reset") - tt.Reset(3, 1, time.Millisecond*100) - shouldNotReceive(t, tt, "value arrived too early") + tt.Reset(3, 1, time.Millisecond*100) + synctest.Wait() + shouldNotReceive(t, tt, "value arrived too early") - tt.Extend(time.Millisecond * 300) - time.Sleep(time.Millisecond * 200) - shouldNotReceive(t, tt, "value arrived too early after extend") + tt.Extend(time.Millisecond * 300) + time.Sleep(time.Millisecond * 200) + synctest.Wait() + shouldNotReceive(t, tt, "value arrived too early after extend") - time.Sleep(time.Millisecond * 300) - shouldReceive(t, tt, 3, 1, "no value in timer after extend") + time.Sleep(time.Millisecond * 300) + synctest.Wait() + shouldReceive(t, tt, 3, 1, "no value in timer after extend") + }) } func shouldReceive(t *testing.T, tt *Timer, height uint32, view byte, msg string) {