Skip to content

Commit

Permalink
Merge pull request ipfs-force-community#52 from ipfs-force-community/…
Browse files Browse the repository at this point in the history
…feat/lt/auxiliary_cmd

add some auxiliary cmd
  • Loading branch information
diwufeiwen authored Mar 2, 2022
2 parents 9755ef9 + c7f6202 commit 6224b00
Show file tree
Hide file tree
Showing 19 changed files with 1,099 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile-on-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v2

- name: dependencies
run: sudo apt update & sudo apt upgrade & sudo apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev wget -y
run: sudo apt update & sudo apt upgrade & sudo apt install --reinstall mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev wget -y

- name: setup go
uses: actions/setup-go@v2
Expand Down
16 changes: 14 additions & 2 deletions venus-sector-manager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package api
import (
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"

"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/types"

"github.com/ipfs-force-community/venus-cluster/venus-sector-manager/pkg/objstore"
Expand Down Expand Up @@ -35,13 +38,17 @@ type SealerAPI interface {

PollProofState(context.Context, abi.SectorID) (PollProofStateResp, error)

ListSectors(context.Context) ([]*SectorState, error)
ListSectors(context.Context, SectorWorkerState) ([]*SectorState, error)

ReportState(context.Context, abi.SectorID, ReportStateReq) (Meta, error)

ReportFinalized(context.Context, abi.SectorID) (Meta, error)

ReportAborted(context.Context, abi.SectorID, string) (Meta, error)

CheckProvable(context.Context, abi.RegisteredPoStProof, []storage.SectorRef, bool) (map[abi.SectorNumber]string, error)

SimulateWdPoSt(context.Context, address.Address, []builtin.ExtendedSectorInfo, abi.PoStRandomness) error
}

type RandomnessAPI interface {
Expand Down Expand Up @@ -81,11 +88,16 @@ type SectorStateManager interface {
Load(context.Context, abi.SectorID) (*SectorState, error)
Update(context.Context, abi.SectorID, ...interface{}) error
Finalize(context.Context, abi.SectorID, func(*SectorState) error) error
All(ctx context.Context) ([]*SectorState, error)
All(ctx context.Context, ws SectorWorkerState) ([]*SectorState, error)
}

type SectorIndexer interface {
Find(context.Context, abi.SectorID) (string, bool, error)
Update(context.Context, abi.SectorID, string) error
StoreMgr() objstore.Manager
}

type SectorTracker interface {
Provable(context.Context, abi.RegisteredPoStProof, []storage.SectorRef, bool) (map[abi.SectorNumber]string, error)
PubToPrivate(context.Context, abi.ActorID, []builtin.ExtendedSectorInfo) (SortedPrivateSectorInfo, error)
}
10 changes: 9 additions & 1 deletion venus-sector-manager/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package api
import (
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"

"github.com/filecoin-project/venus/venus-shared/actors/builtin"
)

type SealerClient struct {
Expand All @@ -25,11 +29,15 @@ type SealerClient struct {

PollProofState func(context.Context, abi.SectorID) (PollProofStateResp, error)

ListSectors func(context.Context) ([]*SectorState, error)
ListSectors func(context.Context, SectorWorkerState) ([]*SectorState, error)

ReportState func(context.Context, abi.SectorID, ReportStateReq) (Meta, error)

ReportFinalized func(context.Context, abi.SectorID) (Meta, error)

ReportAborted func(context.Context, abi.SectorID, string) (Meta, error)

CheckProvable func(context.Context, abi.RegisteredPoStProof, []storage.SectorRef, bool) (map[abi.SectorNumber]string, error)

SimulateWdPoSt func(context.Context, address.Address, []builtin.ExtendedSectorInfo, abi.PoStRandomness) error
}
7 changes: 7 additions & 0 deletions venus-sector-manager/api/types_sector_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ func (s SectorState) DealIDs() []abi.DealID {
}
return res
}

type SectorWorkerState string

const (
WorkerOnline SectorWorkerState = "online"
WorkerOffline SectorWorkerState = "offline"
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var utilSealerCmd = &cli.Command{
},
Subcommands: []*cli.Command{
utilSealerSectorsCmd,
utilSealerProvingCmd,
},
}

Expand All @@ -53,6 +54,7 @@ var utilSealerSectorsCmd = &cli.Command{
Subcommands: []*cli.Command{
utilSealerSectorsWorkerStatesCmd,
utilSealerSectorsAbortCmd,
utilSealerSectorsListCmd,
},
}

Expand All @@ -66,7 +68,7 @@ var utilSealerSectorsWorkerStatesCmd = &cli.Command{

defer stop()

states, err := cli.ListSectors(gctx)
states, err := cli.ListSectors(gctx, api.WorkerOnline)
if err != nil {
return err
}
Expand Down Expand Up @@ -138,3 +140,64 @@ var utilSealerSectorsAbortCmd = &cli.Command{
return nil
},
}

var utilSealerSectorsListCmd = &cli.Command{
Name: "list",
Usage: "Print sector data in completed state",
Action: func(cctx *cli.Context) error {
cli, gctx, stop, err := extractSealerClient(cctx)
if err != nil {
return err
}

defer stop()

states, err := cli.ListSectors(gctx, api.WorkerOffline)
if err != nil {
return err
}

fmt.Fprintf(os.Stdout, "Sectors(%d):\n", len(states))
for _, state := range states {
fmt.Fprintf(os.Stdout, "m-%d-s-%d:\n", state.ID.Miner, state.ID.Number)
if state.LatestState == nil {
fmt.Fprintln(os.Stdout, "NULL")
continue
}

fmt.Fprintln(os.Stdout, "\tDeals:")
if state.Deals == nil {
fmt.Fprintln(os.Stdout, "\t\tNULL")
} else {
for _, deal := range state.Deals {
fmt.Fprintf(os.Stdout, "\t\tID: %d\n", deal.ID)
fmt.Fprintf(os.Stdout, "\t\tPiece: %v\n", deal.Piece)
}
}

fmt.Fprintln(os.Stdout, "\tTicket:")
fmt.Fprintf(os.Stdout, "\t\tHeight: %d\n", state.Ticket.Epoch)
fmt.Fprintf(os.Stdout, "\t\tValue: %x\n", state.Ticket.Ticket)

fmt.Fprintln(os.Stdout, "\tSeed:")
fmt.Fprintf(os.Stdout, "\t\tHeight: %d\n", state.Seed.Epoch)
fmt.Fprintf(os.Stdout, "\t\tValue: %x\n", state.Seed.Seed)

fmt.Fprintln(os.Stdout, "\tMessageInfo:")
fmt.Fprintf(os.Stdout, "\t\tPre: %s\n", state.MessageInfo.PreCommitCid.String())
fmt.Fprintf(os.Stdout, "\t\tProve: %s\n", state.MessageInfo.CommitCid.String())
fmt.Fprintf(os.Stdout, "\t\tNeedSeed: %v\n", state.MessageInfo.NeedSend)

fmt.Fprintln(os.Stdout, "\tState:")
fmt.Fprintf(os.Stdout, "\t\tPrev: %s\n", state.LatestState.StateChange.Prev)
fmt.Fprintf(os.Stdout, "\t\tCurrent: %s\n", state.LatestState.StateChange.Next)
fmt.Fprintf(os.Stdout, "\t\tEvent: %s\n", state.LatestState.StateChange.Event)

fmt.Fprintf(os.Stdout, "\tFinalized: %v\n", state.Finalized)

fmt.Fprintln(os.Stdout, "")
}

return nil
},
}
Loading

0 comments on commit 6224b00

Please sign in to comment.