diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index fad5a91a3..350c7b2c9 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -14,6 +14,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' # The Go version to download (if necessary) and use. + go-version: '1.24' # The Go version to download (if necessary) and use. - name: run benchmarks run: make bench diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd437a474..5612758ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.24" # The Go version to download (if necessary) and use. # Some tests, notably TestRandomOperations, are extremely slow in CI # with the race detector enabled, so we use -short when -race is diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bc8533895..b97d77e8e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,8 +15,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "^1.20.0" + go-version: "1.24" - name: golangci-lint uses: golangci/golangci-lint-action@v4 with: - version: v1.55.2 + version: v1.57.0 diff --git a/.golangci.yml b/.golangci.yml index 816d9c4a9..6d449cd67 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,7 +9,7 @@ linters: - bodyclose - dogsled - errcheck - - exportloopref + - copyloopvar - goconst - gocritic - gofumpt diff --git a/Makefile b/Makefile index 73e05df27..8aa44179d 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ format: # look into .golangci.yml for enabling / disabling linters golangci_lint_cmd=golangci-lint -golangci_version=v1.55.2 +golangci_version=v1.57.0 lint: @echo "--> Running linter" diff --git a/benchmarks/bench_test.go b/benchmarks/bench_test.go index 8a82590d6..ccca550b8 100644 --- a/benchmarks/bench_test.go +++ b/benchmarks/bench_test.go @@ -348,7 +348,6 @@ func runBenchmarks(b *testing.B, benchmarks []benchmark) { ) if bb.dbType != "nodb" { d, err = dbm.NewDB("test", bb.dbType, dirName) - if err != nil { if strings.Contains(err.Error(), "unknown db_backend") { // As an exception to run benchmarks: if the error is about cleveldb, or rocksdb, diff --git a/cmd/legacydump/go.mod b/cmd/legacydump/go.mod index 4b33bb151..1f7142174 100644 --- a/cmd/legacydump/go.mod +++ b/cmd/legacydump/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/iavl/cmd/legacydump -go 1.20 +go 1.24 require ( github.com/cometbft/cometbft-db v0.7.0 @@ -29,3 +29,5 @@ require ( golang.org/x/sys v0.13.0 // indirect google.golang.org/protobuf v1.33.0 // indirect ) + +toolchain go1.24.4 diff --git a/cmd/legacydump/legacydump b/cmd/legacydump/legacydump index 9992570af..707005b27 100755 Binary files a/cmd/legacydump/legacydump and b/cmd/legacydump/legacydump differ diff --git a/cmd/legacydump/legacydump.macos b/cmd/legacydump/legacydump.macos new file mode 100755 index 000000000..4a7a83ec1 Binary files /dev/null and b/cmd/legacydump/legacydump.macos differ diff --git a/db/wrapper.go b/db/wrapper.go index fce80f692..16fd92b56 100644 --- a/db/wrapper.go +++ b/db/wrapper.go @@ -34,6 +34,11 @@ func (db *Wrapper) NewBatchWithSize(size int) Batch { return db.DB.NewBatchWithSize(size) } +// Close implements DB. +func (db *Wrapper) Close() error { + return db.DB.Close() +} + // NewDB returns a new Wrapper. func NewDB(name, backendType, dir string) (*Wrapper, error) { db, err := dbm.NewDB(name, dbm.BackendType(backendType), dir) diff --git a/go.mod b/go.mod index 5ec61d8d2..46c65ea31 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/cosmos/iavl -go 1.21 +go 1.24 + +toolchain go1.24.4 require ( cosmossdk.io/log v1.3.1 diff --git a/internal/bytes/bytes.go b/internal/bytes/bytes.go index 23c042196..281bb0908 100644 --- a/internal/bytes/bytes.go +++ b/internal/bytes/bytes.go @@ -57,9 +57,9 @@ func (bz HexBytes) String() string { func (bz HexBytes) Format(s fmt.State, verb rune) { switch verb { case 'p': - s.Write([]byte(fmt.Sprintf("%p", bz))) + _, _ = s.Write([]byte(fmt.Sprintf("%p", bz))) default: - s.Write([]byte(fmt.Sprintf("%X", []byte(bz)))) + _, _ = s.Write([]byte(fmt.Sprintf("%X", []byte(bz)))) } } diff --git a/migrate_test.go b/migrate_test.go index 547ef572e..abc00af22 100644 --- a/migrate_test.go +++ b/migrate_test.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path" + "runtime" "testing" "time" @@ -30,7 +31,12 @@ func createLegacyTree(t *testing.T, dbDir string, version int) (string, error) { } } - cmd := exec.Command("sh", "-c", fmt.Sprintf("./cmd/legacydump/legacydump %s %s random %d %d", dbType, relateDir, version, version/2)) //nolint:gosec + // Use platform-specific binary + binaryPath := "./cmd/legacydump/legacydump" // Linux binary for CI + if runtime.GOOS == "darwin" { + binaryPath = "./cmd/legacydump/legacydump.macos" // macOS binary for local development + } + cmd := exec.Command(binaryPath, dbType, relateDir, "random", fmt.Sprintf("%d", version), fmt.Sprintf("%d", version/2)) //nolint:gosec var out bytes.Buffer var stderr bytes.Buffer cmd.Stdout = &out @@ -340,6 +346,7 @@ func TestRandomSet(t *testing.T) { require.NoError(t, err) } - err = tree.DeleteVersionsTo(int64(legacyVersion + postVersions - 1)) + // Delete versions but keep the legacy version + err = tree.DeleteVersionsTo(int64(legacyVersion + postVersions - 2)) require.NoError(t, err) } diff --git a/nodedb.go b/nodedb.go index dc0bc9f4b..46a2105c6 100644 --- a/nodedb.go +++ b/nodedb.go @@ -505,7 +505,6 @@ func (ndb *nodeDB) DeleteVersionsFrom(fromVersion int64) error { err = ndb.traverseRange(nodeKeyPrefixFormat.KeyInt64(fromVersion), nodeKeyPrefixFormat.KeyInt64(latest+1), func(k, v []byte) error { return ndb.batch.Delete(k) }) - if err != nil { return err } @@ -1213,7 +1212,6 @@ func (ndb *nodeDB) String() (string, error) { index++ return nil }) - if err != nil { return "", err }