diff --git a/chain/types/fil.go b/chain/types/fil.go index 21125e6d6..60a2940c6 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -102,7 +102,7 @@ func ParseFIL(s string) (FIL, error) { return FIL{}, fmt.Errorf("string length too large: %d", len(s)) } - r, ok := new(big.Rat).SetString(s) + r, ok := new(big.Rat).SetString(s) //nolint:gosec if !ok { return FIL{}, fmt.Errorf("failed to parse %q as a decimal number", s) } diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index ce0b8d86e..c0a3c4a53 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -149,7 +149,7 @@ var importBenchCmd = &cli.Command{ http.Handle("/debug/metrics", exporter) - http.ListenAndServe("localhost:6060", nil) //nolint:errcheck + _ = http.ListenAndServe("localhost:6060", nil) }() var tdir string @@ -771,7 +771,7 @@ var importAnalyzeCmd = &cli.Command{ } go func() { - http.ListenAndServe("localhost:6060", nil) //nolint:errcheck + _ = http.ListenAndServe("localhost:6060", nil) }() fi, err := os.Open(cctx.Args().First()) diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index 059c248f6..53fd288f7 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -127,7 +127,12 @@ var runCmd = &cli.Command{ os.Exit(0) }() - return http.ListenAndServe(cctx.String("front"), nil) + server := &http.Server{ + Addr: cctx.String("front"), + ReadHeaderTimeout: 3 * time.Second, + } + + return server.ListenAndServe() }, } diff --git a/cmd/lotus-pcr/main.go b/cmd/lotus-pcr/main.go index 49f21cab0..8c1cca05b 100644 --- a/cmd/lotus-pcr/main.go +++ b/cmd/lotus-pcr/main.go @@ -421,7 +421,7 @@ var runCmd = &cli.Command{ }, Action: func(cctx *cli.Context) error { go func() { - http.ListenAndServe(":6060", nil) //nolint:errcheck + _ = http.ListenAndServe(":6060", nil) }() ctx := context.Background() diff --git a/cmd/lotus-shed/fip-0036.go b/cmd/lotus-shed/fip-0036.go index 9fbc1b1e8..485302b9b 100644 --- a/cmd/lotus-shed/fip-0036.go +++ b/cmd/lotus-shed/fip-0036.go @@ -219,7 +219,7 @@ var finalResultCmd = &cli.Command{ // TODO: Confirm that these are always ID addresses signers, err := ms.Signers() if err != nil { - return xerrors.Errorf("fail to get msig signers", err) + return xerrors.Errorf("fail to get msig signers: %w", err) } for _, s := range signers { signerId := lookupId(s) @@ -244,12 +244,12 @@ var finalResultCmd = &cli.Command{ if builtin.IsStorageMinerActor(act.Code) { m, err := miner.Load(store, act) if err != nil { - return xerrors.Errorf("fail to load miner actor: \n", err) + return xerrors.Errorf("fail to load miner actor: %w", err) } info, err := m.Info() if err != nil { - return xerrors.Errorf("fail to get miner info: \n", err) + return xerrors.Errorf("fail to get miner info: %w\n", err) } ownerId := lookupId(info.Owner) @@ -353,7 +353,7 @@ var finalResultCmd = &cli.Command{ //process votes for regular accounts accountActor, err := st.GetActor(signerId) if err != nil { - return xerrors.Errorf("fail to get account account for signer: ", err) + return xerrors.Errorf("fail to get account account for signer: %w\n", err) } clientBytes, ok := clientToDealStorage[signerId] diff --git a/cmd/lotus-shed/gas-estimation.go b/cmd/lotus-shed/gas-estimation.go index b05380535..cf56ea03d 100644 --- a/cmd/lotus-shed/gas-estimation.go +++ b/cmd/lotus-shed/gas-estimation.go @@ -234,6 +234,9 @@ var replayOfflineCmd = &cli.Command{ return xerrors.Errorf("could not find message within the last %d epochs", lookbackLimit) } executionTs, err := cs.GetTipsetByHeight(ctx, ts.Height()-2, ts, true) + if err != nil { + return err + } tw := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', tabwriter.AlignRight) res, err := sm.CallWithGas(ctx, msg, []types.ChainMsg{}, executionTs) diff --git a/cmd/lotus-shed/invariants.go b/cmd/lotus-shed/invariants.go index 9fb67393d..e48f301c4 100644 --- a/cmd/lotus-shed/invariants.go +++ b/cmd/lotus-shed/invariants.go @@ -98,6 +98,9 @@ var invariantsCmd = &cli.Command{ fmt.Println("Network Version ", nv) av, err := actorstypes.VersionForNetwork(nv) + if err != nil { + return err + } fmt.Println("Actors Version ", av) actorCodeCids, err := actors.GetActorCodeIDs(av) @@ -114,6 +117,9 @@ var invariantsCmd = &cli.Command{ } actorTree, err := builtin.LoadTree(actorStore, stateRoot.Actors) + if err != nil { + return err + } startTime := time.Now() diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index 9e4a2629c..f03ec3ee5 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -93,7 +93,12 @@ var mpoolStatsCmd = &cli.Command{ http.Handle("/debug/metrics", expo) go func() { - if err := http.ListenAndServe(":10555", nil); err != nil { + server := &http.Server{ + Addr: ":10555", + ReadHeaderTimeout: 3 * time.Second, + } + + if err := server.ListenAndServe(); err != nil { panic(err) } }() diff --git a/cmd/lotus-stats/main.go b/cmd/lotus-stats/main.go index 20b2ee45c..58096f90a 100644 --- a/cmd/lotus-stats/main.go +++ b/cmd/lotus-stats/main.go @@ -160,7 +160,11 @@ var runCmd = &cli.Command{ go func() { http.Handle("/metrics", exporter) - if err := http.ListenAndServe(":6688", nil); err != nil { + server := &http.Server{ + Addr: ":6688", + ReadHeaderTimeout: 3 * time.Second, + } + if err := server.ListenAndServe(); err != nil { log.Errorw("failed to start http server", "err", err) } }()