Skip to content

Commit

Permalink
refactor deprecated things
Browse files Browse the repository at this point in the history
  • Loading branch information
Cool Developer committed Mar 13, 2023
1 parent 4e0408c commit a97f9ef
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 42 deletions.
4 changes: 2 additions & 2 deletions cmd/dumpstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/0xPolygonHermez/zkevm-node/config"
Expand Down Expand Up @@ -158,5 +158,5 @@ func dumpState(ctx *cli.Context) error {
if err != nil {
return err
}
return ioutil.WriteFile(outputFile, file, 0600) //nolint:gomnd
return os.WriteFile(outputFile, file, 0600) //nolint:gomnd
}
4 changes: 2 additions & 2 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
"encoding/json"
"io/ioutil"
"io"
"os"

"github.com/0xPolygonHermez/zkevm-node/log"
Expand Down Expand Up @@ -58,7 +58,7 @@ func loadGenesisFileConfig(ctx *cli.Context) (NetworkConfig, error) {
}
}()

b, err := ioutil.ReadAll(f)
b, err := io.ReadAll(f)
if err != nil {
return NetworkConfig{}, err
}
Expand Down
3 changes: 1 addition & 2 deletions config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"flag"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -187,7 +186,7 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
for _, tc := range tcs {
tc := tc
t.Run(tc.description, func(t *testing.T) {
file, err := ioutil.TempFile("", "genesisConfig")
file, err := os.CreateTemp("", "genesisConfig")
require.NoError(t, err)
defer func() {
require.NoError(t, os.Remove(file.Name()))
Expand Down
4 changes: 2 additions & 2 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math"
"math/big"
"os"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -1028,7 +1028,7 @@ func newKeyFromKeystore(path, password string) (*keystore.Key, error) {
if path == "" && password == "" {
return nil, nil
}
keystoreEncrypted, err := ioutil.ReadFile(filepath.Clean(path))
keystoreEncrypted, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions etherman/etherscan/etherscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/big"
"net/http"

Expand Down Expand Up @@ -58,7 +58,7 @@ func (e *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
return big.NewInt(0), err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return big.NewInt(0), err
}
Expand Down
4 changes: 2 additions & 2 deletions etherman/ethgasstation/ethgasstation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/big"
"net/http"

Expand Down Expand Up @@ -47,7 +47,7 @@ func (e *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
return big.NewInt(0), err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return big.NewInt(0), err
}
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ require (
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand Down Expand Up @@ -110,7 +109,6 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/skeema/knownhosts v1.1.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
Expand All @@ -131,7 +129,6 @@ require (
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk=
Expand Down Expand Up @@ -727,8 +724,6 @@ github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down Expand Up @@ -1183,8 +1178,6 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 2 additions & 2 deletions jsonrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"time"
Expand Down Expand Up @@ -231,7 +231,7 @@ func (s *Server) handle(w http.ResponseWriter, req *http.Request) {
return
}

data, err := ioutil.ReadAll(req.Body)
data, err := io.ReadAll(req.Body)
if err != nil {
s.handleInvalidRequest(w, err)
return
Expand Down
6 changes: 3 additions & 3 deletions state/runtime/instrumentation/intrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package instrumentation_test
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"os"
"testing"
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestSCTxs(t *testing.T) {
require.NoError(t, err)
defer tracerFile.Close()
byteCode, err := ioutil.ReadAll(tracerFile)
byteCode, err := io.ReadAll(tracerFile)
require.NoError(t, err)
err = json.Unmarshal(byteCode, &tracer)
Expand All @@ -88,7 +88,7 @@ func TestSCTxs(t *testing.T) {
// log.Debug(string(j))
file, _ := json.MarshalIndent(result.ExecutorTrace, "", " ")
err = ioutil.WriteFile("trace.json", file, 0644)
err = os.WriteFile("trace.json", file, 0644)
require.NoError(t, err)
log.Debug(string(result.ExecutorTraceResult))
Expand Down
6 changes: 3 additions & 3 deletions state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math"
"math/big"
"os"
Expand Down Expand Up @@ -1232,7 +1232,7 @@ func TestExecutorTxHashAndRLP(t *testing.T) {
require.NoError(t, err)
defer func() { _ = jsonFile.Close() }()

bytes, err := ioutil.ReadAll(jsonFile)
bytes, err := io.ReadAll(jsonFile)
require.NoError(t, err)

err = json.Unmarshal(bytes, &testCases)
Expand All @@ -1242,7 +1242,7 @@ func TestExecutorTxHashAndRLP(t *testing.T) {
require.NoError(t, err)
defer func() { _ = jsonFile2.Close() }()

bytes2, err := ioutil.ReadAll(jsonFile2)
bytes2, err := io.ReadAll(jsonFile2)
require.NoError(t, err)

err = json.Unmarshal(bytes2, &testCases2)
Expand Down
4 changes: 2 additions & 2 deletions test/operations/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"math/big"
"net/http"
"os"
Expand Down Expand Up @@ -193,7 +193,7 @@ func NodeUpCondition(target string) (bool, error) {
}()
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)

if err != nil {
return false, err
Expand Down
3 changes: 1 addition & 2 deletions test/scripts/cmd/compilesc/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package compilesc
import (
"fmt"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"os/user"
Expand Down Expand Up @@ -70,7 +69,7 @@ func NewManager(basePath string) (*Manager, error) {
// Run executes the compilation of smart contracts and generation of golang
// bindings.
func (cm *Manager) Run() error {
yamlFile, err := ioutil.ReadFile(path.Join(cm.absoluteBasePath, "index.yaml"))
yamlFile, err := os.ReadFile(path.Join(cm.absoluteBasePath, "index.yaml"))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions test/vectors/smartcontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package vectors

import (
"encoding/json"
"io/ioutil"
"io"
"os"
"path/filepath"
)
Expand All @@ -17,7 +17,7 @@ func LoadTxEventsSendBatchTestCases(path string) ([]TxEventsSendBatchTestCase, e
}
defer func() { _ = jsonFile.Close() }()

bytes, err := ioutil.ReadAll(jsonFile)
bytes, err := io.ReadAll(jsonFile)
if err != nil {
return testCases, err
}
Expand Down
4 changes: 2 additions & 2 deletions test/vectors/statetransition.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package vectors

import (
"encoding/json"
"io/ioutil"
"io"
"os"
"path/filepath"
)
Expand All @@ -18,7 +18,7 @@ func LoadStateTransitionTestCases(path string) ([]StateTransitionTestCase, error
}
defer func() { _ = jsonFile.Close() }()

bytes, err := ioutil.ReadAll(jsonFile)
bytes, err := io.ReadAll(jsonFile)
if err != nil {
return testCases, err
}
Expand Down
8 changes: 4 additions & 4 deletions tools/executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/hex"
"encoding/json"
"io/ioutil"
"os"
"os/exec"
"strings"
"time"
Expand Down Expand Up @@ -48,7 +48,7 @@ func main() {
log.Info("DONE starting DB and prover")

// Load vector file names
files, err := ioutil.ReadDir(vectorDir)
files, err := os.ReadDir(vectorDir)
if err != nil {
log.Errorf("Error reading directory: %v", err)
return
Expand Down Expand Up @@ -173,7 +173,7 @@ func loadCase(vectorFileName string) ([]genesisItem, testCase, error) {
tc := testCase{}
gen := []genesisItem{}
// Load and parse test case
f, err := ioutil.ReadFile(vectorFileName)
f, err := os.ReadFile(vectorFileName)
if err != nil {
return gen, tc, err
}
Expand All @@ -182,7 +182,7 @@ func loadCase(vectorFileName string) ([]genesisItem, testCase, error) {
return gen, tc, err
}
// Load and parse genesis
f, err = ioutil.ReadFile(genesisDir + tc.GenesisFile)
f, err = os.ReadFile(genesisDir + tc.GenesisFile)
if err != nil {
return gen, tc, err
}
Expand Down

0 comments on commit a97f9ef

Please sign in to comment.