add on-chain-info to lotus-miner sectors status command
This commit is contained in:
parent
e60adb01fa
commit
26998fca32
@ -30,7 +30,7 @@ type StorageMiner interface {
|
|||||||
PledgeSector(context.Context) error
|
PledgeSector(context.Context) error
|
||||||
|
|
||||||
// Get the status of a given sector by ID
|
// Get the status of a given sector by ID
|
||||||
SectorsStatus(context.Context, abi.SectorNumber) (SectorInfo, error)
|
SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (SectorInfo, error)
|
||||||
|
|
||||||
// List all staged sectors
|
// List all staged sectors
|
||||||
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
||||||
@ -117,6 +117,19 @@ type SectorInfo struct {
|
|||||||
LastErr string
|
LastErr string
|
||||||
|
|
||||||
Log []SectorLog
|
Log []SectorLog
|
||||||
|
|
||||||
|
// On Chain Info
|
||||||
|
SealProof abi.RegisteredSealProof // The seal proof type implies the PoSt proof/s
|
||||||
|
Activation abi.ChainEpoch // Epoch during which the sector proof was accepted
|
||||||
|
Expiration abi.ChainEpoch // Epoch during which the sector expires
|
||||||
|
DealWeight abi.DealWeight // Integral of active deals over sector lifetime
|
||||||
|
VerifiedDealWeight abi.DealWeight // Integral of active verified deals over sector lifetime
|
||||||
|
InitialPledge abi.TokenAmount // Pledge collected to commit this sector
|
||||||
|
// Expiration Info
|
||||||
|
OnTime abi.ChainEpoch
|
||||||
|
// non-zero if sector is faulty, epoch at which it will be permanently
|
||||||
|
// removed if it doesn't recover
|
||||||
|
Early abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
type SealedRef struct {
|
type SealedRef struct {
|
||||||
|
@ -215,7 +215,7 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
PledgeSector func(context.Context) error `perm:"write"`
|
PledgeSector func(context.Context) error `perm:"write"`
|
||||||
|
|
||||||
SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"`
|
SectorsStatus func(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) `perm:"read"`
|
||||||
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
||||||
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
||||||
SectorStartSealing func(context.Context, abi.SectorNumber) error `perm:"write"`
|
SectorStartSealing func(context.Context, abi.SectorNumber) error `perm:"write"`
|
||||||
@ -845,8 +845,8 @@ func (c *StorageMinerStruct) PledgeSector(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the status of a given sector by ID
|
// Get the status of a given sector by ID
|
||||||
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid abi.SectorNumber) (api.SectorInfo, error) {
|
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) {
|
||||||
return c.Internal.SectorsStatus(ctx, sid)
|
return c.Internal.SectorsStatus(ctx, sid, showOnChainInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List all staged sectors
|
// List all staged sectors
|
||||||
|
@ -192,7 +192,7 @@ func startSealingWaiting(t *testing.T, ctx context.Context, miner TestStorageNod
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, snum := range snums {
|
for _, snum := range snums {
|
||||||
si, err := miner.SectorsStatus(ctx, snum)
|
si, err := miner.SectorsStatus(ctx, snum, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Logf("Sector state: %s", si.State)
|
t.Logf("Sector state: %s", si.State)
|
||||||
|
@ -97,7 +97,7 @@ func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n i
|
|||||||
|
|
||||||
for len(toCheck) > 0 {
|
for len(toCheck) > 0 {
|
||||||
for n := range toCheck {
|
for n := range toCheck {
|
||||||
st, err := miner.SectorsStatus(ctx, n)
|
st, err := miner.SectorsStatus(ctx, n, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if st.State == api.SectorState(sealing.Proving) {
|
if st.State == api.SectorState(sealing.Proving) {
|
||||||
delete(toCheck, n)
|
delete(toCheck, n)
|
||||||
|
@ -222,7 +222,7 @@ func sectorsInfo(ctx context.Context, napi api.StorageMiner) error {
|
|||||||
"Total": len(sectors),
|
"Total": len(sectors),
|
||||||
}
|
}
|
||||||
for _, s := range sectors {
|
for _, s := range sectors {
|
||||||
st, err := napi.SectorsStatus(ctx, s)
|
st, err := napi.SectorsStatus(ctx, s, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ var sectorsStatusCmd = &cli.Command{
|
|||||||
Name: "log",
|
Name: "log",
|
||||||
Usage: "display event log",
|
Usage: "display event log",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "on-chain-info",
|
||||||
|
Usage: "show sector on chain info",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
@ -78,7 +82,8 @@ var sectorsStatusCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := nodeApi.SectorsStatus(ctx, abi.SectorNumber(id))
|
onChainInfo := cctx.Bool("on-chain-info")
|
||||||
|
status, err := nodeApi.SectorsStatus(ctx, abi.SectorNumber(id), onChainInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -98,6 +103,19 @@ var sectorsStatusCmd = &cli.Command{
|
|||||||
fmt.Printf("Last Error:\t\t%s\n", status.LastErr)
|
fmt.Printf("Last Error:\t\t%s\n", status.LastErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if onChainInfo {
|
||||||
|
fmt.Printf("\nSector On Chain Info\n")
|
||||||
|
fmt.Printf("SealProof:\t\t%x\n", status.SealProof)
|
||||||
|
fmt.Printf("Activation:\t\t%v\n", status.Activation)
|
||||||
|
fmt.Printf("Expiration:\t\t%v\n", status.Expiration)
|
||||||
|
fmt.Printf("DealWeight:\t\t%v\n", status.DealWeight)
|
||||||
|
fmt.Printf("VerifiedDealWeight:\t\t%v\n", status.VerifiedDealWeight)
|
||||||
|
fmt.Printf("InitialPledge:\t\t%v\n", status.InitialPledge)
|
||||||
|
fmt.Printf("\nExpiration Info\n")
|
||||||
|
fmt.Printf("OnTime:\t\t%v\n", status.OnTime)
|
||||||
|
fmt.Printf("Early:\t\t%v\n", status.Early)
|
||||||
|
}
|
||||||
|
|
||||||
if cctx.Bool("log") {
|
if cctx.Bool("log") {
|
||||||
fmt.Printf("--------\nEvent Log:\n")
|
fmt.Printf("--------\nEvent Log:\n")
|
||||||
|
|
||||||
@ -165,7 +183,7 @@ var sectorsListCmd = &cli.Command{
|
|||||||
w := tabwriter.NewWriter(os.Stdout, 8, 4, 1, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 4, 1, ' ', 0)
|
||||||
|
|
||||||
for _, s := range list {
|
for _, s := range list {
|
||||||
st, err := nodeApi.SectorsStatus(ctx, s)
|
st, err := nodeApi.SectorsStatus(ctx, s, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(w, "%d:\tError: %s\n", s, err)
|
fmt.Fprintf(w, "%d:\tError: %s\n", s, err)
|
||||||
continue
|
continue
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/filecoin-project/sector-storage/fsutil"
|
"github.com/filecoin-project/sector-storage/fsutil"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -102,7 +103,7 @@ func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) error {
|
|||||||
return sm.Miner.PledgeSector()
|
return sm.Miner.PledgeSector()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumber) (api.SectorInfo, error) {
|
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) {
|
||||||
info, err := sm.Miner.GetSectorInfo(sid)
|
info, err := sm.Miner.GetSectorInfo(sid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.SectorInfo{}, err
|
return api.SectorInfo{}, err
|
||||||
@ -126,7 +127,7 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.SectorInfo{
|
sInfo := api.SectorInfo{
|
||||||
SectorID: sid,
|
SectorID: sid,
|
||||||
State: api.SectorState(info.State),
|
State: api.SectorState(info.State),
|
||||||
CommD: info.CommD,
|
CommD: info.CommD,
|
||||||
@ -145,7 +146,40 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumb
|
|||||||
|
|
||||||
LastErr: info.LastErr,
|
LastErr: info.LastErr,
|
||||||
Log: log,
|
Log: log,
|
||||||
}, nil
|
// on chain info
|
||||||
|
SealProof: 0,
|
||||||
|
Activation: 0,
|
||||||
|
Expiration: 0,
|
||||||
|
DealWeight: big.Zero(),
|
||||||
|
VerifiedDealWeight: big.Zero(),
|
||||||
|
InitialPledge: big.Zero(),
|
||||||
|
OnTime: 0,
|
||||||
|
Early: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !showOnChainInfo {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
onChainInfo, err := sm.Full.StateSectorGetInfo(ctx, sm.Miner.Address(), sid, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
sInfo.SealProof = onChainInfo.SealProof
|
||||||
|
sInfo.Activation = onChainInfo.Activation
|
||||||
|
sInfo.Expiration = onChainInfo.Expiration
|
||||||
|
sInfo.DealWeight = onChainInfo.DealWeight
|
||||||
|
sInfo.VerifiedDealWeight = onChainInfo.VerifiedDealWeight
|
||||||
|
sInfo.InitialPledge = onChainInfo.InitialPledge
|
||||||
|
|
||||||
|
ex, err := sm.Full.StateSectorExpiration(ctx, sm.Miner.Address(), sid, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
sInfo.OnTime = ex.OnTime
|
||||||
|
sInfo.Early = ex.Early
|
||||||
|
|
||||||
|
return sInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// List all staged sectors
|
// List all staged sectors
|
||||||
|
Loading…
Reference in New Issue
Block a user