From cccac0c0bba4727ea505526bb75dfa2b8504ba09 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 08:41:14 -0800 Subject: [PATCH 1/7] ci: bump golang to 1.23.6 --- .github/workflows/ci.yml | 2 +- .golangci.yml | 2 +- RELEASES.md | 2 ++ go.mod | 4 ++-- go.sum | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b180a501d..71741d8eb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.56 + version: v1.63 working-directory: . args: --timeout 3m skip-pkg-cache: true diff --git a/.golangci.yml b/.golangci.yml index c6c8d5748a..071cca2ec1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,7 @@ run: tests: true # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true + issues.exclude-dirs-use-default: true # Include non-test files tagged as test-only. # Context: https://github.com/ava-labs/avalanchego/pull/3173 diff --git a/RELEASES.md b/RELEASES.md index 628e454843..77edd729b9 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,6 +1,8 @@ # Release Notes ## Pending Release +- Bump golang version to v1.23.6 +- Bump golangci-lint to v1.63 ## [v0.14.1](https://github.com/ava-labs/coreth/releases/tag/v0.14.1) diff --git a/go.mod b/go.mod index 37f94451a6..f3257ce832 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/ava-labs/coreth -go 1.22.8 +go 1.23.6 require ( github.com/VictoriaMetrics/fastcache v1.12.1 - github.com/ava-labs/avalanchego v1.12.3-0.20250213221544-df1bf8c8a6cf + github.com/ava-labs/avalanchego v1.12.3-0.20250216200402-d76684b684f1 github.com/cespare/cp v0.1.0 github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index a5038c5855..6ae24cb046 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.12.3-0.20250213221544-df1bf8c8a6cf h1:4aq9V24PsH92vDSQTBx+uhm60BTeaNcXg/7FreQ8Q3M= -github.com/ava-labs/avalanchego v1.12.3-0.20250213221544-df1bf8c8a6cf/go.mod h1:PkpeGfEdsTccz87SDHidto21U5+BSBGZ+BNPW6Zplbc= +github.com/ava-labs/avalanchego v1.12.3-0.20250216200402-d76684b684f1 h1:bp+RMUpgUX2HL22FnArOMkhg9IaGjA7xHExAH3zy3Og= +github.com/ava-labs/avalanchego v1.12.3-0.20250216200402-d76684b684f1/go.mod h1:kjz2dtxgb9UiSzCDMon8AqFpsRPb9SGGW9F6tsKwufc= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= From 1005365a6a71738b89c32b87bb921f6a6160925f Mon Sep 17 00:00:00 2001 From: Martin HS Date: Mon, 14 Oct 2024 19:25:22 +0200 Subject: [PATCH 2/7] build: update to golangci-lint 1.61.0 (#30587) Changelog: https://golangci-lint.run/product/changelog/#1610 Removes `exportloopref` (no longer needed), replaces it with `copyloopvar` which is basically the opposite. Also adds: - `durationcheck` - `gocheckcompilerdirectives` - `reassign` - `mirror` - `tenv` --------- Co-authored-by: Marius van der Wijden --- .golangci.yml | 17 +++++++++++++++++ accounts/abi/abi_test.go | 1 - accounts/abi/bind/bind.go | 2 +- accounts/abi/event_test.go | 1 - accounts/abi/pack_test.go | 1 - accounts/abi/reflect_test.go | 1 - accounts/abi/topics_test.go | 3 --- accounts/abi/unpack_test.go | 3 +-- core/rawdb/accessors_chain_test.go | 6 +++--- core/types/transaction_test.go | 2 -- eth/filters/api.go | 1 - .../internal/tracetest/calltrace_test.go | 2 -- .../internal/tracetest/flat_calltrace_test.go | 1 - eth/tracers/internal/tracetest/prestate_test.go | 1 - eth/tracers/logger/logger.go | 2 +- rpc/client_test.go | 1 - rpc/types_test.go | 1 - 17 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 071cca2ec1..8d5189a3b1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,23 @@ linters: disable-all: true enable: - goimports + - govet + - ineffassign + - misspell + - unconvert + - typecheck + - unused + # - staticcheck + - bidichk + - durationcheck + - copyloopvar + - whitespace + # - revive # only certain checks enabled + - durationcheck + - gocheckcompilerdirectives + - reassign + - mirror + - tenv - gosimple - govet - ineffassign diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 68052e639a..023ff5cc4e 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -1210,7 +1210,6 @@ func TestUnpackRevert(t *testing.T) { {"4e487b7100000000000000000000000000000000000000000000000000000000000000ff", "unknown panic code: 0xff", nil}, } for index, c := range cases { - index, c := index, c t.Run(fmt.Sprintf("case %d", index), func(t *testing.T) { t.Parallel() got, err := UnpackRevert(common.Hex2Bytes(c.input)) diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index 0a4223c5e5..3dfbb6d243 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -262,7 +262,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string] } // Parse library references. for pattern, name := range libs { - matched, err := regexp.Match("__\\$"+pattern+"\\$__", []byte(contracts[types[i]].InputBin)) + matched, err := regexp.MatchString("__\\$"+pattern+"\\$__", contracts[types[i]].InputBin) if err != nil { log.Error("Could not search for pattern", "pattern", pattern, "contract", contracts[types[i]], "err", err) } diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go index a967decd52..4a254e9950 100644 --- a/accounts/abi/event_test.go +++ b/accounts/abi/event_test.go @@ -341,7 +341,6 @@ func TestEventTupleUnpack(t *testing.T) { for _, tc := range testCases { assert := assert.New(t) - tc := tc t.Run(tc.name, func(t *testing.T) { err := unpackTestEventData(tc.dest, tc.data, tc.jsonLog, assert) if tc.error == "" { diff --git a/accounts/abi/pack_test.go b/accounts/abi/pack_test.go index 47d4931698..b13de922a5 100644 --- a/accounts/abi/pack_test.go +++ b/accounts/abi/pack_test.go @@ -44,7 +44,6 @@ import ( func TestPack(t *testing.T) { t.Parallel() for i, test := range packUnpackTests { - i, test := i, test t.Run(strconv.Itoa(i), func(t *testing.T) { t.Parallel() encb, err := hex.DecodeString(test.packed) diff --git a/accounts/abi/reflect_test.go b/accounts/abi/reflect_test.go index 5d90cdb763..624032968d 100644 --- a/accounts/abi/reflect_test.go +++ b/accounts/abi/reflect_test.go @@ -182,7 +182,6 @@ var reflectTests = []reflectTest{ func TestReflectNameToStruct(t *testing.T) { t.Parallel() for _, test := range reflectTests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() m, err := mapArgNamesToStructFields(test.args, reflect.ValueOf(test.struc)) diff --git a/accounts/abi/topics_test.go b/accounts/abi/topics_test.go index 70522b6ce6..53e4327bf6 100644 --- a/accounts/abi/topics_test.go +++ b/accounts/abi/topics_test.go @@ -147,7 +147,6 @@ func TestMakeTopics(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := MakeTopics(tt.args.query...) @@ -383,7 +382,6 @@ func TestParseTopics(t *testing.T) { tests := setupTopicsTests() for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() createObj := tt.args.createObj() @@ -403,7 +401,6 @@ func TestParseTopicsIntoMap(t *testing.T) { tests := setupTopicsTests() for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() outMap := make(map[string]interface{}) diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 0b4224efa5..d7f383a731 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -399,7 +399,6 @@ func TestMethodMultiReturn(t *testing.T) { "Can not unpack into a slice with wrong types", }} for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { require := require.New(t) err := abi.UnpackIntoInterface(tc.dest, "multi", data) @@ -957,7 +956,7 @@ func TestOOMMaliciousInput(t *testing.T) { } encb, err := hex.DecodeString(test.enc) if err != nil { - t.Fatalf("invalid hex: %s" + test.enc) + t.Fatalf("invalid hex: %s", test.enc) } _, err = abi.Methods["method"].Outputs.UnpackValues(encb) if err == nil { diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index 27c7cf4a95..1157eee792 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -291,10 +291,10 @@ func TestBlockReceiptStorage(t *testing.T) { // Insert the receipt slice into the database and check presence WriteReceipts(db, hash, 0, receipts) if rs := ReadReceipts(db, hash, 0, 0, params.TestChainConfig); len(rs) == 0 { - t.Fatalf("no receipts returned") + t.Fatal("no receipts returned") } else { if err := checkReceiptsRLP(rs, receipts); err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } } // Delete the body and ensure that the receipts are no longer returned (metadata can't be recomputed) @@ -308,7 +308,7 @@ func TestBlockReceiptStorage(t *testing.T) { } // Ensure that receipts without metadata can be returned without the block body too if err := checkReceiptsRLP(ReadRawReceipts(db, hash, 0), receipts); err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } // Sanity check that body and header alone without the receipt is a full purge WriteHeader(db, header) diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 4471a6ba45..02ea3d16a4 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -520,9 +520,7 @@ func TestYParityJSONUnmarshalling(t *testing.T) { DynamicFeeTxType, BlobTxType, } { - txType := txType for _, test := range tests { - test := test t.Run(fmt.Sprintf("txType=%d: %s", txType, test.name), func(t *testing.T) { // Copy the base json testJson := make(map[string]interface{}) diff --git a/eth/filters/api.go b/eth/filters/api.go index 2416e91061..fb8178ed63 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -350,7 +350,6 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc select { case logs := <-matchedLogs: for _, log := range logs { - log := log notifier.Notify(rpcSub.ID, &log) } case <-rpcSub.Err(): // client send an unsubscribe request diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 8166a3b045..075a804f18 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -113,7 +113,6 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) { if !strings.HasSuffix(file.Name(), ".json") { continue } - file := file // capture range variable t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Parallel() @@ -205,7 +204,6 @@ func BenchmarkTracers(b *testing.B) { if !strings.HasSuffix(file.Name(), ".json") { continue } - file := file // capture range variable b.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(b *testing.B) { blob, err := os.ReadFile(filepath.Join("testdata", "call_tracer", file.Name())) if err != nil { diff --git a/eth/tracers/internal/tracetest/flat_calltrace_test.go b/eth/tracers/internal/tracetest/flat_calltrace_test.go index 9305bf7150..b9be17981b 100644 --- a/eth/tracers/internal/tracetest/flat_calltrace_test.go +++ b/eth/tracers/internal/tracetest/flat_calltrace_test.go @@ -167,7 +167,6 @@ func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) { if !strings.HasSuffix(file.Name(), ".json") { continue } - file := file // capture range variable t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Parallel() diff --git a/eth/tracers/internal/tracetest/prestate_test.go b/eth/tracers/internal/tracetest/prestate_test.go index 7f659d6f71..fd4231b002 100644 --- a/eth/tracers/internal/tracetest/prestate_test.go +++ b/eth/tracers/internal/tracetest/prestate_test.go @@ -83,7 +83,6 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) { if !strings.HasSuffix(file.Name(), ".json") { continue } - file := file // capture range variable t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Parallel() diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index d94ffd3cf7..c6d3f1b0fb 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -446,7 +446,7 @@ func formatLogs(logs []StructLog) []StructLogRes { } formatted[index].Stack = &stack } - if trace.ReturnData != nil && len(trace.ReturnData) > 0 { + if len(trace.ReturnData) > 0 { formatted[index].ReturnData = hexutil.Bytes(trace.ReturnData).String() } if trace.Memory != nil { diff --git a/rpc/client_test.go b/rpc/client_test.go index eec18afb8f..97bc69e61b 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -723,7 +723,6 @@ func TestClientHTTP(t *testing.T) { ) defer client.Close() for i := range results { - i := i go func() { errc <- client.Call(&results[i], "test_echo", wantResult.String, wantResult.Int, wantResult.Args) }() diff --git a/rpc/types_test.go b/rpc/types_test.go index a255c1e9f7..779b23296f 100644 --- a/rpc/types_test.go +++ b/rpc/types_test.go @@ -145,7 +145,6 @@ func TestBlockNumberOrHash_WithNumber_MarshalAndUnmarshal(t *testing.T) { {"earliest", int64(EarliestBlockNumber)}, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { bnh := BlockNumberOrHashWithNumber(BlockNumber(test.number)) marshalled, err := json.Marshal(bnh) From ca5c31afbb3e459af091e3f3e79010f5772d316c Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 09:24:50 -0800 Subject: [PATCH 3/7] fix copyloopvar --- core/blockchain_test.go | 1 - core/predicate_check_test.go | 1 - plugin/evm/atomic_trie_test.go | 1 - plugin/evm/prestate_tracer_test.go | 1 - plugin/evm/vm_test.go | 1 - 5 files changed, 5 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 601cb12f02..7460efd92e 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -290,7 +290,6 @@ func TestBlockChainOfflinePruningUngracefulShutdown(t *testing.T) { return createBlockChain(db, pruningConfig, gspec, lastAcceptedHash) } for _, tt := range tests { - tt := tt t.Run(tt.Name, func(t *testing.T) { t.Parallel() tt.testFunc(t, create) diff --git a/core/predicate_check_test.go b/core/predicate_check_test.go index 3d98416fc3..3c17aac698 100644 --- a/core/predicate_check_test.go +++ b/core/predicate_check_test.go @@ -293,7 +293,6 @@ func TestCheckPredicate(t *testing.T) { expectedErr: ErrIntrinsicGas, }, } { - test := test t.Run(name, func(t *testing.T) { require := require.New(t) // Create the rules from TestChainConfig and update the predicates based on the test params diff --git a/plugin/evm/atomic_trie_test.go b/plugin/evm/atomic_trie_test.go index 71d62ef7ca..1a065d4530 100644 --- a/plugin/evm/atomic_trie_test.go +++ b/plugin/evm/atomic_trie_test.go @@ -706,7 +706,6 @@ func TestAtomicTrie_AcceptTrie(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase // capture range variable for running tests with Go < 1.22 t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/plugin/evm/prestate_tracer_test.go b/plugin/evm/prestate_tracer_test.go index 097155a8ae..511098bb62 100644 --- a/plugin/evm/prestate_tracer_test.go +++ b/plugin/evm/prestate_tracer_test.go @@ -37,7 +37,6 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) { if !strings.HasSuffix(file.Name(), ".json") { continue } - file := file // capture range variable t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Parallel() diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index 9fb8949c9a..0f54053cef 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -1136,7 +1136,6 @@ func TestConflictingImportTxsAcrossBlocks(t *testing.T) { "apricotPhase4": genesisJSONApricotPhase4, "apricotPhase5": genesisJSONApricotPhase5, } { - genesis := genesis t.Run(name, func(t *testing.T) { testConflictingImportTxs(t, genesis) }) From c757f57e4d15b4a1c700fab42a376906c61e32ac Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 09:26:49 -0800 Subject: [PATCH 4/7] align linters w/ upstream --- .golangci.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8d5189a3b1..4bec591709 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,6 +12,7 @@ run: linters: disable-all: true enable: + - gosimple - goimports - govet - ineffassign @@ -30,13 +31,6 @@ linters: - reassign - mirror - tenv - - gosimple - - govet - - ineffassign - - misspell - - unconvert - - unused - - whitespace linters-settings: gofmt: From 7d27f710afecb53dea15057fe9845ff6963ae359 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 09:27:30 -0800 Subject: [PATCH 5/7] nit --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 4bec591709..813710641e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,8 +12,8 @@ run: linters: disable-all: true enable: - - gosimple - goimports + - gosimple - govet - ineffassign - misspell From 538b81903eaaaf143f748a77ca7fab0f2717d883 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 10:54:27 -0800 Subject: [PATCH 6/7] Update RELEASES.md Co-authored-by: Quentin McGaw Signed-off-by: Darioush Jalali --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 77edd729b9..0cce20cbc4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,7 +2,7 @@ ## Pending Release - Bump golang version to v1.23.6 -- Bump golangci-lint to v1.63 +- Bump golangci-lint to v1.63 and add linters ## [v0.14.1](https://github.com/ava-labs/coreth/releases/tag/v0.14.1) From 38f684c055ff9289718f884adfeff00e2ceaefe6 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Mon, 17 Feb 2025 11:10:15 -0800 Subject: [PATCH 7/7] remove unneeded flag + comments --- .golangci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 813710641e..ace8a22dad 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,11 +3,6 @@ run: timeout: 10m tests: true - # default is true. Enables skipping of directories: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - issues.exclude-dirs-use-default: true - # Include non-test files tagged as test-only. - # Context: https://github.com/ava-labs/avalanchego/pull/3173 linters: disable-all: true