diff --git a/CHANGELOG.md b/CHANGELOG.md index dc51fd29ba..7ea39b6040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Lotus changelog -# v1.21.0-rc1 / 2023-03-21 +# v1.21.0-rc2 / 2023-03-29 This is an optional but highly recommended feature release of Lotus. It includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers. @@ -11,7 +11,10 @@ Before upgrading to this feature release read carefully through these bullet poi - Starting from this release, the SplitStore feature is automatically activated on new nodes. However, for existing Lotus users, you need to explicitly configure SplitStore by uncommenting the `EnableSplitstore` option in your `config.toml` file. To enable SplitStore, set `EnableSplitstore=true`, and to disable it, set `EnableSplitstore=false`. **It's important to note that your Lotus node will not start unless this configuration is properly set. Set it to false if you are running a full archival node!** - This feature release requires a **minimum Go version of v1.19.7 or higher to successfully build Lotus**. Additionally, Go version v1.20 and higher is now also supported. - **Storage Providers:** The proofs libraries now have CUDA enabled by default, which requires you to install (CUDA)[https://lotus.filecoin.io/tutorials/lotus-miner/cuda/] if you haven't already done so. If you prefer to use OpenCL on your GPUs instead, you can use the `FFI_USE_OPENCL=1` flag when building from source. On the other hand, if you want to disable GPUs altogether, you can use the `FFI_NO_GPU=1` environment variable when building from source. -- **Exchanges:** Execution traces (returned from `lotus state exec-trace`, `lotus state replay`, etc.), has changed to account for changes introduced by the by the FVM. **Please make sure to read the `Execution trace format change` section carefully, as these are interface breaking changes** +- **Storage Providers:** The `lotus-miner sectors extend` command has been refactored to the functionality of `lotus-miner sectors renew`. The issue where extions did not work has been fixed in this release candidate. +- **Exchanges/Node operators/RPC-providers::** Execution traces (returned from `lotus state exec-trace`, `lotus state replay`, etc.), has changed to account for changes introduced by the by the FVM. **Please make sure to read the `Execution trace format change` section carefully, as these are interface breaking changes** +- **Syncing issues:** If you have been struggling with syncing issues in normal operations you can try to adjust the amount of threads used for more concurrent FMV execution through via the `LOTUS_FVM_CONCURRENCY` enviroment variable. It is set to 4 threads by default. Recommended formula for concurrency == YOUR_RAM/4 , but max is 128. If you are a Storage Provider and are pushing many messages within a short period of time, exporting `LOTUS_SKIP_APPLY_TS_MESSAGE_CALL_WITH_GAS=1` will also help with keeping in sync. +- **Catching up from a Snapshot:** Users have noticed that catching up sync from a snapshot is taking a lot longer these day. This is largely related to the built-in market actor consuming a lot of computational demand for block validation. A FIP for a short-term mitigation for this is currently in Last Call and will be included network version 19 upgrade if accepted. You [can read the FIP here.](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0060.md) ## Highlights @@ -26,8 +29,10 @@ SplitStore also has some new configuration settings that you can set in your con The SplitStore also has two new commands: -- `lotus chain prune hot` will run an online (badger vlog) garbage collection on the hotstore. -- `lotus chain prune hot-moving` will run an moving garbage collection the hotstore +- `lotus chain prune hot` is a much less resource-intensive GC and is best suited for situations where you don't have the spare disk space for a full GC. +- `lotus chain prune hot-moving` will run a full moving garbage collection of the hotstore. This commands create a new hotstore before deleting the old one so you need working room in the hotstore directory. The current size of a fully GC'd hotstore is around 295 GiB so you need to make sure you have at least that available. + +You can read more about the new SplitStore commands in [the documentation](https://lotus.filecoin.io/lotus/configure/splitstore/#manual-chain-store-garbage-collection). **RPC API improvements** @@ -98,6 +103,12 @@ The `lotus-Miner sector list` is now running in parallel - which should speed up ## Improvements +- backport: fix: miner: correctly count sector extensions (10555) ([filecoin-project/lotus#10555](https://github.com/filecoin-project/lotus/pull/10555)) + - Fixes the issue with sector extensions. +- fix: proving: Initialize slice with with same length as partition (#10574) ([filecoin-project/lotus#10574])(https://github.com/filecoin-project/lotus/pull/10574) + - Fixes an issue where `lotus-miner proving compute window-post` paniced when trying to make skipped sectors human readable. +- feat: stmgr: speed up calculation of genesis circ supply (#10553) ([filecoin-project/lotus#10553])(https://github.com/filecoin-project/lotus/pull/10553) +- perf: eth: gas estimate set applyTsMessages false (#10546) ([filecoin-project/lotus#10456](https://github.com/filecoin-project/lotus/pull/10546)) - feat: config: Force existing users to opt into new defaults (#10488) ([filecoin-project/lotus#10488](https://github.com/filecoin-project/lotus/pull/10488)) - Force existing users to opt into the new SplitStore defaults. - fix: splitstore: Demote now common logs (#10516) ([filecoin-project/lotus#10516](https://github.com/filecoin-project/lotus/pull/10516)) @@ -171,6 +182,9 @@ The `lotus-Miner sector list` is now running in parallel - which should speed up - github.com/filecoin-project/go-fil-markets (v1.25.2 -> v1.27.0-rc1): - github.com/filecoin-project/go-jsonrpc (v0.2.1 -> v0.2.3): - github.com/filecoin-project/go-statemachine (v1.0.2 -> v1.0.3): +- github.com/ipfs/go-cid (v0.3.2 -> v0.4.0): +- github.com/ipfs/go-libipfs (v0.5.0 -> v0.7.0): +- github.com/ipfs/go-path (v0.3.0 -> v0.3.1): - deps: update go-libp2p-pubsub to v0.9.3 ([filecoin-project/lotus#10483](https://github.com/filecoin-project/lotus/pull/10483)) - deps: Update go-jsonrpc to v0.2.2 ([filecoin-project/lotus#10395](https://github.com/filecoin-project/lotus/pull/10395)) - Update to go-data-transfer v2 and libp2p, still wip ([filecoin-project/lotus#10382](https://github.com/filecoin-project/lotus/pull/10382)) @@ -178,6 +192,7 @@ The `lotus-Miner sector list` is now running in parallel - which should speed up - chore: node: migrate go-bitswap to go-libipfs/bitswap ([filecoin-project/lotus#10138](https://github.com/filecoin-project/lotus/pull/10138)) - chore: all: bump go-libipfs to replace go-block-format ([filecoin-project/lotus#10126](https://github.com/filecoin-project/lotus/pull/10126)) - chore: market: Upgrade to index-provider 0.10.0 ([filecoin-project/lotus#9981](https://github.com/filecoin-project/lotus/pull/9981)) +- chore: all: bump go-libipfs ([filecoin-project/lotus#10563](https://github.com/filecoin-project/lotus/pull/10563)) ## Others - Update service_developer_bug_report.yml ([filecoin-project/lotus#10321](https://github.com/filecoin-project/lotus/pull/10321)) @@ -207,6 +222,7 @@ The `lotus-Miner sector list` is now running in parallel - which should speed up - chore: update ffi to increase execution parallelism (#10480) ([filecoin-project/lotus#10480](https://github.com/filecoin-project/lotus/pull/10480)) - chore: update the FFI for release (#10435) ([filecoin-project/lotus#10444](https://github.com/filecoin-project/lotus/pull/10444)) - build: bump version to v1.21.0-dev ([filecoin-project/lotus#10249](https://github.com/filecoin-project/lotus/pull/10249)) +- build: docker: Update GO-version (#10591) ([filecoin-project/lotus#10249](https://github.com/filecoin-project/lotus/pull/10591)) - chore: merge release/v1.20.0 into master ([filecoin-project/lotus#10184](https://github.com/filecoin-project/lotus/pull/10184)) - docs: API Gateway: patch documentation note about make gen command ([filecoin-project/lotus#10422](https://github.com/filecoin-project/lotus/pull/10422)) - chore: docs: fix docs typos ([filecoin-project/lotus#10155](https://github.com/filecoin-project/lotus/pull/10155)) diff --git a/blockstore/ipfs.go b/blockstore/ipfs.go index 756314f2de..c7dbb480a4 100644 --- a/blockstore/ipfs.go +++ b/blockstore/ipfs.go @@ -3,7 +3,7 @@ package blockstore import ( "bytes" "context" - "io/ioutil" + "io" "github.com/ipfs/go-cid" httpapi "github.com/ipfs/go-ipfs-http-client" @@ -103,7 +103,7 @@ func (i *IPFSBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, er return nil, xerrors.Errorf("getting ipfs block: %w", err) } - data, err := ioutil.ReadAll(rd) + data, err := io.ReadAll(rd) if err != nil { return nil, err } diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 58de79c43b..901026656e 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index 40ad3b483d..1c688e400b 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index b43c893c99..a5e305ce55 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index d854d62083..a4cad968cc 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/build/version.go b/build/version.go index 70be30d80f..9a37dc5d8d 100644 --- a/build/version.go +++ b/build/version.go @@ -37,7 +37,7 @@ func BuildTypeString() string { } // BuildVersion is the local build version -const BuildVersion = "1.21.0-rc1" +const BuildVersion = "1.21.0-rc2" func UserVersion() string { if os.Getenv("LOTUS_VERSION_IGNORE_COMMIT") == "1" { diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index b9f3a22a43..811ea27e98 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "io/ioutil" "os" "path/filepath" "strconv" @@ -66,7 +65,7 @@ func generateAdapters() error { } { - af, err := ioutil.ReadFile(filepath.Join(actDir, "actor.go.template")) + af, err := os.ReadFile(filepath.Join(actDir, "actor.go.template")) if err != nil { return xerrors.Errorf("loading actor template: %w", err) } @@ -90,7 +89,7 @@ func generateAdapters() error { return err } - if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil { + if err := os.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil { return err } } @@ -100,7 +99,7 @@ func generateAdapters() error { } func generateState(actDir string, versions []int) error { - af, err := ioutil.ReadFile(filepath.Join(actDir, "state.go.template")) + af, err := os.ReadFile(filepath.Join(actDir, "state.go.template")) if err != nil { if os.IsNotExist(err) { return nil // skip @@ -123,7 +122,7 @@ func generateState(actDir string, versions []int) error { return err } - if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("v%d.go", version)), b.Bytes(), 0666); err != nil { + if err := os.WriteFile(filepath.Join(actDir, fmt.Sprintf("v%d.go", version)), b.Bytes(), 0666); err != nil { return err } } @@ -132,7 +131,7 @@ func generateState(actDir string, versions []int) error { } func generateMessages(actDir string) error { - af, err := ioutil.ReadFile(filepath.Join(actDir, "message.go.template")) + af, err := os.ReadFile(filepath.Join(actDir, "message.go.template")) if err != nil { if os.IsNotExist(err) { return nil // skip @@ -155,7 +154,7 @@ func generateMessages(actDir string) error { return err } - if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("message%d.go", version)), b.Bytes(), 0666); err != nil { + if err := os.WriteFile(filepath.Join(actDir, fmt.Sprintf("message%d.go", version)), b.Bytes(), 0666); err != nil { return err } } @@ -165,7 +164,7 @@ func generateMessages(actDir string) error { func generatePolicy(policyPath string) error { - pf, err := ioutil.ReadFile(policyPath + ".template") + pf, err := os.ReadFile(policyPath + ".template") if err != nil { if os.IsNotExist(err) { return nil // skip @@ -187,7 +186,7 @@ func generatePolicy(policyPath string) error { return err } - if err := ioutil.WriteFile(policyPath, b.Bytes(), 0666); err != nil { + if err := os.WriteFile(policyPath, b.Bytes(), 0666); err != nil { return err } @@ -196,7 +195,7 @@ func generatePolicy(policyPath string) error { func generateBuiltin(builtinPath string) error { - bf, err := ioutil.ReadFile(builtinPath + ".template") + bf, err := os.ReadFile(builtinPath + ".template") if err != nil { if os.IsNotExist(err) { return nil // skip @@ -218,7 +217,7 @@ func generateBuiltin(builtinPath string) error { return err } - if err := ioutil.WriteFile(builtinPath, b.Bytes(), 0666); err != nil { + if err := os.WriteFile(builtinPath, b.Bytes(), 0666); err != nil { return err } @@ -227,7 +226,7 @@ func generateBuiltin(builtinPath string) error { func generateRegistry(registryPath string) error { - bf, err := ioutil.ReadFile(registryPath + ".template") + bf, err := os.ReadFile(registryPath + ".template") if err != nil { if os.IsNotExist(err) { return nil // skip @@ -248,7 +247,7 @@ func generateRegistry(registryPath string) error { return err } - if err := ioutil.WriteFile(registryPath, b.Bytes(), 0666); err != nil { + if err := os.WriteFile(registryPath, b.Bytes(), 0666); err != nil { return err } diff --git a/chain/gen/gen.go b/chain/gen/gen.go index de2df97c27..8e3c41a895 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -5,7 +5,7 @@ import ( "context" "fmt" "io" - "io/ioutil" + "os" "sync/atomic" "time" @@ -167,7 +167,7 @@ func NewGeneratorWithSectorsAndUpgradeSchedule(numSectors int, us stmgr.UpgradeS maddr1 := genesis2.MinerAddress(0) - m1temp, err := ioutil.TempDir("", "preseal") + m1temp, err := os.MkdirTemp("", "preseal") if err != nil { return nil, err } @@ -179,7 +179,7 @@ func NewGeneratorWithSectorsAndUpgradeSchedule(numSectors int, us stmgr.UpgradeS maddr2 := genesis2.MinerAddress(1) - m2temp, err := ioutil.TempDir("", "preseal") + m2temp, err := os.MkdirTemp("", "preseal") if err != nil { return nil, err } diff --git a/cli/state.go b/cli/state.go index c039cb80a7..3099bff17d 100644 --- a/cli/state.go +++ b/cli/state.go @@ -9,7 +9,6 @@ import ( "fmt" "html/template" "io" - "io/ioutil" "os" "reflect" "sort" @@ -1090,7 +1089,7 @@ var StateComputeStateCmd = &cli.Command{ var stout *lapi.ComputeStateOutput if csofile := cctx.String("compute-state-output"); csofile != "" { - data, err := ioutil.ReadFile(csofile) + data, err := os.ReadFile(csofile) if err != nil { return err } diff --git a/cli/util/retrieval.go b/cli/util/retrieval.go index 3a2ef60770..ac34fcf3a4 100644 --- a/cli/util/retrieval.go +++ b/cli/util/retrieval.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -65,7 +64,7 @@ func ClientExportStream(apiAddr string, apiAuth http.Header, eref api.ExportRef, } if resp.StatusCode != http.StatusOK { - em, err := ioutil.ReadAll(resp.Body) + em, err := io.ReadAll(resp.Body) if err != nil { return nil, xerrors.Errorf("reading error body: %w", err) } diff --git a/cli/wallet.go b/cli/wallet.go index a936efa94b..c66275cdd5 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" "os" "strings" @@ -337,7 +336,7 @@ var walletImport = &cli.Command{ inpdata = indata } else { - fdata, err := ioutil.ReadFile(cctx.Args().First()) + fdata, err := os.ReadFile(cctx.Args().First()) if err != nil { return err } diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 51c567d90a..babf9342b1 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math" "net/http" _ "net/http/pprof" @@ -158,7 +157,7 @@ var importBenchCmd = &cli.Command{ if rdir := cctx.String("repodir"); rdir != "" { tdir = rdir } else { - tmp, err := ioutil.TempDir("", "lotus-import-bench") + tmp, err := os.MkdirTemp("", "lotus-import-bench") if err != nil { return err } diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 279f2d5fdb..43972b1877 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "math/big" "math/rand" "os" @@ -197,7 +196,7 @@ var sealBenchCmd = &cli.Command{ return xerrors.Errorf("creating sectorbuilder dir: %w", err) } - tsdir, err := ioutil.TempDir(sdir, "bench") + tsdir, err := os.MkdirTemp(sdir, "bench") if err != nil { return err } @@ -287,7 +286,7 @@ var sealBenchCmd = &cli.Command{ // sectorbuilder directory... we need a better way to handle // this in other cases - fdata, err := ioutil.ReadFile(filepath.Join(sbdir, "pre-seal-"+maddr.String()+".json")) + fdata, err := os.ReadFile(filepath.Join(sbdir, "pre-seal-"+maddr.String()+".json")) if err != nil { return err } @@ -637,7 +636,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par return err } - if err := ioutil.WriteFile(saveC2inp, b, 0664); err != nil { + if err := os.WriteFile(saveC2inp, b, 0664); err != nil { log.Warnf("%+v", err) } } @@ -751,7 +750,7 @@ var proveCmd = &cli.Command{ return xerrors.Errorf("Usage: lotus-bench prove [input.json]") } - inb, err := ioutil.ReadFile(c.Args().First()) + inb, err := os.ReadFile(c.Args().First()) if err != nil { return xerrors.Errorf("reading input file: %w", err) } diff --git a/cmd/lotus-bench/simple.go b/cmd/lotus-bench/simple.go index 87e2c3bc03..a742b0fb38 100644 --- a/cmd/lotus-bench/simple.go +++ b/cmd/lotus-bench/simple.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" "os" "strconv" "time" @@ -444,7 +443,7 @@ var simpleCommit1 = &cli.Command{ return err } - if err := ioutil.WriteFile(cctx.Args().Get(4), b, 0664); err != nil { + if err := os.WriteFile(cctx.Args().Get(4), b, 0664); err != nil { log.Warnf("%+v", err) } @@ -478,7 +477,7 @@ var simpleCommit2 = &cli.Command{ return xerrors.Errorf("Usage: lotus-bench prove [input.json]") } - inb, err := ioutil.ReadFile(c.Args().First()) + inb, err := os.ReadFile(c.Args().First()) if err != nil { return xerrors.Errorf("reading input file: %w", err) } @@ -861,7 +860,7 @@ var simpleProveReplicaUpdate1 = &cli.Command{ return xerrors.Errorf("json marshal vanilla proofs: %w", err) } - if err := ioutil.WriteFile(cctx.Args().Get(7), vpjb, 0666); err != nil { + if err := os.WriteFile(cctx.Args().Get(7), vpjb, 0666); err != nil { return xerrors.Errorf("writing vanilla proofs file: %w", err) } @@ -934,7 +933,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{ return xerrors.Errorf("parse commr: %w", err) } - vpb, err := ioutil.ReadFile(cctx.Args().Get(3)) + vpb, err := os.ReadFile(cctx.Args().Get(3)) if err != nil { return xerrors.Errorf("reading valilla proof file: %w", err) } diff --git a/cmd/lotus-fountain/recaptcha.go b/cmd/lotus-fountain/recaptcha.go index 69359faa3b..6b2327a033 100644 --- a/cmd/lotus-fountain/recaptcha.go +++ b/cmd/lotus-fountain/recaptcha.go @@ -6,7 +6,7 @@ package main import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -63,7 +63,7 @@ func VerifyToken(token, remoteIP string) (Response, error) { return resp, err } - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) _ = r.Body.Close() // close immediately after reading finished if err != nil { return resp, err diff --git a/cmd/lotus-miner/init.go b/cmd/lotus-miner/init.go index 66a6691af1..e752839ece 100644 --- a/cmd/lotus-miner/init.go +++ b/cmd/lotus-miner/init.go @@ -7,7 +7,6 @@ import ( "encoding/binary" "encoding/json" "fmt" - "io/ioutil" "net/http" "os" "path/filepath" @@ -246,7 +245,7 @@ var initCmd = &cli.Command{ return xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(filepath.Join(lr.Path(), "sectorstore.json"), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(lr.Path(), "sectorstore.json"), b, 0644); err != nil { return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) } @@ -292,7 +291,7 @@ func migratePreSealMeta(ctx context.Context, api v1api.FullNode, metadata string return xerrors.Errorf("expanding preseal dir: %w", err) } - b, err := ioutil.ReadFile(metadata) + b, err := os.ReadFile(metadata) if err != nil { return xerrors.Errorf("reading preseal metadata: %w", err) } diff --git a/cmd/lotus-miner/init_restore.go b/cmd/lotus-miner/init_restore.go index f3ab9d04a4..7e28729bbe 100644 --- a/cmd/lotus-miner/init_restore.go +++ b/cmd/lotus-miner/init_restore.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/json" - "io/ioutil" "os" "github.com/docker/go-units" @@ -59,7 +58,7 @@ var restoreCmd = &cli.Command{ return xerrors.Errorf("expanding storage config path: %w", err) } - cfb, err := ioutil.ReadFile(cf) + cfb, err := os.ReadFile(cf) if err != nil { return xerrors.Errorf("reading storage config: %w", err) } diff --git a/cmd/lotus-miner/storage.go b/cmd/lotus-miner/storage.go index a5aa354f8d..89353497dc 100644 --- a/cmd/lotus-miner/storage.go +++ b/cmd/lotus-miner/storage.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "math/bits" "os" "path/filepath" @@ -167,7 +166,7 @@ over time return xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(filepath.Join(p, metaFile), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(p, metaFile), b, 0644); err != nil { return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(p, metaFile), err) } } diff --git a/cmd/lotus-pcr/main.go b/cmd/lotus-pcr/main.go index 57eaf0ad67..199810e03c 100644 --- a/cmd/lotus-pcr/main.go +++ b/cmd/lotus-pcr/main.go @@ -7,7 +7,6 @@ import ( "encoding/csv" "fmt" "io" - "io/ioutil" "net/http" _ "net/http/pprof" "os" @@ -759,7 +758,7 @@ func (r *refunder) EnsureMinerMinimums(ctx context.Context, tipset *types.TipSet return nil, err } - w := ioutil.Discard + w := io.Discard if len(output) != 0 { f, err := os.Create(output) if err != nil { @@ -1299,7 +1298,7 @@ func loadChainEpoch(fn string) (abi.ChainEpoch, error) { err = f.Close() }() - raw, err := ioutil.ReadAll(f) + raw, err := io.ReadAll(f) if err != nil { return 0, err } diff --git a/cmd/lotus-seed/genesis.go b/cmd/lotus-seed/genesis.go index 1ab6a465af..9fdce456bf 100644 --- a/cmd/lotus-seed/genesis.go +++ b/cmd/lotus-seed/genesis.go @@ -4,7 +4,6 @@ import ( "encoding/csv" "encoding/json" "fmt" - "io/ioutil" "os" "strconv" "strings" @@ -80,7 +79,7 @@ var genesisNewCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, genb, 0644); err != nil { + if err := os.WriteFile(genf, genb, 0644); err != nil { return err } @@ -103,7 +102,7 @@ var genesisAddMinerCmd = &cli.Command{ } var template genesis.Template - genb, err := ioutil.ReadFile(genf) + genb, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -117,7 +116,7 @@ var genesisAddMinerCmd = &cli.Command{ return xerrors.Errorf("expand preseal file path: %w", err) } miners := map[string]genesis.Miner{} - minb, err := ioutil.ReadFile(minf) + minb, err := os.ReadFile(minf) if err != nil { return xerrors.Errorf("read preseal file: %w", err) } @@ -156,7 +155,7 @@ var genesisAddMinerCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, genb, 0644); err != nil { + if err := os.WriteFile(genf, genb, 0644); err != nil { return err } @@ -196,7 +195,7 @@ var genesisAddMsigsCmd = &cli.Command{ } var template genesis.Template - b, err := ioutil.ReadFile(genf) + b, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -237,7 +236,7 @@ var genesisAddMsigsCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, b, 0644); err != nil { + if err := os.WriteFile(genf, b, 0644); err != nil { return err } return nil @@ -339,7 +338,7 @@ var genesisSetVRKCmd = &cli.Command{ } var template genesis.Template - b, err := ioutil.ReadFile(genf) + b, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -404,7 +403,7 @@ var genesisSetVRKCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, b, 0644); err != nil { + if err := os.WriteFile(genf, b, 0644); err != nil { return err } return nil @@ -435,7 +434,7 @@ var genesisSetRemainderCmd = &cli.Command{ } var template genesis.Template - b, err := ioutil.ReadFile(genf) + b, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -500,7 +499,7 @@ var genesisSetRemainderCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, b, 0644); err != nil { + if err := os.WriteFile(genf, b, 0644); err != nil { return err } return nil @@ -529,7 +528,7 @@ var genesisSetActorVersionCmd = &cli.Command{ } var template genesis.Template - b, err := ioutil.ReadFile(genf) + b, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -550,7 +549,7 @@ var genesisSetActorVersionCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, b, 0644); err != nil { + if err := os.WriteFile(genf, b, 0644); err != nil { return err } return nil @@ -607,7 +606,7 @@ var genesisSetVRKSignersCmd = &cli.Command{ } var template genesis.Template - b, err := ioutil.ReadFile(genf) + b, err := os.ReadFile(genf) if err != nil { return xerrors.Errorf("read genesis template: %w", err) } @@ -662,7 +661,7 @@ var genesisSetVRKSignersCmd = &cli.Command{ return err } - if err := ioutil.WriteFile(genf, b, 0644); err != nil { + if err := os.WriteFile(genf, b, 0644); err != nil { return err } return nil diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index 7567f63939..863a508f22 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -4,7 +4,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" "os" "github.com/docker/go-units" @@ -114,7 +113,7 @@ var preSealCmd = &cli.Command{ var k *types.KeyInfo if c.String("key") != "" { k = new(types.KeyInfo) - kh, err := ioutil.ReadFile(c.String("key")) + kh, err := os.ReadFile(c.String("key")) if err != nil { return err } diff --git a/cmd/lotus-seed/seed/seed.go b/cmd/lotus-seed/seed/seed.go index b986737127..48f00f8a63 100644 --- a/cmd/lotus-seed/seed/seed.go +++ b/cmd/lotus-seed/seed/seed.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" @@ -135,7 +134,7 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect return nil, nil, xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(filepath.Join(sbroot, "sectorstore.json"), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(sbroot, "sectorstore.json"), b, 0644); err != nil { return nil, nil, xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(sbroot, "storage.json"), err) } } @@ -228,7 +227,7 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner, log.Infof("Writing preseal manifest to %s", filepath.Join(sbroot, "pre-seal-"+maddr.String()+".json")) - if err := ioutil.WriteFile(filepath.Join(sbroot, "pre-seal-"+maddr.String()+".json"), out, 0664); err != nil { + if err := os.WriteFile(filepath.Join(sbroot, "pre-seal-"+maddr.String()+".json"), out, 0664); err != nil { return err } @@ -239,7 +238,7 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner, } // TODO: allow providing key - if err := ioutil.WriteFile(filepath.Join(sbroot, "pre-seal-"+maddr.String()+".key"), []byte(hex.EncodeToString(b)), 0664); err != nil { + if err := os.WriteFile(filepath.Join(sbroot, "pre-seal-"+maddr.String()+".key"), []byte(hex.EncodeToString(b)), 0664); err != nil { return err } } diff --git a/cmd/lotus-shed/base16.go b/cmd/lotus-shed/base16.go index a5d3848154..28ea4916ff 100644 --- a/cmd/lotus-shed/base16.go +++ b/cmd/lotus-shed/base16.go @@ -4,7 +4,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "os" "strings" @@ -30,7 +29,7 @@ var base16Cmd = &cli.Command{ input = strings.NewReader(cctx.Args().First()) } - bytes, err := ioutil.ReadAll(input) + bytes, err := io.ReadAll(input) if err != nil { return nil } diff --git a/cmd/lotus-shed/base32.go b/cmd/lotus-shed/base32.go index 66e180ddc0..d2ea3dd7ab 100644 --- a/cmd/lotus-shed/base32.go +++ b/cmd/lotus-shed/base32.go @@ -3,7 +3,6 @@ package main import ( "fmt" "io" - "io/ioutil" "os" "strings" @@ -30,7 +29,7 @@ var base32Cmd = &cli.Command{ input = strings.NewReader(cctx.Args().First()) } - bytes, err := ioutil.ReadAll(input) + bytes, err := io.ReadAll(input) if err != nil { return nil } diff --git a/cmd/lotus-shed/base64.go b/cmd/lotus-shed/base64.go index cacc601528..19afa66134 100644 --- a/cmd/lotus-shed/base64.go +++ b/cmd/lotus-shed/base64.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "fmt" "io" - "io/ioutil" "os" "strings" @@ -38,7 +37,7 @@ var base64Cmd = &cli.Command{ input = strings.NewReader(cctx.Args().First()) } - bytes, err := ioutil.ReadAll(input) + bytes, err := io.ReadAll(input) if err != nil { return nil } diff --git a/cmd/lotus-shed/bitfield.go b/cmd/lotus-shed/bitfield.go index f0824de4f2..5ac75b2c61 100644 --- a/cmd/lotus-shed/bitfield.go +++ b/cmd/lotus-shed/bitfield.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "os" "github.com/urfave/cli/v2" @@ -318,7 +317,7 @@ func decodeToByte(cctx *cli.Context, i int) ([]byte, error) { if i > 0 { return nil, xerrors.Errorf("need more than %d args", i) } - r, err := ioutil.ReadAll(os.Stdin) + r, err := io.ReadAll(os.Stdin) if err != nil { return nil, err } diff --git a/cmd/lotus-shed/fip-0036.go b/cmd/lotus-shed/fip-0036.go index 485302b9b6..4c8456c04c 100644 --- a/cmd/lotus-shed/fip-0036.go +++ b/cmd/lotus-shed/fip-0036.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" + "os" "sort" "strconv" @@ -537,7 +537,7 @@ var finalResultCmd = &cli.Command{ // Returns voted sorted by votes from earliest to latest func getVotesMap(file string) ([]Vote, error) { var votes []Vote - vb, err := ioutil.ReadFile(file) + vb, err := os.ReadFile(file) if err != nil { return nil, xerrors.Errorf("read vote: %w", err) } diff --git a/cmd/lotus-shed/jwt.go b/cmd/lotus-shed/jwt.go index e8853b419b..2a24c25693 100644 --- a/cmd/lotus-shed/jwt.go +++ b/cmd/lotus-shed/jwt.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "strings" @@ -81,7 +80,7 @@ var jwtTokenCmd = &cli.Command{ defer inputFile.Close() //nolint:errcheck input := bufio.NewReader(inputFile) - encoded, err := ioutil.ReadAll(input) + encoded, err := io.ReadAll(input) if err != nil { return err } @@ -123,7 +122,7 @@ var jwtTokenCmd = &cli.Command{ return err } - return ioutil.WriteFile(cctx.String("output"), token, 0600) + return os.WriteFile(cctx.String("output"), token, 0600) }, } @@ -142,7 +141,7 @@ var jwtNewCmd = &cli.Command{ keyName := cctx.Args().First() - sk, err := ioutil.ReadAll(io.LimitReader(rand.Reader, 32)) + sk, err := io.ReadAll(io.LimitReader(rand.Reader, 32)) if err != nil { return err } @@ -184,6 +183,6 @@ var jwtNewCmd = &cli.Command{ } filenameToken := fmt.Sprintf("jwt-%s.token", keyName) - return ioutil.WriteFile(filenameToken, token, 0600) + return os.WriteFile(filenameToken, token, 0600) }, } diff --git a/cmd/lotus-shed/keyinfo.go b/cmd/lotus-shed/keyinfo.go index 38f5ee6fef..15b584f3d8 100644 --- a/cmd/lotus-shed/keyinfo.go +++ b/cmd/lotus-shed/keyinfo.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -68,7 +67,7 @@ var keyinfoVerifyCmd = &cli.Command{ defer inputFile.Close() //nolint:errcheck input := bufio.NewReader(inputFile) - keyContent, err := ioutil.ReadAll(input) + keyContent, err := io.ReadAll(input) if err != nil { return err } @@ -162,7 +161,7 @@ var keyinfoImportCmd = &cli.Command{ input = bufio.NewReader(inputFile) } - encoded, err := ioutil.ReadAll(input) + encoded, err := io.ReadAll(input) if err != nil { return err } @@ -274,7 +273,7 @@ var keyinfoInfoCmd = &cli.Command{ input = bufio.NewReader(inputFile) } - encoded, err := ioutil.ReadAll(input) + encoded, err := io.ReadAll(input) if err != nil { return err } diff --git a/cmd/lotus-shed/rpc.go b/cmd/lotus-shed/rpc.go index 3be2693583..8ef7991292 100644 --- a/cmd/lotus-shed/rpc.go +++ b/cmd/lotus-shed/rpc.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -97,7 +96,7 @@ var rpcCmd = &cli.Command{ return err } - rb, err := ioutil.ReadAll(resp.Body) + rb, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/cmd/lotus-worker/main.go b/cmd/lotus-worker/main.go index 42f46c9d83..e0a9312747 100644 --- a/cmd/lotus-worker/main.go +++ b/cmd/lotus-worker/main.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net" "net/http" "os" @@ -464,7 +463,7 @@ var runCmd = &cli.Command{ return xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(filepath.Join(lr.Path(), "sectorstore.json"), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(lr.Path(), "sectorstore.json"), b, 0644); err != nil { return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) } diff --git a/cmd/lotus-worker/storage.go b/cmd/lotus-worker/storage.go index 6b5994c172..9e4bf1c9ba 100644 --- a/cmd/lotus-worker/storage.go +++ b/cmd/lotus-worker/storage.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "io/ioutil" "os" "path/filepath" @@ -121,7 +120,7 @@ var storageAttachCmd = &cli.Command{ return xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(filepath.Join(p, metaFile), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(p, metaFile), b, 0644); err != nil { return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(p, metaFile), err) } } diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index b3341bd799..3803c0f5d7 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "runtime/pprof" @@ -244,7 +243,7 @@ var DaemonCmd = &cli.Command{ var genBytes []byte if cctx.String("genesis") != "" { - genBytes, err = ioutil.ReadFile(cctx.String("genesis")) + genBytes, err = os.ReadFile(cctx.String("genesis")) if err != nil { return xerrors.Errorf("reading genesis: %w", err) } @@ -400,7 +399,7 @@ func importKey(ctx context.Context, api lapi.FullNode, f string) error { return err } - hexdata, err := ioutil.ReadFile(f) + hexdata, err := os.ReadFile(f) if err != nil { return err } diff --git a/conformance/corpus_test.go b/conformance/corpus_test.go index adbebbcc73..ec9f9d5164 100644 --- a/conformance/corpus_test.go +++ b/conformance/corpus_test.go @@ -5,7 +5,6 @@ package conformance import ( "encoding/json" - "io/ioutil" "os" "path/filepath" "strings" @@ -107,7 +106,7 @@ func TestConformance(t *testing.T) { // Run a test for each vector. for _, v := range vectors { path := filepath.Join(corpusRoot, v) - raw, err := ioutil.ReadFile(path) + raw, err := os.ReadFile(path) if err != nil { t.Fatalf("failed to read test raw file: %s", path) } diff --git a/conformance/runner.go b/conformance/runner.go index ff738a4a5e..827c10a5cb 100644 --- a/conformance/runner.go +++ b/conformance/runner.go @@ -6,7 +6,6 @@ import ( "context" "encoding/base64" "fmt" - "io/ioutil" "math" "os" "os/exec" @@ -328,7 +327,7 @@ func dumpThreeWayStateDiff(r Reporter, vector *schema.TestVector, bs blockstore. // writeStateToTempCAR writes the provided roots to a temporary CAR that'll be // cleaned up via t.Cleanup(). It returns the full path of the temp file. func writeStateToTempCAR(bs blockstore.Blockstore, roots ...cid.Cid) (string, error) { - tmp, err := ioutil.TempFile("", "lotus-tests-*.car") + tmp, err := os.CreateTemp("", "lotus-tests-*.car") if err != nil { return "", fmt.Errorf("failed to create temp file to dump CAR for diffing: %w", err) } diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index c5a2300955..50ee5618ad 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -7,7 +7,7 @@ USAGE: lotus-miner [global options] command [command options] [arguments...] VERSION: - 1.21.0-rc1 + 1.21.0-rc2 COMMANDS: init Initialize a lotus miner repo diff --git a/documentation/en/cli-lotus-worker.md b/documentation/en/cli-lotus-worker.md index d7496709ef..33be6055f6 100644 --- a/documentation/en/cli-lotus-worker.md +++ b/documentation/en/cli-lotus-worker.md @@ -7,7 +7,7 @@ USAGE: lotus-worker [global options] command [command options] [arguments...] VERSION: - 1.21.0-rc1 + 1.21.0-rc2 COMMANDS: run Start lotus worker diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index ea5ea6ac11..ce6402e7e4 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -7,7 +7,7 @@ USAGE: lotus [global options] command [command options] [arguments...] VERSION: - 1.21.0-rc1 + 1.21.0-rc2 COMMANDS: daemon Start a lotus daemon process diff --git a/gen/inline-gen/main.go b/gen/inline-gen/main.go index d97134cdd3..4e55816f6b 100644 --- a/gen/inline-gen/main.go +++ b/gen/inline-gen/main.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io/fs" - "io/ioutil" "os" "path/filepath" "strings" @@ -19,7 +18,7 @@ const ( ) func main() { - db, err := ioutil.ReadFile(os.Args[2]) + db, err := os.ReadFile(os.Args[2]) if err != nil { panic(err) } @@ -38,7 +37,7 @@ func main() { if filepath.Ext(path) != ".go" { return nil } - fb, err := ioutil.ReadFile(path) + fb, err := os.ReadFile(path) if err != nil { return err } @@ -110,7 +109,7 @@ func main() { if rewrite { fmt.Printf("write %s\n", path) - if err := ioutil.WriteFile(path, []byte(strings.Join(outLines, "\n")), 0664); err != nil { + if err := os.WriteFile(path, []byte(strings.Join(outLines, "\n")), 0664); err != nil { return err } } diff --git a/go.mod b/go.mod index a4794c03a4..f74501a93f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/filecoin-project/lotus -go 1.18 +go 1.19 retract v1.14.0 // Accidentally force-pushed tag, use v1.14.1+ instead. diff --git a/itests/deals_partial_retrieval_dm-level_test.go b/itests/deals_partial_retrieval_dm-level_test.go index 156ed67fed..e3414c1917 100644 --- a/itests/deals_partial_retrieval_dm-level_test.go +++ b/itests/deals_partial_retrieval_dm-level_test.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "testing" "time" @@ -196,7 +195,7 @@ func validateDMUnixFile(r io.Reader) error { } func testDMExportAsCar(ctx context.Context, client *kit.TestFullNode, expDirective api.ExportRef, tempDir string) error { - out, err := ioutil.TempFile(tempDir, "exp-test") + out, err := os.CreateTemp(tempDir, "exp-test") if err != nil { return err } @@ -214,7 +213,7 @@ func testDMExportAsCar(ctx context.Context, client *kit.TestFullNode, expDirecti return validateDMCar(out) } func tesV0RetrievalAsCar(ctx context.Context, client *kit.TestFullNode, retOrder api0.RetrievalOrder, tempDir string) error { - out, err := ioutil.TempFile(tempDir, "exp-test") + out, err := os.CreateTemp(tempDir, "exp-test") if err != nil { return err } diff --git a/itests/kit/client.go b/itests/kit/client.go index f29fecfebb..134b6b1ceb 100644 --- a/itests/kit/client.go +++ b/itests/kit/client.go @@ -3,7 +3,6 @@ package kit import ( "context" "fmt" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -110,7 +109,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode *TestFullNode) // Retrieve the first file from the Miner // client retrieve - tmpdir, err := ioutil.TempDir(os.TempDir(), "test-cli-client") + tmpdir, err := os.MkdirTemp(os.TempDir(), "test-cli-client") require.NoError(t, err) path := filepath.Join(tmpdir, "outfile.dat") @@ -144,13 +143,13 @@ func createRandomFile(rseed, size int) ([]byte, string, error) { data := make([]byte, size) rand.New(rand.NewSource(int64(rseed))).Read(data) - dir, err := ioutil.TempDir(os.TempDir(), "test-make-deal-") + dir, err := os.MkdirTemp(os.TempDir(), "test-make-deal-") if err != nil { return nil, "", err } path := filepath.Join(dir, "sourcefile.dat") - err = ioutil.WriteFile(path, data, 0644) + err = os.WriteFile(path, data, 0644) if err != nil { return nil, "", err } diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index a96aa60ff5..d38518be86 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -6,9 +6,9 @@ import ( "crypto/rand" "encoding/binary" "fmt" - "io/ioutil" "net" "net/http" + "os" "sync" "testing" "time" @@ -234,7 +234,7 @@ func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts .. peerId, err := peer.IDFromPrivateKey(privkey) require.NoError(n.t, err) - tdir, err := ioutil.TempDir("", "preseal-memgen") + tdir, err := os.MkdirTemp("", "preseal-memgen") require.NoError(n.t, err) minerCnt := len(n.inactive.miners) + len(n.active.miners) diff --git a/itests/kit/node_miner.go b/itests/kit/node_miner.go index dd6f3088cd..4b81c9df0b 100644 --- a/itests/kit/node_miner.go +++ b/itests/kit/node_miner.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net" "os" "path/filepath" @@ -204,7 +203,7 @@ func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*st b, err := json.MarshalIndent(cfg, "", " ") require.NoError(t, err) - err = ioutil.WriteFile(filepath.Join(p, metaFile), b, 0644) + err = os.WriteFile(filepath.Join(p, metaFile), b, 0644) require.NoError(t, err) err = tm.StorageAddLocal(ctx, p) diff --git a/itests/kit/node_worker.go b/itests/kit/node_worker.go index ac200fb0fb..3674763ed8 100644 --- a/itests/kit/node_worker.go +++ b/itests/kit/node_worker.go @@ -3,7 +3,6 @@ package kit import ( "context" "encoding/json" - "io/ioutil" "net" "net/http" "os" @@ -67,7 +66,7 @@ func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*s b, err := json.MarshalIndent(cfg, "", " ") require.NoError(t, err) - err = ioutil.WriteFile(filepath.Join(p, metaFile), b, 0644) + err = os.WriteFile(filepath.Join(p, metaFile), b, 0644) require.NoError(t, err) err = tm.StorageAddLocal(ctx, p) diff --git a/lib/backupds/backupds_test.go b/lib/backupds/backupds_test.go index b76799bfbb..8909a5f3bb 100644 --- a/lib/backupds/backupds_test.go +++ b/lib/backupds/backupds_test.go @@ -5,7 +5,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -77,7 +76,7 @@ func TestLogRestore(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(fls)) - bf, err := ioutil.ReadFile(filepath.Join(logdir, fls[0].Name())) + bf, err := os.ReadFile(filepath.Join(logdir, fls[0].Name())) require.NoError(t, err) ds2 := datastore.NewMapDatastore() diff --git a/lib/consensus/raft/config.go b/lib/consensus/raft/config.go index 81bdb7fdc9..bdd82c1081 100644 --- a/lib/consensus/raft/config.go +++ b/lib/consensus/raft/config.go @@ -1,7 +1,7 @@ package consensus import ( - "io/ioutil" + "io" "path/filepath" "time" @@ -69,7 +69,7 @@ func DefaultClusterRaftConfig() *ClusterRaftConfig { cfg.RaftConfig.LocalID = "will_be_set_automatically" // Set up logging - cfg.RaftConfig.LogOutput = ioutil.Discard + cfg.RaftConfig.LogOutput = io.Discard return &cfg } @@ -91,7 +91,7 @@ func NewClusterRaftConfig(userRaftConfig *config.UserRaftConfig) *ClusterRaftCon cfg.RaftConfig.LocalID = "will_be_set_automatically" // Set up logging - cfg.RaftConfig.LogOutput = ioutil.Discard + cfg.RaftConfig.LogOutput = io.Discard return &cfg diff --git a/lib/rpcenc/reader.go b/lib/rpcenc/reader.go index 34b9fcfb40..2dd64473e7 100644 --- a/lib/rpcenc/reader.go +++ b/lib/rpcenc/reader.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -158,7 +157,7 @@ func ReaderParamEncoder(addr string) jsonrpc.Option { } if resp.StatusCode != http.StatusOK { - b, _ := ioutil.ReadAll(resp.Body) + b, _ := io.ReadAll(resp.Body) log.Errorf("sending reader param (%s): non-200 status: %s, msg: '%s'", u.String(), resp.Status, string(b)) return } @@ -182,7 +181,7 @@ func ReaderParamEncoder(addr string) jsonrpc.Option { defer resp.Body.Close() //nolint if resp.StatusCode != http.StatusOK { - b, _ := ioutil.ReadAll(resp.Body) + b, _ := io.ReadAll(resp.Body) log.Errorf("sending reader param (%s): non-200 status: %s, msg: '%s'", u.String(), resp.Status, string(b)) return } diff --git a/lib/unixfs/filestore.go b/lib/unixfs/filestore.go index acd0a62ac1..0a0b61c4ca 100644 --- a/lib/unixfs/filestore.go +++ b/lib/unixfs/filestore.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "github.com/ipfs/go-blockservice" @@ -68,7 +67,7 @@ func CreateFilestore(ctx context.Context, srcPath string, dstPath string) (cid.C return cid.Undef, xerrors.Errorf("failed to create reader path file: %w", err) } - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") if err != nil { return cid.Undef, xerrors.Errorf("failed to create temp file: %w", err) } diff --git a/lib/unixfs/filestore_test.go b/lib/unixfs/filestore_test.go index f9d5ed6566..67d380701b 100644 --- a/lib/unixfs/filestore_test.go +++ b/lib/unixfs/filestore_test.go @@ -5,7 +5,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "os" "strings" "testing" @@ -67,7 +66,7 @@ func TestRoundtripUnixFS_Dense(t *testing.T) { // ensure contents of the initial input file and the output file are identical. fo, err := os.Open(tmpOutput) require.NoError(t, err) - bz2, err := ioutil.ReadAll(fo) + bz2, err := io.ReadAll(fo) require.NoError(t, err) require.NoError(t, fo.Close()) require.Equal(t, inputContents, bz2) @@ -107,7 +106,7 @@ func TestRoundtripUnixFS_Filestore(t *testing.T) { // ensure contents of the initial input file and the output file are identical. fo, err := os.Open(tmpOutput) require.NoError(t, err) - bz2, err := ioutil.ReadAll(fo) + bz2, err := io.ReadAll(fo) require.NoError(t, err) require.NoError(t, fo.Close()) require.Equal(t, inputContents, bz2) diff --git a/markets/dagstore/mount_test.go b/markets/dagstore/mount_test.go index e044603d4f..d415f8d885 100644 --- a/markets/dagstore/mount_test.go +++ b/markets/dagstore/mount_test.go @@ -4,7 +4,6 @@ package dagstore import ( "context" "io" - "io/ioutil" "net/url" "strings" "testing" @@ -39,7 +38,7 @@ func TestLotusMount(t *testing.T) { io.ReaderAt io.Seeker }{ - ReadCloser: ioutil.NopCloser(strings.NewReader("testing")), + ReadCloser: io.NopCloser(strings.NewReader("testing")), ReaderAt: nil, Seeker: nil, } @@ -48,7 +47,7 @@ func TestLotusMount(t *testing.T) { io.ReaderAt io.Seeker }{ - ReadCloser: ioutil.NopCloser(strings.NewReader("testing")), + ReadCloser: io.NopCloser(strings.NewReader("testing")), ReaderAt: nil, Seeker: nil, } @@ -66,7 +65,7 @@ func TestLotusMount(t *testing.T) { rd, err := mnt.Fetch(context.Background()) require.NoError(t, err) - bz, err := ioutil.ReadAll(rd) + bz, err := io.ReadAll(rd) require.NoError(t, err) require.NoError(t, rd.Close()) require.Equal(t, []byte("testing"), bz) @@ -85,7 +84,7 @@ func TestLotusMount(t *testing.T) { // fetching on this mount should get us back the same data. rd, err = mnt2.Fetch(context.Background()) require.NoError(t, err) - bz, err = ioutil.ReadAll(rd) + bz, err = io.ReadAll(rd) require.NoError(t, err) require.NoError(t, rd.Close()) require.Equal(t, []byte("testing"), bz) diff --git a/node/config/cfgdocgen/gen.go b/node/config/cfgdocgen/gen.go index 5133501523..577e85f9da 100644 --- a/node/config/cfgdocgen/gen.go +++ b/node/config/cfgdocgen/gen.go @@ -2,14 +2,13 @@ package main import ( "fmt" - "io/ioutil" "os" "sort" "strings" ) func run() error { - tfb, err := ioutil.ReadFile("./node/config/types.go") + tfb, err := os.ReadFile("./node/config/types.go") if err != nil { return err } diff --git a/node/config/load.go b/node/config/load.go index 29cb15d27f..9133509120 100644 --- a/node/config/load.go +++ b/node/config/load.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "os" "reflect" "regexp" @@ -47,7 +46,7 @@ func FromFile(path string, opts ...LoadCfgOpt) (interface{}, error) { return nil, err } defer file.Close() //nolint:errcheck,staticcheck // The file is RO - cfgBs, err := ioutil.ReadAll(file) + cfgBs, err := io.ReadAll(file) if err != nil { return nil, xerrors.Errorf("failed to read config for validation checks %w", err) } diff --git a/node/config/load_test.go b/node/config/load_test.go index cab5268df6..e17660c19f 100644 --- a/node/config/load_test.go +++ b/node/config/load_test.go @@ -3,7 +3,6 @@ package config import ( "bytes" - "io/ioutil" "os" "testing" "time" @@ -50,7 +49,7 @@ func TestParitalConfig(t *testing.T) { } { - f, err := ioutil.TempFile("", "config-*.toml") + f, err := os.CreateTemp("", "config-*.toml") fname := f.Name() assert.NoError(err, "tmp file shold not error") @@ -115,7 +114,7 @@ func TestValidateConfigSetsEnableSplitstore(t *testing.T) { assert.False(t, MatchEnableSplitstoreField(string(cfgCommentedOutEnableSS))) // write config with commented out EnableSplitstore to file - f, err := ioutil.TempFile("", "config.toml") + f, err := os.CreateTemp("", "config.toml") fname := f.Name() assert.NoError(t, err) defer func() { @@ -132,7 +131,7 @@ func TestValidateConfigSetsEnableSplitstore(t *testing.T) { // Loading without a config file and a default fails if the default fallback is disabled func TestFailToFallbackToDefault(t *testing.T) { - dir, err := ioutil.TempDir("", "dirWithNoFiles") + dir, err := os.MkdirTemp("", "dirWithNoFiles") assert.NoError(t, err) defer assert.NoError(t, os.RemoveAll(dir)) nonExistantFileName := dir + "/notarealfile" diff --git a/node/config/storage.go b/node/config/storage.go index 2c9d880f92..dfe067840a 100644 --- a/node/config/storage.go +++ b/node/config/storage.go @@ -3,7 +3,6 @@ package config import ( "encoding/json" "io" - "io/ioutil" "os" "golang.org/x/xerrors" @@ -43,7 +42,7 @@ func WriteStorageFile(path string, config storiface.StorageConfig) error { return xerrors.Errorf("marshaling storage config: %w", err) } - if err := ioutil.WriteFile(path, b, 0644); err != nil { + if err := os.WriteFile(path, b, 0644); err != nil { return xerrors.Errorf("persisting storage config (%s): %w", path, err) } diff --git a/node/impl/client/client_test.go b/node/impl/client/client_test.go index 98092bc93f..032fef55a4 100644 --- a/node/impl/client/client_test.go +++ b/node/impl/client/client_test.go @@ -5,7 +5,7 @@ import ( "bytes" "context" "embed" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -77,7 +77,7 @@ func TestImportLocal(t *testing.T) { }) require.NoError(t, err) - outBytes, err := ioutil.ReadFile(out1) + outBytes, err := os.ReadFile(out1) require.NoError(t, err) require.Equal(t, b, outBytes) @@ -128,7 +128,7 @@ func TestImportLocal(t *testing.T) { err = files.WriteTo(file, exportedPath) require.NoError(t, err) - exportedBytes, err := ioutil.ReadFile(exportedPath) + exportedBytes, err := os.ReadFile(exportedPath) require.NoError(t, err) // compare original file to recreated unixfs file. diff --git a/node/modules/core.go b/node/modules/core.go index c74cc2143c..a0d52c291b 100644 --- a/node/modules/core.go +++ b/node/modules/core.go @@ -5,7 +5,6 @@ import ( "crypto/rand" "errors" "io" - "io/ioutil" "os" "path/filepath" "time" @@ -147,7 +146,7 @@ func APISecret(keystore types.KeyStore, lr repo.LockedRepo) (*dtypes.APIAlg, err if errors.Is(err, types.ErrKeyInfoNotFound) { log.Warn("Generating new API secret") - sk, err := ioutil.ReadAll(io.LimitReader(rand.Reader, 32)) + sk, err := io.ReadAll(io.LimitReader(rand.Reader, 32)) if err != nil { return nil, err } diff --git a/node/modules/testing/genesis.go b/node/modules/testing/genesis.go index a3d25e36a1..3876775df1 100644 --- a/node/modules/testing/genesis.go +++ b/node/modules/testing/genesis.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "github.com/ipfs/go-blockservice" @@ -60,7 +59,7 @@ func MakeGenesis(outFile, genesisTemplate string) func(bs dtypes.ChainBlockstore return nil, err } - fdata, err := ioutil.ReadFile(genesisTemplate) + fdata, err := os.ReadFile(genesisTemplate) if err != nil { return nil, xerrors.Errorf("reading preseals json: %w", err) } diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index 2dbedd5e7d..03ddd2d6ce 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -329,7 +328,7 @@ func (fsr *FsRepo) APIEndpoint() (multiaddr.Multiaddr, error) { } defer f.Close() //nolint: errcheck // Read only op - data, err := ioutil.ReadAll(f) + data, err := io.ReadAll(f) if err != nil { return nil, xerrors.Errorf("failed to read %q: %w", p, err) } @@ -354,7 +353,7 @@ func (fsr *FsRepo) APIToken() ([]byte, error) { } defer f.Close() //nolint: errcheck // Read only op - tb, err := ioutil.ReadAll(f) + tb, err := io.ReadAll(f) if err != nil { return nil, err } @@ -582,7 +581,7 @@ func (fsr *fsLockedRepo) SetConfig(c func(interface{})) error { } // write buffer of TOML bytes to config file - err = ioutil.WriteFile(fsr.configPath, buf.Bytes(), 0644) + err = os.WriteFile(fsr.configPath, buf.Bytes(), 0644) if err != nil { return err } @@ -635,14 +634,14 @@ func (fsr *fsLockedRepo) SetAPIEndpoint(ma multiaddr.Multiaddr) error { if err := fsr.stillValid(); err != nil { return err } - return ioutil.WriteFile(fsr.join(fsAPI), []byte(ma.String()), 0644) + return os.WriteFile(fsr.join(fsAPI), []byte(ma.String()), 0644) } func (fsr *fsLockedRepo) SetAPIToken(token []byte) error { if err := fsr.stillValid(); err != nil { return err } - return ioutil.WriteFile(fsr.join(fsAPIToken), token, 0600) + return os.WriteFile(fsr.join(fsAPIToken), token, 0600) } func (fsr *fsLockedRepo) KeyStore() (types.KeyStore, error) { @@ -711,7 +710,7 @@ func (fsr *fsLockedRepo) Get(name string) (types.KeyInfo, error) { } defer file.Close() //nolint: errcheck // read only op - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) if err != nil { return types.KeyInfo{}, xerrors.Errorf("reading key '%s': %w", name, err) } @@ -760,7 +759,7 @@ func (fsr *fsLockedRepo) put(rawName string, info types.KeyInfo, retries int) er return xerrors.Errorf("encoding key '%s': %w", name, err) } - err = ioutil.WriteFile(keyPath, keyData, 0600) + err = os.WriteFile(keyPath, keyData, 0600) if err != nil { return xerrors.Errorf("writing key '%s': %w", name, err) } diff --git a/node/repo/memrepo.go b/node/repo/memrepo.go index 7817776a98..6a4b416e20 100644 --- a/node/repo/memrepo.go +++ b/node/repo/memrepo.go @@ -3,7 +3,6 @@ package repo import ( "context" "encoding/json" - "io/ioutil" "os" "path/filepath" "sync" @@ -103,7 +102,7 @@ func (lmem *lockedMemRepo) Path() string { return lmem.mem.tempDir } - t, err := ioutil.TempDir(os.TempDir(), "lotus-memrepo-temp-") + t, err := os.MkdirTemp(os.TempDir(), "lotus-memrepo-temp-") if err != nil { panic(err) // only used in tests, probably fine } @@ -142,7 +141,7 @@ func (lmem *lockedMemRepo) initSectorStore(t string) { panic(err) } - if err := ioutil.WriteFile(filepath.Join(t, "sectorstore.json"), b, 0644); err != nil { + if err := os.WriteFile(filepath.Join(t, "sectorstore.json"), b, 0644); err != nil { panic(err) } } diff --git a/storage/paths/http_handler_test.go b/storage/paths/http_handler_test.go index b03fd20ee4..4987936dd6 100644 --- a/storage/paths/http_handler_test.go +++ b/storage/paths/http_handler_test.go @@ -2,7 +2,7 @@ package paths_test import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "os" @@ -378,7 +378,7 @@ func TestRemoteGetSector(t *testing.T) { if !tc.isDir { // create file - tempFile, err := ioutil.TempFile("", "TestRemoteGetSector-") + tempFile, err := os.CreateTemp("", "TestRemoteGetSector-") require.NoError(t, err) defer func() { @@ -390,7 +390,7 @@ func TestRemoteGetSector(t *testing.T) { path = tempFile.Name() } else { // create dir with a file - tempFile2, err := ioutil.TempFile("", "TestRemoteGetSector-") + tempFile2, err := os.CreateTemp("", "TestRemoteGetSector-") require.NoError(t, err) defer func() { _ = os.Remove(tempFile2.Name()) @@ -435,7 +435,7 @@ func TestRemoteGetSector(t *testing.T) { _ = resp.Body.Close() }() - bz, err := ioutil.ReadAll(resp.Body) + bz, err := io.ReadAll(resp.Body) require.NoError(t, err) // assert expected status code diff --git a/storage/paths/local.go b/storage/paths/local.go index 2182f24ef4..a866f5bbe5 100644 --- a/storage/paths/local.go +++ b/storage/paths/local.go @@ -3,7 +3,6 @@ package paths import ( "context" "encoding/json" - "io/ioutil" "math/bits" "math/rand" "os" @@ -151,7 +150,7 @@ func (st *Local) OpenPath(ctx context.Context, p string) error { st.localLk.Lock() defer st.localLk.Unlock() - mb, err := ioutil.ReadFile(filepath.Join(p, MetaFile)) + mb, err := os.ReadFile(filepath.Join(p, MetaFile)) if err != nil { return xerrors.Errorf("reading storage metadata for %s: %w", p, err) } @@ -247,7 +246,7 @@ func (st *Local) Redeclare(ctx context.Context, filterId *storiface.ID, dropMiss defer st.localLk.Unlock() for id, p := range st.paths { - mb, err := ioutil.ReadFile(filepath.Join(p.local, MetaFile)) + mb, err := os.ReadFile(filepath.Join(p.local, MetaFile)) if err != nil { return xerrors.Errorf("reading storage metadata for %s: %w", p.local, err) } diff --git a/storage/paths/local_test.go b/storage/paths/local_test.go index 6b9f4a5451..bfa138ff6f 100644 --- a/storage/paths/local_test.go +++ b/storage/paths/local_test.go @@ -3,7 +3,6 @@ package paths import ( "context" "encoding/json" - "io/ioutil" "os" "path/filepath" "testing" @@ -63,7 +62,7 @@ func (t *TestingLocalStorage) init(subpath string) error { return err } - if err := ioutil.WriteFile(metaFile, mb, 0644); err != nil { + if err := os.WriteFile(metaFile, mb, 0644); err != nil { return err } diff --git a/storage/paths/remote.go b/storage/paths/remote.go index 06d1080b3a..852936153b 100644 --- a/storage/paths/remote.go +++ b/storage/paths/remote.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math/bits" "net/http" "net/url" @@ -412,7 +411,7 @@ func (r *Remote) FsStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, er case 404: return fsutil.FsStat{}, errPathNotFound case 500: - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.Body) if err != nil { return fsutil.FsStat{}, xerrors.Errorf("fsstat: got http 500, then failed to read the error: %w", err) } @@ -768,7 +767,7 @@ func (r *Remote) GenerateSingleVanillaProof(ctx context.Context, minerID abi.Act log.Debugw("reading vanilla proof from remote not-found response", "url", url, "store", info.ID) continue } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, xerrors.Errorf("resp.Body ReadAll: %w", err) } @@ -780,7 +779,7 @@ func (r *Remote) GenerateSingleVanillaProof(ctx context.Context, minerID abi.Act return nil, xerrors.Errorf("non-200 code from %s: '%s'", url, strings.TrimSpace(string(body))) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { if err := resp.Body.Close(); err != nil { log.Error("response close: ", err) diff --git a/storage/paths/remote_test.go b/storage/paths/remote_test.go index 2d7fe2c73d..41d5e8a17a 100644 --- a/storage/paths/remote_test.go +++ b/storage/paths/remote_test.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -48,7 +47,7 @@ func createTestStorage(t *testing.T, p string, seal bool, att ...*paths.Local) s b, err := json.MarshalIndent(cfg, "", " ") require.NoError(t, err) - require.NoError(t, ioutil.WriteFile(filepath.Join(p, metaFile), b, 0644)) + require.NoError(t, os.WriteFile(filepath.Join(p, metaFile), b, 0644)) for _, s := range att { require.NoError(t, s.OpenPath(context.Background(), p)) @@ -130,7 +129,7 @@ func TestMoveShared(t *testing.T) { data := make([]byte, 2032) data[1] = 54 - require.NoError(t, ioutil.WriteFile(sp.Sealed, data, 0666)) + require.NoError(t, os.WriteFile(sp.Sealed, data, 0666)) fmt.Println("write to ", sp.Sealed) require.NoError(t, index.StorageDeclareSector(ctx, storiface.ID(sid.Sealed), s1ref.ID, storiface.FTSealed, true)) @@ -145,7 +144,7 @@ func TestMoveShared(t *testing.T) { require.Equal(t, id1, storiface.ID(sid.Sealed)) fmt.Println("read from ", sp.Sealed) - read, err := ioutil.ReadFile(sp.Sealed) + read, err := os.ReadFile(sp.Sealed) require.NoError(t, err) require.EqualValues(t, data, read) } @@ -357,7 +356,7 @@ func TestReader(t *testing.T) { mockCheckAllocation(pf, offset, size, emptyPartialFile, true, nil) - f, err := ioutil.TempFile("", "TestReader-") + f, err := os.CreateTemp("", "TestReader-") require.NoError(t, err) _, err = f.Write(bz) require.NoError(t, err) @@ -502,7 +501,7 @@ func TestReader(t *testing.T) { require.NoError(t, os.Remove(f.Name())) } - bz, err := ioutil.ReadAll(rd) + bz, err := io.ReadAll(rd) require.NoError(t, err) require.Equal(t, tc.expectedSectorBytes, bz) } diff --git a/storage/sealer/ffiwrapper/sealer_cgo.go b/storage/sealer/ffiwrapper/sealer_cgo.go index e9ce5746ed..871012d0be 100644 --- a/storage/sealer/ffiwrapper/sealer_cgo.go +++ b/storage/sealer/ffiwrapper/sealer_cgo.go @@ -11,7 +11,6 @@ import ( "encoding/base64" "encoding/json" "io" - "io/ioutil" "math/bits" "os" "path/filepath" @@ -1095,7 +1094,7 @@ func (sb *Sealer) FinalizeSectorInto(ctx context.Context, sector storiface.Secto } defer done() - files, err := ioutil.ReadDir(paths.Cache) + files, err := os.ReadDir(paths.Cache) if err != nil { return err } diff --git a/storage/sealer/ffiwrapper/sealer_test.go b/storage/sealer/ffiwrapper/sealer_test.go index dd0c1e1845..34dea3b1b8 100644 --- a/storage/sealer/ffiwrapper/sealer_test.go +++ b/storage/sealer/ffiwrapper/sealer_test.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -130,7 +129,7 @@ func (s *seal) unseal(t *testing.T, sb *Sealer, sp *basicfs.Provider, si storifa t.Fatal(err) } - expect, _ := ioutil.ReadAll(data(si.ID.Number, 1016)) + expect, _ := io.ReadAll(data(si.ID.Number, 1016)) if !bytes.Equal(b.Bytes(), expect) { t.Fatal("read wrong bytes") } @@ -160,7 +159,7 @@ func (s *seal) unseal(t *testing.T, sb *Sealer, sp *basicfs.Provider, si storifa t.Fatal(err) } - expect, _ = ioutil.ReadAll(data(si.ID.Number, 1016)) + expect, _ = io.ReadAll(data(si.ID.Number, 1016)) require.Equal(t, expect, b.Bytes()) b.Reset() @@ -240,12 +239,12 @@ func corrupt(t *testing.T, sealer *Sealer, id storiface.SectorRef) { } func getGrothParamFileAndVerifyingKeys(s abi.SectorSize) { - dat, err := ioutil.ReadFile("../../../build/proof-params/parameters.json") + dat, err := os.ReadFile("../../../build/proof-params/parameters.json") if err != nil { panic(err) } - datSrs, err := ioutil.ReadFile("../../../build/proof-params/srs-inner-product.json") + datSrs, err := os.ReadFile("../../../build/proof-params/srs-inner-product.json") if err != nil { panic(err) } @@ -281,7 +280,7 @@ func TestSealAndVerify(t *testing.T) { getGrothParamFileAndVerifyingKeys(sectorSize) - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { t.Fatal(err) } @@ -352,7 +351,7 @@ func TestSealPoStNoCommit(t *testing.T) { getGrothParamFileAndVerifyingKeys(sectorSize) - dir, err := ioutil.TempDir("", "sbtest") + dir, err := os.MkdirTemp("", "sbtest") if err != nil { t.Fatal(err) } @@ -416,7 +415,7 @@ func TestSealAndVerify3(t *testing.T) { getGrothParamFileAndVerifyingKeys(sectorSize) - dir, err := ioutil.TempDir("", "sbtest") + dir, err := os.MkdirTemp("", "sbtest") if err != nil { t.Fatal(err) } @@ -494,7 +493,7 @@ func TestSealAndVerifyAggregate(t *testing.T) { getGrothParamFileAndVerifyingKeys(sectorSize) - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { t.Fatal(err) } @@ -576,7 +575,7 @@ func BenchmarkWriteWithAlignment(b *testing.B) { for i := 0; i < b.N; i++ { b.StopTimer() rf, w, _ := commpffi.ToReadableFile(bytes.NewReader(bytes.Repeat([]byte{0xff, 0}, int(bt/2))), int64(bt)) - tf, _ := ioutil.TempFile("/tmp/", "scrb-") + tf, _ := os.CreateTemp("/tmp/", "scrb-") b.StartTimer() ffi.WriteWithAlignment(abi.RegisteredSealProof_StackedDrg2KiBV1, rf, bt, tf, nil) // nolint:errcheck @@ -735,7 +734,7 @@ func TestGenerateUnsealedCID(t *testing.T) { func TestAddPiece512M(t *testing.T) { sz := abi.PaddedPieceSize(512 << 20).Unpadded() - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { t.Fatal(err) } @@ -779,7 +778,7 @@ func BenchmarkAddPiece512M(b *testing.B) { sz := abi.PaddedPieceSize(512 << 20).Unpadded() b.SetBytes(int64(sz)) - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { b.Fatal(err) } @@ -821,7 +820,7 @@ func BenchmarkAddPiece512M(b *testing.B) { func TestAddPiece512MPadded(t *testing.T) { sz := abi.PaddedPieceSize(512 << 20).Unpadded() - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { t.Fatal(err) } @@ -890,7 +889,7 @@ func TestMulticoreSDR(t *testing.T) { getGrothParamFileAndVerifyingKeys(sectorSize) - dir, err := ioutil.TempDir("", "sbtest") + dir, err := os.MkdirTemp("", "sbtest") if err != nil { t.Fatal(err) } @@ -995,7 +994,7 @@ func TestPoStChallengeAssumptions(t *testing.T) { func TestDCAPCloses(t *testing.T) { sz := abi.PaddedPieceSize(2 << 10).Unpadded() - cdir, err := ioutil.TempDir("", "sbtest-c-") + cdir, err := os.MkdirTemp("", "sbtest-c-") if err != nil { t.Fatal(err) } diff --git a/storage/sealer/fr32/fr32_ffi_cmp_test.go b/storage/sealer/fr32/fr32_ffi_cmp_test.go index 7dece47232..32afa470eb 100644 --- a/storage/sealer/fr32/fr32_ffi_cmp_test.go +++ b/storage/sealer/fr32/fr32_ffi_cmp_test.go @@ -3,7 +3,6 @@ package fr32_test import ( "bytes" "io" - "io/ioutil" "os" "testing" @@ -17,7 +16,7 @@ import ( ) func TestWriteTwoPcs(t *testing.T) { - tf, _ := ioutil.TempFile("/tmp/", "scrb-") + tf, _ := os.CreateTemp("/tmp/", "scrb-") paddedSize := abi.PaddedPieceSize(16 << 20) n := 2 @@ -43,7 +42,7 @@ func TestWriteTwoPcs(t *testing.T) { panic(err) } - ffiBytes, err := ioutil.ReadAll(tf) + ffiBytes, err := io.ReadAll(tf) if err != nil { panic(err) } diff --git a/storage/sealer/fr32/fr32_test.go b/storage/sealer/fr32/fr32_test.go index f9150e550c..437fa4e43c 100644 --- a/storage/sealer/fr32/fr32_test.go +++ b/storage/sealer/fr32/fr32_test.go @@ -3,7 +3,6 @@ package fr32_test import ( "bytes" "io" - "io/ioutil" "math/rand" "os" "testing" @@ -19,7 +18,7 @@ import ( func padFFI(buf []byte) []byte { rf, w, _ := commpffi.ToReadableFile(bytes.NewReader(buf), int64(len(buf))) - tf, _ := ioutil.TempFile("/tmp/", "scrb-") + tf, _ := os.CreateTemp("/tmp/", "scrb-") _, _, _, err := ffi.WriteWithAlignment(abi.RegisteredSealProof_StackedDrg32GiBV1, rf, abi.UnpaddedPieceSize(len(buf)), tf, nil) if err != nil { @@ -33,7 +32,7 @@ func padFFI(buf []byte) []byte { panic(err) } - padded, err := ioutil.ReadAll(tf) + padded, err := io.ReadAll(tf) if err != nil { panic(err) } diff --git a/storage/sealer/fr32/readers_test.go b/storage/sealer/fr32/readers_test.go index 21a5cd9cd8..f84b9d67a2 100644 --- a/storage/sealer/fr32/readers_test.go +++ b/storage/sealer/fr32/readers_test.go @@ -3,7 +3,7 @@ package fr32_test import ( "bufio" "bytes" - "io/ioutil" + "io" "testing" "github.com/stretchr/testify/require" @@ -27,7 +27,7 @@ func TestUnpadReader(t *testing.T) { } // using bufio reader to make sure reads are big enough for the padreader - it can't handle small reads right now - readered, err := ioutil.ReadAll(bufio.NewReaderSize(r, 512)) + readered, err := io.ReadAll(bufio.NewReaderSize(r, 512)) if err != nil { t.Fatal(err) } diff --git a/storage/sealer/manager_test.go b/storage/sealer/manager_test.go index a44f69a898..cdc135916f 100644 --- a/storage/sealer/manager_test.go +++ b/storage/sealer/manager_test.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -46,7 +45,7 @@ func (t testStorage) DiskUsage(path string) (int64, error) { } func newTestStorage(t *testing.T) *testStorage { - tp, err := ioutil.TempDir(os.TempDir(), "sealer-test-") + tp, err := os.MkdirTemp(os.TempDir(), "sealer-test-") require.NoError(t, err) { @@ -58,7 +57,7 @@ func newTestStorage(t *testing.T) *testStorage { }, "", " ") require.NoError(t, err) - err = ioutil.WriteFile(filepath.Join(tp, "sectorstore.json"), b, 0644) + err = os.WriteFile(filepath.Join(tp, "sectorstore.json"), b, 0644) require.NoError(t, err) } diff --git a/storage/sealer/mock/mock.go b/storage/sealer/mock/mock.go index 6e88b86a58..ab973b3b41 100644 --- a/storage/sealer/mock/mock.go +++ b/storage/sealer/mock/mock.go @@ -6,7 +6,6 @@ import ( "crypto/sha256" "fmt" "io" - "io/ioutil" "math/rand" "sync" @@ -461,7 +460,7 @@ func (mgr *SectorMgr) ReadPiece(ctx context.Context, sector storiface.SectorRef, io.Seeker io.ReaderAt }{ - ReadCloser: ioutil.NopCloser(br), + ReadCloser: io.NopCloser(br), Seeker: br, ReaderAt: br, }, false, nil diff --git a/storage/sealer/piece_provider_test.go b/storage/sealer/piece_provider_test.go index ea2866e5d2..4cbc79a93e 100644 --- a/storage/sealer/piece_provider_test.go +++ b/storage/sealer/piece_provider_test.go @@ -3,7 +3,7 @@ package sealer import ( "bytes" "context" - "io/ioutil" + "io" "math/rand" "net" "net/http" @@ -346,7 +346,7 @@ func (p *pieceProviderTestHarness) readPiece(t *testing.T, offset storiface.Unpa defer func() { _ = rd.Close() }() // Make sure the input matches the output - readData, err := ioutil.ReadAll(rd) + readData, err := io.ReadAll(rd) require.NoError(t, err) require.Equal(t, expectedBytes, readData) }