lpwinning: fix PoSt prover gen
This commit is contained in:
parent
2a4ce7d358
commit
d719db3f2c
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/lotus/provider/lpwinning"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -41,6 +40,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
"github.com/filecoin-project/lotus/provider"
|
"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/paths"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer"
|
"github.com/filecoin-project/lotus/storage/sealer"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
# type: bool
|
# type: bool
|
||||||
#EnableWinningPost = false
|
#EnableWinningPost = false
|
||||||
|
|
||||||
|
# type: int
|
||||||
|
#WinningPostMaxTasks = 0
|
||||||
|
|
||||||
|
|
||||||
[Fees]
|
[Fees]
|
||||||
# type: types.FIL
|
# type: types.FIL
|
||||||
|
@ -995,6 +995,12 @@ sectors.`,
|
|||||||
Name: "EnableWinningPost",
|
Name: "EnableWinningPost",
|
||||||
Type: "bool",
|
Type: "bool",
|
||||||
|
|
||||||
|
Comment: ``,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "WinningPostMaxTasks",
|
||||||
|
Type: "int",
|
||||||
|
|
||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -6,11 +6,19 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"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-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
prooftypes "github.com/filecoin-project/go-state-types/proof"
|
prooftypes "github.com/filecoin-project/go-state-types/proof"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/gen"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
@ -22,10 +30,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/lib/promise"
|
"github.com/filecoin-project/lotus/lib/promise"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
"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")
|
var log = logging.Logger("lpwinning")
|
||||||
@ -63,7 +67,7 @@ type WinPostAPI interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProverWinningPoSt 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 {
|
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)
|
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 {
|
if err != nil {
|
||||||
err = xerrors.Errorf("failed to compute winning post proof: %w", err)
|
err = xerrors.Errorf("failed to compute winning post proof: %w", err)
|
||||||
return false, err
|
return false, err
|
||||||
|
Loading…
Reference in New Issue
Block a user