From cff77167074966e5512f3b9a8413dd75a5bdae74 Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 10 Jul 2023 15:28:14 -0600 Subject: [PATCH 01/10] Tool for measuring partition summaries --- cmd/lotus-shed/cron-count.go | 151 ++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 2b8dc8ebf4d..33e320dacc3 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -1,14 +1,18 @@ package main import ( + "encoding/json" "fmt" + "os" "github.com/urfave/cli/v2" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" ) @@ -17,6 +21,151 @@ var cronWcCmd = &cli.Command{ Description: "cron stats", Subcommands: []*cli.Command{ minerDeadlineCronCountCmd, + minerDeadlinePartitionMeasurementCmd, + }, +} + +type DeadlineRef struct { + Addr address.Address + Height abi.ChainEpoch +} + +type DeadlineSummary struct { + Partitions []PartitionSummary +} + +type PartitionSummary struct { + Live int + Dead int + Diff PartitionDiff +} + +type PartitionDiff struct { + Faulted int + Recovered int + Killed int +} + +var minerDeadlinePartitionMeasurementCmd = &cli.Command{ + Name: "deadline-summary", + Description: "", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "json", + Usage: "read input as json", + Value: true, + }, + &cli.StringFlag{ + Name: "tipset", + Usage: "specify tipset state to search on (pass comma separated array of cids)", + }, + }, + Action: func(c *cli.Context) error { + // read in values to process + if !c.Bool("json") { + return xerrors.Errorf("unsupported non json input format") + } + var refStream []DeadlineRef + if err := json.NewDecoder(os.Stdin).Decode(&refStream); err != nil { + return xerrors.Errorf("failed to parse input: %w", err) + } + + // go from height and sp addr to deadline partition data + n, acloser, err := lcli.GetFullNodeAPI(c) + if err != nil { + return err + } + defer acloser() + ctx := lcli.ReqContext(c) + + dSummaries := make([]DeadlineSummary, len(refStream)) + for _, ref := range refStream { + // get miner's deadline + tsBefore, err := n.ChainGetTipSetByHeight(ctx, ref.Height, types.EmptyTSK) + if err != nil { + return xerrors.Errorf("failed to get tipset at epoch: %d: %w", ref.Height, err) + } + tsAfter, err := n.ChainGetTipSetByHeight(ctx, ref.Height+1, types.EmptyTSK) + if err != nil { + return xerrors.Errorf("failed to get tipset at epoch %d: %w", ref.Height, err) + } + + dline, err := n.StateMinerProvingDeadline(ctx, ref.Addr, tsBefore.Key()) + if err != nil { + return xerrors.Errorf("failed to read proving deadline: %w", err) + } + + // iterate through all partitions at epoch of processing + var pSummaries []PartitionSummary + psBefore, err := n.StateMinerPartitions(ctx, ref.Addr, dline.Index, tsBefore.Key()) + if err != nil { + return xerrors.Errorf("failed to get partitions: %w", err) + } + psAfter, err := n.StateMinerPartitions(ctx, ref.Addr, dline.Index, tsAfter.Key()) + if err != nil { + return xerrors.Errorf("failed to get partitions: %w", err) + } + if len(psBefore) != len(psAfter) { + return xerrors.Errorf("faield") + } + + type partitionCount struct { + live int + dead int + faulty int + recovering int + } + countPartition := func(p api.Partition) (partitionCount, error) { + liveSectors, err := p.LiveSectors.All(abi.MaxSectorNumber) + if err != nil { + return partitionCount{}, xerrors.Errorf("failed to count live sectors in partition: %w", err) + } + allSectors, err := p.AllSectors.All(abi.MaxSectorNumber) + if err != nil { + return partitionCount{}, xerrors.Errorf("failed to count all sectors in partition: %w", err) + } + faultySectors, err := p.FaultySectors.All(abi.MaxSectorNumber) + if err != nil { + return partitionCount{}, xerrors.Errorf("failed to count faulty sectors in partition: %w", err) + } + recoveringSectors, err := p.RecoveringSectors.All(abi.MaxSectorNumber) + if err != nil { + return partitionCount{}, xerrors.Errorf("failed to count recovering sectors in partition: %w", err) + } + + return partitionCount{ + live: len(liveSectors), + dead: len(allSectors) - len(liveSectors), + faulty: len(faultySectors), + recovering: len(recoveringSectors), + }, nil + } + + for i := 0; i < len(psBefore); i++ { + cntBefore, err := countPartition(psBefore[i]) + if err != nil { + return err + } + cntAfter, err := countPartition(psAfter[i]) + if err != nil { + return err + } + pSummaries = append(pSummaries, PartitionSummary{ + Live: cntBefore.live, + Dead: cntBefore.dead, + Diff: PartitionDiff{ + Faulted: cntAfter.faulty - cntBefore.faulty, + Recovered: cntBefore.recovering - cntAfter.recovering, + Killed: cntAfter.dead - cntBefore.dead, + }, + }) + } + dSummaries = append(dSummaries, DeadlineSummary{Partitions: pSummaries}) + } + + // output partition info + json.NewEncoder(os.Stdout).Encode(dSummaries) + return nil }, } From 921e5520ead4e1f67c7bf3f69f4ef7a397de9cda Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 10 Jul 2023 15:32:19 -0600 Subject: [PATCH 02/10] debug --- cmd/lotus-shed/cron-count.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 33e320dacc3..3c0c9862ae8 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -89,7 +89,7 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ if err != nil { return xerrors.Errorf("failed to get tipset at epoch %d: %w", ref.Height, err) } - + fmt.Printf("ref: %v\n", ref) dline, err := n.StateMinerProvingDeadline(ctx, ref.Addr, tsBefore.Key()) if err != nil { return xerrors.Errorf("failed to read proving deadline: %w", err) From 921bdb85ab0cdd4ec676d0a700affa468f255b78 Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 10 Jul 2023 15:54:07 -0600 Subject: [PATCH 03/10] correct json parsing of addr --- cmd/lotus-shed/cron-count.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 3c0c9862ae8..90372db9dda 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -26,8 +26,8 @@ var cronWcCmd = &cli.Command{ } type DeadlineRef struct { - Addr address.Address - Height abi.ChainEpoch + AddrStr string + Height abi.ChainEpoch } type DeadlineSummary struct { @@ -89,19 +89,22 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ if err != nil { return xerrors.Errorf("failed to get tipset at epoch %d: %w", ref.Height, err) } - fmt.Printf("ref: %v\n", ref) - dline, err := n.StateMinerProvingDeadline(ctx, ref.Addr, tsBefore.Key()) + addr, err := address.NewFromString(ref.AddrStr) + if err != nil { + return xerrors.Errorf("faield to get address from input string: %w", err) + } + dline, err := n.StateMinerProvingDeadline(ctx, addr, tsBefore.Key()) if err != nil { return xerrors.Errorf("failed to read proving deadline: %w", err) } // iterate through all partitions at epoch of processing var pSummaries []PartitionSummary - psBefore, err := n.StateMinerPartitions(ctx, ref.Addr, dline.Index, tsBefore.Key()) + psBefore, err := n.StateMinerPartitions(ctx, addr, dline.Index, tsBefore.Key()) if err != nil { return xerrors.Errorf("failed to get partitions: %w", err) } - psAfter, err := n.StateMinerPartitions(ctx, ref.Addr, dline.Index, tsAfter.Key()) + psAfter, err := n.StateMinerPartitions(ctx, addr, dline.Index, tsAfter.Key()) if err != nil { return xerrors.Errorf("failed to get partitions: %w", err) } From 3f4429a5efc03b3cb8d7938403252001813a858e Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 10 Jul 2023 15:59:19 -0600 Subject: [PATCH 04/10] match json parsing --- cmd/lotus-shed/cron-count.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 90372db9dda..330abb2348f 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -26,8 +26,9 @@ var cronWcCmd = &cli.Command{ } type DeadlineRef struct { - AddrStr string - Height abi.ChainEpoch + To string + Height abi.ChainEpoch + Gas json.RawMessage } type DeadlineSummary struct { @@ -89,7 +90,7 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ if err != nil { return xerrors.Errorf("failed to get tipset at epoch %d: %w", ref.Height, err) } - addr, err := address.NewFromString(ref.AddrStr) + addr, err := address.NewFromString(ref.To) if err != nil { return xerrors.Errorf("faield to get address from input string: %w", err) } From 9bd0e9ed5850e506346cb67030ddb7e33ddec893 Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 10 Jul 2023 16:32:37 -0600 Subject: [PATCH 05/10] Fix classic bug --- cmd/lotus-shed/cron-count.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 330abb2348f..f3d0816b5ed 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -28,7 +28,7 @@ var cronWcCmd = &cli.Command{ type DeadlineRef struct { To string Height abi.ChainEpoch - Gas json.RawMessage + Gas json.RawMessage } type DeadlineSummary struct { @@ -80,7 +80,7 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ ctx := lcli.ReqContext(c) dSummaries := make([]DeadlineSummary, len(refStream)) - for _, ref := range refStream { + for j, ref := range refStream { // get miner's deadline tsBefore, err := n.ChainGetTipSetByHeight(ctx, ref.Height, types.EmptyTSK) if err != nil { @@ -164,7 +164,7 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ }, }) } - dSummaries = append(dSummaries, DeadlineSummary{Partitions: pSummaries}) + dSummaries[j] = DeadlineSummary{Partitions: pSummaries} } // output partition info From 2776e290425c00d6e8319895da9b79899d3b36fc Mon Sep 17 00:00:00 2001 From: zenground0 Date: Fri, 21 Jul 2023 08:53:24 -0600 Subject: [PATCH 06/10] Gather info about overhead operations in deadline summary --- cmd/lotus-shed/cron-count.go | 113 ++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index f3d0816b5ed..a12c99316ca 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -5,11 +5,17 @@ import ( "fmt" "os" + "github.com/ipfs/go-cid" + ipldcbor "github.com/ipfs/go-ipld-cbor" "github.com/urfave/cli/v2" + cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin" + miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner" + "github.com/filecoin-project/go-state-types/builtin/v11/util/adt" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" @@ -32,7 +38,25 @@ type DeadlineRef struct { } type DeadlineSummary struct { - Partitions []PartitionSummary + Partitions []PartitionSummary + PreCommitsBefore PreCommitSummary + PreCommitDiff PreCommitDiff + VestingDiff VestingDiff +} + +type PreCommitDiff struct { + ExpiryQueueDelta int + PrecommitDelta int +} + +type PreCommitSummary struct { + SizeExpiryQueue int + SizePrecommits int +} + +type VestingDiff struct { + PrevTableSize int + NewTableSize int } type PartitionSummary struct { @@ -79,6 +103,9 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ defer acloser() ctx := lcli.ReqContext(c) + bs := ReadOnlyAPIBlockstore{n} + adtStore := adt.WrapStore(ctx, ipldcbor.NewCborStore(&bs)) + dSummaries := make([]DeadlineSummary, len(refStream)) for j, ref := range refStream { // get miner's deadline @@ -145,6 +172,36 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ }, nil } + countPreCommit := func(expiryQ, precommits cid.Cid, store adt.Store) (PreCommitSummary, error) { + precommitMap, err := adt.AsMap(store, precommits, builtin.DefaultHamtBitwidth) + if err != nil { + return PreCommitSummary{}, err + } + count := 0 + var empty cbg.Deferred + precommitMap.ForEach(&empty, func(_ string) error { + count++ + return nil + }) + expiryQArray, err := adt.AsArray(store, expiryQ, miner11.PrecommitCleanUpAmtBitwidth) + if err != nil { + return PreCommitSummary{}, err + } + return PreCommitSummary{ + SizeExpiryQueue: int(expiryQArray.Length()), + SizePrecommits: count, + }, nil + + } + + countVestingTable := func(table cid.Cid) (int, error) { + var vestingTable miner11.VestingFunds + if err := adtStore.Get(ctx, table, &vestingTable); err != nil { + return 0, err + } + return len(vestingTable.Funds), nil + } + for i := 0; i < len(psBefore); i++ { cntBefore, err := countPartition(psBefore[i]) if err != nil { @@ -164,7 +221,59 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ }, }) } - dSummaries[j] = DeadlineSummary{Partitions: pSummaries} + + // Precommit and vesting table data + // Before + aBefore, err := n.StateGetActor(ctx, addr, tsBefore.Key()) + if err != nil { + return err + } + var st miner11.State + err = adtStore.Get(ctx, aBefore.Head, &st) + if err != nil { + return err + } + preCommitBefore, err := countPreCommit(st.PreCommittedSectorsCleanUp, st.PreCommittedSectors, adtStore) + if err != nil { + return err + } + vestingBefore, err := countVestingTable(st.VestingFunds) + if err != nil { + return err + } + + // After + aAfter, err := n.StateGetActor(ctx, addr, tsAfter.Key()) + if err != nil { + return err + } + var stAfter miner11.State + err = adtStore.Get(ctx, aAfter.Head, &stAfter) + if err != nil { + return err + } + preCommitAfter, err := countPreCommit(stAfter.PreCommittedSectorsCleanUp, stAfter.PreCommittedSectors, adtStore) + if err != nil { + return err + } + vestingAfter, err := countVestingTable(stAfter.VestingFunds) + if err != nil { + return err + } + + dSummaries[j] = DeadlineSummary{ + Partitions: pSummaries, + PreCommitsBefore: preCommitAfter, + PreCommitDiff: PreCommitDiff{ + ExpiryQueueDelta: preCommitBefore.SizeExpiryQueue - preCommitAfter.SizeExpiryQueue, + PrecommitDelta: preCommitBefore.SizePrecommits - preCommitAfter.SizePrecommits, + }, + VestingDiff: VestingDiff{ + PrevTableSize: vestingBefore, + NewTableSize: vestingAfter, + }, + } + } // output partition info From 8c4e705df3f6eb92f1fdbe8411053c75d4ece501 Mon Sep 17 00:00:00 2001 From: zenground0 Date: Fri, 21 Jul 2023 09:30:45 -0600 Subject: [PATCH 07/10] Count all precommit sector numbers that we are checking --- cmd/lotus-shed/cron-count.go | 73 +++++++++++++----------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index a12c99316ca..b4370a60fc6 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -8,12 +8,11 @@ import ( "github.com/ipfs/go-cid" ipldcbor "github.com/ipfs/go-ipld-cbor" "github.com/urfave/cli/v2" - cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin" miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner" "github.com/filecoin-project/go-state-types/builtin/v11/util/adt" "github.com/filecoin-project/lotus/api" @@ -38,20 +37,13 @@ type DeadlineRef struct { } type DeadlineSummary struct { - Partitions []PartitionSummary - PreCommitsBefore PreCommitSummary - PreCommitDiff PreCommitDiff - VestingDiff VestingDiff + Partitions []PartitionSummary + PreCommitExpiry PreCommitExpiry + VestingDiff VestingDiff } -type PreCommitDiff struct { - ExpiryQueueDelta int - PrecommitDelta int -} - -type PreCommitSummary struct { - SizeExpiryQueue int - SizePrecommits int +type PreCommitExpiry struct { + Expired []uint64 } type VestingDiff struct { @@ -172,28 +164,6 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ }, nil } - countPreCommit := func(expiryQ, precommits cid.Cid, store adt.Store) (PreCommitSummary, error) { - precommitMap, err := adt.AsMap(store, precommits, builtin.DefaultHamtBitwidth) - if err != nil { - return PreCommitSummary{}, err - } - count := 0 - var empty cbg.Deferred - precommitMap.ForEach(&empty, func(_ string) error { - count++ - return nil - }) - expiryQArray, err := adt.AsArray(store, expiryQ, miner11.PrecommitCleanUpAmtBitwidth) - if err != nil { - return PreCommitSummary{}, err - } - return PreCommitSummary{ - SizeExpiryQueue: int(expiryQArray.Length()), - SizePrecommits: count, - }, nil - - } - countVestingTable := func(table cid.Cid) (int, error) { var vestingTable miner11.VestingFunds if err := adtStore.Get(ctx, table, &vestingTable); err != nil { @@ -233,10 +203,26 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ if err != nil { return err } - preCommitBefore, err := countPreCommit(st.PreCommittedSectorsCleanUp, st.PreCommittedSectors, adtStore) + expiryQArray, err := adt.AsArray(adtStore, st.PreCommittedSectorsCleanUp, miner11.PrecommitCleanUpAmtBitwidth) if err != nil { return err } + var sectorsBf bitfield.BitField + var accumulator []uint64 + if err := expiryQArray.ForEach(§orsBf, func(i int64) error { + if abi.ChainEpoch(i) > ref.Height { + return nil + } + sns, err := sectorsBf.All(abi.MaxSectorNumber) + if err != nil { + return err + } + accumulator = append(accumulator, sns...) + return nil + }); err != nil { + return err + } + vestingBefore, err := countVestingTable(st.VestingFunds) if err != nil { return err @@ -252,21 +238,16 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ if err != nil { return err } - preCommitAfter, err := countPreCommit(stAfter.PreCommittedSectorsCleanUp, stAfter.PreCommittedSectors, adtStore) - if err != nil { - return err - } + vestingAfter, err := countVestingTable(stAfter.VestingFunds) if err != nil { return err } dSummaries[j] = DeadlineSummary{ - Partitions: pSummaries, - PreCommitsBefore: preCommitAfter, - PreCommitDiff: PreCommitDiff{ - ExpiryQueueDelta: preCommitBefore.SizeExpiryQueue - preCommitAfter.SizeExpiryQueue, - PrecommitDelta: preCommitBefore.SizePrecommits - preCommitAfter.SizePrecommits, + Partitions: pSummaries, + PreCommitExpiry: PreCommitExpiry{ + Expired: accumulator, }, VestingDiff: VestingDiff{ PrevTableSize: vestingBefore, From df17f709a4ac734470543c9fa51d58f51a03b4cc Mon Sep 17 00:00:00 2001 From: zenground0 Date: Fri, 21 Jul 2023 13:07:25 -0600 Subject: [PATCH 08/10] Record faulty status of sectors --- cmd/lotus-shed/cron-count.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index b4370a60fc6..4f0ecf9b7cf 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -52,9 +52,10 @@ type VestingDiff struct { } type PartitionSummary struct { - Live int - Dead int - Diff PartitionDiff + Live int + Dead int + Faulty int + Diff PartitionDiff } type PartitionDiff struct { @@ -182,8 +183,9 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ return err } pSummaries = append(pSummaries, PartitionSummary{ - Live: cntBefore.live, - Dead: cntBefore.dead, + Live: cntBefore.live, + Dead: cntBefore.dead, + Faulty: cntBefore.faulty, Diff: PartitionDiff{ Faulted: cntAfter.faulty - cntBefore.faulty, Recovered: cntBefore.recovering - cntAfter.recovering, From 6a07def34a61169036b59591367ebbc1103f8d4a Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 31 Jul 2023 10:53:07 -0600 Subject: [PATCH 09/10] gen --- cmd/lotus-shed/cron-count.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index 4f0ecf9b7cf..fd48d199622 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -15,6 +15,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner" "github.com/filecoin-project/go-state-types/builtin/v11/util/adt" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" From 482c90412dc4f87bc8321bd1f7bbfbcda8c4da7f Mon Sep 17 00:00:00 2001 From: zenground0 Date: Mon, 31 Jul 2023 11:12:56 -0600 Subject: [PATCH 10/10] Lint --- cmd/lotus-shed/cron-count.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-shed/cron-count.go b/cmd/lotus-shed/cron-count.go index fd48d199622..9741792ecf1 100644 --- a/cmd/lotus-shed/cron-count.go +++ b/cmd/lotus-shed/cron-count.go @@ -212,8 +212,9 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ } var sectorsBf bitfield.BitField var accumulator []uint64 + h := ref.Height if err := expiryQArray.ForEach(§orsBf, func(i int64) error { - if abi.ChainEpoch(i) > ref.Height { + if abi.ChainEpoch(i) > h { return nil } sns, err := sectorsBf.All(abi.MaxSectorNumber) @@ -261,7 +262,9 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{ } // output partition info - json.NewEncoder(os.Stdout).Encode(dSummaries) + if err := json.NewEncoder(os.Stdout).Encode(dSummaries); err != nil { + return err + } return nil }, }