Skip to content

Commit d3a9179

Browse files
committed
Drop source code locally
1 parent 535e9d4 commit d3a9179

23 files changed

+300
-185
lines changed

.github/goreleaser.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ dockers:
6060
- "--label=org.opencontainers.image.title={{.ProjectName}}"
6161
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
6262
- "--label=org.opencontainers.image.version={{.Version}}"
63-
extra_files:
64-
- scripts
6563
- use: buildx
6664
dockerfile: Dockerfile.release
6765
goos: linux
@@ -75,8 +73,6 @@ dockers:
7573
- "--label=org.opencontainers.image.title={{.ProjectName}}"
7674
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
7775
- "--label=org.opencontainers.image.version={{.Version}}"
78-
extra_files:
79-
- scripts
8076
- use: buildx
8177
dockerfile: Dockerfile.release
8278
goos: linux
@@ -91,8 +87,6 @@ dockers:
9187
- "--label=org.opencontainers.image.title={{.ProjectName}}"
9288
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
9389
- "--label=org.opencontainers.image.version={{.Version}}"
94-
extra_files:
95-
- scripts
9690
- use: buildx
9791
dockerfile: Dockerfile.release
9892
goos: linux
@@ -107,8 +101,6 @@ dockers:
107101
- "--label=org.opencontainers.image.title={{.ProjectName}}"
108102
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
109103
- "--label=org.opencontainers.image.version={{.Version}}"
110-
extra_files:
111-
- scripts
112104

113105
docker_manifests:
114106
# https://goreleaser.com/customization/docker_manifest/

.golangci.yaml

+79-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,62 @@
11
run:
2-
timeout: 5m
2+
concurrency: 8
3+
timeout: 10m
4+
issue-exit-code: 1
35
tests: true
46
skip-dirs-use-default: true
7+
modules-download-mode: readonly
8+
allow-parallel-runners: false
9+
go: ""
510

6-
service:
7-
golangci-lint-version: latest
11+
output:
12+
uniq-by-line: false
13+
path-prefix: ""
14+
sort-results: true
15+
16+
issues:
17+
max-issues-per-linter: 0
18+
max-same-issues: 0
19+
new: false
20+
fix: false
21+
exclude-rules:
22+
- path: (.+)_test.go
23+
linters:
24+
- nilnil
25+
- gosec
826

927
linters:
28+
fast: false
1029
disable-all: true
1130
enable:
31+
- asasalint # Check for pass []any as any in variadic func(...any)
32+
- asciicheck # Detects funky ASCII characters
33+
- bidichk # Checks for dangerous unicode character sequences
34+
- durationcheck # Check for two durations multiplied together
35+
- errcheck # Forces to not skip error check
36+
- exportloopref # Checks for pointers to enclosing loop variables
37+
- gocritic # Bundles different linting checks
38+
- godot # Checks for periods at the end of comments
39+
- gomoddirectives # Allow or ban replace directives in go.mod
40+
- gosimple # Code simplification
41+
- govet # Official Go tool
42+
- ineffassign # Detects when assignments to existing variables are not used
43+
- nakedret # Finds naked/bare returns and requires change them
44+
- nilerr # Requires explicit returns
45+
- nilnil # Requires explicit returns
46+
- promlinter # Lints Prometheus metrics names
47+
- reassign # Checks that package variables are not reassigned
48+
- revive # Drop-in replacement for golint
49+
- tenv # Detects using os.Setenv instead of t.Setenv
50+
- testableexamples # Checks if examples are testable (have expected output)
51+
- unparam # Finds unused params
52+
- usestdlibvars # Detects the possibility to use variables/constants from stdlib
53+
- wastedassign # Finds wasted assignment statements
54+
- loggercheck # Checks the odd number of key and value pairs for common logger libraries
55+
- nestif # Finds deeply nested if statements
56+
- nonamedreturns # Reports all named returns
57+
- decorder # Check declaration order of types, consts, vars and funcs
58+
- gocheckcompilerdirectives # Checks that compiler directive comments (//go:) are valid
59+
- gochecknoinits # Checks for init methods
1260
- whitespace # Tool for detection of leading and trailing whitespace
1361
- wsl # Forces you to use empty lines
1462
- unconvert # Unnecessary type conversions
@@ -25,22 +73,44 @@ linters:
2573
- importas # Enforces consistent import aliases
2674
- gosec # Security problems
2775
- gofmt # Whether the code was gofmt-ed
76+
- gofumpt # Stricter gofmt
2877
- goimports # Unused imports
2978
- goconst # Repeated strings that could be replaced by a constant
30-
- forcetypeassert # Finds forced type assertions
3179
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
32-
- dupl # Code clone detection
3380
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
3481
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
3582
- unused # Checks Go code for unused constants, variables, functions and types
3683

37-
issues:
38-
exclude-files:
39-
- tools/tools.go
40-
4184
linters-settings:
85+
gocritic:
86+
enabled-tags:
87+
- diagnostic
88+
- experimental
89+
- opinionated
90+
- performance
91+
- style
92+
disabled-checks:
93+
- hugeParam
94+
- rangeExprCopy
95+
- rangeValCopy
96+
- importShadow
97+
- unnamedResult
98+
errcheck:
99+
check-type-assertions: false
100+
check-blank: true
101+
exclude-functions:
102+
- io/ioutil.ReadFile
103+
- io.Copy(*bytes.Buffer)
104+
- io.Copy(os.Stdout)
105+
nakedret:
106+
max-func-lines: 1
107+
govet:
108+
enable-all: true
42109
gofmt:
43110
simplify: true
44111
goconst:
45112
min-len: 3
46113
min-occurrences: 3
114+
godot:
115+
scope: all
116+
period: false

Dockerfile.release

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
FROM scratch
2-
COPY scripts /scripts
32
COPY supernova /
43
ENTRYPOINT [ "/supernova" ]

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ test:
1313
.PHONY: lint
1414
lint:
1515
$(golangci_lint) run --config .golangci.yaml
16+
17+
.PHONY: gofumpt
18+
gofumpt:
19+
go install mvdan.cc/gofumpt@latest
20+
gofumpt -l -w .
21+
22+
.PHONY: fixalign
23+
fixalign:
24+
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
25+
fieldalignment -fix $(filter-out $@,$(MAKECMDGOALS)) # the full package name (not path!)

internal/batcher/batcher.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func prepareTransactions(txs []*std.Tx) ([][]byte, error) {
8787

8888
marshalledTxs[index] = txBin
8989

90-
_ = bar.Add(1)
90+
_ = bar.Add(1) //nolint:errcheck // No need to check
9191
}
9292

9393
return marshalledTxs, nil
@@ -117,7 +117,7 @@ func (b *Batcher) generateBatches(txs [][]byte, batchSize int) ([]common.Batch,
117117

118118
readyBatches[index] = cliBatch
119119

120-
_ = bar.Add(1)
120+
_ = bar.Add(1) //nolint:errcheck // No need to check
121121
}
122122

123123
return readyBatches, nil
@@ -142,7 +142,7 @@ func sendBatches(readyBatches []common.Batch) ([][]any, error) {
142142

143143
batchResults[index] = batchResult
144144

145-
_ = bar.Add(1)
145+
_ = bar.Add(1) //nolint:errcheck // No need to check
146146
}
147147

148148
fmt.Printf("✅ Successfully sent %d batches\n", numBatches)
@@ -184,7 +184,7 @@ func parseBatchResults(batchResults [][]any, numTx int) ([][]byte, error) {
184184
txHashes[index] = txResult.Hash
185185
index++
186186

187-
_ = bar.Add(1)
187+
_ = bar.Add(1) //nolint:errcheck // No need to check
188188
}
189189
}
190190

internal/client/client.go

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func (h *Client) GetAccount(address string) (*gnoland.GnoAccount, error) {
9595
fmt.Sprintf("auth/accounts/%s", address),
9696
[]byte{},
9797
)
98-
9998
if err != nil {
10099
return nil, fmt.Errorf("unable to fetch account %s, %w", address, err)
101100
}

internal/collector/collector.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import (
99
"github.com/schollz/progressbar/v3"
1010
)
1111

12-
var (
13-
errTimeout = errors.New("collector timed out")
14-
)
12+
var errTimeout = errors.New("collector timed out")
1513

1614
// Collector is the transaction / block stat
1715
// collector.
@@ -86,7 +84,7 @@ func (c *Collector) GetRunResult(
8684
}
8785

8886
processed += belong
89-
_ = bar.Add(belong)
87+
_ = bar.Add(belong) //nolint:errcheck // No need to check
9088

9189
// Fetch the total gas used by transactions
9290
blockGasUsed, err := c.cli.GetBlockGasUsed(blockNum)
@@ -159,7 +157,7 @@ func (t *txLookup) anyBelong(txs types.Txs) int {
159157

160158
// calculateTPS calculates the TPS for the sequence
161159
func calculateTPS(startTime time.Time, totalTx int) float64 {
162-
diff := time.Now().Sub(startTime).Seconds()
160+
diff := time.Since(startTime).Seconds()
163161

164162
return float64(totalTx) / diff
165163
}

internal/collector/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ type Client interface {
1515

1616
// RunResult is the complete test-run result
1717
type RunResult struct {
18-
AverageTPS float64 `json:"averageTPS"`
1918
Blocks []*BlockResult `json:"blocks"`
19+
AverageTPS float64 `json:"averageTPS"`
2020
}
2121

2222
// BlockResult is the single-block test run result
2323
type BlockResult struct {
24-
Number int64 `json:"blockNumber"`
2524
Time time.Time `json:"created"`
25+
Number int64 `json:"blockNumber"`
2626
Transactions int64 `json:"numTransactions"`
2727
GasUsed int64 `json:"gasUsed"`
2828
GasLimit int64 `json:"gasLimit"`

internal/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ var (
1919

2020
var (
2121
// httpRegex is used for verifying the cluster's JSON-RPC HTTP endpoint
22-
httpRegex = regexp.MustCompile(`(https?://.*)(:(\d*)\/?(.*))?`)
22+
httpRegex = regexp.MustCompile(`(https?://.*)(:(\d*)/?(.*))?`)
2323

2424
// wsRegex is used for verifying the cluster's JSON-RPC WS endpoint
25-
wsRegex = regexp.MustCompile(`(wss?://.*)(:(\d*)\/?(.*))?`)
25+
wsRegex = regexp.MustCompile(`(wss?://.*)(:(\d*)/?(.*))?`)
2626
)
2727

2828
// Config is the central pipeline configuration

internal/distributor/distributor.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import (
1414
"github.com/schollz/progressbar/v3"
1515
)
1616

17-
var (
18-
errInsufficientFunds = errors.New("insufficient distributor funds")
19-
)
17+
var errInsufficientFunds = errors.New("insufficient distributor funds")
2018

2119
type Client interface {
2220
GetAccount(address string) (*gnoland.GnoAccount, error)
@@ -89,8 +87,8 @@ func (d *Distributor) fundAccounts(
8987
chainID string,
9088
) ([]std.Account, error) {
9189
type shortAccount struct {
92-
address crypto.Address
9390
missingFunds std.Coin
91+
address crypto.Address
9492
}
9593

9694
var (
@@ -232,7 +230,7 @@ func (d *Distributor) fundAccounts(
232230
// Mark the account as funded
233231
readyAccounts = append(readyAccounts, nodeAccount)
234232

235-
_ = bar.Add(1)
233+
_ = bar.Add(1) //nolint:errcheck // No need to check
236234
}
237235

238236
fmt.Printf("✅ Successfully funded %d accounts\n", len(shortAccounts))

internal/output.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ func displayResults(result *collector.RunResult) {
1414
w := tabwriter.NewWriter(os.Stdout, 10, 20, 2, ' ', 0)
1515

1616
// TPS //
17-
_, _ = fmt.Fprintln(w, fmt.Sprintf("\nTPS: %.2f", result.AverageTPS))
17+
_, _ = fmt.Fprintf(w, "\nTPS: %.2f\n", result.AverageTPS)
1818

1919
// Block info //
2020
_, _ = fmt.Fprintln(w, "\nBlock #\tGas Used\tGas Limit\tTransactions\tUtilization")
2121
for _, block := range result.Blocks {
22-
_, _ = fmt.Fprintln(
22+
_, _ = fmt.Fprintf(
2323
w,
24-
fmt.Sprintf(
25-
"Block #%d\t%d\t%d\t%d\t%.2f%%",
26-
block.Number,
27-
block.GasUsed,
28-
block.GasLimit,
29-
block.Transactions,
30-
(float64(block.GasUsed)/float64(block.GasLimit))*100,
31-
),
24+
"Block #%d\t%d\t%d\t%d\t%.2f%%\n",
25+
block.Number,
26+
block.GasUsed,
27+
block.GasLimit,
28+
block.Transactions,
29+
(float64(block.GasUsed)/float64(block.GasLimit))*100,
3230
)
3331
}
3432

internal/pipeline.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (p *Pipeline) initializeAccounts() []crypto.PrivKey {
152152
// Register the accounts with the keybase
153153
for i := 0; i < int(p.cfg.SubAccounts)+1; i++ {
154154
accounts[i] = signer.GenerateKeyFromSeed(seed, uint32(i))
155-
_ = bar.Add(1)
155+
_ = bar.Add(1) //nolint:errcheck // No need to check
156156
}
157157

158158
fmt.Printf("✅ Successfully generated %d accounts\n", len(accounts))
@@ -218,7 +218,7 @@ func prepareRuntime(
218218
return fmt.Errorf("unable to broadcast predeploy tx, %w", err)
219219
}
220220

221-
_ = bar.Add(1)
221+
_ = bar.Add(1) //nolint:errcheck // No need to check
222222
}
223223

224224
fmt.Printf("✅ Successfully predeployed %d transactions\n", len(predeployTxs))

0 commit comments

Comments
 (0)