From 2ff38d70fe91e41849f56415f900be9f0be50342 Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Mon, 17 Feb 2025 12:21:50 +0100 Subject: [PATCH 1/3] build: use go1.23.6 --- .github/ISSUE_TEMPLATE/BUG-REPORT.md | 4 ++-- .github/workflows/examples.yml | 10 ++++---- .github/workflows/gnofmt_template.yml | 4 ++-- .github/workflows/gnoland.yml | 2 +- .github/workflows/main_template.yml | 3 +-- CONTRIBUTING.md | 3 +-- Dockerfile | 4 ++-- contribs/github-bot/go.mod | 4 +--- contribs/gnodev/go.mod | 4 +--- contribs/gnofaucet/go.mod | 4 +--- contribs/gnogenesis/go.mod | 4 +--- contribs/gnohealth/go.mod | 2 +- contribs/gnokeykc/go.mod | 4 +--- contribs/gnomigrate/go.mod | 4 +--- .../local-setup/installation.md | 2 +- .../validators/connect-to-existing-chain.md | 2 +- .../validators/setting-up-a-new-chain.md | 2 +- gnovm/cmd/gno/bug.go | 2 +- gnovm/pkg/gnolang/internal/txlog/txlog.go | 24 ++++++++++++------- .../pkg/gnolang/internal/txlog/txlog_test.go | 5 ++-- gnovm/pkg/gnolang/store.go | 10 ++++---- go.mod | 4 +--- misc/autocounterd/go.mod | 4 +--- misc/docs-linter/go.mod | 4 +--- misc/loop/go.mod | 4 +--- misc/stdlib_diff/go.mod | 4 +--- 26 files changed, 51 insertions(+), 72 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.md b/.github/ISSUE_TEMPLATE/BUG-REPORT.md index a63b450d678..3f2fe8452b5 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.md @@ -13,7 +13,7 @@ Describe your issue in as much detail as possible here ### Your environment -* Go version (example: go1.22.4) +* Go version (example: go1.23.6) * OS and CPU architecture (example: linux/amd64) * Gno commit hash causing the issue (example: f24690e7ebf325bffcfaf9e328c3df8e6b21e50c) @@ -37,4 +37,4 @@ Please paste any logs here that demonstrate the issue, if they exist ### Proposed solution -If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it \ No newline at end of file +If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index ffe40c2db7e..ee18c864236 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: goversion: - - "1.22.x" + - "1.23.x" runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: goversion: - - "1.22.x" + - "1.23.x" # unittests: TODO: matrix with contracts runs-on: ubuntu-latest timeout-minutes: 30 @@ -58,7 +58,7 @@ jobs: fail-fast: false matrix: goversion: - - "1.22.x" + - "1.23.x" # unittests: TODO: matrix with contracts runs-on: ubuntu-latest timeout-minutes: 10 @@ -83,13 +83,13 @@ jobs: uses: ./.github/workflows/build_template.yml with: modulepath: "examples" - go-version: "1.22.x" + go-version: "1.23.x" mod-tidy: strategy: fail-fast: false matrix: - go-version: [ "1.22.x" ] + go-version: ["1.23.x"] # unittests: TODO: matrix with contracts runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/.github/workflows/gnofmt_template.yml b/.github/workflows/gnofmt_template.yml index 096dbaa1b5d..edf9311f480 100644 --- a/.github/workflows/gnofmt_template.yml +++ b/.github/workflows/gnofmt_template.yml @@ -9,7 +9,7 @@ on: description: "Go version to use" required: false type: string - default: "1.22.x" + default: "1.23.x" jobs: fmt: @@ -30,4 +30,4 @@ jobs: - name: Check for unformatted code run: | - git diff --exit-code || (echo "Some gno files are not formatted, please run 'make fmt'." && exit 1) \ No newline at end of file + git diff --exit-code || (echo "Some gno files are not formatted, please run 'make fmt'." && exit 1) diff --git a/.github/workflows/gnoland.yml b/.github/workflows/gnoland.yml index c4bc26a45fc..44644842618 100644 --- a/.github/workflows/gnoland.yml +++ b/.github/workflows/gnoland.yml @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: ["1.22.x"] + go-version: ["1.23.x"] # unittests: TODO: matrix with contracts runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/.github/workflows/main_template.yml b/.github/workflows/main_template.yml index a463bb330ea..6b62a176cae 100644 --- a/.github/workflows/main_template.yml +++ b/.github/workflows/main_template.yml @@ -11,7 +11,7 @@ on: description: "Go version to use" required: false type: string - default: "1.22.x" + default: "1.23.x" secrets: codecov-token: required: true @@ -39,4 +39,3 @@ jobs: tests-extra-args: ${{ inputs.tests-extra-args }} secrets: codecov-token: ${{ secrets.codecov-token }} - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9562a531227..2e0e989ccac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,7 @@ The gno repository is primarily based on Go (Golang) and Gno. The primary tech stack for working on the repository: -- Go (version 1.22+) +- Go (version 1.23+) - make (for using Makefile configurations) It is recommended to work on a Unix environment, as most of the tooling is built around ready-made tools in Unix (WSL2 @@ -514,4 +514,3 @@ automatic label management. | info needed | Issue is lacking information needed for resolving | | investigating | Issue is still being investigated by the team | | question | Issue starts a discussion or raises a question | - diff --git a/Dockerfile b/Dockerfile index effc30ca32f..057d4388415 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build gno -FROM golang:1.22-alpine AS build-gno +FROM golang:1.23-alpine AS build-gno RUN go env -w GOMODCACHE=/root/.cache/go-build WORKDIR /gnoroot ENV GNOROOT="/gnoroot" @@ -11,7 +11,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./ RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gno ./gnovm/cmd/gno # build misc binaries -FROM golang:1.22-alpine AS build-misc +FROM golang:1.23-alpine AS build-misc RUN go env -w GOMODCACHE=/root/.cache/go-build WORKDIR /gnoroot ENV GNOROOT="/gnoroot" diff --git a/contribs/github-bot/go.mod b/contribs/github-bot/go.mod index f8914819d54..e3072115c95 100644 --- a/contribs/github-bot/go.mod +++ b/contribs/github-bot/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gno/contribs/github-bot -go 1.22.0 - -toolchain go1.23.2 +go 1.23.6 replace github.com/gnolang/gno => ../.. diff --git a/contribs/gnodev/go.mod b/contribs/gnodev/go.mod index 9aea08c4a30..f520e2fbb79 100644 --- a/contribs/gnodev/go.mod +++ b/contribs/gnodev/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gno/contribs/gnodev -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 replace github.com/gnolang/gno => ../.. diff --git a/contribs/gnofaucet/go.mod b/contribs/gnofaucet/go.mod index 88c05e0d778..0a862162331 100644 --- a/contribs/gnofaucet/go.mod +++ b/contribs/gnofaucet/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gno/contribs/gnofaucet -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require ( github.com/gnolang/faucet v0.3.2 diff --git a/contribs/gnogenesis/go.mod b/contribs/gnogenesis/go.mod index 8af370f8169..e03ad1dde42 100644 --- a/contribs/gnogenesis/go.mod +++ b/contribs/gnogenesis/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/contribs/gnogenesis -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require ( github.com/gnolang/gno v0.0.0-00010101000000-000000000000 diff --git a/contribs/gnohealth/go.mod b/contribs/gnohealth/go.mod index 76d7cd9c437..81c0ae7325b 100644 --- a/contribs/gnohealth/go.mod +++ b/contribs/gnohealth/go.mod @@ -1,6 +1,6 @@ module github.com/gnolang/gno/contribs/gnohealth -go 1.22.4 +go 1.23.6 replace github.com/gnolang/gno => ../.. diff --git a/contribs/gnokeykc/go.mod b/contribs/gnokeykc/go.mod index 3abcf3d834f..0ecc7b34cf3 100644 --- a/contribs/gnokeykc/go.mod +++ b/contribs/gnokeykc/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gno/contribs/gnokeykc -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 replace github.com/gnolang/gno => ../.. diff --git a/contribs/gnomigrate/go.mod b/contribs/gnomigrate/go.mod index 96f6dc9bdc6..0381c6acd01 100644 --- a/contribs/gnomigrate/go.mod +++ b/contribs/gnomigrate/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gnomigrate -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require ( github.com/gnolang/gno v0.0.0-00010101000000-000000000000 diff --git a/docs/getting-started/local-setup/installation.md b/docs/getting-started/local-setup/installation.md index e05c2f9b205..2d091d6bf44 100644 --- a/docs/getting-started/local-setup/installation.md +++ b/docs/getting-started/local-setup/installation.md @@ -13,7 +13,7 @@ to run on your machine. ## Prerequisites - **Git** - **`make` (for running Makefiles)** -- **Go 1.22+** +- **Go 1.23+** - **Go Environment Setup**: - Make sure `$GOPATH` is well-defined, and `$GOPATH/bin` is added to your `$PATH` variable. - To do this, you can add the following line to your `.bashrc`, `.zshrc` or other config file: diff --git a/docs/gno-infrastructure/validators/connect-to-existing-chain.md b/docs/gno-infrastructure/validators/connect-to-existing-chain.md index f15f6bb59e2..82adeb557c4 100644 --- a/docs/gno-infrastructure/validators/connect-to-existing-chain.md +++ b/docs/gno-infrastructure/validators/connect-to-existing-chain.md @@ -12,7 +12,7 @@ In this tutorial, you will learn how to start a local Gno node and connect to an - **Git** - **`make` (for running Makefiles)** -- **Go 1.22+** +- **Go 1.23+** - **Go Environment Setup**: Ensure you have Go set up as outlined in the [Go official installation documentation](https://go.dev/doc/install) for your environment diff --git a/docs/gno-infrastructure/validators/setting-up-a-new-chain.md b/docs/gno-infrastructure/validators/setting-up-a-new-chain.md index 5db8a7f1a59..58ae7e011b8 100644 --- a/docs/gno-infrastructure/validators/setting-up-a-new-chain.md +++ b/docs/gno-infrastructure/validators/setting-up-a-new-chain.md @@ -13,7 +13,7 @@ Additionally, you will see the different options you can use to make your Gno in - **Git** - **`make` (for running Makefiles)** -- **Go 1.22+** +- **Go 1.23+** - **Go Environment Setup**: Ensure you have Go set up as outlined in the [Go official installation documentation](https://go.dev/doc/install) for your environment diff --git a/gnovm/cmd/gno/bug.go b/gnovm/cmd/gno/bug.go index 6f4f78410d6..fd5f907bc40 100644 --- a/gnovm/cmd/gno/bug.go +++ b/gnovm/cmd/gno/bug.go @@ -69,7 +69,7 @@ func newBugCmd(io commands.IO) *commands.Command { The new issue body is prefilled for you with the following information: - Gno version (the output of "gno version") -- Go version (example: go1.22.4) +- Go version (example: go1.23.4) - OS and CPU architecture (example: linux/amd64) - Gno commit hash causing the issue (example: f24690e7ebf325bffcfaf9e328c3df8e6b21e50c) diff --git a/gnovm/pkg/gnolang/internal/txlog/txlog.go b/gnovm/pkg/gnolang/internal/txlog/txlog.go index cda11083672..ad721940a41 100644 --- a/gnovm/pkg/gnolang/internal/txlog/txlog.go +++ b/gnovm/pkg/gnolang/internal/txlog/txlog.go @@ -7,12 +7,14 @@ // when calling [MapCommitter.Commit]. package txlog +import "iter" + // Map is a generic interface to a key/value map, like Go's builtin map. type Map[K comparable, V any] interface { Get(K) (V, bool) Set(K, V) Delete(K) - Iterate() func(yield func(K, V) bool) + Iterate() iter.Seq2[K, V] } // MapCommitter is a Map which also implements a Commit() method, which writes @@ -47,7 +49,7 @@ func (m GoMap[K, V]) Delete(k K) { } // Iterate implements [Map]. -func (m GoMap[K, V]) Iterate() func(yield func(K, V) bool) { +func (m GoMap[K, V]) Iterate() iter.Seq2[K, V] { return func(yield func(K, V) bool) { for k, v := range m { if !yield(k, v) { @@ -103,21 +105,25 @@ func (b txLog[K, V]) Delete(k K) { b.dirty[k] = deletable[V]{deleted: true} } -func (b txLog[K, V]) Iterate() func(yield func(K, V) bool) { +func (b txLog[K, V]) Iterate() iter.Seq2[K, V] { return func(yield func(K, V) bool) { // go through b.source; skip deleted values, and use updated values // for those which exist in b.dirty. - b.source.Iterate()(func(k K, v V) bool { + for k, v := range b.source.Iterate() { if dirty, ok := b.dirty[k]; ok { if dirty.deleted { - return true + continue + } + if !yield(k, dirty.v) { + return } - return yield(k, dirty.v) } // not in dirty - return yield(k, v) - }) + if !yield(k, v) { + return + } + } // iterate over all "new" values (ie. exist in b.dirty but not b.source). for k, v := range b.dirty { @@ -129,7 +135,7 @@ func (b txLog[K, V]) Iterate() func(yield func(K, V) bool) { continue } if !yield(k, v.v) { - break + return } } } diff --git a/gnovm/pkg/gnolang/internal/txlog/txlog_test.go b/gnovm/pkg/gnolang/internal/txlog/txlog_test.go index b0780fc8380..80f3b30643a 100644 --- a/gnovm/pkg/gnolang/internal/txlog/txlog_test.go +++ b/gnovm/pkg/gnolang/internal/txlog/txlog_test.go @@ -150,13 +150,12 @@ func verifyHashMapValues(t *testing.T, m Map[int, *struct{}], expectedReadonly m t.Helper() expected := maps.Clone(expectedReadonly) - m.Iterate()(func(k int, v *struct{}) bool { + for k, v := range m.Iterate() { ev, eok := expected[k] _ = assert.True(t, eok, "mapping %d:%v should exist in expected map", k, v) && assert.Equal(t, ev, v, "values should match") delete(expected, k) - return true - }) + } assert.Empty(t, expected, "(some) expected values not found in the Map") } diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 3a70d07381b..a76ecb90a66 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -246,14 +246,12 @@ func CopyFromCachedStore(destStore, cachedStore Store, cachedBase, cachedIavl st ds.iavlStore.Set(iter.Key(), iter.Value()) } - ss.cacheTypes.Iterate()(func(k TypeID, v Type) bool { + for k, v := range ss.cacheTypes.Iterate() { ds.cacheTypes.Set(k, v) - return true - }) - ss.cacheNodes.Iterate()(func(k Location, v BlockNode) bool { + } + for k, v := range ss.cacheNodes.Iterate() { ds.cacheNodes.Set(k, v) - return true - }) + } } func (ds *defaultStore) GetAllocator() *Allocator { diff --git a/go.mod b/go.mod index 027ba6359bc..c9e910b3721 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/gnolang/gno -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require ( dario.cat/mergo v1.0.1 diff --git a/misc/autocounterd/go.mod b/misc/autocounterd/go.mod index 972975d4fb0..7d9def2b3cc 100644 --- a/misc/autocounterd/go.mod +++ b/misc/autocounterd/go.mod @@ -1,8 +1,6 @@ module autocounterd -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require github.com/gnolang/gno v0.0.0-00010101000000-000000000000 diff --git a/misc/docs-linter/go.mod b/misc/docs-linter/go.mod index 2951bcbef54..a98f8115b1c 100644 --- a/misc/docs-linter/go.mod +++ b/misc/docs-linter/go.mod @@ -1,8 +1,6 @@ module linter -go 1.22.0 - -toolchain go1.23.2 +go 1.23.6 require ( github.com/gnolang/gno v0.0.0-00010101000000-000000000000 diff --git a/misc/loop/go.mod b/misc/loop/go.mod index 4c5a3f41839..7d0252da82c 100644 --- a/misc/loop/go.mod +++ b/misc/loop/go.mod @@ -1,8 +1,6 @@ module loop -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require ( github.com/docker/docker v25.0.6+incompatible diff --git a/misc/stdlib_diff/go.mod b/misc/stdlib_diff/go.mod index f2ddffba2b2..7ec537a127e 100644 --- a/misc/stdlib_diff/go.mod +++ b/misc/stdlib_diff/go.mod @@ -1,7 +1,5 @@ module github.com/gnolang/gno/misc/stdlib_diff -go 1.22.0 - -toolchain go1.22.10 +go 1.23.6 require github.com/hexops/gotextdiff v1.0.3 From 509c5bdbd489da027a10f83e8e9bf98c117873ea Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Wed, 19 Feb 2025 17:39:51 +0100 Subject: [PATCH 2/3] fixup txlog --- gnovm/pkg/gnolang/internal/txlog/txlog.go | 1 + gnovm/pkg/gnolang/internal/txlog/txlog_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gnovm/pkg/gnolang/internal/txlog/txlog.go b/gnovm/pkg/gnolang/internal/txlog/txlog.go index ad721940a41..0c5e8640bf7 100644 --- a/gnovm/pkg/gnolang/internal/txlog/txlog.go +++ b/gnovm/pkg/gnolang/internal/txlog/txlog.go @@ -117,6 +117,7 @@ func (b txLog[K, V]) Iterate() iter.Seq2[K, V] { if !yield(k, dirty.v) { return } + continue } // not in dirty diff --git a/gnovm/pkg/gnolang/internal/txlog/txlog_test.go b/gnovm/pkg/gnolang/internal/txlog/txlog_test.go index 80f3b30643a..fd2a2597194 100644 --- a/gnovm/pkg/gnolang/internal/txlog/txlog_test.go +++ b/gnovm/pkg/gnolang/internal/txlog/txlog_test.go @@ -51,17 +51,17 @@ func ExampleWrap() { func Test_txLog(t *testing.T) { t.Parallel() - type Value = struct{} + type Value = struct{ b byte } // Full "integration test" of the txLog + mapwrapper. source := GoMap[int, *Value](map[int]*Value{}) // create 4 empty values (we'll just use the pointers) vs := [...]*Value{ - {}, - {}, - {}, - {}, + {0}, + {1}, + {2}, + {3}, } source.Set(0, vs[0]) source.Set(1, vs[1]) @@ -121,8 +121,8 @@ func Test_txLog(t *testing.T) { assert.Equal(t, saved, txm.source) // double-check on the iterators. - verifyHashMapValues(t, source, map[int]*Value{1: vs[1], 2: vs[0]}) - verifyHashMapValues(t, txm, map[int]*Value{2: vs[2], 3: vs[3]}) + verifyHashMapValues(t, source, map[int]*Value{1: vs[1], 2: vs[2]}) + verifyHashMapValues(t, txm, map[int]*Value{2: vs[0], 3: vs[3]}) } { @@ -146,7 +146,7 @@ func Test_txLog(t *testing.T) { } } -func verifyHashMapValues(t *testing.T, m Map[int, *struct{}], expectedReadonly map[int]*struct{}) { +func verifyHashMapValues(t *testing.T, m Map[int, *struct{ b byte }], expectedReadonly map[int]*struct{ b byte }) { t.Helper() expected := maps.Clone(expectedReadonly) From 480a30fe7dbd65b7cb156de49aa40a94116fd05e Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Thu, 20 Feb 2025 15:52:56 +0100 Subject: [PATCH 3/3] update go directive --- go.mod | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c9e910b3721..026351cec77 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/gnolang/gno -go 1.23.6 +go 1.23 + +toolchain go1.23.6 require ( dario.cat/mergo v1.0.1