Skip to content

Commit

Permalink
chore: prepare upgrade for v8 (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed Sep 6, 2024
1 parent f0a831d commit 85bee39
Show file tree
Hide file tree
Showing 367 changed files with 1,136 additions and 1,396 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.23"
check-latest: true

- name: Initialize CodeQL
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: '1.23'
- run: |
make check-no-lint
version=$(grep golangci_version= ./Makefile | awk -F '=' '{print $2}')
echo "GOLANGCI_VERSION=$version" >> $GITHUB_ENV
- uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
version: ${{ env.GOLANGCI_VERSION }}
args: --timeout 10m

test:
Expand All @@ -46,7 +50,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: '1.23'
- run: make test

mock:
Expand All @@ -55,7 +59,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: '1.23'
- run: |
make mocks
git diff --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: '1.23'
- run: make test-nightly
8 changes: 5 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ run:
tests: true

# Define the Go version limit.
# Mainly related to generics support since go1.21.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.21
go: '1.21'
# Mainly related to generics support since go1.23.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.23
go: '1.23'

linters:
enable:
Expand All @@ -34,6 +34,8 @@ linters-settings:
min-complexity: 15
gocritic:
disabled-checks: ["assignOp", "ifElseChain", "appendAssign"]
gosec:
excludes: [ "G115" ]
gci:
custom-order: true
sections:
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# compile fx-core
FROM golang:1.21.4-alpine3.18 as builder
FROM golang:1.23.0-alpine3.19 as builder

RUN apk add --no-cache git build-base linux-headers

Expand All @@ -9,8 +8,7 @@ COPY . .

RUN make build

# build fx-core
FROM alpine:3.18
FROM alpine:3.19

WORKDIR root

Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ run-local: install
### Linting ###
###############################################################################

golangci_version=v1.55.2
golangci_version=v1.60.3

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
Expand All @@ -141,14 +141,17 @@ lint-install:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version); \
fi

lint: lint-install
echo "--> Running linter"
@golangci-lint run --build-tags=$(GO_BUILD) --out-format=tab
@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -ne 45 ]; then \
check-no-lint:
@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -ne 44 ]; then \
echo "\033[91m--> increase or decrease nolint, please recheck them\033[0m"; \
echo "\033[91m--> list nolint: \`find . -name '*.go' -type f | xargs grep 'nolint\|#nosec'\`\033[0m"; exit 1;\
echo "\033[91m--> list nolint: \`find . -name '*.go' -type f | xargs grep 'nolint\|#nosec'\`\033[0m"; \
exit 1;\
fi

lint: check-no-lint lint-install
@echo "--> Running linter"
@golangci-lint run --build-tags=$(GO_BUILD) --out-format=tab

format: lint-install
@golangci-lint run --build-tags=$(GO_BUILD) --out-format=tab --fix

Expand Down Expand Up @@ -248,7 +251,7 @@ contract-publish:
###############################################################################

PACKAGE_NAME := $(shell go list -m)
GOLANG_CROSS_VERSION := v1.21
GOLANG_CROSS_VERSION := v1.23
release-dry-run:
docker run --rm --privileged -e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

[![Version](https://img.shields.io/github/v/release/functionx/fx-core.svg)](https://github.com/functionx/fx-core/releases/latest)
[![License](https://img.shields.io/github/license/functionx/fx-core.svg)](https://github.com/functionx/fx-core/blob/main/LICENSE)
[![API Reference](https://pkg.go.dev/badge/github.com/functionx/fx-core.svg)](https://pkg.go.dev/github.com/functionx/fx-core/v7)
[![Go Report Card](https://goreportcard.com/badge/github.com/functionx/fx-core/v7)](https://goreportcard.com/report/github.com/functionx/fx-core/v7)
[![API Reference](https://pkg.go.dev/badge/github.com/functionx/fx-core.svg)](https://pkg.go.dev/github.com/functionx/fx-core/v8)
[![Go Report Card](https://goreportcard.com/badge/github.com/functionx/fx-core/v8)](https://goreportcard.com/report/github.com/functionx/fx-core/v8)
[![Go Tests/Lint](https://github.com/FunctionX/fx-core/actions/workflows/golang.yml/badge.svg)](https://github.com/FunctionX/fx-core/actions/workflows/golang.yml)
[![CodeQL](https://github.com/FunctionX/fx-core/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/FunctionX/fx-core/actions/workflows/codeql-analysis.yml)
[![Solidity](https://github.com/FunctionX/fx-core/actions/workflows/solidity.yml/badge.svg)](https://github.com/FunctionX/fx-core/actions/workflows/solidity.yml)

**Note**: Requires [Go 1.21+](https://go.dev/dl)
**Note**: Requires [Go 1.23+](https://go.dev/dl)

## Releases

Expand Down
2 changes: 1 addition & 1 deletion ante/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common"
evmtypes "github.com/evmos/ethermint/x/evm/types"

fxstakingtypes "github.com/functionx/fx-core/v7/x/staking/types"
fxstakingtypes "github.com/functionx/fx-core/v8/x/staking/types"
)

type PubKeyDecorator struct {
Expand Down
28 changes: 14 additions & 14 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ import (
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

fxante "github.com/functionx/fx-core/v7/ante"
"github.com/functionx/fx-core/v7/app/keepers"
_ "github.com/functionx/fx-core/v7/docs/statik"
fxcfg "github.com/functionx/fx-core/v7/server/config"
fxauth "github.com/functionx/fx-core/v7/server/grpc/auth"
gaspricev1 "github.com/functionx/fx-core/v7/server/grpc/gasprice/legacy/v1"
gaspricev2 "github.com/functionx/fx-core/v7/server/grpc/gasprice/legacy/v2"
fxtypes "github.com/functionx/fx-core/v7/types"
"github.com/functionx/fx-core/v7/x/crosschain"
"github.com/functionx/fx-core/v7/x/crosschain/keeper"
crosschaintypes "github.com/functionx/fx-core/v7/x/crosschain/types"
"github.com/functionx/fx-core/v7/x/gravity"
gravitykeeper "github.com/functionx/fx-core/v7/x/gravity/keeper"
gravitytypes "github.com/functionx/fx-core/v7/x/gravity/types"
fxante "github.com/functionx/fx-core/v8/ante"
"github.com/functionx/fx-core/v8/app/keepers"
_ "github.com/functionx/fx-core/v8/docs/statik"
fxcfg "github.com/functionx/fx-core/v8/server/config"
fxauth "github.com/functionx/fx-core/v8/server/grpc/auth"
gaspricev1 "github.com/functionx/fx-core/v8/server/grpc/gasprice/legacy/v1"
gaspricev2 "github.com/functionx/fx-core/v8/server/grpc/gasprice/legacy/v2"
fxtypes "github.com/functionx/fx-core/v8/types"
"github.com/functionx/fx-core/v8/x/crosschain"
"github.com/functionx/fx-core/v8/x/crosschain/keeper"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
"github.com/functionx/fx-core/v8/x/gravity"
gravitykeeper "github.com/functionx/fx-core/v8/x/gravity/keeper"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

var _ servertypes.Application = (*App)(nil)
Expand Down
4 changes: 2 additions & 2 deletions app/app_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/functionx/fx-core/v7/testutil/helpers"
fxtypes "github.com/functionx/fx-core/v7/types"
"github.com/functionx/fx-core/v8/testutil/helpers"
fxtypes "github.com/functionx/fx-core/v8/types"
)

func TestAppDB(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"

"github.com/functionx/fx-core/v7/app"
fxtypes "github.com/functionx/fx-core/v7/types"
crosschaintypes "github.com/functionx/fx-core/v7/x/crosschain/types"
govlegacy "github.com/functionx/fx-core/v7/x/gov/legacy"
gravitytypes "github.com/functionx/fx-core/v7/x/gravity/types"
"github.com/functionx/fx-core/v8/app"
fxtypes "github.com/functionx/fx-core/v8/types"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
govlegacy "github.com/functionx/fx-core/v8/x/gov/legacy"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

func Test_MsgServiceRouter(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/evmos/ethermint/crypto/ethsecp256k1"
etherminttypes "github.com/evmos/ethermint/types"

crosschaintypes "github.com/functionx/fx-core/v7/x/crosschain/types"
gravitytypes "github.com/functionx/fx-core/v7/x/gravity/types"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

// EncodingConfig specifies the concrete encoding types to use for a given app.
Expand Down
4 changes: 2 additions & 2 deletions app/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"

"github.com/functionx/fx-core/v7/app"
"github.com/functionx/fx-core/v7/testutil/helpers"
"github.com/functionx/fx-core/v8/app"
"github.com/functionx/fx-core/v8/testutil/helpers"
)

func TestMakeEncodingConfig_RegisterInterfaces(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions app/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"

"github.com/functionx/fx-core/v7/app"
fxcfg "github.com/functionx/fx-core/v7/server/config"
"github.com/functionx/fx-core/v7/testutil/helpers"
"github.com/functionx/fx-core/v7/testutil/network"
fxtypes "github.com/functionx/fx-core/v7/types"
fxstakingtypes "github.com/functionx/fx-core/v7/x/staking/types"
"github.com/functionx/fx-core/v8/app"
fxcfg "github.com/functionx/fx-core/v8/server/config"
"github.com/functionx/fx-core/v8/testutil/helpers"
"github.com/functionx/fx-core/v8/testutil/network"
fxtypes "github.com/functionx/fx-core/v8/types"
fxstakingtypes "github.com/functionx/fx-core/v8/x/staking/types"
)

func Test_ExportGenesisAndRunNode(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

fxtypes "github.com/functionx/fx-core/v7/types"
ethtypes "github.com/functionx/fx-core/v7/x/eth/types"
fxstakingtypes "github.com/functionx/fx-core/v7/x/staking/types"
fxtypes "github.com/functionx/fx-core/v8/types"
ethtypes "github.com/functionx/fx-core/v8/x/eth/types"
fxstakingtypes "github.com/functionx/fx-core/v8/x/staking/types"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions app/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package app_test
import (
"testing"

"github.com/functionx/fx-core/v7/app"
"github.com/functionx/fx-core/v7/testutil/helpers"
fxtypes "github.com/functionx/fx-core/v7/types"
"github.com/functionx/fx-core/v8/app"
"github.com/functionx/fx-core/v8/testutil/helpers"
fxtypes "github.com/functionx/fx-core/v8/types"
)

func TestNewDefaultGenesisByDenom(t *testing.T) {
Expand Down
62 changes: 31 additions & 31 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,37 @@ import (
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
"github.com/spf13/cast"

fxtypes "github.com/functionx/fx-core/v7/types"
arbitrumtypes "github.com/functionx/fx-core/v7/x/arbitrum/types"
fxauthzkeeper "github.com/functionx/fx-core/v7/x/authz/keeper"
avalanchetypes "github.com/functionx/fx-core/v7/x/avalanche/types"
bsctypes "github.com/functionx/fx-core/v7/x/bsc/types"
"github.com/functionx/fx-core/v7/x/crosschain"
crosschainkeeper "github.com/functionx/fx-core/v7/x/crosschain/keeper"
crosschainprecompile "github.com/functionx/fx-core/v7/x/crosschain/precompile"
crosschaintypes "github.com/functionx/fx-core/v7/x/crosschain/types"
"github.com/functionx/fx-core/v7/x/erc20"
erc20keeper "github.com/functionx/fx-core/v7/x/erc20/keeper"
erc20types "github.com/functionx/fx-core/v7/x/erc20/types"
ethtypes "github.com/functionx/fx-core/v7/x/eth/types"
fxevmkeeper "github.com/functionx/fx-core/v7/x/evm/keeper"
fxgovkeeper "github.com/functionx/fx-core/v7/x/gov/keeper"
fxgovtypes "github.com/functionx/fx-core/v7/x/gov/types"
gravitytypes "github.com/functionx/fx-core/v7/x/gravity/types"
fxtransfer "github.com/functionx/fx-core/v7/x/ibc/applications/transfer"
fxtransferkeeper "github.com/functionx/fx-core/v7/x/ibc/applications/transfer/keeper"
fxibctransfertypes "github.com/functionx/fx-core/v7/x/ibc/applications/transfer/types"
"github.com/functionx/fx-core/v7/x/ibc/ibcrouter"
layer2types "github.com/functionx/fx-core/v7/x/layer2/types"
migratekeeper "github.com/functionx/fx-core/v7/x/migrate/keeper"
migratetypes "github.com/functionx/fx-core/v7/x/migrate/types"
optimismtypes "github.com/functionx/fx-core/v7/x/optimism/types"
polygontypes "github.com/functionx/fx-core/v7/x/polygon/types"
fxslashingkeeper "github.com/functionx/fx-core/v7/x/slashing/keeper"
fxstakingkeeper "github.com/functionx/fx-core/v7/x/staking/keeper"
stakingprecompile "github.com/functionx/fx-core/v7/x/staking/precompile"
tronkeeper "github.com/functionx/fx-core/v7/x/tron/keeper"
trontypes "github.com/functionx/fx-core/v7/x/tron/types"
fxtypes "github.com/functionx/fx-core/v8/types"
arbitrumtypes "github.com/functionx/fx-core/v8/x/arbitrum/types"
fxauthzkeeper "github.com/functionx/fx-core/v8/x/authz/keeper"
avalanchetypes "github.com/functionx/fx-core/v8/x/avalanche/types"
bsctypes "github.com/functionx/fx-core/v8/x/bsc/types"
"github.com/functionx/fx-core/v8/x/crosschain"
crosschainkeeper "github.com/functionx/fx-core/v8/x/crosschain/keeper"
crosschainprecompile "github.com/functionx/fx-core/v8/x/crosschain/precompile"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
"github.com/functionx/fx-core/v8/x/erc20"
erc20keeper "github.com/functionx/fx-core/v8/x/erc20/keeper"
erc20types "github.com/functionx/fx-core/v8/x/erc20/types"
ethtypes "github.com/functionx/fx-core/v8/x/eth/types"
fxevmkeeper "github.com/functionx/fx-core/v8/x/evm/keeper"
fxgovkeeper "github.com/functionx/fx-core/v8/x/gov/keeper"
fxgovtypes "github.com/functionx/fx-core/v8/x/gov/types"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
fxtransfer "github.com/functionx/fx-core/v8/x/ibc/applications/transfer"
fxtransferkeeper "github.com/functionx/fx-core/v8/x/ibc/applications/transfer/keeper"
fxibctransfertypes "github.com/functionx/fx-core/v8/x/ibc/applications/transfer/types"
"github.com/functionx/fx-core/v8/x/ibc/ibcrouter"
layer2types "github.com/functionx/fx-core/v8/x/layer2/types"
migratekeeper "github.com/functionx/fx-core/v8/x/migrate/keeper"
migratetypes "github.com/functionx/fx-core/v8/x/migrate/types"
optimismtypes "github.com/functionx/fx-core/v8/x/optimism/types"
polygontypes "github.com/functionx/fx-core/v8/x/polygon/types"
fxslashingkeeper "github.com/functionx/fx-core/v8/x/slashing/keeper"
fxstakingkeeper "github.com/functionx/fx-core/v8/x/staking/keeper"
stakingprecompile "github.com/functionx/fx-core/v8/x/staking/precompile"
tronkeeper "github.com/functionx/fx-core/v8/x/tron/keeper"
trontypes "github.com/functionx/fx-core/v8/x/tron/types"
)

type CrossChainKeepers struct {
Expand Down
9 changes: 4 additions & 5 deletions app/keepers/keepers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/stretchr/testify/assert"

"github.com/functionx/fx-core/v7/app"
"github.com/functionx/fx-core/v7/app/keepers"
fxtypes "github.com/functionx/fx-core/v7/types"
"github.com/functionx/fx-core/v8/app"
"github.com/functionx/fx-core/v8/app/keepers"
fxtypes "github.com/functionx/fx-core/v8/types"
)

func TestNewAppKeeper(t *testing.T) {
Expand Down Expand Up @@ -69,8 +69,7 @@ func checkStructField(t *testing.T, valueOf reflect.Value, name string) {
assert.Falsef(t, valueOfField.IsNil(), "%s-%s-%s", valueOf.Type().PkgPath(), typeOfField.Name, name)
}

switch valueOfField.Kind() {
case reflect.Pointer, reflect.Interface:
if valueOfField.Kind() == reflect.Pointer || valueOfField.Kind() == reflect.Interface {
if typeOfField.Name == "QueryServer" ||
(name == "EvidenceKeeper" && typeOfField.Name == "router") {
return
Expand Down
Loading

0 comments on commit 85bee39

Please sign in to comment.