Skip to content

Commit

Permalink
Merge pull request #844 from ipfs-force-community/dev/wdpost
Browse files Browse the repository at this point in the history
Dev/wdpost
  • Loading branch information
0x5459 authored Jul 28, 2023
2 parents b93eb07 + 5541014 commit 9e1a02d
Show file tree
Hide file tree
Showing 83 changed files with 4,192 additions and 1,498 deletions.
20 changes: 18 additions & 2 deletions damocles-manager/cmd/damocles-manager/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ var daemonRunCmd = &cli.Command{
Value: false,
Usage: "enable external prover",
},
&cli.BoolFlag{
Name: "worker-prover",
Value: false,
Usage: "enable worker prover",
},
daemonRunProxyFlag,
daemonRunProxySectorIndexerOffFlag,
},
Expand All @@ -101,6 +106,10 @@ var daemonRunCmd = &cli.Command{
proxyOpt := dep.ProxyOptions{
EnableSectorIndexer: !cctx.Bool(daemonRunProxySectorIndexerOffFlag.Name),
}
extProver, workerProver := cctx.Bool("ext-prover"), cctx.Bool("worker-prover")
if extProver && workerProver {
return fmt.Errorf("ext-prover and worker-prover are mutually exclusive")
}

var apiService *APIService
stopper, err := dix.New(
Expand All @@ -119,9 +128,16 @@ var daemonRunCmd = &cli.Command{
dep.Miner(),
),
dep.Gateway(),
dix.If(cctx.Bool("ext-prover"), dep.ExtProver()),
dix.Override(new(*APIService), NewAPIServiceDisbaleWorkerWdPoSt),

dix.If(extProver, dep.ExtProver()),
dix.If(
workerProver,
dep.WorkerProver(),
dix.Override(new(*APIService), NewAPIService),
),
dep.Sealer(),
dix.Override(new(*APIService), NewAPIService),

dix.Populate(dep.InvokePopulate, &apiService),
)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions damocles-manager/cmd/damocles-manager/internal/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ type APIClient struct {
Chain chain.API
Messager messager.API
Market market.API
Sealer core.SealerCliClient
Miner core.MinerAPIClient
Damocles *core.APIClient
}

func extractAPI(cctx *cli.Context, target ...interface{}) (*APIClient, context.Context, stopper, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ var utilSealerActorControlList = &cli.Command{
if err != nil {
return fmt.Errorf("invalid miner addr '%s': %w", maddr, err)
}
minerConfig, err := api.Miner.GetMinerConfig(ctx, abi.ActorID(mid))
minerConfig, err := api.Damocles.GetMinerConfig(ctx, abi.ActorID(mid))
if err != nil {
return fmt.Errorf("get miner config: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/filecoin-project/venus/venus-shared/types"

"github.com/ipfs-force-community/damocles/damocles-manager/core"
"github.com/ipfs-force-community/damocles/damocles-manager/modules/impl/prover"
"github.com/ipfs-force-community/damocles/damocles-manager/modules/policy"
"github.com/ipfs-force-community/damocles/damocles-manager/modules/util"
chainAPI "github.com/ipfs-force-community/damocles/damocles-manager/pkg/chain"
Expand Down Expand Up @@ -627,7 +626,7 @@ var utilSealerProvingCheckProvableCmd = &cli.Command{
return fmt.Errorf("invalid seal proof type %d: %w", tocheck[0].SealProof, err)
}

bad, err := api.Sealer.CheckProvable(ctx, abi.ActorID(mid), postProofType, tocheck, slow, stateCheck)
bad, err := api.Damocles.CheckProvable(ctx, abi.ActorID(mid), postProofType, tocheck, slow, stateCheck)
if err != nil {
return err
}
Expand Down Expand Up @@ -685,8 +684,8 @@ var utilSealerProvingSimulateWdPoStCmd = &cli.Command{
if err != nil {
return err
}

partitions, err := api.Chain.StateMinerPartitions(ctx, maddr, cctx.Uint64("ddl-idx"), ts.Key())
ddlIdx := cctx.Uint64("ddl-idx")
partitions, err := api.Chain.StateMinerPartitions(ctx, maddr, ddlIdx, ts.Key())
if err != nil {
return fmt.Errorf("get parttion info failed: %w", err)
}
Expand Down Expand Up @@ -752,7 +751,7 @@ var utilSealerProvingSimulateWdPoStCmd = &cli.Command{
return fmt.Errorf("convert to winning post proof: %w", err)
}

err = api.Sealer.SimulateWdPoSt(ctx, maddr, ppt, proofSectors, rand)
err = api.Damocles.SimulateWdPoSt(ctx, ddlIdx, maddr, ppt, proofSectors, rand)
if err != nil {
return err
}
Expand Down Expand Up @@ -792,7 +791,7 @@ var utilSealerProvingSectorInfoCmd = &cli.Command{

slog := mlog.With("num", num)

info, err := api.Sealer.ProvingSectorInfo(actx, abi.SectorID{
info, err := api.Damocles.ProvingSectorInfo(actx, abi.SectorID{
Miner: mid,
Number: abi.SectorNumber(num),
})
Expand Down Expand Up @@ -830,7 +829,11 @@ var utilSealerProvingWinningVanillaCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
api, actx, astop, err := extractAPI(cctx)
var (
prover core.Prover
verifier core.Verifier
)
api, actx, astop, err := extractAPI(cctx, &prover, &verifier)
if err != nil {
return err
}
Expand Down Expand Up @@ -877,7 +880,8 @@ var utilSealerProvingWinningVanillaCmd = &cli.Command{
slog.Infof("commR: %v", commR)

randomness := make(abi.PoStRandomness, abi.RandomnessLength)
challenges, err := prover.Prover.GeneratePoStFallbackSectorChallenges(actx, abi.RegisteredPoStProof_StackedDrgWinning32GiBV1, sectorID.Miner, randomness, []abi.SectorNumber{sectorID.Number})

challenges, err := prover.GeneratePoStFallbackSectorChallenges(actx, abi.RegisteredPoStProof_StackedDrgWinning32GiBV1, sectorID.Miner, randomness, []abi.SectorNumber{sectorID.Number})
if err != nil {
return fmt.Errorf("generate challenge for sector %s: %w", sealedFileName, err)
}
Expand All @@ -889,7 +893,7 @@ var utilSealerProvingWinningVanillaCmd = &cli.Command{

slog.Infof("%d challenge generated", len(challenge))

vannilla, err := prover.Prover.GenerateSingleVanillaProof(actx, core.FFIPrivateSectorInfo{
vannilla, err := prover.GenerateSingleVanillaProof(actx, core.FFIPrivateSectorInfo{
SectorInfo: sectorInfo,
PoStProofType: abi.RegisteredPoStProof_StackedDrgWinning32GiBV1,
CacheDirPath: cacheDirPath,
Expand All @@ -901,14 +905,14 @@ var utilSealerProvingWinningVanillaCmd = &cli.Command{

slog.Infof("vannilla generated with %d bytes", len(vannilla))

proofs, err := prover.Prover.GenerateWinningPoStWithVanilla(actx, abi.RegisteredPoStProof_StackedDrgWinning32GiBV1, sectorID.Miner, randomness, [][]byte{vannilla})
proofs, err := prover.GenerateWinningPoStWithVanilla(actx, abi.RegisteredPoStProof_StackedDrgWinning32GiBV1, sectorID.Miner, randomness, [][]byte{vannilla})
if err != nil {
return fmt.Errorf("generate winning post with vannilla for %s: %w", sealedFileName, err)
}

slog.Infof("proof generated with %d bytes", len(proofs[0].ProofBytes))

verified, err := prover.Verifier.VerifyWinningPoSt(actx, core.WinningPoStVerifyInfo{
verified, err := verifier.VerifyWinningPoSt(actx, core.WinningPoStVerifyInfo{
Randomness: randomness,
Proofs: proofs,
ChallengedSectors: []core.SectorInfo{sectorInfo},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var utilSealerSectorsListCmd = &cli.Command{

defer stop()

states, err := cli.Sealer.ListSectors(gctx, extractListWorkerState(cctx), core.SectorWorkerJobAll)
states, err := cli.Damocles.ListSectors(gctx, extractListWorkerState(cctx), core.SectorWorkerJobAll)
if err != nil {
return err
}
Expand Down Expand Up @@ -298,7 +298,7 @@ var utilSealerSectorsRestoreCmd = &cli.Command{

defer stop()

_, err = cli.Sealer.RestoreSector(gctx, abi.SectorID{
_, err = cli.Damocles.RestoreSector(gctx, abi.SectorID{
Miner: miner,
Number: abi.SectorNumber(sectorNum),
}, cctx.Bool("force"))
Expand Down Expand Up @@ -462,7 +462,7 @@ var utilSealerSectorsExpiredCmd = &cli.Command{
toCheck := bitfield.New()
toCheckSectors := make(map[abi.SectorNumber]*core.SectorState)
{
sectors, err := extAPI.Sealer.ListSectors(ctx, core.WorkerOffline, core.SectorWorkerJobAll)
sectors, err := extAPI.Damocles.ListSectors(ctx, core.WorkerOffline, core.SectorWorkerJobAll)
if err != nil {
return fmt.Errorf("getting sector list: %w", err)
}
Expand Down Expand Up @@ -577,7 +577,7 @@ var utilSealerSectorsExpiredCmd = &cli.Command{
for _, number := range toRemove {
fmt.Printf("Removing sector\t%s:\t", color.YellowString("%d", number))

err = extAPI.Sealer.RemoveSector(ctx, abi.SectorID{Miner: abi.ActorID(actor), Number: number})
err = extAPI.Damocles.RemoveSector(ctx, abi.SectorID{Miner: abi.ActorID(actor), Number: number})
if err != nil {
color.Red("ERROR: %s\n", err.Error())
} else {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ var utilSealerSectorsTerminateCmd = &cli.Command{
}

actor := cctx.Uint64("actor")
resp, err := cli.Sealer.TerminateSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
resp, err := cli.Damocles.TerminateSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
if err != nil {
return err
}
Expand Down Expand Up @@ -1230,7 +1230,7 @@ var utilSealerSectorsTerminateQueryCmd = &cli.Command{
}

actor := cctx.Uint64("actor")
resp, err := cli.Sealer.PollTerminateSectorState(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
resp, err := cli.Damocles.PollTerminateSectorState(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
if err != nil {
return err
}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ var utilSealerSectorsRemoveCmd = &cli.Command{
}

actor := cctx.Uint64("actor")
err = cli.Sealer.RemoveSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
err = cli.Damocles.RemoveSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
if err != nil {
return err
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ var utilSealerSectorsFinalizeCmd = &cli.Command{
}

actor := cctx.Uint64("actor")
err = cli.Sealer.FinalizeSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
err = cli.Damocles.FinalizeSector(gctx, abi.SectorID{Miner: abi.ActorID(actor), Number: abi.SectorNumber(id)})
if err != nil {
return err
}
Expand Down Expand Up @@ -1369,7 +1369,7 @@ var utilSealerSectorsStateCmd = &cli.Command{
Number: sectorNumber,
}

state, err := cli.Sealer.FindSectorInAllStates(gctx, sid)
state, err := cli.Damocles.FindSectorInAllStates(gctx, sid)
if err != nil {
return RPCCallError("FindSectorInAllStates", err)
}
Expand Down Expand Up @@ -1498,7 +1498,7 @@ var utilSealerSectorsFindDealCmd = &cli.Command{

defer stop()

sectors, err := cli.Sealer.FindSectorsWithDeal(gctx, extractListWorkerState(cctx), abi.DealID(dealID))
sectors, err := cli.Damocles.FindSectorsWithDeal(gctx, extractListWorkerState(cctx), abi.DealID(dealID))
if err != nil {
return RPCCallError("FindSectorsWithDeal", err)
}
Expand Down Expand Up @@ -1551,7 +1551,7 @@ var utilSealerSectorsResendPreCommitCmd = &cli.Command{
Number: sectorNumber,
}

state, err := cli.Sealer.FindSector(gctx, core.WorkerOnline, sid)
state, err := cli.Damocles.FindSector(gctx, core.WorkerOnline, sid)
if err != nil {
return RPCCallError("FindSector", err)
}
Expand All @@ -1573,7 +1573,7 @@ var utilSealerSectorsResendPreCommitCmd = &cli.Command{
return fmt.Errorf("convert to pre commit on chain info: %w", err)
}

resp, err := cli.Sealer.SubmitPreCommit(gctx, core.AllocatedSector{
resp, err := cli.Damocles.SubmitPreCommit(gctx, core.AllocatedSector{
ID: sid,
ProofType: state.SectorType,
}, onChainInfo, true)
Expand Down Expand Up @@ -1626,7 +1626,7 @@ var utilSealerSectorsResendProveCommitCmd = &cli.Command{
Number: sectorNumber,
}

state, err := cli.Sealer.FindSector(gctx, core.WorkerOnline, sid)
state, err := cli.Damocles.FindSector(gctx, core.WorkerOnline, sid)
if err != nil {
return RPCCallError("FindSector", err)
}
Expand All @@ -1639,7 +1639,7 @@ var utilSealerSectorsResendProveCommitCmd = &cli.Command{
return fmt.Errorf("sector is still being marked as 'Need To Be Send' in the state machine")
}

resp, err := cli.Sealer.SubmitProof(gctx, sid, *state.Proof, true)
resp, err := cli.Damocles.SubmitProof(gctx, sid, *state.Proof, true)

if err != nil {
return RPCCallError("SubmitProof", err)
Expand Down Expand Up @@ -1739,7 +1739,7 @@ var utilSealerSectorsImportCmd = &cli.Command{
continue
}

imported, err := cli.Sealer.ImportSector(gctx, core.WorkerOffline, state, override)
imported, err := cli.Damocles.ImportSector(gctx, core.WorkerOffline, state, override)
if err != nil {
slog.Errorf("import failed: %s", err)
continue
Expand Down Expand Up @@ -1820,7 +1820,7 @@ var utilSealerSectorsExportMetadataCmd = &cli.Command{
}
defer stop()

states, err := cli.Sealer.ListSectors(gctx, core.WorkerOffline, core.SectorWorkerJobAll)
states, err := cli.Damocles.ListSectors(gctx, core.WorkerOffline, core.SectorWorkerJobAll)
if err != nil {
return err
}
Expand Down Expand Up @@ -1972,7 +1972,7 @@ var utilSealerSectorsExportFilesCmd = &cli.Command{
}
defer stop()

states, err := cli.Sealer.ListSectors(gctx, core.WorkerOffline, core.SectorWorkerJobAll)
states, err := cli.Damocles.ListSectors(gctx, core.WorkerOffline, core.SectorWorkerJobAll)
if err != nil {
return err
}
Expand All @@ -1991,7 +1991,7 @@ var utilSealerSectorsExportFilesCmd = &cli.Command{
continue
}

loc, err := cli.Sealer.ProvingSectorInfo(ctx, state.ID)
loc, err := cli.Damocles.ProvingSectorInfo(ctx, state.ID)
if err != nil {
fmt.Fprintf(os.Stdout, "find sector %v location: %s\n", state.ID.Number, err)
failCounts++
Expand Down Expand Up @@ -2355,7 +2355,7 @@ var utilSealerSectorsRebuildCmd = &cli.Command{

defer stop()

_, err = cli.Sealer.SectorSetForRebuild(gctx, abi.SectorID{
_, err = cli.Damocles.SectorSetForRebuild(gctx, abi.SectorID{
Miner: miner,
Number: abi.SectorNumber(sectorNum),
}, core.RebuildOptions{
Expand Down Expand Up @@ -2449,14 +2449,14 @@ var utilSealerSectorsUnsealCmd = &cli.Command{
Miner: miner,
Number: sector,
}
sectorState, err = cli.Sealer.FindSectorInAllStates(gctx, sectorID)
sectorState, err = cli.Damocles.FindSectorInAllStates(gctx, sectorID)
if err != nil {
return fmt.Errorf("get sector info failed: %w", err)
}
} else if cctx.IsSet("actor") || cctx.IsSet("sector") {
return fmt.Errorf("flag \"--actor\" and \"--sector\" must be set together")
} else {
sector, err := cli.Sealer.FindSectorWithPiece(gctx, core.WorkerOffline, pieceCid)
sector, err := cli.Damocles.FindSectorWithPiece(gctx, core.WorkerOffline, pieceCid)
if err != nil {
return fmt.Errorf("find sector with piece: %w", err)
}
Expand Down Expand Up @@ -2564,7 +2564,7 @@ var utilSealerSectorsUnsealCmd = &cli.Command{
}

} else {
stream, err := cli.Sealer.UnsealPiece(gctx, sectorID, pieceCid, types.UnpaddedByteIndex(offset), size, dest)
stream, err := cli.Damocles.UnsealPiece(gctx, sectorID, pieceCid, types.UnpaddedByteIndex(offset), size, dest)
if err != nil {
return fmt.Errorf("set task for unseal failed: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var utilSealerSnapFetchCmd = &cli.Command{

defer stop()

res, err := api.Sealer.SnapUpPreFetch(gctx, mid, &deadidx)
res, err := api.Damocles.SnapUpPreFetch(gctx, mid, &deadidx)
if err != nil {
return RPCCallError("SnapPreFetch", err)
}
Expand Down Expand Up @@ -88,7 +88,7 @@ var utilSealerSnapCandidatesCmd = &cli.Command{

defer stop()

candidates, err := api.Sealer.SnapUpCandidates(gctx, mid)
candidates, err := api.Damocles.SnapUpCandidates(gctx, mid)
if err != nil {
return RPCCallError("SnapPreFetch", err)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ var utilSealerSnapCancelCommitmentCmd = &cli.Command{

defer stop()

err = api.Sealer.SnapUpCancelCommitment(gctx, abi.SectorID{
err = api.Damocles.SnapUpCancelCommitment(gctx, abi.SectorID{
Miner: mid,
Number: num,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ var utilStorageListCmd = &cli.Command{
}
defer astop()

details, err := api.Sealer.StoreList(actx)
details, err := api.Damocles.StoreList(actx)
if err != nil {
return RPCCallError("StoreList", err)
}
Expand Down Expand Up @@ -491,7 +491,7 @@ var utilStorageReleaseReservedCmd = &cli.Command{
Miner: minerID,
Number: num,
}
done, err := api.Sealer.StoreReleaseReserved(actx, sid)
done, err := api.Damocles.StoreReleaseReserved(actx, sid)
if err != nil {
return RPCCallError("StoreReleaseReserved", err)
}
Expand Down
Loading

0 comments on commit 9e1a02d

Please sign in to comment.