Skip to content

Commit 45eab94

Browse files
authored
(BIDS-2454) Update dependencies and solve breaking changes (#2534)
* (BIDS-2454) Update dependencies and solve breaking changes * (BIDS-2454) Update Go version from 1.18 to 1.19 * (BIDS-2454) Update build.yml to use Go 1.19 * (BIDS-2454) Properly format services/configuration.go * (BIDS-2454) Remove use of deprecated "io/ioutil" * (BIDS-2454) Remove commented code
1 parent ab3844a commit 45eab94

22 files changed

+349
-190
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
name: Build
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: Set up Go 1.18
17+
- name: Set up Go 1.19
1818
uses: actions/setup-go@v3
1919
with:
20-
go-version: 1.18
20+
go-version: 1.19
2121
id: go
2222

2323
- name: Check out code into the Go module directory

.github/workflows/staticcheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: ["ubuntu-latest"]
20-
go: ["1.18.x"]
20+
go: ["1.19.x"]
2121
runs-on: ${{ matrix.os }}
2222
steps:
2323
- uses: actions/checkout@v1

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The dockerfile is currently still WIP and might be broken
2-
FROM golang:1.18 AS build-env
2+
FROM golang:1.19 AS build-env
33
COPY go.mod go.sum /src/
44
WORKDIR /src
55
RUN go mod download

cmd/bundle/main.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/md5"
55
"eth2-exporter/utils"
66
"fmt"
7-
"io/ioutil"
87
"log"
98
"os"
109
"path"
@@ -72,7 +71,7 @@ func bundle(staticDir string) (map[string]string, error) {
7271
}
7372

7473
for _, match := range matches {
75-
code, err := ioutil.ReadFile(match)
74+
code, err := os.ReadFile(match)
7675
if err != nil {
7776
return nameMapping, fmt.Errorf("error reading file %v", err)
7877
}
@@ -97,7 +96,7 @@ func bundle(staticDir string) (map[string]string, error) {
9796
newPath := strings.ReplaceAll(matchHash, "static/", "")
9897
nameMapping[path] = newPath
9998

100-
err = ioutil.WriteFile(matchHash, code, 0755)
99+
err = os.WriteFile(matchHash, code, 0755)
101100
if err != nil {
102101
return nameMapping, fmt.Errorf("error failed to write file %v", err)
103102
}
@@ -116,7 +115,7 @@ func replaceFilesNames(files map[string]string) error {
116115
return err
117116
}
118117
for _, match := range matches {
119-
html, err := ioutil.ReadFile(match)
118+
html, err := os.ReadFile(match)
120119
if err != nil {
121120
return err
122121
}
@@ -125,7 +124,7 @@ func replaceFilesNames(files map[string]string) error {
125124
// logrus.Info("replacing: ", oldPath, " with: ", newPath)
126125
h = strings.ReplaceAll(h, oldPath, newPath)
127126
}
128-
err = ioutil.WriteFile(match, []byte(h), 0755)
127+
err = os.WriteFile(match, []byte(h), 0755)
129128
if err != nil {
130129
return err
131130
}

cmd/eth1indexer/main.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414
"eth2-exporter/version"
1515
"flag"
1616
"fmt"
17-
"io/ioutil"
17+
"io"
1818
"math/big"
1919
"net/http"
20+
"os"
2021
"strconv"
2122
"strings"
2223
"sync/atomic"
@@ -383,7 +384,7 @@ func main() {
383384

384385
func UpdateTokenPrices(bt *db.Bigtable, client *rpc.ErigonClient, tokenListPath string) error {
385386

386-
tokenListContent, err := ioutil.ReadFile(tokenListPath)
387+
tokenListContent, err := os.ReadFile(tokenListPath)
387388
if err != nil {
388389
return err
389390
}
@@ -423,7 +424,7 @@ func UpdateTokenPrices(bt *db.Bigtable, client *rpc.ErigonClient, tokenListPath
423424
return fmt.Errorf("error querying defillama api: %v", resp.Status)
424425
}
425426

426-
body, err := ioutil.ReadAll(resp.Body)
427+
body, err := io.ReadAll(resp.Body)
427428
if err != nil {
428429
return err
429430
}
@@ -796,7 +797,7 @@ func ImportMainnetERC20TokenMetadataFromTokenDirectory(bt *db.Bigtable) {
796797
utils.LogFatal(err, "getting client error", 0)
797798
}
798799

799-
body, err := ioutil.ReadAll(resp.Body)
800+
body, err := io.ReadAll(resp.Body)
800801

801802
if err != nil {
802803
utils.LogFatal(err, "reading body for ERC20 tokens error", 0)
@@ -849,7 +850,7 @@ func ImportMainnetERC20TokenMetadataFromTokenDirectory(bt *db.Bigtable) {
849850
resp, err := client.Get(token.LogoURI)
850851

851852
if err == nil && resp.StatusCode == 200 {
852-
body, err := ioutil.ReadAll(resp.Body)
853+
body, err := io.ReadAll(resp.Body)
853854

854855
if err != nil {
855856
utils.LogFatal(err, "reading body for ERC20 token logo URI error", 0)
@@ -879,7 +880,7 @@ func ImportNameLabels(bt *db.Bigtable) {
879880

880881
res := make(map[string]*NameEntry)
881882

882-
data, err := ioutil.ReadFile("")
883+
data, err := os.ReadFile("")
883884

884885
if err != nil {
885886
utils.LogFatal(err, "reading file error", 0)

cmd/signatures/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"eth2-exporter/version"
1111
"flag"
1212
"fmt"
13-
"io/ioutil"
13+
"io"
1414
"net/http"
1515
"time"
1616

@@ -202,7 +202,7 @@ func GetNextSignatures(bt *db.Bigtable, page string, status types.SignatureImpor
202202
return nil, nil, fmt.Errorf("error querying signatures api: %v", resp.Status)
203203
}
204204

205-
body, err := ioutil.ReadAll(resp.Body)
205+
body, err := io.ReadAll(resp.Body)
206206
if err != nil {
207207
return nil, nil, err
208208
}

db/node_jobs.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"eth2-exporter/types"
77
"eth2-exporter/utils"
88
"fmt"
9-
"io/ioutil"
9+
"io"
1010
"net/http"
1111
"strings"
1212
"time"
@@ -311,7 +311,7 @@ func SubmitBLSToExecutionChangesNodeJob(job *types.NodeJob) error {
311311
}
312312
jobStatus := types.SubmittedToNodeNodeJobStatus
313313
if resp.StatusCode != 200 {
314-
d, _ := ioutil.ReadAll(resp.Body)
314+
d, _ := io.ReadAll(resp.Body)
315315
if len(d) > 1000 {
316316
d = d[:1000]
317317
}
@@ -447,7 +447,7 @@ func SubmitVoluntaryExitNodeJob(job *types.NodeJob) error {
447447
}
448448
jobStatus := types.SubmittedToNodeNodeJobStatus
449449
if resp.StatusCode != 200 {
450-
d, _ := ioutil.ReadAll(resp.Body)
450+
d, _ := io.ReadAll(resp.Body)
451451
if len(d) > 1000 {
452452
d = d[:1000]
453453
}

erc20/erc20.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"encoding/json"
55
"eth2-exporter/utils"
66
"fmt"
7-
"io/ioutil"
87
"math/big"
8+
"os"
99
"strings"
1010

1111
"github.com/ethereum/go-ethereum/accounts/abi"
@@ -22,7 +22,7 @@ var tokenMap = make(map[string]*ERC20TokenDetail)
2222
var logger = logrus.StandardLogger().WithField("module", "erc20")
2323

2424
func InitTokenList(path string) {
25-
body, err := ioutil.ReadFile(path)
25+
body, err := os.ReadFile(path)
2626
if err != nil {
2727
utils.LogFatal(err, "unable to retrieve erc20 token list", 0)
2828
}

eth1data/eth1data.go

+16-15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/ethereum/go-ethereum/accounts/abi"
1919
"github.com/ethereum/go-ethereum/accounts/abi/bind"
2020
"github.com/ethereum/go-ethereum/common"
21+
"github.com/ethereum/go-ethereum/core"
2122
geth_types "github.com/ethereum/go-ethereum/core/types"
2223
"github.com/sirupsen/logrus"
2324
)
@@ -87,37 +88,37 @@ func GetEth1Transaction(hash common.Hash) (*types.Eth1TxData, error) {
8788
txPageData.BlockNumber = header.Number.Int64()
8889
txPageData.Timestamp = time.Unix(int64(header.Time), 0)
8990

90-
msg, err := tx.AsMessage(geth_types.NewLondonSigner(tx.ChainId()), header.BaseFee)
91+
msg, err := core.TransactionToMessage(tx, geth_types.NewLondonSigner(tx.ChainId()), header.BaseFee)
9192
if err != nil {
9293
return nil, fmt.Errorf("error converting tx %v to message: %v", hash, err)
9394
}
94-
txPageData.From = msg.From()
95-
txPageData.Nonce = msg.Nonce()
95+
txPageData.From = msg.From
96+
txPageData.Nonce = msg.Nonce
9697
txPageData.Type = receipt.Type
9798
txPageData.TypeFormatted = utils.FormatTransactionType(receipt.Type)
9899
txPageData.TxnPosition = receipt.TransactionIndex
99100

100-
txPageData.Gas.MaxPriorityFee = msg.GasTipCap().Bytes()
101-
txPageData.Gas.MaxFee = msg.GasFeeCap().Bytes()
101+
txPageData.Gas.MaxPriorityFee = msg.GasTipCap.Bytes()
102+
txPageData.Gas.MaxFee = msg.GasFeeCap.Bytes()
102103
if header.BaseFee != nil {
103104
txPageData.Gas.BlockBaseFee = header.BaseFee.Bytes()
104105
}
105106
txPageData.Gas.Used = receipt.GasUsed
106-
txPageData.Gas.Limit = msg.Gas()
107-
txPageData.Gas.UsedPerc = float64(receipt.GasUsed) / float64(msg.Gas())
107+
txPageData.Gas.Limit = msg.GasLimit
108+
txPageData.Gas.UsedPerc = float64(receipt.GasUsed) / float64(msg.GasLimit)
108109
if receipt.Type >= 2 {
109110
tmp := new(big.Int)
110111
tmp.Add(tmp, header.BaseFee)
111-
if t := *new(big.Int).Sub(msg.GasFeeCap(), tmp); t.Cmp(msg.GasTipCap()) == -1 {
112+
if t := *new(big.Int).Sub(msg.GasFeeCap, tmp); t.Cmp(msg.GasTipCap) == -1 {
112113
tmp.Add(tmp, &t)
113114
} else {
114-
tmp.Add(tmp, msg.GasTipCap())
115+
tmp.Add(tmp, msg.GasTipCap)
115116
}
116117
txPageData.Gas.EffectiveFee = tmp.Bytes()
117118
txPageData.Gas.TxFee = tmp.Mul(tmp, big.NewInt(int64(receipt.GasUsed))).Bytes()
118119
} else {
119-
txPageData.Gas.EffectiveFee = msg.GasFeeCap().Bytes()
120-
txPageData.Gas.TxFee = msg.GasFeeCap().Mul(msg.GasFeeCap(), big.NewInt(int64(receipt.GasUsed))).Bytes()
120+
txPageData.Gas.EffectiveFee = msg.GasFeeCap.Bytes()
121+
txPageData.Gas.TxFee = msg.GasFeeCap.Mul(msg.GasFeeCap, big.NewInt(int64(receipt.GasUsed))).Bytes()
121122
}
122123

123124
if receipt.Status != 1 {
@@ -135,17 +136,17 @@ func GetEth1Transaction(hash common.Hash) (*types.Eth1TxData, error) {
135136
if err != nil {
136137
return nil, fmt.Errorf("error loading token transfers from tx %v: %v", hash, err)
137138
}
138-
txPageData.InternalTxns, err = db.BigtableClient.GetInternalTransfersForTransaction(tx.Hash().Bytes(), msg.From().Bytes())
139+
txPageData.InternalTxns, err = db.BigtableClient.GetInternalTransfersForTransaction(tx.Hash().Bytes(), msg.From.Bytes())
139140
if err != nil {
140141
return nil, fmt.Errorf("error loading internal transfers from tx %v: %v", hash, err)
141142
}
142143
}
143-
txPageData.FromName, err = db.BigtableClient.GetAddressName(msg.From().Bytes())
144+
txPageData.FromName, err = db.BigtableClient.GetAddressName(msg.From.Bytes())
144145
if err != nil {
145146
return nil, fmt.Errorf("error retrieveing from name for tx %v: %v", hash, err)
146147
}
147-
if msg.To() != nil {
148-
txPageData.ToName, err = db.BigtableClient.GetAddressName(msg.To().Bytes())
148+
if msg.To != nil {
149+
txPageData.ToName, err = db.BigtableClient.GetAddressName(msg.To.Bytes())
149150
if err != nil {
150151
return nil, fmt.Errorf("error retrieveing to name for tx %v: %v", hash, err)
151152
}

exporter/appsubscription_oracle.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"eth2-exporter/types"
99
"eth2-exporter/utils"
1010
"fmt"
11-
"io/ioutil"
1211
"log"
12+
"os"
1313
"strings"
1414
"time"
1515

@@ -98,7 +98,7 @@ func VerifyReceipt(googleClient *playstore.Client, receipt *types.PremiumData) (
9898
}
9999

100100
func initGoogle() *playstore.Client {
101-
jsonKey, err := ioutil.ReadFile(utils.Config.Frontend.AppSubsGoogleJSONPath)
101+
jsonKey, err := os.ReadFile(utils.Config.Frontend.AppSubsGoogleJSONPath)
102102
if err != nil {
103103
log.Fatal(err)
104104
}

exporter/rocketpool.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package exporter
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"math"
88
"math/big"
99
"net/http"
@@ -1858,7 +1858,7 @@ func DownloadRewardsFile(fileName string, interval uint64, cid string, isDaemon
18581858
continue
18591859
} else {
18601860
// If we got here, we have a successful download
1861-
bytes, err := ioutil.ReadAll(resp.Body)
1861+
bytes, err := io.ReadAll(resp.Body)
18621862
if err != nil {
18631863
errBuilder.WriteString(fmt.Sprintf("Error reading response bytes from %s: %s\n", url, err.Error()))
18641864
continue

0 commit comments

Comments
 (0)