lpwinning: fix PoSt prover gen

This commit is contained in:
Łukasz Magiera 2023-11-10 20:36:41 +01:00
parent 2a4ce7d358
commit d719db3f2c
4 changed files with 41 additions and 7 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"encoding/base64"
"fmt"
"github.com/filecoin-project/lotus/provider/lpwinning"
"net"
"net/http"
"os"
@ -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"

View File

@ -8,6 +8,9 @@
# type: bool
#EnableWinningPost = false
# type: int
#WinningPostMaxTasks = 0
[Fees]
# type: types.FIL

View File

@ -995,6 +995,12 @@ sectors.`,
Name: "EnableWinningPost",
Type: "bool",
Comment: ``,
},
{
Name: "WinningPostMaxTasks",
Type: "int",
Comment: ``,
},
},

View File

@ -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"
@ -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")
@ -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 {
@ -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