Count all precommit sector numbers that we are checking

This commit is contained in:
zenground0 2023-07-21 09:30:45 -06:00
parent 2776e29042
commit 8c4e705df3

View File

@ -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(&sectorsBf, 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,