Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade IBC & lint #1823

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
119 changes: 111 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,116 @@
issues:
exclude:
- comment on exported (method|function|type|const|var)
exclude-use-default: true

# Skip generated k8s code
run:
tests: true
timeout: 10m
sort-results: true
allow-parallel-runners: true
skip-dirs:
- pkg/client
- ".*/mocks"

# Skip vendor/ etc
skip-dirs-use-default: true

linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- staticcheck
- revive
- stylecheck
- typecheck
- unconvert
- unused

issues:
exclude-use-default: true
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck
- path: "migrations"
text: "SA1019:"
linters:
- staticcheck
- text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out
linters:
- staticcheck
- text: "leading space"
linters:
- nolintlint

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
# - G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement
misspell:
locale: US
gofumpt:
extra-rules: true
dogsled:
max-blank-identifiers: 5
maligned:
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: true
require-specific: false
gosimple:
checks: ["all"]
34 changes: 18 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"

icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"

icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

apptypes "github.com/akash-network/node/app/types"
utypes "github.com/akash-network/node/upgrades/types"
Expand Down Expand Up @@ -350,7 +350,7 @@ func NewApp(

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

app.MM = module.NewManager(
append([]module.AppModule{
Expand Down Expand Up @@ -475,7 +475,7 @@ func NewApp(
return app
}

func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { // nolint: unused,deadcode
func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { //nolint:unused,deadcode // we'd like to preserve this unused code
if v := appOpts.Get("GenesisTime"); v != nil {
// in tests, GenesisTime is supplied using appOpts
genTime, ok := v.(time.Time)
Expand Down Expand Up @@ -527,7 +527,8 @@ func (app *AkashApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) a

// EndBlocker is a function in which application updates every end block
func (app *AkashApp) EndBlocker(
ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
ctx sdk.Context, req abci.RequestEndBlock,
) abci.ResponseEndBlock {
return app.MM.EndBlock(ctx, req)
}

Expand Down Expand Up @@ -634,7 +635,8 @@ func (app *AkashApp) LoadHeight(height int64) error {

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key,
tkey sdk.StoreKey) paramskeeper.Keeper {
tkey sdk.StoreKey,
) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
Expand Down
4 changes: 2 additions & 2 deletions app/app_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"

audittypes "github.com/akash-network/akash-api/go/node/audit/v1beta3"
certtypes "github.com/akash-network/akash-api/go/node/cert/v1beta3"
Expand Down
87 changes: 42 additions & 45 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,52 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"

appparams "github.com/akash-network/node/app/params"
)

var (
mbasics = module.NewBasicManager(
append([]module.AppModuleBasic{
// accounts, fees.
auth.AppModuleBasic{},
// authorizations
authzmodule.AppModuleBasic{},
// genesis utilities
genutil.AppModuleBasic{},
// tokens, token balance.
bank.AppModuleBasic{},
capability.AppModuleBasic{},
// validator staking
staking.AppModuleBasic{},
// inflation
mint.AppModuleBasic{},
// distribution of fess and inflation
distr.AppModuleBasic{},
// governance functionality (voting)
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler,
upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
ibcclient.UpdateClientProposalHandler, ibcclient.UpgradeProposalHandler,
),
// chain parameters
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
},
// akash
akashModuleBasics()...,
)...,
)
var mbasics = module.NewBasicManager(
append([]module.AppModuleBasic{
// accounts, fees.
auth.AppModuleBasic{},
// authorizations
authzmodule.AppModuleBasic{},
// genesis utilities
genutil.AppModuleBasic{},
// tokens, token balance.
bank.AppModuleBasic{},
capability.AppModuleBasic{},
// validator staking
staking.AppModuleBasic{},
// inflation
mint.AppModuleBasic{},
// distribution of fess and inflation
distr.AppModuleBasic{},
// governance functionality (voting)
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler,
upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
ibcclient.UpdateClientProposalHandler, ibcclient.UpgradeProposalHandler,
),
// chain parameters
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
},
// akash
akashModuleBasics()...,
)...,
)

// ModuleBasics returns all app modules basics
Expand Down Expand Up @@ -134,5 +132,4 @@ func transientStoreKeys() map[string]*sdk.TransientStoreKey {

func memStoreKeys() map[string]*sdk.MemoryStoreKey {
return sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

}
4 changes: 2 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (app *AkashApp) ExportAppStateAndValidators(
// prepForZeroHeightGenesis prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
//
// in favour of export at a block height
// in favor of export at a block height
func (app *AkashApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down Expand Up @@ -229,7 +229,7 @@ func Setup(isCheckTx bool) *AkashApp {
}

func OptsWithGenesisTime(seed int64) servertypes.AppOptions {
r := rand.New(rand.NewSource(seed)) // nolint: gosec
r := rand.New(rand.NewSource(seed))
genTime := simulation.RandTimestamp(r)

appOpts := viper.New()
Expand Down
2 changes: 1 addition & 1 deletion app/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"

escrowtypes "github.com/akash-network/akash-api/go/node/escrow/v1beta3"
)
Expand Down
Loading
Loading