Count all precommit sector numbers that we are checking
This commit is contained in:
parent
2776e29042
commit
8c4e705df3
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
ipldcbor "github.com/ipfs/go-ipld-cbor"
|
ipldcbor "github.com/ipfs/go-ipld-cbor"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"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/abi"
|
||||||
"github.com/filecoin-project/go-state-types/builtin"
|
|
||||||
miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
|
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/go-state-types/builtin/v11/util/adt"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -39,19 +38,12 @@ type DeadlineRef struct {
|
|||||||
|
|
||||||
type DeadlineSummary struct {
|
type DeadlineSummary struct {
|
||||||
Partitions []PartitionSummary
|
Partitions []PartitionSummary
|
||||||
PreCommitsBefore PreCommitSummary
|
PreCommitExpiry PreCommitExpiry
|
||||||
PreCommitDiff PreCommitDiff
|
|
||||||
VestingDiff VestingDiff
|
VestingDiff VestingDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
type PreCommitDiff struct {
|
type PreCommitExpiry struct {
|
||||||
ExpiryQueueDelta int
|
Expired []uint64
|
||||||
PrecommitDelta int
|
|
||||||
}
|
|
||||||
|
|
||||||
type PreCommitSummary struct {
|
|
||||||
SizeExpiryQueue int
|
|
||||||
SizePrecommits int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type VestingDiff struct {
|
type VestingDiff struct {
|
||||||
@ -172,28 +164,6 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{
|
|||||||
}, nil
|
}, 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) {
|
countVestingTable := func(table cid.Cid) (int, error) {
|
||||||
var vestingTable miner11.VestingFunds
|
var vestingTable miner11.VestingFunds
|
||||||
if err := adtStore.Get(ctx, table, &vestingTable); err != nil {
|
if err := adtStore.Get(ctx, table, &vestingTable); err != nil {
|
||||||
@ -233,10 +203,26 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
preCommitBefore, err := countPreCommit(st.PreCommittedSectorsCleanUp, st.PreCommittedSectors, adtStore)
|
expiryQArray, err := adt.AsArray(adtStore, st.PreCommittedSectorsCleanUp, miner11.PrecommitCleanUpAmtBitwidth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
vestingBefore, err := countVestingTable(st.VestingFunds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -252,10 +238,7 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
preCommitAfter, err := countPreCommit(stAfter.PreCommittedSectorsCleanUp, stAfter.PreCommittedSectors, adtStore)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
vestingAfter, err := countVestingTable(stAfter.VestingFunds)
|
vestingAfter, err := countVestingTable(stAfter.VestingFunds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -263,10 +246,8 @@ var minerDeadlinePartitionMeasurementCmd = &cli.Command{
|
|||||||
|
|
||||||
dSummaries[j] = DeadlineSummary{
|
dSummaries[j] = DeadlineSummary{
|
||||||
Partitions: pSummaries,
|
Partitions: pSummaries,
|
||||||
PreCommitsBefore: preCommitAfter,
|
PreCommitExpiry: PreCommitExpiry{
|
||||||
PreCommitDiff: PreCommitDiff{
|
Expired: accumulator,
|
||||||
ExpiryQueueDelta: preCommitBefore.SizeExpiryQueue - preCommitAfter.SizeExpiryQueue,
|
|
||||||
PrecommitDelta: preCommitBefore.SizePrecommits - preCommitAfter.SizePrecommits,
|
|
||||||
},
|
},
|
||||||
VestingDiff: VestingDiff{
|
VestingDiff: VestingDiff{
|
||||||
PrevTableSize: vestingBefore,
|
PrevTableSize: vestingBefore,
|
||||||
|
Loading…
Reference in New Issue
Block a user