diff --git a/.golangci.yml b/.golangci.yml index d95b76d4024..263277fb363 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,6 +24,7 @@ issues: # gosec - "^G101: Potential hardcoded credentials" - "^G108: Profiling endpoint is automatically exposed on /debug/pprof" + - "^G115: integer overflow conversion u?int(8|32|64)? -> u?int(8|32|64)?" - "^G204: Subprocess launched with (variable|a potential tainted input or cmd arguments)" - "^G301: Expect directory permissions to be 0750 or less" - "^G302: Expect file permissions to be 0600 or less" @@ -47,6 +48,7 @@ issues: - "^var-naming: (method|range var) \\w*(Api|Http|Id|Rpc|Url)[^\\s]* should be \\w*(API|HTTP|ID|RPC|URL)" - "^var-naming: don't use underscores in Go names" - "^var-naming: don't use ALL_CAPS in Go names; use CamelCase" + - "^redefines-builtin-id: redefinition of the built-in (function|type) (max|min|cap|recover|new|error)" exclude-use-default: false exclude-rules: diff --git a/CHANGELOG.md b/CHANGELOG.md index 989a79acaf8..82b53eaa58b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ > * [CHANGELOG_1.2x.md](./documentation/changelog/CHANGELOG_1.2x.md) - v1.20.0 to v1.29.2 # UNRELEASED +- The minimum supported Golang version is now `1.24.7` - feat(gateway): expose StateGetRandomnessDigestFromBeacon ([filecoin-project/lotus#13339](https://github.com/filecoin-project/lotus/pull/13339)) # Node and Miner v1.34.0 / 2025-09-11 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 127049645d7..efb4a301687 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -126,29 +126,34 @@ When updating the Go version (either patch or minor), the following files must b #### Step-by-Step Process ```bash +OLD_GO_VERSION="1.23.7" +NEW_GO_VERSION="1.23.10" + # Update go.mod -sed -i 's/go 1.23.7/go 1.23.10/' go.mod +sed -i "s/go $OLD_GO_VERSION/go $NEW_GO_VERSION/" go.mod # Update GO_VERSION_MIN -echo "1.23.10" > GO_VERSION_MIN +echo "$NEW_GO_VERSION" > GO_VERSION_MIN # Update README.md badge and documentation -sed -i 's/1.23.7/1.23.10/' README.md +sed -i "s/$OLD_GO_VERSION/$NEW_GO_VERSION/g" README.md # Update Dockerfile -sed -i 's/FROM golang:1.23.7-bullseye/FROM golang:1.23.10-bullseye/' Dockerfile +sed -i "s/FROM golang:$OLD_GO_VERSION-bullseye/FROM golang:$NEW_GO_VERSION-bullseye/" Dockerfile # Add a changelog entry +# Validate go mod tidy make build make unittests +make lint ``` - #### Example Reference -For an example of a Go patch version update, see [PR #13190](https://github.com/filecoin-project/lotus/pull/13190) which updated from Go 1.23.7 to 1.23.10. +For an example of a Go patch version update, see [PR #13190](https://github.com/filecoin-project/lotus/pull/13190), which updated from Go 1.23.7 to 1.23.10. +For an example of a Go minor version update, see [PR #13354](https://github.com/filecoin-project/lotus/pull/13354), which updated from Go 1.23.10 to 1.24.7. ### Developer Notes diff --git a/Dockerfile b/Dockerfile index dc144741ed5..f5d0123f50c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ##################################### -FROM golang:1.23.10-bullseye AS lotus-builder +FROM golang:1.24.7-bookworm AS lotus-builder MAINTAINER Lotus Development Team RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev diff --git a/GO_VERSION_MIN b/GO_VERSION_MIN index b6773170a5f..8407e260086 100644 --- a/GO_VERSION_MIN +++ b/GO_VERSION_MIN @@ -1 +1 @@ -1.23.10 +1.24.7 diff --git a/Makefile b/Makefile index caef1461e3f..6063e2d1a81 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ $(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell $(error Update Golang to version to at least $(shell cat GO_VERSION_MIN)) endif -GOLANGCI_LINT_VERSION=v1.60.1 +GOLANGCI_LINT_VERSION=v1.64.8 # git modules that need to be loaded MODULES:= diff --git a/README.md b/README.md index addae88c33d..b5a38f90f67 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ - +

@@ -58,10 +58,10 @@ For other distributions you can find the required dependencies [here.](https://l #### Go -To build Lotus, you need a working installation of [Go 1.23.10 or higher](https://golang.org/dl/): +To build Lotus, you need a working installation of [Go 1.24.7 or higher](https://golang.org/dl/): ```bash -wget -c https://golang.org/dl/go1.23.10.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local +wget -c https://golang.org/dl/go1.24.7.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local ``` **TIP:** diff --git a/api/api_test.go b/api/api_test.go index 2757a47298f..d2b386b8830 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -16,12 +16,21 @@ import ( "github.com/filecoin-project/go-jsonrpc" ) +func goRoot() (string, error) { + out, err := exec.Command("go", "env", "GOROOT").Output() + if err != nil { + return "", err + } + return strings.TrimSpace(string(out)), nil +} + func goCmd() string { var exeSuffix string if runtime.GOOS == "windows" { exeSuffix = ".exe" } - path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) + root, _ := goRoot() + path := filepath.Join(root, "bin", "go"+exeSuffix) if _, err := os.Stat(path); err == nil { return path } diff --git a/chain/types/ethtypes/rlp.go b/chain/types/ethtypes/rlp.go index 15cee4a22a9..65801ac45c8 100644 --- a/chain/types/ethtypes/rlp.go +++ b/chain/types/ethtypes/rlp.go @@ -60,17 +60,16 @@ func encodeRLP(val interface{}) ([]byte, error) { } else if len(data) <= 55 { prefix := byte(0x80 + len(data)) return append([]byte{prefix}, data...), nil - } else { - lenInBytes, err := encodeLength(len(data)) - if err != nil { - return nil, err - } - prefix := byte(0xb7 + len(lenInBytes)) - return append( - []byte{prefix}, - append(lenInBytes, data...)..., - ), nil } + lenInBytes, err := encodeLength(len(data)) + if err != nil { + return nil, err + } + prefix := byte(0xb7 + len(lenInBytes)) + return append( + []byte{prefix}, + append(lenInBytes, data...)..., + ), nil case []interface{}: encodedList, err := encodeRLPListItems(data) if err != nil { diff --git a/go.mod b/go.mod index 10d076c82bf..e4b13ad6fae 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/filecoin-project/lotus -go 1.23.10 +go 1.24.7 retract v1.14.0 // Accidentally force-pushed tag, use v1.14.1+ instead. diff --git a/node/config/dep_test.go b/node/config/dep_test.go index 91167e690f1..675c5f83625 100644 --- a/node/config/dep_test.go +++ b/node/config/dep_test.go @@ -9,12 +9,21 @@ import ( "testing" ) +func goRoot() (string, error) { + out, err := exec.Command("go", "env", "GOROOT").Output() + if err != nil { + return "", err + } + return strings.TrimSpace(string(out)), nil +} + func goCmd() string { var exeSuffix string if runtime.GOOS == "windows" { exeSuffix = ".exe" } - path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) + root, _ := goRoot() + path := filepath.Join(root, "bin", "go"+exeSuffix) if _, err := os.Stat(path); err == nil { return path }