Skip to content

Commit b628d72

Browse files
authored
build: upgrade to go 1.19 (ethereum#25726)
This changes the CI / release builds to use the latest Go version. It also upgrades golangci-lint to a newer version compatible with Go 1.19. In Go 1.19, godoc has gained official support for links and lists. The syntax for code blocks in doc comments has changed and now requires a leading tab character. gofmt adapts comments to the new syntax automatically, so there are a lot of comment re-formatting changes in this PR. We need to apply the new format in order to pass the CI lint stage with Go 1.19. With the linter upgrade, I have decided to disable 'gosec' - it produces too many false-positive warnings. The 'deadcode' and 'varcheck' linters have also been removed because golangci-lint warns about them being unmaintained. 'unused' provides similar coverage and we already have it enabled, so we don't lose much with this change.
1 parent 389021a commit b628d72

File tree

107 files changed

+998
-974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+998
-974
lines changed

.golangci.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ run:
1212
linters:
1313
disable-all: true
1414
enable:
15-
- deadcode
1615
- goconst
1716
- goimports
1817
- gosimple
1918
- govet
2019
- ineffassign
2120
- misspell
2221
- unconvert
23-
- varcheck
2422
- typecheck
2523
- unused
2624
- staticcheck
2725
- bidichk
2826
- durationcheck
2927
- exportloopref
30-
- gosec
3128
- whitespace
3229

3330
# - structcheck # lots of false positives
@@ -45,11 +42,6 @@ linters-settings:
4542
goconst:
4643
min-len: 3 # minimum length of string constant
4744
min-occurrences: 6 # minimum number of occurrences
48-
gosec:
49-
excludes:
50-
- G404 # Use of weak random number generator - lots of FP
51-
- G107 # Potential http request -- those are intentional
52-
- G306 # G306: Expect WriteFile permissions to be 0600 or less
5345

5446
issues:
5547
exclude-rules:
@@ -58,16 +50,15 @@ issues:
5850
- deadcode
5951
- staticcheck
6052
- path: internal/build/pgp.go
61-
text: 'SA1019: package golang.org/x/crypto/openpgp is deprecated'
53+
text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated: this package is unmaintained except for security fixes.'
6254
- path: core/vm/contracts.go
63-
text: 'SA1019: package golang.org/x/crypto/ripemd160 is deprecated'
55+
text: 'SA1019: "golang.org/x/crypto/ripemd160" is deprecated: RIPEMD-160 is a legacy hash and should not be used for new applications.'
6456
- path: accounts/usbwallet/trezor.go
65-
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
57+
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
6658
- path: accounts/usbwallet/trezor/
67-
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
59+
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
6860
exclude:
6961
- 'SA1019: event.TypeMux is deprecated: use Feed'
7062
- 'SA1019: strings.Title is deprecated'
7163
- 'SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.'
7264
- 'SA1029: should not use built-in type string as key for value'
73-
- 'G306: Expect WriteFile permissions to be 0600 or less'

.travis.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- stage: lint
1717
os: linux
1818
dist: bionic
19-
go: 1.18.x
19+
go: 1.19.x
2020
env:
2121
- lint
2222
git:
@@ -31,7 +31,7 @@ jobs:
3131
os: linux
3232
arch: amd64
3333
dist: bionic
34-
go: 1.18.x
34+
go: 1.19.x
3535
env:
3636
- docker
3737
services:
@@ -48,7 +48,7 @@ jobs:
4848
os: linux
4949
arch: arm64
5050
dist: bionic
51-
go: 1.18.x
51+
go: 1.19.x
5252
env:
5353
- docker
5454
services:
@@ -65,7 +65,7 @@ jobs:
6565
if: type = push
6666
os: linux
6767
dist: bionic
68-
go: 1.18.x
68+
go: 1.19.x
6969
env:
7070
- ubuntu-ppa
7171
- GO111MODULE=on
@@ -90,7 +90,7 @@ jobs:
9090
os: linux
9191
dist: bionic
9292
sudo: required
93-
go: 1.18.x
93+
go: 1.19.x
9494
env:
9595
- azure-linux
9696
- GO111MODULE=on
@@ -162,7 +162,7 @@ jobs:
162162
- stage: build
163163
if: type = push
164164
os: osx
165-
go: 1.18.x
165+
go: 1.19.x
166166
env:
167167
- azure-osx
168168
- azure-ios
@@ -194,7 +194,7 @@ jobs:
194194
os: linux
195195
arch: amd64
196196
dist: bionic
197-
go: 1.18.x
197+
go: 1.19.x
198198
env:
199199
- GO111MODULE=on
200200
script:
@@ -214,7 +214,7 @@ jobs:
214214
- stage: build
215215
os: linux
216216
dist: bionic
217-
go: 1.17.x
217+
go: 1.18.x
218218
env:
219219
- GO111MODULE=on
220220
script:
@@ -225,7 +225,7 @@ jobs:
225225
if: type = cron
226226
os: linux
227227
dist: bionic
228-
go: 1.18.x
228+
go: 1.19.x
229229
env:
230230
- azure-purge
231231
- GO111MODULE=on
@@ -239,7 +239,7 @@ jobs:
239239
if: type = cron
240240
os: linux
241241
dist: bionic
242-
go: 1.18.x
242+
go: 1.19.x
243243
env:
244244
- GO111MODULE=on
245245
script:

accounts/abi/abi_test.go

+20-14
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ func TestInvalidABI(t *testing.T) {
165165

166166
// TestConstructor tests a constructor function.
167167
// The test is based on the following contract:
168-
// contract TestConstructor {
169-
// constructor(uint256 a, uint256 b) public{}
168+
//
169+
// contract TestConstructor {
170+
// constructor(uint256 a, uint256 b) public{}
170171
// }
171172
func TestConstructor(t *testing.T) {
172173
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
@@ -724,16 +725,19 @@ func TestBareEvents(t *testing.T) {
724725
}
725726

726727
// TestUnpackEvent is based on this contract:
727-
// contract T {
728-
// event received(address sender, uint amount, bytes memo);
729-
// event receivedAddr(address sender);
730-
// function receive(bytes memo) external payable {
731-
// received(msg.sender, msg.value, memo);
732-
// receivedAddr(msg.sender);
733-
// }
734-
// }
728+
//
729+
// contract T {
730+
// event received(address sender, uint amount, bytes memo);
731+
// event receivedAddr(address sender);
732+
// function receive(bytes memo) external payable {
733+
// received(msg.sender, msg.value, memo);
734+
// receivedAddr(msg.sender);
735+
// }
736+
// }
737+
//
735738
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
736-
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
739+
//
740+
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
737741
func TestUnpackEvent(t *testing.T) {
738742
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
739743
abi, err := JSON(strings.NewReader(abiJSON))
@@ -1078,8 +1082,9 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
10781082
// TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
10791083
// conflict and that the second send event will be renamed send1.
10801084
// The test runs the abi of the following contract.
1081-
// contract DuplicateEvent {
1082-
// event send(uint256 a);
1085+
//
1086+
// contract DuplicateEvent {
1087+
// event send(uint256 a);
10831088
// event send0();
10841089
// event send();
10851090
// }
@@ -1106,7 +1111,8 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
11061111
// TestUnnamedEventParam checks that an event with unnamed parameters is
11071112
// correctly handled.
11081113
// The test runs the abi of the following contract.
1109-
// contract TestEvent {
1114+
//
1115+
// contract TestEvent {
11101116
// event send(uint256, uint256);
11111117
// }
11121118
func TestUnnamedEventParam(t *testing.T) {

0 commit comments

Comments
 (0)