Merge pull request #2469 from filecoin-project/fix/miner-info
fix miner info
This commit is contained in:
commit
c4ded2fc07
@ -374,8 +374,8 @@ type FileRef struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MinerSectors struct {
|
type MinerSectors struct {
|
||||||
Sset uint64
|
Sectors uint64
|
||||||
Pset uint64
|
Active uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectorExpiration struct {
|
type SectorExpiration struct {
|
||||||
|
@ -127,7 +127,7 @@ type FullNodeStruct struct {
|
|||||||
|
|
||||||
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
||||||
StateMinerSectors func(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerSectors func(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
||||||
StateMinerProvingSet func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
||||||
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) `perm:"read"`
|
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) `perm:"read"`
|
||||||
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
||||||
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) `perm:"read"`
|
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) `perm:"read"`
|
||||||
@ -585,7 +585,7 @@ func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Add
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
||||||
return c.Internal.StateMinerProvingSet(ctx, addr, tsk)
|
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
|
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
|
||||||
|
@ -106,16 +106,16 @@ var infoCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("counting faults: %w", err)
|
return xerrors.Errorf("counting faults: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(uint64(mi.SectorSize)))))
|
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sectors), types.NewInt(uint64(mi.SectorSize)))))
|
||||||
if nfaults == 0 {
|
if nfaults == 0 {
|
||||||
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))))
|
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Active), types.NewInt(uint64(mi.SectorSize)))))
|
||||||
} else {
|
} else {
|
||||||
var faultyPercentage float64
|
var faultyPercentage float64
|
||||||
if secCounts.Sset != 0 {
|
if secCounts.Sectors != 0 {
|
||||||
faultyPercentage = float64(10000*nfaults/secCounts.Sset) / 100.
|
faultyPercentage = float64(10000*nfaults/secCounts.Sectors) / 100.
|
||||||
}
|
}
|
||||||
fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n",
|
fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n",
|
||||||
types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))),
|
types.SizeStr(types.BigMul(types.NewInt(secCounts.Sectors), types.NewInt(uint64(mi.SectorSize)))),
|
||||||
types.SizeStr(types.BigMul(types.NewInt(nfaults), types.NewInt(uint64(mi.SectorSize)))),
|
types.SizeStr(types.BigMul(types.NewInt(nfaults), types.NewInt(uint64(mi.SectorSize)))),
|
||||||
faultyPercentage)
|
faultyPercentage)
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,51 @@ func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
|
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
|
||||||
return api.MinerSectors{}, xerrors.Errorf("TODO: FIXME") // TODO
|
var out api.MinerSectors
|
||||||
|
|
||||||
|
err := a.StateManager.WithParentStateTsk(tsk,
|
||||||
|
a.StateManager.WithActor(addr,
|
||||||
|
a.StateManager.WithActorState(ctx, func(store adt.Store, mas *miner.State) error {
|
||||||
|
var allActive []*abi.BitField
|
||||||
|
|
||||||
|
err := a.StateManager.WithDeadlines(
|
||||||
|
a.StateManager.WithEachDeadline(
|
||||||
|
a.StateManager.WithEachPartition(func(store adt.Store, partIdx uint64, partition *miner.Partition) error {
|
||||||
|
active, err := partition.ActiveSectors()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("partition.ActiveSectors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
allActive = append(allActive, active)
|
||||||
|
return nil
|
||||||
|
})))(store, mas)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("with deadlines: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
active, err := bitfield.MultiMerge(allActive...)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("merging active sector bitfields: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
out.Active, err = active.Count()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("counting active sectors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sarr, err := adt.AsArray(store, mas.Sectors)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
out.Sectors = sarr.Length()
|
||||||
|
return nil
|
||||||
|
})))
|
||||||
|
if err != nil {
|
||||||
|
return api.MinerSectors{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user