Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
44 changes: 44 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: golangci-lint
on:
pull_request:
push:
branches: [master, dev]
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/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
Comment on lines +16 to +20
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update checkout action to latest version.

The actions/checkout action should be updated to v4 for better compatibility and security.

Apply this diff:

-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
🧰 Tools
🪛 actionlint (1.7.4)

16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
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: --timeout=15m -v

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

# 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-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
5 changes: 1 addition & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
- uses: actions/checkout@master
- uses: actions/checkout@v3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the checkout action version.

The actions/checkout@v3 action might be outdated. Consider updating to the latest version.


🌐 Web query:

What is the latest version of actions/checkout GitHub Action?

💡 Result:

The latest stable version of the actions/checkout GitHub Action is v4, as referenced across multiple sources[1][2][5][7]. This version addresses Node.js compatibility issues (deprecating Node.js 16 in favor of Node.js 20)[4][7] and includes reliability improvements for various environments[5].

For most workflows, you can implement it with:

- uses: actions/checkout@v4

Key updates in recent versions:

  • Compatibility with GitHub's updated runner environments
  • Reduced dependency on Node.js tooling[5]
  • Improved security practices for token handling[2]

Always check the official repository for new releases, as GitHub periodically updates actions to maintain compatibility with platform changes[6].

Citations:


Action Required: Update GitHub Checkout Action Version

File: .github/workflows/pre-commit.yml (Line 11)

The workflow currently uses:

      - uses: actions/checkout@v3

Based on the latest information, the current stable version of the checkout action is v4. This update addresses Node.js compatibility (switching to Node.js 20), improves security practices, and enhances overall reliability. Please update the workflow step to:

      - uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

11-11: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

with:
fetch-depth: 2
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0
- uses: pre-commit/action@v2.0.2
102 changes: 48 additions & 54 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
{
"run": {
"tests": false,
},
"linters": {
"fast": false,
"enable": [
"errcheck",
"errorlint",
"gas",
"gocritic",
"gosimple",
"govet",
"ineffassign",
"megacheck",
"misspell",
"nakedret",
"prealloc",
"revive",
"staticcheck",
"unconvert",
"unparam",
],
"disable": [
"unused",
]
},
"linters-settings": {
"revive": {
"enableAllRules": true,
"rules": [
{
"name": "var-naming",
"arguments": [
["ID"]
]
}
]
},
"gocritic": {
"enabled-tags": [
"diagnostic",
"experimental",
"opinionated",
"performance",
"style",
],
"disabled-checks": [
"hugeParam",
"unnamedResult",
]
}
},
}
run:
tests: false
skip-dirs:
- chain
- exchange
- injective_data
- proto

linters:
fast: false
enable:
- errcheck
- errorlint
- gas
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- megacheck
- misspell
- nakedret
- prealloc
- revive
- staticcheck
- unconvert
- unparam
disable:
- unused

linters-settings:
revive:
enableAllRules: true
rules:
- name: var-naming
arguments:
- ["ID"]
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- hugeParam
- unnamedResult
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ repos:
- id: end-of-file-fixer
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/dnephin/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-imports
- id: golangci-lint
args: [--timeout=15m]
22 changes: 18 additions & 4 deletions eip712_cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"bytes"
"encoding/json"
"fmt"
"math"
"math/big"
"reflect"
"runtime/debug"
"strings"
"time"

"cosmossdk.io/math"
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cosmtypes "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -64,6 +65,12 @@
[]cosmtypes.Msg{}, memo,
)

if chainID > uint64(math.MaxInt64) {
err := fmt.Errorf("chainID is too large: %s (max supported value is %s)", chainID, math.MaxInt64)

Check failure on line 69 in eip712_cosmos.go

View workflow job for this annotation

GitHub Actions / lint

printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)
return typeddata.TypedData{}, err
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix formatting in error messages.

The error messages use incorrect format specifier for uint64 values.

Apply this fix to both error messages:

-err := fmt.Errorf("chainID is too large: %s (max supported value is %s)", chainID, math.MaxInt64)
+err := fmt.Errorf("chainID is too large: %d (max supported value is %d)", chainID, math.MaxInt64)

Also applies to: 542-545

🧰 Tools
🪛 GitHub Check: lint

[failure] 69-69:
printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

🪛 GitHub Actions: golangci-lint

[error] 69-69: printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

intChainId := int64(chainID)

txData := make(map[string]interface{})
if err := json.Unmarshal(data, &txData); err != nil {
err = errors.Wrap(err, "failed to unmarshal data provided into WrapTxToEIP712")
Expand Down Expand Up @@ -98,7 +105,7 @@
domain := typeddata.TypedDataDomain{
Name: "Injective Web3",
Version: "1.0.0",
ChainId: ethmath.NewHexOrDecimal256(int64(chainID)),
ChainId: ethmath.NewHexOrDecimal256(intChainId),
VerifyingContract: "cosmos",
Salt: "0",
}
Expand Down Expand Up @@ -413,7 +420,7 @@
hashType = reflect.TypeOf(common.Hash{})
addressType = reflect.TypeOf(common.Address{})
bigIntType = reflect.TypeOf(big.Int{})
cosmIntType = reflect.TypeOf(math.Int{})
cosmIntType = reflect.TypeOf(sdkmath.Int{})
cosmosAnyType = reflect.TypeOf(&codectypes.Any{})
timeType = reflect.TypeOf(time.Time{})
)
Expand Down Expand Up @@ -531,10 +538,17 @@
msgs []cosmtypes.Msg,
feeDelegation *FeeDelegationOptions,
) (typeddata.TypedData, error) {

if chainID > uint64(math.MaxInt64) {
err := fmt.Errorf("chainID is too large: %s (max supported value is %s)", chainID, math.MaxInt64)

Check failure on line 543 in eip712_cosmos.go

View workflow job for this annotation

GitHub Actions / lint

printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)
return typeddata.TypedData{}, err
}
intChainId := int64(chainID)

domain := typeddata.TypedDataDomain{
Name: "Injective Web3",
Version: "1.0.0",
ChainId: ethmath.NewHexOrDecimal256(int64(chainID)),
ChainId: ethmath.NewHexOrDecimal256(intChainId),
VerifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
Salt: "0",
}
Expand Down
8 changes: 7 additions & 1 deletion ethereum/util/noncecache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package util

import (
"math"
"sync"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -127,7 +128,12 @@ func (n nonceCache) Sync(account common.Address, syncFn func() (uint64, error))
}
if nonce, err := syncFn(); err == nil {
n.mux.Lock()
n.nonces[account] = int64(nonce)
if nonce > uint64(math.MaxInt64) {
// Handle overflow case - could log error or take other action
n.nonces[account] = math.MaxInt64
} else {
n.nonces[account] = int64(nonce)
}
n.mux.Unlock()
}
}
Expand Down
Loading