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

Chore/action lint fix #41

Merged
merged 2 commits into from
Jul 17, 2024
Merged
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
38 changes: 29 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ jobs:
golangci:
env:
# for private repo access
GOPRIVATE: github.com/initia-labs/*
GOPRIVATE: github.com/initia-labs
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
GOLANGCI_LINT_VERSION: v1.59.1
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: technote-space/get-diff-action@v5
check-latest: true
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
Expand All @@ -41,26 +44,43 @@ jobs:
go.sum
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
- name: run go linters
# install golangci-lint
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
- name: run go linters (long)
if: env.GIT_DIFF
id: lint_long
run: |
make tools
make lint
if: env.GIT_DIFF
- uses: technote-space/[email protected]
if: steps.lint_long.outcome == 'skipped'
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: run go linters (short)
if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF
run: |
make lint
env:
GIT_DIFF: ${{ env.GIT_DIFF }}
LINT_DIFF: 1
# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
env:
# for private repo access
GOPRIVATE: github.com/initia-labs/*
GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
- run: |
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,17 @@ benchmark:
@go test -timeout 20m -mod=readonly -bench=. ./...

.PHONY: test test-all test-cover test-unit test-race benchmark contracts-gen

###############################################################################
### Linting ###
###############################################################################

lint:
golangci-lint run --out-format=tab --timeout=15m

lint-fix:
golangci-lint run --fix --out-format=tab --timeout=15m

.PHONY: lint lint-fix


2 changes: 1 addition & 1 deletion app/ante/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
case signing.SignMode_SIGN_MODE_DIRECT_AUX:
return signingv1beta1.SignMode_SIGN_MODE_DIRECT_AUX, nil
case signing.SignMode_SIGN_MODE_EIP_191:
return signingv1beta1.SignMode_SIGN_MODE_EIP_191, nil
return signingv1beta1.SignMode_SIGN_MODE_EIP_191, nil //nolint:staticcheck

Check warning on line 35 in app/ante/verify.go

View check run for this annotation

Codecov / codecov/patch

app/ante/verify.go#L35

Added line #L35 was not covered by tests
default:
return signingv1beta1.SignMode_SIGN_MODE_UNSPECIFIED, fmt.Errorf("unsupported sign mode %s", mode)
}
Expand Down
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,9 @@
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap())
if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {
panic(err)

Check warning on line 1084 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L1084

Added line #L1084 was not covered by tests
}
return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down
4 changes: 2 additions & 2 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func SetupWithGenesisAccounts(
// allow empty validator
if valSet == nil || len(valSet.Validators) == 0 {
privVal := ed25519.GenPrivKey()
pubKey, err := cryptocodec.ToTmPubKeyInterface(privVal.PubKey())
pubKey, err := cryptocodec.ToTmPubKeyInterface(privVal.PubKey()) //nolint:staticcheck
if err != nil {
panic(err)
}
Expand All @@ -103,7 +103,7 @@ func SetupWithGenesisAccounts(

validators := make([]opchildtypes.Validator, 0, len(valSet.Validators))
for _, val := range valSet.Validators {
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey)
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) //nolint:staticcheck
if err != nil {
panic(err)
}
Expand Down
10 changes: 8 additions & 2 deletions jsonrpc/backend/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@

txs := []*rpctypes.RPCTransaction{}
if fullTx {
b.app.EVMIndexer().IterateBlockTxs(queryCtx, blockNumber, func(tx *rpctypes.RPCTransaction) (bool, error) {
err = b.app.EVMIndexer().IterateBlockTxs(queryCtx, blockNumber, func(tx *rpctypes.RPCTransaction) (bool, error) {

Check warning on line 109 in jsonrpc/backend/block.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/block.go#L109

Added line #L109 was not covered by tests
txs = append(txs, tx)
return false, nil
})
if err != nil {
return nil, err
}

Check warning on line 115 in jsonrpc/backend/block.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/block.go#L113-L115

Added lines #L113 - L115 were not covered by tests
}

return formatBlock(header, txs), nil
Expand All @@ -129,10 +132,13 @@
txs := []*rpctypes.RPCTransaction{}
if fullTx {
blockNumber := header.Number.Uint64()
b.app.EVMIndexer().IterateBlockTxs(queryCtx, blockNumber, func(tx *rpctypes.RPCTransaction) (bool, error) {
err = b.app.EVMIndexer().IterateBlockTxs(queryCtx, blockNumber, func(tx *rpctypes.RPCTransaction) (bool, error) {

Check warning on line 135 in jsonrpc/backend/block.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/block.go#L135

Added line #L135 was not covered by tests
txs = append(txs, tx)
return false, nil
})
if err != nil {
return nil, err
}

Check warning on line 141 in jsonrpc/backend/block.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/block.go#L139-L141

Added lines #L139 - L141 were not covered by tests
}

return formatBlock(header, txs), nil
Expand Down
5 changes: 4 additions & 1 deletion jsonrpc/backend/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
}

txs := []*rpctypes.RPCTransaction{}
b.app.EVMIndexer().IterateBlockTxs(queryCtx, height, func(tx *rpctypes.RPCTransaction) (bool, error) {
err = b.app.EVMIndexer().IterateBlockTxs(queryCtx, height, func(tx *rpctypes.RPCTransaction) (bool, error) {

Check warning on line 24 in jsonrpc/backend/filters.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/filters.go#L24

Added line #L24 was not covered by tests
txs = append(txs, tx)
return false, nil
})
if err != nil {
return nil, err
}

Check warning on line 30 in jsonrpc/backend/filters.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/filters.go#L28-L30

Added lines #L28 - L30 were not covered by tests

for _, tx := range txs {
receipt, err := b.app.EVMIndexer().TxReceiptByHash(queryCtx, tx.Hash)
Expand Down
11 changes: 8 additions & 3 deletions jsonrpc/backend/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,21 @@
}

txBuilder := b.app.TxConfig().NewTxBuilder()
txBuilder.SetMsgs(sdkMsgs...)
txBuilder.SetSignatures(signing.SignatureV2{
if err = txBuilder.SetMsgs(sdkMsgs...); err != nil {
return hexutil.Uint64(0), err
}
if err = txBuilder.SetSignatures(signing.SignatureV2{

Check warning on line 67 in jsonrpc/backend/gas.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/gas.go#L64-L67

Added lines #L64 - L67 were not covered by tests
PubKey: nil,
Data: &signing.SingleSignatureData{
SignMode: keeper.SignMode_SIGN_MODE_ETHEREUM,
Signature: nil,
},
Sequence: uint64(*args.Nonce),
})
}); err != nil {
return hexutil.Uint64(0), err
}

Check warning on line 76 in jsonrpc/backend/gas.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/gas.go#L74-L76

Added lines #L74 - L76 were not covered by tests
tx := txBuilder.GetTx()

Check warning on line 78 in jsonrpc/backend/gas.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/gas.go#L78

Added line #L78 was not covered by tests
txBytes, err := b.app.TxConfig().TxEncoder()(tx)
if err != nil {
return hexutil.Uint64(0), err
Expand Down
15 changes: 12 additions & 3 deletions x/evm/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@
}

kvs := []types.GenesisKeyValue{}
k.VMStore.Walk(ctx, nil, func(key, value []byte) (stop bool, err error) {
err = k.VMStore.Walk(ctx, nil, func(key, value []byte) (stop bool, err error) {
kvs = append(kvs, types.GenesisKeyValue{Key: key, Value: value})
return false, nil
})
if err != nil {
panic(err)

Check warning on line 112 in x/evm/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/genesis.go#L112

Added line #L112 was not covered by tests
}

var stores *types.GenesisERC20Stores
erc20Stores := []types.GenesisERC20Stores{}
k.ERC20Stores.Walk(ctx, nil, func(key collections.Pair[[]byte, []byte]) (stop bool, err error) {
err = k.ERC20Stores.Walk(ctx, nil, func(key collections.Pair[[]byte, []byte]) (stop bool, err error) {
if stores == nil || !bytes.Equal(stores.Address, key.K1()) {
erc20Stores = append(erc20Stores, types.GenesisERC20Stores{
Address: key.K1(),
Expand All @@ -125,16 +128,22 @@
stores.Stores = append(stores.Stores, key.K2())
return false, nil
})
if err != nil {
panic(err)

Check warning on line 132 in x/evm/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/genesis.go#L132

Added line #L132 was not covered by tests
}

denomAddresses := []types.GenesisDenomAddress{}
k.ERC20ContractAddrsByDenom.Walk(ctx, nil, func(denom string, contractAddr []byte) (stop bool, err error) {
err = k.ERC20ContractAddrsByDenom.Walk(ctx, nil, func(denom string, contractAddr []byte) (stop bool, err error) {
denomAddresses = append(denomAddresses, types.GenesisDenomAddress{
Denom: denom,
ContractAddress: contractAddr,
})

return false, nil
})
if err != nil {
panic(err)

Check warning on line 145 in x/evm/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/genesis.go#L145

Added line #L145 was not covered by tests
}

factoryAddr, err := k.ERC20FactoryAddr.Get(ctx)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions x/evm/keeper/txutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@
}

txBuilder := authtx.NewTxConfig(u.cdc, authtx.DefaultSignModes).NewTxBuilder()
txBuilder.SetMsgs(sdkMsgs...)
if err = txBuilder.SetMsgs(sdkMsgs...); err != nil {
return nil, err
}

Check warning on line 159 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L158-L159

Added lines #L158 - L159 were not covered by tests
txBuilder.SetFeeAmount(feeAmount)
txBuilder.SetGasLimit(gasLimit)
txBuilder.SetSignatures(sig)
if err = txBuilder.SetSignatures(sig); err != nil {
return nil, err
}

Check warning on line 164 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L163-L164

Added lines #L163 - L164 were not covered by tests

// set memo
memo, err := json.Marshal(metadata{
Expand Down
Loading