Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Jan 13, 2025
2 parents 2f5e034 + 9076e8c commit 98376cf
Show file tree
Hide file tree
Showing 82 changed files with 568 additions and 2,125 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Install Go
run: |
GO_VERSION=1.22.4
GO_VERSION=1.23.4
curl -LO https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '~1.22'
go-version: '~1.23'
cache: false
- uses: actions/checkout@v3
- name: golangci-lint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
- name: Set up Go 1.23
uses: actions/setup-go@v4
with:
go-version: ~1.22
go-version: ~1.23
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ linters:
enable:
- dogsled
- errcheck
- exportloopref
- copyloopvar
- goconst
- gocritic
- gofumpt
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM golang:1.22-bullseye
FROM golang:1.23-bullseye
RUN apt-get update && apt-get install -y jq xxd
EXPOSE 26656 26657 1317 9090
COPY --from=app . /opt/neutron
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.22"
ARG GO_VERSION="1.23"
ARG RUNNER_IMAGE="gcr.io/distroless/static"

# --------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BINDIR ?= $(GOPATH)/bin
SIMAPP = ./app
GO_VERSION=1.22
GOLANGCI_LINT_VERSION=v1.55.2
GO_VERSION=1.23
GOLANGCI_LINT_VERSION=v1.63.4
BUILDDIR ?= $(CURDIR)/build

# for dockerized protobuf tools
Expand Down Expand Up @@ -202,14 +202,14 @@ test-sim-multi-seed-short: runsim
###############################################################################

lint:
golangci-lint run --skip-files ".*.pb.go"
golangci-lint run --exclude-files ".*.pb.go"
find . -name '*.go' -not -name "*.pb.go" -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*_test.go" | xargs gofmt -d -s

format:
@go install mvdan.cc/gofumpt@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs -I % sh -c 'gofumpt -w -l % && goimports -w -local github.com/neutron-org %'
golangci-lint run --fix --skip-files ".*.pb.go"
golangci-lint run --fix --exclude-files ".*.pb.go"

.PHONY: format

Expand Down
30 changes: 18 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"time"

v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2"
v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4"
v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5"
dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types"

"github.com/skip-mev/feemarket/x/feemarket"
Expand Down Expand Up @@ -230,6 +232,8 @@ var (
Upgrades = []upgrades.Upgrade{
v500.Upgrade,
v502.Upgrade,
v504.Upgrade,
v505.Upgrade,
}

// DefaultNodeHome default home directories for the application daemon
Expand Down Expand Up @@ -621,6 +625,17 @@ func New(
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

tokenFactoryKeeper := tokenfactorykeeper.NewKeeper(
appCodec,
app.keys[tokenfactorytypes.StoreKey],
maccPerms,
app.AccountKeeper,
&app.BankKeeper,
&app.WasmKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
app.TokenFactoryKeeper = &tokenFactoryKeeper

app.WireICS20PreWasmKeeper(appCodec)
app.PFMModule = packetforward.NewAppModule(app.PFMKeeper, app.GetSubspace(pfmtypes.ModuleName))

Expand Down Expand Up @@ -684,17 +699,6 @@ func New(
app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks())
consumerModule := ccvconsumer.NewAppModule(app.ConsumerKeeper, app.GetSubspace(ccvconsumertypes.ModuleName))

tokenFactoryKeeper := tokenfactorykeeper.NewKeeper(
appCodec,
app.keys[tokenfactorytypes.StoreKey],
maccPerms,
app.AccountKeeper,
&app.BankKeeper,
&app.WasmKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
app.TokenFactoryKeeper = &tokenFactoryKeeper

app.BankKeeper.BaseSendKeeper = app.BankKeeper.BaseSendKeeper.SetHooks(
banktypes.NewMultiBankHooks(
app.TokenFactoryKeeper.Hooks(),
Expand Down Expand Up @@ -1338,7 +1342,6 @@ func (app *App) setupUpgradeStoreLoaders() {
}

for _, upgrd := range Upgrades {
upgrd := upgrd
if upgradeInfo.Name == upgrd.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrd.StoreUpgrades))
}
Expand Down Expand Up @@ -1371,6 +1374,8 @@ func (app *App) setupUpgradeHandlers() {
DynamicfeesKeeper: app.DynamicFeesKeeper,
DexKeeper: &app.DexKeeper,
IbcRateLimitKeeper: app.RateLimitingICS4Wrapper.IbcratelimitKeeper,
ChannelKeeper: &app.IBCKeeper.ChannelKeeper,
TransferKeeper: app.TransferKeeper.Keeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName),
},
Expand Down Expand Up @@ -1720,6 +1725,7 @@ func (app *App) WireICS20PreWasmKeeper(
transferSudo.NewIBCModule(
app.TransferKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
app.TokenFactoryKeeper,
),
app.PFMKeeper,
0,
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
Expand Down Expand Up @@ -69,6 +70,7 @@ type UpgradeKeepers struct {
DynamicfeesKeeper *dynamicfeeskeeper.Keeper
DexKeeper *dexkeeper.Keeper
IbcRateLimitKeeper *ibcratelimitkeeper.Keeper
ChannelKeeper *channelkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
CcvConsumerSubspace paramtypes.Subspace
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v5.0.4/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v504

import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.4"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
35 changes: 35 additions & 0 deletions app/upgrades/v5.0.4/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v504

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}
37 changes: 37 additions & 0 deletions app/upgrades/v5.0.4/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package v504_test

import (
"testing"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4"
"github.com/neutron-org/neutron/v5/testutil"
)

type UpgradeTestSuite struct {
testutil.IBCConnectionTestSuite
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()

upgrade := upgradetypes.Plan{
Name: v504.UpgradeName,
Info: "some text here",
Height: 100,
}
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))
}
18 changes: 18 additions & 0 deletions app/upgrades/v5.0.5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v505

import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.5"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
45 changes: 45 additions & 0 deletions app/upgrades/v5.0.5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v505

import (
"context"
"fmt"

transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

transferChannels := keepers.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, keepers.TransferKeeper.GetPort(ctx))
for _, channel := range transferChannels {
escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)
ctx.Logger().Info("Saving escrow address", "port_id", channel.PortId, "channel_id",
channel.ChannelId, "address", escrowAddress.String())
keepers.TokenFactoryKeeper.StoreEscrowAddress(ctx, escrowAddress)
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}
52 changes: 52 additions & 0 deletions app/upgrades/v5.0.5/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package v505_test

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5"
"github.com/neutron-org/neutron/v5/testutil"
)

type UpgradeTestSuite struct {
testutil.IBCConnectionTestSuite
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()

upgrade := upgradetypes.Plan{
Name: v505.UpgradeName,
Info: "some text here",
Height: 100,
}

var escrowAddresses []sdk.AccAddress
transferChannels := app.IBCKeeper.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, app.TransferKeeper.GetPort(ctx))
for _, channel := range transferChannels {
escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId))
}
require.Greater(t, len(escrowAddresses), 0)
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))

for _, escrowAddress := range escrowAddresses {
require.True(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, escrowAddress))
}
require.False(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, []byte{1, 2, 3, 4, 5}))
}
Loading

0 comments on commit 98376cf

Please sign in to comment.