Skip to content

Commit 980cd3c

Browse files
authored
build: bump Go to 1.26.5 and alpine to 3.24.1 (#1629)
1 parent 9fc9ef3 commit 980cd3c

15 files changed

Lines changed: 63 additions & 73 deletions

File tree

.github/workflows/lint-go.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
2727
- name: Check `modernize` (code style)
2828
run: |
29-
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 -test ./...
29+
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.21.1 -test ./...
3030
3131
- name: golangci-lint
3232
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
3333
with:
34-
version: v2.11.3
34+
version: v2.12.2
3535
# use the default if on main branch, otherwise use the pull request config
3636
args: --timeout=30m --config=.golangci.yml
3737
only-new-issues: false

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Build thor in a Go builder container
2-
FROM golang:1.26.1-alpine AS builder
2+
FROM golang:1.26.5-alpine AS builder
33

44
RUN apk add --no-cache make gcc musl-dev linux-headers git
55
WORKDIR /go/thor
66
COPY . /go/thor
77
RUN make all
88

99
# Pull thor into a second stage deploy alpine container
10-
FROM alpine:3.23.3
10+
FROM alpine:3.24.1
1111

1212
RUN apk add --no-cache ca-certificates
1313
COPY --from=builder /go/thor/bin/thor /usr/local/bin/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PACKAGES = `go list ./... | grep -v '/vendor/'`
1010
FUZZTIME=1m
1111

1212
REQUIRED_GO_MAJOR = 1
13-
REQUIRED_GO_MINOR = 25
13+
REQUIRED_GO_MINOR = 26
1414
MAJOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f1)
1515
MINOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f2)
1616
export GO111MODULE=on
@@ -84,7 +84,7 @@ lint: | go_version_check lint_command_check #@ Run 'golangci-lint'
8484
@echo "running golangci-lint..."
8585
@golangci-lint run --config .golangci.yml
8686
@echo "running modernize..."
87-
@go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 ./...
87+
@go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.21.1 ./...
8888
@echo "done."
8989

9090
lint-fix: | go_version_check lint_command_check #@ Attempt to fix linting issues

abi/ethabi/abifuzzer_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func unpackPack(abi ABI, method string, input []byte) ([]any, bool) {
8181

8282
func packUnpack(abi ABI, method string, input *[]any) bool {
8383
if packed, err := abi.Pack(method, input); err == nil {
84-
outptr := reflect.New(reflect.TypeOf(input))
84+
outptr := reflect.New(reflect.TypeFor[*[]any]())
8585
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)
8686
if err != nil {
8787
panic(err)
@@ -101,34 +101,35 @@ type arg struct {
101101
}
102102

103103
func createABI(name string, stateMutability, payable *string, inputs []arg) (ABI, error) {
104-
sig := fmt.Sprintf(`[{ "type" : "function", "name" : "%v" `, name)
104+
var sig strings.Builder
105+
fmt.Fprintf(&sig, `[{ "type" : "function", "name" : "%v" `, name)
105106
if stateMutability != nil {
106-
sig += fmt.Sprintf(`, "stateMutability": "%v" `, *stateMutability)
107+
fmt.Fprintf(&sig, `, "stateMutability": "%v" `, *stateMutability)
107108
}
108109
if payable != nil {
109-
sig += fmt.Sprintf(`, "payable": %v `, *payable)
110+
fmt.Fprintf(&sig, `, "payable": %v `, *payable)
110111
}
111112
if len(inputs) > 0 {
112-
sig += `, "inputs" : [ {`
113+
sig.WriteString(`, "inputs" : [ {`)
113114
for i, inp := range inputs {
114-
sig += fmt.Sprintf(`"name" : "%v", "type" : "%v" `, inp.name, inp.typ)
115+
fmt.Fprintf(&sig, `"name" : "%v", "type" : "%v" `, inp.name, inp.typ)
115116
if i+1 < len(inputs) {
116-
sig += ","
117+
sig.WriteString(",")
117118
}
118119
}
119-
sig += "} ]"
120-
sig += `, "outputs" : [ {`
120+
sig.WriteString("} ]")
121+
sig.WriteString(`, "outputs" : [ {`)
121122
for i, inp := range inputs {
122-
sig += fmt.Sprintf(`"name" : "%v", "type" : "%v" `, inp.name, inp.typ)
123+
fmt.Fprintf(&sig, `"name" : "%v", "type" : "%v" `, inp.name, inp.typ)
123124
if i+1 < len(inputs) {
124-
sig += ","
125+
sig.WriteString(",")
125126
}
126127
}
127-
sig += "} ]"
128+
sig.WriteString("} ]")
128129
}
129-
sig += `}]`
130+
sig.WriteString(`}]`)
130131
// fmt.Printf("sig: %s\n", sig)
131-
return JSON(strings.NewReader(sig))
132+
return JSON(strings.NewReader(sig.String()))
132133
}
133134

134135
func fuzzAbi(input []byte) {

abi/ethabi/argument.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]any, data []byte) error {
112112
// Copy performs the operation go format -> provided struct.
113113
func (arguments Arguments) Copy(v any, values []any) error {
114114
// make sure the passed value is arguments pointer
115-
if reflect.Ptr != reflect.ValueOf(v).Kind() {
115+
if reflect.Pointer != reflect.ValueOf(v).Kind() {
116116
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
117117
}
118118
if len(values) == 0 {

abi/ethabi/pack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func packElement(t Type, reflectValue reflect.Value) ([]byte, error) {
3939
switch t.T {
4040
case UintTy:
4141
// make sure to not pack a negative value into a uint type.
42-
if reflectValue.Kind() == reflect.Ptr {
42+
if reflectValue.Kind() == reflect.Pointer {
4343
val := new(big.Int).Set(reflectValue.Interface().(*big.Int))
4444
if val.Sign() == -1 {
4545
return nil, errInvalidSign
@@ -65,7 +65,7 @@ func packElement(t Type, reflectValue reflect.Value) ([]byte, error) {
6565
if reflectValue.Kind() == reflect.Array {
6666
reflectValue = mustArrayToByteSlice(reflectValue)
6767
}
68-
if reflectValue.Type() != reflect.TypeOf([]byte{}) {
68+
if reflectValue.Type() != reflect.TypeFor[[]byte]() {
6969
return []byte{}, errors.New("bytes type is neither slice nor array")
7070
}
7171
return packBytesSlice(reflectValue.Bytes(), reflectValue.Len()), nil
@@ -86,7 +86,7 @@ func packNum(value reflect.Value) []byte {
8686
return u256Bytes(new(big.Int).SetUint64(value.Uint()))
8787
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
8888
return u256Bytes(big.NewInt(value.Int()))
89-
case reflect.Ptr:
89+
case reflect.Pointer:
9090
return u256Bytes(new(big.Int).Set(value.Interface().(*big.Int)))
9191
default:
9292
panic("abi: fatal error")

abi/ethabi/reflect.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func ConvertType(in any, proto any) any {
5353
// indirect recursively dereferences the value until it either gets the value
5454
// or finds a big.Int
5555
func indirect(v reflect.Value) reflect.Value {
56-
if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeFor[big.Int]() {
56+
if v.Kind() == reflect.Pointer && v.Elem().Type() != reflect.TypeFor[big.Int]() {
5757
return indirect(v.Elem())
5858
}
5959
return v
@@ -102,9 +102,9 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
102102
func set(dst, src reflect.Value) error {
103103
dstType, srcType := dst.Type(), src.Type()
104104
switch {
105-
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
105+
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Pointer || dst.Elem().CanSet()):
106106
return set(dst.Elem(), src)
107-
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeFor[big.Int]():
107+
case dstType.Kind() == reflect.Pointer && dstType.Elem() != reflect.TypeFor[big.Int]():
108108
return set(dst.Elem(), src)
109109
case srcType.AssignableTo(dstType) && dst.CanSet():
110110
dst.Set(src)
@@ -138,7 +138,7 @@ func setSlice(dst, src reflect.Value) error {
138138
}
139139

140140
func setArray(dst, src reflect.Value) error {
141-
if src.Kind() == reflect.Ptr {
141+
if src.Kind() == reflect.Pointer {
142142
return set(dst, indirect(src))
143143
}
144144
array := reflect.New(dst.Type()).Elem()
@@ -188,15 +188,15 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri
188188
struct2abi := make(map[string]string)
189189

190190
// first round ~~~
191-
for i := 0; i < typ.NumField(); i++ {
192-
structFieldName := typ.Field(i).Name
191+
for i := range typ.Fields() {
192+
structFieldName := i.Name
193193

194194
// skip private struct fields.
195195
if structFieldName[:1] != strings.ToUpper(structFieldName[:1]) {
196196
continue
197197
}
198198
// skip fields that have no abi:"" tag.
199-
tagName, ok := typ.Field(i).Tag.Lookup("abi")
199+
tagName, ok := i.Tag.Lookup("abi")
200200
if !ok {
201201
continue
202202
}

abi/ethabi/type.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
164164
}
165165
case "tuple":
166166
var (
167-
fields []reflect.StructField
168-
elems []*Type
169-
names []string
170-
expression string // canonical parameter expression
171-
used = make(map[string]bool)
167+
fields []reflect.StructField
168+
elems []*Type
169+
names []string
170+
used = make(map[string]bool)
172171
)
173-
expression += "("
172+
var expression strings.Builder // canonical parameter expression
173+
expression.WriteString("(")
174174
for idx, c := range components {
175175
cType, err := NewType(c.Type, c.InternalType, c.Components)
176176
if err != nil {
@@ -192,18 +192,18 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
192192
})
193193
elems = append(elems, &cType)
194194
names = append(names, c.Name)
195-
expression += cType.stringKind
195+
expression.WriteString(cType.stringKind)
196196
if idx != len(components)-1 {
197-
expression += ","
197+
expression.WriteString(",")
198198
}
199199
}
200-
expression += ")"
200+
expression.WriteString(")")
201201

202202
typ.TupleType = reflect.StructOf(fields)
203203
typ.TupleElems = elems
204204
typ.TupleRawNames = names
205205
typ.T = TupleTy
206-
typ.stringKind = expression
206+
typ.stringKind = expression.String()
207207

208208
const structPrefix = "struct "
209209
// After solidity 0.5.10, a new field of abi "internalType"

api/events/events_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestOptionalIndexes(t *testing.T) {
8686
filter := api.EventFilter{
8787
CriteriaSet: make([]*api.EventCriteria, 0),
8888
Range: nil,
89-
Options: &api.Options{Limit: ptr(6), IncludeIndexes: tc.includeIndexes},
89+
Options: &api.Options{Limit: new(uint64(6)), IncludeIndexes: tc.includeIndexes},
9090
Order: logdb.DESC,
9191
}
9292

@@ -132,10 +132,6 @@ func TestEvents_WithOptionsNoLimit(t *testing.T) {
132132
assert.Equal(t, 4, len(tLogs))
133133
}
134134

135-
func ptr(v uint64) *uint64 {
136-
return &v
137-
}
138-
139135
func TestOption(t *testing.T) {
140136
thorChain := initEventServer(t, 5)
141137
defer ts.Close()
@@ -145,7 +141,7 @@ func TestOption(t *testing.T) {
145141
filter := api.EventFilter{
146142
CriteriaSet: make([]*api.EventCriteria, 0),
147143
Range: nil,
148-
Options: &api.Options{Limit: ptr(6)},
144+
Options: &api.Options{Limit: new(uint64(6))},
149145
Order: logdb.DESC,
150146
}
151147

@@ -154,7 +150,7 @@ func TestOption(t *testing.T) {
154150
assert.Equal(t, "options.limit exceeds the maximum allowed value of 5", strings.Trim(string(res), "\n"))
155151
assert.Equal(t, http.StatusForbidden, statusCode)
156152

157-
filter.Options.Limit = ptr(5)
153+
filter.Options.Limit = new(uint64(5))
158154
_, statusCode, err = tclient.RawHTTPClient().RawHTTPPost("/logs/event", filter)
159155
require.NoError(t, err)
160156
assert.Equal(t, http.StatusOK, statusCode)

api/transfers/transfers_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestOption(t *testing.T) {
6767
filter := api.TransferFilter{
6868
CriteriaSet: make([]*logdb.TransferCriteria, 0),
6969
Range: nil,
70-
Options: &api.Options{Limit: ptr(6)},
70+
Options: &api.Options{Limit: new(uint64(6))},
7171
Order: logdb.DESC,
7272
}
7373

@@ -76,7 +76,7 @@ func TestOption(t *testing.T) {
7676
assert.Equal(t, "options.limit exceeds the maximum allowed value of 5", strings.Trim(string(res), "\n"))
7777
assert.Equal(t, http.StatusForbidden, statusCode)
7878

79-
filter.Options.Limit = ptr(5)
79+
filter.Options.Limit = new(uint64(5))
8080
_, statusCode, err = tclient.RawHTTPClient().RawHTTPPost("/logs/transfer", filter)
8181
require.NoError(t, err)
8282
assert.Equal(t, http.StatusOK, statusCode)
@@ -131,7 +131,7 @@ func TestOptionalData(t *testing.T) {
131131
filter := api.TransferFilter{
132132
CriteriaSet: make([]*logdb.TransferCriteria, 0),
133133
Range: nil,
134-
Options: &api.Options{Limit: ptr(5), IncludeIndexes: tc.includeIndexes},
134+
Options: &api.Options{Limit: new(uint64(5)), IncludeIndexes: tc.includeIndexes},
135135
Order: logdb.DESC,
136136
}
137137

@@ -194,7 +194,7 @@ func testTransferBadRequest(t *testing.T) {
194194
emptyFilter := api.TransferFilter{
195195
CriteriaSet: criteriaSet,
196196
Range: nil,
197-
Options: &api.Options{Limit: ptr(6)},
197+
Options: &api.Options{Limit: new(uint64(6))},
198198
Order: logdb.DESC,
199199
}
200200

@@ -297,7 +297,3 @@ func newReceipt() *tx.Receipt {
297297
},
298298
}
299299
}
300-
301-
func ptr(v uint64) *uint64 {
302-
return &v
303-
}

0 commit comments

Comments
 (0)