Skip to content

Commit 1363f80

Browse files
authored
Bump go version to 1.23 (#1363)
1 parent 8b02ed1 commit 1363f80

33 files changed

+68
-63
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linters:
1313
- unused
1414
# extra
1515
- exhaustive
16-
- exportloopref
16+
- copyloopvar
1717
- revive
1818
- goimports
1919
- gosec

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
golang 1.21.9
1+
golang 1.22.3
22
nodejs 18.20.3
33
k3d 5.6.3
44
act 0.2.52
5-
golangci-lint 1.57.2
5+
golangci-lint 1.62.0
66
actionlint 1.6.26
77
shellcheck 0.9.0
88
helm 3.15.2

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/.changeset/v1.50.15.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Bump Dockerfile.base to go 1.23
2+
- Bump lib/go.mod to go 1.23

lib/blockchain/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (h *SafeEVMHeader) UnmarshalJSON(bs []byte) error {
165165

166166
h.Hash = jsonHead.Hash
167167
h.Number = (*big.Int)(jsonHead.Number)
168-
h.Timestamp = time.Unix(int64(jsonHead.Timestamp), 0).UTC()
168+
h.Timestamp = time.Unix(int64(jsonHead.Timestamp), 0).UTC() //nolint
169169
h.BaseFee = (*big.Int)(jsonHead.BaseFee)
170170
return nil
171171
}

lib/blockchain/celo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package blockchain
33
import (
44
"context"
55
"fmt"
6+
"math"
67
"math/big"
78
"strings"
89

@@ -83,6 +84,9 @@ func (e *CeloClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts,
8384
if err != nil {
8485
return nil, err
8586
}
87+
if nonce > math.MaxInt64 {
88+
return nil, fmt.Errorf("nonce value %d exceeds int64 range", nonce)
89+
}
8690
opts.Nonce = big.NewInt(int64(nonce))
8791

8892
gasPrice, err := e.Client.SuggestGasPrice(context.Background())

lib/blockchain/ethereum.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"encoding/hex"
1212
"errors"
1313
"fmt"
14+
"math"
1415
"math/big"
1516
"regexp"
1617
"strconv"
@@ -263,7 +264,11 @@ func (e *EthereumClient) HeaderTimestampByNumber(ctx context.Context, bn *big.In
263264
if err != nil {
264265
return 0, err
265266
}
266-
return uint64(h.Timestamp.UTC().Unix()), nil
267+
timestamp := h.Timestamp.UTC().Unix()
268+
if timestamp < 0 {
269+
return 0, fmt.Errorf("negative timestamp value: %d", timestamp)
270+
}
271+
return uint64(timestamp), nil
267272
}
268273

269274
// BlockNumber gets latest block number
@@ -539,7 +544,7 @@ func (e *EthereumClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOp
539544
if err != nil {
540545
return nil, err
541546
}
542-
opts.Nonce = big.NewInt(int64(nonce))
547+
opts.Nonce = big.NewInt(0).SetUint64(nonce)
543548

544549
if e.NetworkConfig.MinimumConfirmations <= 0 { // Wait for your turn to send on an L2 chain
545550
<-e.NonceSettings.registerInstantTransaction(from.Address(), nonce)
@@ -708,7 +713,7 @@ func (e *EthereumClient) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.
708713
func (e *EthereumClient) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error) {
709714
if e.NetworkConfig.FinalityDepth > 0 {
710715
if header.Number.Cmp(new(big.Int).Add(txHdr.Number,
711-
big.NewInt(int64(e.NetworkConfig.FinalityDepth)))) > 0 {
716+
big.NewInt(0).SetUint64(e.NetworkConfig.FinalityDepth))) > 0 {
712717
return true, header.Number, header.Timestamp, nil
713718
}
714719
return false, nil, time.Time{}, nil
@@ -1058,8 +1063,6 @@ func (e *EthereumClient) WaitForEvents() error {
10581063
g := errgroup.Group{}
10591064

10601065
for subName, sub := range queuedEvents {
1061-
subName := subName
1062-
sub := sub
10631066
g.Go(func() error {
10641067
defer func() {
10651068
// if the subscription is complete, delete it from the queue
@@ -1100,6 +1103,9 @@ func (e *EthereumClient) GetLatestFinalizedBlockHeader(ctx context.Context) (*ty
11001103
}
11011104
latestBlockNumber := header.Number.Uint64()
11021105
finalizedBlockNumber := latestBlockNumber - e.NetworkConfig.FinalityDepth
1106+
if finalizedBlockNumber > math.MaxInt64 {
1107+
return nil, fmt.Errorf("finalized block number %d exceeds int64 range", finalizedBlockNumber)
1108+
}
11031109
return e.Client.HeaderByNumber(ctx, big.NewInt(int64(finalizedBlockNumber)))
11041110
}
11051111

@@ -1121,7 +1127,7 @@ func (e *EthereumClient) EstimatedFinalizationTime(ctx context.Context) (time.Du
11211127
if e.NetworkConfig.FinalityDepth == 0 {
11221128
return 0, fmt.Errorf("finality depth is 0 and finality tag is not enabled")
11231129
}
1124-
timeBetween := time.Duration(e.NetworkConfig.FinalityDepth) * blckTime
1130+
timeBetween := time.Duration(e.NetworkConfig.FinalityDepth) * blckTime //nolint
11251131
e.l.Info().
11261132
Str("Time", timeBetween.String()).
11271133
Str("Network", e.GetNetworkName()).
@@ -1159,7 +1165,7 @@ func (e *EthereumClient) TimeBetweenFinalizedBlocks(ctx context.Context, maxTime
11591165
return 0, err
11601166
}
11611167
if nextFinalizedHeader.Number.Cmp(currentFinalizedHeader.Number) > 0 {
1162-
timeBetween := time.Unix(int64(nextFinalizedHeader.Time), 0).Sub(time.Unix(int64(currentFinalizedHeader.Time), 0))
1168+
timeBetween := time.Unix(int64(nextFinalizedHeader.Time), 0).Sub(time.Unix(int64(currentFinalizedHeader.Time), 0)) //nolint
11631169
e.l.Info().
11641170
Str("Time", timeBetween.String()).
11651171
Str("Network", e.GetNetworkName()).
@@ -1190,24 +1196,24 @@ func (e *EthereumClient) AvgBlockTime(ctx context.Context) (time.Duration, error
11901196
}
11911197
totalTime := time.Duration(0)
11921198
var previousHeader *types.Header
1193-
previousHeader, err = e.Client.HeaderByNumber(ctx, big.NewInt(int64(startBlockNumber-1)))
1199+
previousHeader, err = e.Client.HeaderByNumber(ctx, big.NewInt(int64(startBlockNumber-1))) //nolint
11941200
if err != nil {
11951201
return totalTime, err
11961202
}
11971203
for i := startBlockNumber; i <= latestBlockNumber; i++ {
1198-
hdr, err := e.Client.HeaderByNumber(ctx, big.NewInt(int64(i)))
1204+
hdr, err := e.Client.HeaderByNumber(ctx, big.NewInt(int64(i))) //nolint
11991205
if err != nil {
12001206
return totalTime, err
12011207
}
12021208

1203-
blockTime := time.Unix(int64(hdr.Time), 0)
1204-
previousBlockTime := time.Unix(int64(previousHeader.Time), 0)
1209+
blockTime := time.Unix(int64(hdr.Time), 0) //nolint
1210+
previousBlockTime := time.Unix(int64(previousHeader.Time), 0) //nolint
12051211
blockDuration := blockTime.Sub(previousBlockTime)
12061212
totalTime += blockDuration
12071213
previousHeader = hdr
12081214
}
12091215

1210-
averageBlockTime := totalTime / time.Duration(numBlocks)
1216+
averageBlockTime := totalTime / time.Duration(numBlocks) //nolint
12111217

12121218
return averageBlockTime, nil
12131219
}
@@ -1730,7 +1736,6 @@ func (e *EthereumMultinodeClient) DeleteHeaderEventSubscription(key string) {
17301736
func (e *EthereumMultinodeClient) WaitForEvents() error {
17311737
g := errgroup.Group{}
17321738
for _, c := range e.Clients {
1733-
c := c
17341739
g.Go(func() error {
17351740
return c.WaitForEvents()
17361741
})

lib/blockchain/transaction_confirmers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (e *EthereumClient) backfillMissedBlocks(lastBlockSeen uint64, headerChanne
453453
Uint64("Latest Block", latestBlockNumber).
454454
Msg("Backfilling missed blocks since RPC connection issues")
455455
for i := lastBlockSeen + 1; i <= latestBlockNumber; i++ {
456-
header, err := e.HeaderByNumber(context.Background(), big.NewInt(int64(i)))
456+
header, err := e.HeaderByNumber(context.Background(), big.NewInt(int64(i))) //nolint
457457
if err != nil {
458458
e.l.Err(err).Uint64("Number", i).Msg("Error getting header, unable to backfill and process it")
459459
return
@@ -492,7 +492,6 @@ func (e *EthereumClient) receiveHeader(header *SafeEVMHeader) error {
492492

493493
g := errgroup.Group{}
494494
for _, sub := range subs {
495-
sub := sub
496495
g.Go(func() error {
497496
return sub.ReceiveHeader(safeHeader)
498497
})

lib/client/rpc_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// nolint
12
package client
23

34
import (

lib/client/rpc_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// nolint
12
package client
23

34
import (

0 commit comments

Comments
 (0)