diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c722400..567f052 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,6 +23,8 @@ concurrency: jobs: golangci: env: + 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 @@ -39,6 +41,7 @@ jobs: **/**.go go.mod go.sum + - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ # install golangci-lint - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} - name: run go linters (long) @@ -65,6 +68,10 @@ jobs: # 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,github.com/skip-mev/slinky + GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} runs-on: ubuntu-latest name: tidy steps: @@ -74,6 +81,7 @@ jobs: with: go-version: 1.22 check-latest: true + - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ - run: | go mod tidy CHANGES_IN_REPO=$(git status --porcelain) diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..497ee05 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,47 @@ +linters: + enable: + - asciicheck + - bodyclose + - dogsled + - dupl + - errcheck + - exportloopref + - goconst + - gofmt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + # - nakedret + - nolintlint + # - prealloc + - staticcheck + # - structcheck // to be fixed by golangci-lint + - stylecheck + - typecheck + - unconvert + - unused + +issues: + exclude-rules: + - path: _test\.go + linters: + - gosec + - linters: + - stylecheck + text: "ST1003:" + max-same-issues: 50 + +linters-settings: + dogsled: + max-blank-identifiers: 3 + #golint: + # min-confidence: 0 + goconst: + ignore-tests: true + #maligned: + # suggest-new: true + misspell: + locale: US diff --git a/executor/batch/handler.go b/executor/batch/handler.go index d58b6f6..b17f6b2 100644 --- a/executor/batch/handler.go +++ b/executor/batch/handler.go @@ -177,7 +177,7 @@ func (bs *BatchSubmitter) finalizeBatch(blockHeight uint64) error { Save: true, }) - for offset := int64(0); ; offset += int64(bs.batchCfg.MaxChunkSize) { + for offset := int64(0); ; offset += bs.batchCfg.MaxChunkSize { readLength, err := bs.batchFile.ReadAt(batchBuffer, offset) if err != nil && err != io.EOF { return err diff --git a/executor/child/handler.go b/executor/child/handler.go index aef5623..ac1416d 100644 --- a/executor/child/handler.go +++ b/executor/child/handler.go @@ -30,7 +30,7 @@ func (ch *Child) beginBlockHandler(args nodetypes.BeginBlockArgs) (err error) { func (ch *Child) endBlockHandler(args nodetypes.EndBlockArgs) error { blockHeight := uint64(args.Block.Header.Height) batchKVs := make([]types.RawKV, 0) - treeKVs, storageRoot, err := ch.handleTree(blockHeight, uint64(args.LatestHeight), args.BlockID, args.Block.Header) + treeKVs, storageRoot, err := ch.handleTree(blockHeight, args.LatestHeight, args.BlockID, args.Block.Header) if err != nil { return err } diff --git a/executor/child/withdraw.go b/executor/child/withdraw.go index abc584a..3780276 100644 --- a/executor/child/withdraw.go +++ b/executor/child/withdraw.go @@ -93,7 +93,7 @@ func (ch *Child) prepareTree(blockHeight uint64) error { err := ch.mk.LoadWorkingTree(blockHeight - 1) if err == dbtypes.ErrNotFound { // must not happened - // TOOD: if user want to start from a specific height, we need to provide a way to do so + // TODO: if user want to start from a specific height, we need to provide a way to do so panic(fmt.Errorf("working tree not found at height: %d, current: %d", blockHeight-1, blockHeight)) } else if err != nil { return err diff --git a/merkle/merkle.go b/merkle/merkle.go index 33049b0..0def1ce 100644 --- a/merkle/merkle.go +++ b/merkle/merkle.go @@ -186,7 +186,6 @@ func (m *Merkle) fillLeaves() error { } lastLeaf := m.workingTree.LastSiblings[0] - //nolint:typecheck for range numRestLeaves { if err := m.InsertLeaf(lastLeaf); err != nil { return err diff --git a/node/broadcaster/broadcaster.go b/node/broadcaster/broadcaster.go index 3a3caff..8eaddab 100644 --- a/node/broadcaster/broadcaster.go +++ b/node/broadcaster/broadcaster.go @@ -125,8 +125,8 @@ func (b Broadcaster) getClientCtx() client.Context { WithFromAddress(b.keyAddress) } -func (n Broadcaster) GetTxf() tx.Factory { - return n.txf +func (b Broadcaster) GetTxf() tx.Factory { + return b.txf } func (b *Broadcaster) prepareBroadcaster(_ /*lastBlockHeight*/ uint64, lastBlockTime time.Time) error { diff --git a/node/process.go b/node/process.go index b09eedb..bb219a3 100644 --- a/node/process.go +++ b/node/process.go @@ -232,7 +232,7 @@ func (n *Node) txChecker(ctx context.Context) error { } } - err = n.broadcaster.RemovePendingTx(int64(res.Height), pendingTx.TxHash, pendingTx.Sequence) + err = n.broadcaster.RemovePendingTx(res.Height, pendingTx.TxHash, pendingTx.Sequence) if err != nil { return err }