iotex-core icon indicating copy to clipboard operation
iotex-core copied to clipboard

Further checks for go1.22 upgrades

Open envestcc opened this issue 9 months ago • 3 comments

Due to the introduction of incompatible changes to loop in Go 1.22, this may cause potential bugs in our program. Therefore, we've created this issue to track related matters.

We can reduce the likelihood of bugs from the following perspectives:

1. Fullsync

2. For our own code, review the codes that cause inconsistent compiler behavior.

The following indicates the specific ourself's codes where may lead to changes in compiler behavior (generated and organized based on official tools(list at bottom)).

# github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm
action/protocol/execution/evm/evmstatedbadapter.go:730:9: loop variable addr now per-iteration, stack-allocated
action/protocol/execution/evm/evmstatedbadapter.go:1067:9: loop variable addr now per-iteration, heap-allocated
action/protocol/execution/evm/evmstatedbadapter.go:1090:9: loop variable addr now per-iteration, heap-allocated
action/protocol/execution/evm/evmstatedbadapter.go:1098:6: loop variable addr now per-iteration, stack-allocated

# github.com/iotexproject/iotex-core/v2/blockchain/blockdao
blockchain/blockdao/blockdao.go:146:6: loop variable i now per-iteration, stack-allocated

# github.com/iotexproject/iotex-core/v2/blockindex
blockindex/bloomfilterindexer.go:333:11: loop variable topic now per-iteration, stack-allocated
blockindex/bloomfilterindexer.go:349:11: loop variable topic now per-iteration, stack-allocated

# github.com/iotexproject/iotex-election/committee
../go/pkg/mod/github.com/iotexproject/[email protected]/committee/recordtableoperator.go:199:7: loop variable h now per-iteration, stack-allocated
../go/pkg/mod/github.com/iotexproject/[email protected]/committee/deltarecordtableoperator.go:192:7: loop variable h now per-iteration, stack-allocated

# github.com/iotexproject/iotex-core/v2/action/protocol/poll
action/protocol/poll/lifelong_protocol.go:33:9: loop variable delegate now per-iteration, stack-allocated

# github.com/iotexproject/iotex-core/v2/state/factory
state/factory/workingset.go:442:15: loop variable receivedNonces now per-iteration, stack-allocated
state/factory/util.go:69:11: loop variable topic now per-iteration, heap-allocated

# github.com/iotexproject/iotex-core/v2/api
api/grpcserver.go:700:9: loop variable log now per-iteration, stack-allocated
api/grpcserver.go:702:10: loop variable s now per-iteration, stack-allocated
api/web3server_marshal.go:418:9: loop variable tpc now per-iteration, stack-allocated
api/web3server_utils.go:597:13: loop variable log now per-iteration, stack-allocated

3. For third-party dependencies, upgrade to the new version if it already supports Go 1.22 whenever possible.

The following lists third-party dependency libraries that may lead to changes in compiler behavior.

# github.com/cockroachdb/errors/contexttags
# github.com/cockroachdb/logtags
# [go1.22] github.com/cockroachdb/pebble
# github.com/dlclark/regexp2
# github.com/dop251/goja
# [go1.22] github.com/ethereum/go-ethereum
# [go1.22] github.com/gballet/go-verkle
# github.com/go-redis/redis/v8
# [deprecated] github.com/gogo/protobuf/proto
# github.com/google/pprof/profile
# [archived] github.com/grpc-ecosystem/go-grpc-prometheus
# github.com/hashicorp/go-sockaddr
# github.com/huin/goupnp
# github.com/ipfs/go-log/tracer
# [go1.23] github.com/ipld/go-ipld-prime/node/bindnode
# github.com/klauspost/compress/huff0
# github.com/koron/go-ssdp/internal/multicast
# [go1.23] github.com/libp2p/go-libp2p-kad-dht/netsize
# [go1.23] github.com/libp2p/go-libp2p-pubsub
# [go1.23] github.com/libp2p/go-libp2p/p2p/host/eventbus
# [go1.23] github.com/libp2p/go-nat
# [go1.22] github.com/libp2p/go-netroute
# github.com/mattn/go-sqlite3
# github.com/miekg/dns
# github.com/prometheus/client_golang/prometheus
# [go1.23] github.com/quic-go/quic-go
# github.com/shirou/gopsutil/v3/disk
# [go1.22] go.opentelemetry.io/otel/exporters/jaeger
# gopkg.in/square/go-jose.v2
# gopkg.in/yaml.v2
# gopkg.in/yaml.v3

see-places-of-code-affected

go build -gcflags=all=-d=loopvar=2 -o ./bin/server -v ./server

the full loop.log

envestcc avatar Feb 14 '25 04:02 envestcc

:white_check_mark: I have checked part2 (own codes), and no error found.

envestcc avatar Feb 14 '25 05:02 envestcc

✅ I have checked part2 (own codes), and no error found.

checked as well. looks good

CoderZhi avatar Feb 17 '25 09:02 CoderZhi

here are third-party modules that are compatible with Go versions 1.22 or 1.23:

  • github.com/cockroachdb/pebble
  • github.com/ethereum/go-ethereum
  • github.com/gballet/go-verkle
  • github.com/google/pprof/profile
  • github.com/ipld/go-ipld-prime
  • github.com/libp2p/go-libp2p-kad-dht
  • github.com/libp2p/go-libp2p-pubsub
  • github.com/libp2p/go-libp2p
  • github.com/libp2p/go-nat
  • github.com/libp2p/go-netroute
  • github.com/quic-go/quic-go
  • go.opentelemetry.io/otel/exporters

btw, these two are deprecated or archived:

  • github.com/gogo/protobuf/proto
  • github.com/grpc-ecosystem/go-grpc-prometheus

envestcc avatar Feb 18 '25 00:02 envestcc