Skip to content

Commit

Permalink
lpwinning: fix PoSt prover gen
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Nov 10, 2023
1 parent 397e320 commit 9112693
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/lotus-provider/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"encoding/base64"
"fmt"
"github.com/filecoin-project/lotus/provider/lpwinning"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -41,6 +40,7 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/provider"
"github.com/filecoin-project/lotus/provider/lpwinning"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
Expand Down
3 changes: 3 additions & 0 deletions documentation/en/default-lotus-provider-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# type: bool
#EnableWinningPost = false

# type: int
#WinningPostMaxTasks = 0


[Fees]
# type: types.FIL
Expand Down
6 changes: 6 additions & 0 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 31 additions & 6 deletions provider/lpwinning/winning_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ import (
"crypto/rand"
"encoding/binary"
"encoding/json"
"time"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"

ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"
prooftypes "github.com/filecoin-project/go-state-types/proof"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/gen"
Expand All @@ -22,10 +30,6 @@ import (
"github.com/filecoin-project/lotus/lib/promise"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"time"
)

var log = logging.Logger("lpwinning")
Expand Down Expand Up @@ -63,7 +67,7 @@ type WinPostAPI interface {
}

type ProverWinningPoSt interface {
GenerateWinningPoSt(ctx context.Context, ppt abi.RegisteredPoStProof, minerID abi.ActorID, sectorInfo []prooftypes.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]prooftypes.PoStProof, error)
GenerateWinningPoSt(ctx context.Context, ppt abi.RegisteredPoStProof, minerID abi.ActorID, sectorInfo []storiface.PostSectorChallenge, randomness abi.PoStRandomness) ([]prooftypes.PoStProof, error)
}

func NewWinPostTask(max int, db *harmonydb.DB, prover ProverWinningPoSt, verifier storiface.Verifier, api WinPostAPI, actors []dtypes.MinerAddress) *WinPostTask {
Expand Down Expand Up @@ -216,7 +220,28 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don

prand := abi.PoStRandomness(brand)

wpostProof, err = t.prover.GenerateWinningPoSt(ctx, mi.WindowPoStProofType, abi.ActorID(details.SpID), mbi.Sectors, prand)
sectorNums := make([]abi.SectorNumber, len(mbi.Sectors))
for i, s := range mbi.Sectors {
sectorNums[i] = s.SectorNumber
}

postChallenges, err := ffi.GeneratePoStFallbackSectorChallenges(mi.WindowPoStProofType, abi.ActorID(details.SpID), prand, sectorNums)
if err != nil {
return false, xerrors.Errorf("generating fallback challenges: %v", err)
}

sectorChallenges := make([]storiface.PostSectorChallenge, len(mbi.Sectors))
for i, s := range mbi.Sectors {
sectorChallenges[i] = storiface.PostSectorChallenge{
SealProof: s.SealProof,
SectorNumber: s.SectorNumber,
SealedCID: s.SealedCID,
Challenge: postChallenges.Challenges[s.SectorNumber],
Update: s.SectorKey != nil,
}
}

wpostProof, err = t.prover.GenerateWinningPoSt(ctx, mi.WindowPoStProofType, abi.ActorID(details.SpID), sectorChallenges, prand)
if err != nil {
err = xerrors.Errorf("failed to compute winning post proof: %w", err)
return false, err
Expand Down

0 comments on commit 9112693

Please sign in to comment.