make it all build finally
This commit is contained in:
parent
48619dc238
commit
df6e3e83bf
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-filestore"
|
"github.com/ipfs/go-filestore"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
xerrors "golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -229,7 +230,8 @@ type PaymentInfo struct {
|
|||||||
|
|
||||||
type VoucherSpec struct {
|
type VoucherSpec struct {
|
||||||
Amount types.BigInt
|
Amount types.BigInt
|
||||||
TimeLock abi.ChainEpoch
|
TimeLockMin abi.ChainEpoch
|
||||||
|
TimeLockMax abi.ChainEpoch
|
||||||
MinSettle abi.ChainEpoch
|
MinSettle abi.ChainEpoch
|
||||||
|
|
||||||
Extra *paych.ModVerifyParams
|
Extra *paych.ModVerifyParams
|
||||||
@ -339,3 +341,18 @@ type MpoolUpdate struct {
|
|||||||
Type MpoolChange
|
Type MpoolChange
|
||||||
Message *types.SignedMessage
|
Message *types.SignedMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, abi.RegisteredProof, error) {
|
||||||
|
switch ssize {
|
||||||
|
case 2 << 10:
|
||||||
|
return abi.RegisteredProof_StackedDRG2KiBPoSt, abi.RegisteredProof_StackedDRG2KiBSeal, nil
|
||||||
|
case 8 << 20:
|
||||||
|
return abi.RegisteredProof_StackedDRG8MiBPoSt, abi.RegisteredProof_StackedDRG8MiBSeal, nil
|
||||||
|
case 512 << 20:
|
||||||
|
return abi.RegisteredProof_StackedDRG512MiBPoSt, abi.RegisteredProof_StackedDRG512MiBSeal, nil
|
||||||
|
case 32 << 30:
|
||||||
|
return abi.RegisteredProof_StackedDRG32GiBPoSt, abi.RegisteredProof_StackedDRG32GiBSeal, nil
|
||||||
|
default:
|
||||||
|
return 0, 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
)
|
)
|
||||||
@ -123,12 +125,12 @@ type SectorLog struct {
|
|||||||
type SectorInfo struct {
|
type SectorInfo struct {
|
||||||
SectorID abi.SectorNumber
|
SectorID abi.SectorNumber
|
||||||
State SectorState
|
State SectorState
|
||||||
CommD []byte
|
CommD *cid.Cid
|
||||||
CommR []byte
|
CommR *cid.Cid
|
||||||
Proof []byte
|
Proof []byte
|
||||||
Deals []abi.DealID
|
Deals []abi.DealID
|
||||||
Ticket abi.SealRandomness
|
Ticket SealTicket
|
||||||
Seed abi.Randomness
|
Seed SealSeed
|
||||||
Retries uint64
|
Retries uint64
|
||||||
|
|
||||||
LastErr string
|
LastErr string
|
||||||
@ -145,3 +147,21 @@ type SealedRef struct {
|
|||||||
type SealedRefs struct {
|
type SealedRefs struct {
|
||||||
Refs []SealedRef
|
Refs []SealedRef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SealTicket struct {
|
||||||
|
Value abi.SealRandomness
|
||||||
|
Epoch abi.ChainEpoch
|
||||||
|
}
|
||||||
|
|
||||||
|
type SealSeed struct {
|
||||||
|
Value abi.InteractiveSealRandomness
|
||||||
|
Epoch abi.ChainEpoch
|
||||||
|
}
|
||||||
|
|
||||||
|
func (st *SealTicket) Equals(ost *SealTicket) bool {
|
||||||
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
||||||
|
}
|
||||||
|
|
||||||
|
func (st *SealSeed) Equals(ost *SealSeed) bool {
|
||||||
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
@ -23,7 +24,6 @@ import (
|
|||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/ipfs/go-merkledag"
|
"github.com/ipfs/go-merkledag"
|
||||||
|
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
||||||
@ -136,7 +136,7 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
genm1, k1, err := seed.PreSeal(maddr1, 1024, 0, 1, m1temp, []byte("some randomness"), nil)
|
genm1, k1, err := seed.PreSeal(maddr1, abi.RegisteredProof_StackedDRG2KiBPoSt, 0, 1, m1temp, []byte("some randomness"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
genm2, k2, err := seed.PreSeal(maddr2, 1024, 0, 1, m2temp, []byte("some randomness"), nil)
|
genm2, k2, err := seed.PreSeal(maddr2, abi.RegisteredProof_StackedDRG2KiBPoSt, 0, 1, m2temp, []byte("some randomness"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -514,32 +514,37 @@ func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*cr
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ElectionPoStProver interface {
|
type ElectionPoStProver interface {
|
||||||
GenerateCandidates(context.Context, sectorbuilder.SortedPublicSectorInfo, []byte) ([]sectorbuilder.EPostCandidate, error)
|
GenerateCandidates(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]ffi.PoStCandidateWithTicket, error)
|
||||||
ComputeProof(context.Context, sectorbuilder.SortedPublicSectorInfo, []byte, []sectorbuilder.EPostCandidate) ([]byte, error)
|
ComputeProof(context.Context, []abi.SectorInfo, []byte, []ffi.PoStCandidateWithTicket) ([]abi.PoStProof, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type eppProvider struct{}
|
type eppProvider struct{}
|
||||||
|
|
||||||
func (epp *eppProvider) GenerateCandidates(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte) ([]sectorbuilder.EPostCandidate, error) {
|
func (epp *eppProvider) GenerateCandidates(ctx context.Context, _ []abi.SectorInfo, eprand abi.PoStRandomness) ([]ffi.PoStCandidateWithTicket, error) {
|
||||||
return []sectorbuilder.EPostCandidate{
|
return []ffi.PoStCandidateWithTicket{
|
||||||
{
|
{
|
||||||
SectorNum: 1,
|
Candidate: abi.PoStCandidate{
|
||||||
PartialTicket: [32]byte{},
|
RegisteredProof: abi.RegisteredProof_StackedDRG2KiBPoSt,
|
||||||
Ticket: [32]byte{},
|
SectorID: abi.SectorID{Number: 1},
|
||||||
SectorChallengeIndex: 1,
|
PartialTicket: abi.PartialTicket{},
|
||||||
|
PrivateProof: abi.PrivatePoStCandidateProof{},
|
||||||
|
ChallengeIndex: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (epp *eppProvider) ComputeProof(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte, winners []sectorbuilder.EPostCandidate) ([]byte, error) {
|
func (epp *eppProvider) ComputeProof(ctx context.Context, _ []abi.SectorInfo, eprand []byte, winners []ffi.PoStCandidateWithTicket) ([]abi.PoStProof, error) {
|
||||||
|
|
||||||
return []byte("valid proof"), nil
|
return []abi.PoStProof{{
|
||||||
|
ProofBytes: []byte("valid proof"),
|
||||||
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProofInput struct {
|
type ProofInput struct {
|
||||||
sectors sectorbuilder.SortedPublicSectorInfo
|
sectors []abi.SectorInfo
|
||||||
hvrf []byte
|
hvrf []byte
|
||||||
winners []sectorbuilder.EPostCandidate
|
winners []ffi.PoStCandidateWithTicket
|
||||||
vrfout []byte
|
vrfout []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,23 +572,16 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var sinfos []ffi.PublicSectorInfo
|
var sinfos []abi.SectorInfo
|
||||||
for _, s := range pset {
|
for _, s := range pset {
|
||||||
cr, err := commcid.CIDToReplicaCommitmentV1(s.Info.Info.SealedCID)
|
sinfos = append(sinfos, abi.SectorInfo{
|
||||||
if err != nil {
|
SectorNumber: s.ID,
|
||||||
return nil, xerrors.Errorf("get sealed cid: %w", err)
|
SealedCID: s.Info.Info.SealedCID,
|
||||||
}
|
|
||||||
var commRa [32]byte
|
|
||||||
copy(commRa[:], cr)
|
|
||||||
sinfos = append(sinfos, ffi.PublicSectorInfo{
|
|
||||||
SectorNum: s.ID,
|
|
||||||
CommR: commRa,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
sectors := sectorbuilder.NewSortedPublicSectorInfo(sinfos)
|
|
||||||
|
|
||||||
hvrf := sha256.Sum256(vrfout)
|
hvrf := sha256.Sum256(vrfout)
|
||||||
candidates, err := epp.GenerateCandidates(ctx, sectors, hvrf[:])
|
candidates, err := epp.GenerateCandidates(ctx, sinfos, hvrf[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to generate electionPoSt candidates: %w", err)
|
return nil, xerrors.Errorf("failed to generate electionPoSt candidates: %w", err)
|
||||||
}
|
}
|
||||||
@ -598,9 +596,9 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
|||||||
return nil, xerrors.Errorf("failed to look up miners sector size: %w", err)
|
return nil, xerrors.Errorf("failed to look up miners sector size: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var winners []sectorbuilder.EPostCandidate
|
var winners []ffi.PoStCandidateWithTicket
|
||||||
for _, c := range candidates {
|
for _, c := range candidates {
|
||||||
if types.IsTicketWinner(c.PartialTicket[:], ssize, uint64(len(sinfos)), pow.TotalPower) {
|
if types.IsTicketWinner(c.Candidate.PartialTicket, ssize, uint64(len(sinfos)), pow.TotalPower) {
|
||||||
winners = append(winners, c)
|
winners = append(winners, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -611,7 +609,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &ProofInput{
|
return &ProofInput{
|
||||||
sectors: sectors,
|
sectors: sinfos,
|
||||||
hvrf: hvrf[:],
|
hvrf: hvrf[:],
|
||||||
winners: winners,
|
winners: winners,
|
||||||
vrfout: vrfout,
|
vrfout: vrfout,
|
||||||
@ -625,16 +623,16 @@ func ComputeProof(ctx context.Context, epp ElectionPoStProver, pi *ProofInput) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
ept := types.EPostProof{
|
ept := types.EPostProof{
|
||||||
Proof: proof,
|
Proofs: proof,
|
||||||
PostRand: pi.vrfout,
|
PostRand: pi.vrfout,
|
||||||
}
|
}
|
||||||
for _, win := range pi.winners {
|
for _, win := range pi.winners {
|
||||||
part := make([]byte, 32)
|
part := make([]byte, 32)
|
||||||
copy(part, win.PartialTicket[:])
|
copy(part, win.Candidate.PartialTicket)
|
||||||
ept.Candidates = append(ept.Candidates, types.EPostTicket{
|
ept.Candidates = append(ept.Candidates, types.EPostTicket{
|
||||||
Partial: part,
|
Partial: part,
|
||||||
SectorID: win.SectorNum,
|
SectorID: win.Candidate.SectorID.Number,
|
||||||
ChallengeIndex: win.SectorChallengeIndex,
|
ChallengeIndex: uint64(win.Candidate.ChallengeIndex),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,17 +674,17 @@ type genFakeVerifier struct{}
|
|||||||
|
|
||||||
var _ sectorbuilder.Verifier = (*genFakeVerifier)(nil)
|
var _ sectorbuilder.Verifier = (*genFakeVerifier)(nil)
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifyElectionPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address) (bool, error) {
|
func (m genFakeVerifier) VerifyElectionPost(ctx context.Context, pvi abi.PoStVerifyInfo) (bool, error) {
|
||||||
panic("nyi")
|
panic("nyi")
|
||||||
}
|
}
|
||||||
func (m genFakeVerifier) GenerateDataCommitment(ssize abi.PaddedPieceSize, pieces []ffi.PublicPieceInfo) ([sectorbuilder.CommLen]byte, error) {
|
func (m genFakeVerifier) GenerateDataCommitment(ssize abi.PaddedPieceSize, pieces []abi.PieceInfo) (cid.Cid, error) {
|
||||||
return sbmock.MockVerifier.GenerateDataCommitment(ssize, pieces)
|
return sbmock.MockVerifier.GenerateDataCommitment(ssize, pieces)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifySeal(sectorSize abi.SectorSize, commR, commD []byte, proverID address.Address, ticket []byte, seed []byte, sectorID abi.SectorNumber, proof []byte) (bool, error) {
|
func (m genFakeVerifier) VerifySeal(svi abi.SealVerifyInfo) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifyFallbackPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address, faults uint64) (bool, error) {
|
func (m genFakeVerifier) VerifyFallbackPost(ctx context.Context, pvi abi.PoStVerifyInfo) (bool, error) {
|
||||||
panic("nyi")
|
panic("nyi")
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
build.SectorSizes = []abi.SectorSize{1024}
|
build.SectorSizes = []abi.SectorSize{2048}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 2048
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneration(t testing.TB, n int, msgs int) {
|
func testGeneration(t testing.TB, n int, msgs int) {
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-amt-ipld/v2"
|
"github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
@ -257,7 +258,7 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys
|
|||||||
Miner: builtin.InitActorAddr,
|
Miner: builtin.InitActorAddr,
|
||||||
Ticket: genesisticket,
|
Ticket: genesisticket,
|
||||||
EPostProof: types.EPostProof{
|
EPostProof: types.EPostProof{
|
||||||
Proof: []byte("not a real proof"),
|
Proofs: []abi.PoStProof{{ProofBytes: []byte("not a real proof")}},
|
||||||
PostRand: []byte("i guess this is kinda random"),
|
PostRand: []byte("i guess this is kinda random"),
|
||||||
},
|
},
|
||||||
Parents: []cid.Cid{},
|
Parents: []cid.Cid{},
|
||||||
|
@ -61,6 +61,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
var maddr address.Address
|
var maddr address.Address
|
||||||
{
|
{
|
||||||
constructorParams := &power.CreateMinerParams{
|
constructorParams := &power.CreateMinerParams{
|
||||||
|
Owner: m.Worker,
|
||||||
Worker: m.Worker,
|
Worker: m.Worker,
|
||||||
SectorSize: m.SectorSize,
|
SectorSize: m.SectorSize,
|
||||||
Peer: m.PeerId,
|
Peer: m.PeerId,
|
||||||
|
@ -2,13 +2,14 @@ package chain
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
"github.com/Gurpartap/async"
|
"github.com/Gurpartap/async"
|
||||||
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
@ -666,14 +667,20 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc
|
|||||||
return xerrors.Errorf("failed to get sector size for miner: %w", err)
|
return xerrors.Errorf("failed to get sector size for miner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var winners []sectorbuilder.EPostCandidate
|
mid, err := address.IDFromAddress(h.Miner)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to get ID from miner address %s: %w", h.Miner, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var winners []abi.PoStCandidate
|
||||||
for _, t := range h.EPostProof.Candidates {
|
for _, t := range h.EPostProof.Candidates {
|
||||||
var partial [32]byte
|
winners = append(winners, abi.PoStCandidate{
|
||||||
copy(partial[:], t.Partial)
|
PartialTicket: t.Partial,
|
||||||
winners = append(winners, sectorbuilder.EPostCandidate{
|
SectorID: abi.SectorID{
|
||||||
PartialTicket: partial,
|
Number: t.SectorID,
|
||||||
SectorNum: t.SectorID,
|
Miner: abi.ActorID(mid),
|
||||||
SectorChallengeIndex: t.ChallengeIndex,
|
},
|
||||||
|
ChallengeIndex: int64(t.ChallengeIndex),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,14 +694,44 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if build.InsecurePoStValidation {
|
if build.InsecurePoStValidation {
|
||||||
if string(h.EPostProof.Proof) == "valid proof" {
|
if len(h.EPostProof.Proofs) == 0 {
|
||||||
|
return xerrors.Errorf("[TESTING] No election post proof given")
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(h.EPostProof.Proofs[0].ProofBytes) == "valid proof" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return xerrors.Errorf("[TESTING] election post was invalid")
|
return xerrors.Errorf("[TESTING] election post was invalid")
|
||||||
}
|
}
|
||||||
hvrf := sha256.Sum256(h.EPostProof.PostRand)
|
|
||||||
|
|
||||||
ok, err := sectorbuilder.ProofVerifier.VerifyElectionPost(ctx, ssize, *sectorInfo, hvrf[:], h.EPostProof.Proof, winners, h.Miner)
|
rt, _, err := api.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates := make([]abi.PoStCandidate, 0, len(h.EPostProof.Candidates))
|
||||||
|
for _, c := range h.EPostProof.Candidates {
|
||||||
|
candidates = append(candidates, abi.PoStCandidate{
|
||||||
|
RegisteredProof: rt,
|
||||||
|
PartialTicket: c.Partial,
|
||||||
|
SectorID: abi.SectorID{Number: c.SectorID}, // this should not be an ID, we already know who the miner is...
|
||||||
|
ChallengeIndex: int64(c.ChallengeIndex),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: why do we need this here?
|
||||||
|
challengeCount := sectorbuilder.ElectionPostChallengeCount(uint64(len(sectorInfo)), 0)
|
||||||
|
|
||||||
|
pvi := abi.PoStVerifyInfo{
|
||||||
|
Randomness: h.EPostProof.PostRand,
|
||||||
|
Candidates: candidates,
|
||||||
|
Proofs: h.EPostProof.Proofs,
|
||||||
|
EligibleSectors: sectorInfo,
|
||||||
|
Prover: abi.ActorID(mid),
|
||||||
|
ChallengeCount: challengeCount,
|
||||||
|
}
|
||||||
|
|
||||||
|
ok, err := sectorbuilder.ProofVerifier.VerifyElectionPost(ctx, pvi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to verify election post: %w", err)
|
return xerrors.Errorf("failed to verify election post: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ type EPostTicket struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EPostProof struct {
|
type EPostProof struct {
|
||||||
Proof []byte
|
Proofs []abi.PoStProof
|
||||||
PostRand []byte
|
PostRand []byte
|
||||||
Candidates []EPostTicket
|
Candidates []EPostTicket
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
@ -27,7 +28,7 @@ func testBlockHeader(t testing.TB) *BlockHeader {
|
|||||||
return &BlockHeader{
|
return &BlockHeader{
|
||||||
Miner: addr,
|
Miner: addr,
|
||||||
EPostProof: EPostProof{
|
EPostProof: EPostProof{
|
||||||
Proof: []byte("pruuf"),
|
Proofs: []abi.PoStProof{{ProofBytes: []byte("pruuf")}},
|
||||||
PostRand: []byte("random"),
|
PostRand: []byte("random"),
|
||||||
},
|
},
|
||||||
Ticket: &Ticket{
|
Ticket: &Ticket{
|
||||||
|
@ -392,16 +392,6 @@ func (t *EPostProof) MarshalCBOR(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// t.Proof ([]uint8) (slice)
|
// t.Proof ([]uint8) (slice)
|
||||||
if len(t.Proof) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.Proof was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.Proof); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.PostRand ([]uint8) (slice)
|
// t.PostRand ([]uint8) (slice)
|
||||||
if len(t.PostRand) > cbg.ByteArrayMaxLen {
|
if len(t.PostRand) > cbg.ByteArrayMaxLen {
|
||||||
@ -459,10 +449,6 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error {
|
|||||||
if maj != cbg.MajByteString {
|
if maj != cbg.MajByteString {
|
||||||
return fmt.Errorf("expected byte array")
|
return fmt.Errorf("expected byte array")
|
||||||
}
|
}
|
||||||
t.Proof = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.Proof); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// t.PostRand ([]uint8) (slice)
|
// t.PostRand ([]uint8) (slice)
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeader(br)
|
maj, extra, err = cbg.CborReadHeader(br)
|
||||||
|
@ -61,7 +61,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
|
|||||||
return &types.BlockHeader{
|
return &types.BlockHeader{
|
||||||
Miner: addr,
|
Miner: addr,
|
||||||
EPostProof: types.EPostProof{
|
EPostProof: types.EPostProof{
|
||||||
Proof: []byte("election post proof proof"),
|
Proofs: []abi.PoStProof{{ProofBytes: []byte("election post proof proof")}},
|
||||||
},
|
},
|
||||||
Ticket: &types.Ticket{
|
Ticket: &types.Ticket{
|
||||||
VRFProof: []byte(fmt.Sprintf("====%d=====", ticketNonce)),
|
VRFProof: []byte(fmt.Sprintf("====%d=====", ticketNonce)),
|
||||||
|
@ -138,8 +138,14 @@ var runCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("get params: %w", err)
|
return xerrors.Errorf("get params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppt, spt, err := api.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
sb, err := sectorbuilder.NewStandalone(§orbuilder.Config{
|
sb, err := sectorbuilder.NewStandalone(§orbuilder.Config{
|
||||||
SectorSize: ssize,
|
SealProofType: spt,
|
||||||
|
PoStProofType: ppt,
|
||||||
Miner: act,
|
Miner: act,
|
||||||
WorkerThreads: workers,
|
WorkerThreads: workers,
|
||||||
Paths: sectorbuilder.SimplePath(r),
|
Paths: sectorbuilder.SimplePath(r),
|
||||||
|
@ -82,13 +82,14 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
|
|||||||
switch task.Type {
|
switch task.Type {
|
||||||
case sectorbuilder.WorkerPreCommit:
|
case sectorbuilder.WorkerPreCommit:
|
||||||
w.limiter.workLimit <- struct{}{}
|
w.limiter.workLimit <- struct{}{}
|
||||||
rspco, err := w.sb.SealPreCommit(ctx, task.SectorNum, task.SealTicket, task.Pieces)
|
sealedCid, unsealedCid, err := w.sb.SealPreCommit(ctx, task.SectorNum, task.SealTicket, task.Pieces)
|
||||||
<-w.limiter.workLimit
|
<-w.limiter.workLimit
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errRes(xerrors.Errorf("precomitting: %w", err))
|
return errRes(xerrors.Errorf("precomitting: %w", err))
|
||||||
}
|
}
|
||||||
res.Rspco = rspco.ToJson()
|
res.Rspco.CommD = unsealedCid
|
||||||
|
res.Rspco.CommR = sealedCid
|
||||||
|
|
||||||
if err := w.push("sealed", task.SectorNum); err != nil {
|
if err := w.push("sealed", task.SectorNum); err != nil {
|
||||||
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
|
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
|
||||||
@ -103,7 +104,7 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
|
|||||||
}
|
}
|
||||||
case sectorbuilder.WorkerCommit:
|
case sectorbuilder.WorkerCommit:
|
||||||
w.limiter.workLimit <- struct{}{}
|
w.limiter.workLimit <- struct{}{}
|
||||||
proof, err := w.sb.SealCommit(ctx, task.SectorNum, task.SealTicket, task.SealSeed, task.Pieces, task.Rspco)
|
proof, err := w.sb.SealCommit(ctx, task.SectorNum, task.SealTicket, task.SealSeed, task.Pieces, task.SealedCID, task.UnsealedCID)
|
||||||
<-w.limiter.workLimit
|
<-w.limiter.workLimit
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -5,15 +5,16 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
crypto2 "github.com/filecoin-project/specs-actors/actors/crypto"
|
crypto2 "github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
@ -181,8 +182,14 @@ var initCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppt, spt, err := lapi.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
oldsb, err := sectorbuilder.New(§orbuilder.Config{
|
oldsb, err := sectorbuilder.New(§orbuilder.Config{
|
||||||
SectorSize: ssize,
|
SealProofType: spt,
|
||||||
|
PoStProofType: ppt,
|
||||||
WorkerThreads: 2,
|
WorkerThreads: 2,
|
||||||
Paths: sectorbuilder.SimplePath(pssb),
|
Paths: sectorbuilder.SimplePath(pssb),
|
||||||
}, namespace.Wrap(oldmds, datastore.NewKey("/sectorbuilder")))
|
}, namespace.Wrap(oldmds, datastore.NewKey("/sectorbuilder")))
|
||||||
@ -191,7 +198,8 @@ var initCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsb, err := sectorbuilder.New(§orbuilder.Config{
|
nsb, err := sectorbuilder.New(§orbuilder.Config{
|
||||||
SectorSize: ssize,
|
SealProofType: spt,
|
||||||
|
PoStProofType: ppt,
|
||||||
WorkerThreads: 2,
|
WorkerThreads: 2,
|
||||||
Paths: sectorbuilder.SimplePath(lr.Path()),
|
Paths: sectorbuilder.SimplePath(lr.Path()),
|
||||||
}, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
|
}, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
|
||||||
@ -250,6 +258,8 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, metadata string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("finding storage deal for pre-sealed sector %d: %w", sector.SectorID, err)
|
return xerrors.Errorf("finding storage deal for pre-sealed sector %d: %w", sector.SectorID, err)
|
||||||
}
|
}
|
||||||
|
commD := sector.CommD
|
||||||
|
commR := sector.CommR
|
||||||
|
|
||||||
info := &sealing.SectorInfo{
|
info := &sealing.SectorInfo{
|
||||||
State: lapi.Proving,
|
State: lapi.Proving,
|
||||||
@ -258,15 +268,15 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, metadata string,
|
|||||||
{
|
{
|
||||||
DealID: &dealID,
|
DealID: &dealID,
|
||||||
Size: abi.PaddedPieceSize(meta.SectorSize).Unpadded(),
|
Size: abi.PaddedPieceSize(meta.SectorSize).Unpadded(),
|
||||||
CommP: sector.CommD[:],
|
CommP: sector.CommD,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CommD: sector.CommD[:],
|
CommD: &commD,
|
||||||
CommR: sector.CommR[:],
|
CommR: &commR,
|
||||||
Proof: nil,
|
Proof: nil,
|
||||||
Ticket: sealing.SealTicket{},
|
Ticket: lapi.SealTicket{},
|
||||||
PreCommitMessage: nil,
|
PreCommitMessage: nil,
|
||||||
Seed: sealing.SealSeed{},
|
Seed: lapi.SealSeed{},
|
||||||
CommitMessage: nil,
|
CommitMessage: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
@ -78,10 +79,10 @@ var sectorsStatusCmd = &cli.Command{
|
|||||||
fmt.Printf("Status:\t%s\n", api.SectorStates[status.State])
|
fmt.Printf("Status:\t%s\n", api.SectorStates[status.State])
|
||||||
fmt.Printf("CommD:\t\t%x\n", status.CommD)
|
fmt.Printf("CommD:\t\t%x\n", status.CommD)
|
||||||
fmt.Printf("CommR:\t\t%x\n", status.CommR)
|
fmt.Printf("CommR:\t\t%x\n", status.CommR)
|
||||||
fmt.Printf("Ticket:\t\t%x\n", status.Ticket.TicketBytes)
|
fmt.Printf("Ticket:\t\t%x\n", status.Ticket.Value)
|
||||||
fmt.Printf("TicketH:\t\t%d\n", status.Ticket.BlockHeight)
|
fmt.Printf("TicketH:\t\t%d\n", status.Ticket.Epoch)
|
||||||
fmt.Printf("Seed:\t\t%x\n", status.Seed.TicketBytes)
|
fmt.Printf("Seed:\t\t%x\n", status.Seed.Value)
|
||||||
fmt.Printf("SeedH:\t\t%d\n", status.Seed.BlockHeight)
|
fmt.Printf("SeedH:\t\t%d\n", status.Seed.Epoch)
|
||||||
fmt.Printf("Proof:\t\t%x\n", status.Proof)
|
fmt.Printf("Proof:\t\t%x\n", status.Proof)
|
||||||
fmt.Printf("Deals:\t\t%v\n", status.Deals)
|
fmt.Printf("Deals:\t\t%v\n", status.Deals)
|
||||||
fmt.Printf("Retries:\t\t%d\n", status.Retries)
|
fmt.Printf("Retries:\t\t%d\n", status.Retries)
|
||||||
@ -170,8 +171,8 @@ var sectorsListCmd = &cli.Command{
|
|||||||
api.SectorStates[st.State],
|
api.SectorStates[st.State],
|
||||||
yesno(inSSet),
|
yesno(inSSet),
|
||||||
yesno(inPSet),
|
yesno(inPSet),
|
||||||
st.Ticket.BlockHeight,
|
st.Ticket.Epoch,
|
||||||
st.Seed.BlockHeight,
|
st.Seed.Epoch,
|
||||||
st.Deals,
|
st.Deals,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
4
go.mod
4
go.mod
@ -18,10 +18,10 @@ require (
|
|||||||
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
||||||
github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce
|
github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce
|
||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
||||||
github.com/filecoin-project/go-fil-markets v0.0.0-20200223154807-f7afd8e927f9
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200227194154-8ef88c730c81
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
||||||
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663
|
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663
|
||||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200226210935-4739f8749f56
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200227214225-a550d0267977
|
||||||
github.com/filecoin-project/go-statestore v0.1.0
|
github.com/filecoin-project/go-statestore v0.1.0
|
||||||
github.com/filecoin-project/specs-actors v0.0.0-20200226233922-9ed222007d11
|
github.com/filecoin-project/specs-actors v0.0.0-20200226233922-9ed222007d11
|
||||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||||
|
10
go.sum
10
go.sum
@ -116,6 +116,10 @@ github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5 h1
|
|||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5/go.mod h1:JbkIgFF/Z9BDlvrJO1FuKkaWsH673/UdFaiVS6uIHlA=
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5/go.mod h1:JbkIgFF/Z9BDlvrJO1FuKkaWsH673/UdFaiVS6uIHlA=
|
||||||
github.com/filecoin-project/go-fil-markets v0.0.0-20200223154807-f7afd8e927f9 h1:uFS5r3K3AgIuR7cGBYY8k+vgwn/UXhin9NR2yCXVe7o=
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200223154807-f7afd8e927f9 h1:uFS5r3K3AgIuR7cGBYY8k+vgwn/UXhin9NR2yCXVe7o=
|
||||||
github.com/filecoin-project/go-fil-markets v0.0.0-20200223154807-f7afd8e927f9/go.mod h1:ftsiBbjLjNLAZ52FVDigkdCp73ltdcvAzAXav6drSLA=
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200223154807-f7afd8e927f9/go.mod h1:ftsiBbjLjNLAZ52FVDigkdCp73ltdcvAzAXav6drSLA=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200227185910-091d5f0ab546 h1:wIrzVUX4TZ56WMbTpl9cNr/XRyTfI9RTc3GfFxUtznA=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200227185910-091d5f0ab546/go.mod h1:f272JjgKXzn2OxdlmVhq6CjvlX5FfV743TvWLirsDpk=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200227194154-8ef88c730c81 h1:3jFhWp4lC7irXg/d4Q4p3FQtw0m8hne+9GHveViCM04=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.0.0-20200227194154-8ef88c730c81/go.mod h1:rfRwhd3ujcCXnD4N9oEM2wjh8GRZGoeNXME+UPG/9ts=
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6 h1:92PET+sx1Hb4W/8CgFwGuxaKbttwY+UNspYZTvXY0vs=
|
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6 h1:92PET+sx1Hb4W/8CgFwGuxaKbttwY+UNspYZTvXY0vs=
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6/go.mod h1:0HgYnrkeSU4lu1p+LEOeDpFsNBssa0OGGriWdA4hvaE=
|
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6/go.mod h1:0HgYnrkeSU4lu1p+LEOeDpFsNBssa0OGGriWdA4hvaE=
|
||||||
github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878/go.mod h1:40kI2Gv16mwcRsHptI3OAV4nlOEU7wVDc4RgMylNFjU=
|
github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878/go.mod h1:40kI2Gv16mwcRsHptI3OAV4nlOEU7wVDc4RgMylNFjU=
|
||||||
@ -129,6 +133,12 @@ github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200224193134-7d37ec0f772
|
|||||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200224193134-7d37ec0f7723/go.mod h1:u8n91UJUua9zEiyAPw8wRAgUEoyTH8BBM9LWJ5WuxOM=
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200224193134-7d37ec0f7723/go.mod h1:u8n91UJUua9zEiyAPw8wRAgUEoyTH8BBM9LWJ5WuxOM=
|
||||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200226210935-4739f8749f56 h1:CqldkHf9HtAsewneyOZdi19Btc6kEvktVVeZsP9N7NQ=
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200226210935-4739f8749f56 h1:CqldkHf9HtAsewneyOZdi19Btc6kEvktVVeZsP9N7NQ=
|
||||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200226210935-4739f8749f56/go.mod h1:tzTc9BxxSbjlIzhFwm5h9oBkXKkRuLxeiWspntwnKyw=
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200226210935-4739f8749f56/go.mod h1:tzTc9BxxSbjlIzhFwm5h9oBkXKkRuLxeiWspntwnKyw=
|
||||||
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200227214127-332d57b390aa h1:EVToQ5L+49psMvYP5ICsOcFRua79oDMyYQAeEqxkzwU=
|
||||||
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200227214127-332d57b390aa/go.mod h1:u8n91UJUua9zEiyAPw8wRAgUEoyTH8BBM9LWJ5WuxOM=
|
||||||
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200227214225-a550d0267977 h1:Q4VnMiorS/AcZMDHtoi+7lVzkTj+qDa0bmgMkwmvxIM=
|
||||||
|
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200227214225-a550d0267977/go.mod h1:tzTc9BxxSbjlIzhFwm5h9oBkXKkRuLxeiWspntwnKyw=
|
||||||
|
github.com/filecoin-project/go-statemachine v0.0.0-20200226041606-2074af6d51d9 h1:k9qVR9ItcziSB2rxtlkN/MDWNlbsI6yzec+zjUatLW0=
|
||||||
|
github.com/filecoin-project/go-statemachine v0.0.0-20200226041606-2074af6d51d9/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
|
||||||
github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ=
|
github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ=
|
||||||
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
|
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
|
||||||
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf h1:fbxBG12yrxilPFV1EG2lYqpUyAlRZWkvtqjk2svSeXY=
|
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf h1:fbxBG12yrxilPFV1EG2lYqpUyAlRZWkvtqjk2svSeXY=
|
||||||
|
@ -31,7 +31,7 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID uin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpn.sb.ReadPieceFromSealedSector(ctx, abi.SectorNumber(sectorID), sectorbuilder.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.Ticket.TicketBytes, si.CommD)
|
return rpn.sb.ReadPieceFromSealedSector(ctx, abi.SectorNumber(sectorID), sectorbuilder.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.Ticket.Value, *si.CommD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount) (abi.TokenAmount, error) {
|
func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount) (abi.TokenAmount, error) {
|
||||||
|
@ -76,6 +76,17 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed getting miner worker: %w", err)
|
return nil, xerrors.Errorf("failed getting miner worker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize, err := a.StateMinerSectorSize(ctx, miner, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed checking miners sector size: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rt, _, err := api.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("bad sector size: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
providerInfo := utils.NewStorageProviderInfo(miner, mw, 0, pid)
|
providerInfo := utils.NewStorageProviderInfo(miner, mw, 0, pid)
|
||||||
ts, err := a.ChainHead(ctx)
|
ts, err := a.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -92,7 +103,9 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
|
|||||||
ts.Height()+dealStartBuffer,
|
ts.Height()+dealStartBuffer,
|
||||||
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
|
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
|
||||||
epochPrice,
|
epochPrice,
|
||||||
big.Zero())
|
big.Zero(),
|
||||||
|
rt,
|
||||||
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to start deal: %w", err)
|
return nil, xerrors.Errorf("failed to start deal: %w", err)
|
||||||
|
@ -67,7 +67,8 @@ func (a *PaychAPI) PaychNewPayment(ctx context.Context, from, to address.Address
|
|||||||
Lane: uint64(lane),
|
Lane: uint64(lane),
|
||||||
|
|
||||||
Extra: v.Extra,
|
Extra: v.Extra,
|
||||||
TimeLock: v.TimeLock,
|
TimeLockMin: v.TimeLockMin,
|
||||||
|
TimeLockMax: v.TimeLockMax,
|
||||||
MinSettleHeight: v.MinSettle,
|
MinSettleHeight: v.MinSettle,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,13 +3,14 @@ package impl
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
files "github.com/ipfs/go-ipfs-files"
|
files "github.com/ipfs/go-ipfs-files"
|
||||||
@ -209,8 +210,8 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumb
|
|||||||
CommR: info.CommR,
|
CommR: info.CommR,
|
||||||
Proof: info.Proof,
|
Proof: info.Proof,
|
||||||
Deals: deals,
|
Deals: deals,
|
||||||
Ticket: info.Ticket.SB(),
|
Ticket: info.Ticket,
|
||||||
Seed: info.Seed.SB(),
|
Seed: info.Seed,
|
||||||
Retries: info.Nonce,
|
Retries: info.Nonce,
|
||||||
|
|
||||||
LastErr: info.LastErr,
|
LastErr: info.LastErr,
|
||||||
|
@ -3,6 +3,7 @@ package modules
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
|
|
||||||
"github.com/ipfs/go-bitswap"
|
"github.com/ipfs/go-bitswap"
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
||||||
storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
||||||
smnet "github.com/filecoin-project/go-fil-markets/storagemarket/network"
|
smnet "github.com/filecoin-project/go-fil-markets/storagemarket/network"
|
||||||
|
"github.com/filecoin-project/go-fil-markets/storedcounter"
|
||||||
"github.com/filecoin-project/go-statestore"
|
"github.com/filecoin-project/go-statestore"
|
||||||
"github.com/ipfs/go-bitswap"
|
"github.com/ipfs/go-bitswap"
|
||||||
"github.com/ipfs/go-bitswap/network"
|
"github.com/ipfs/go-bitswap/network"
|
||||||
@ -117,8 +118,9 @@ func StorageClient(h host.Host, ibs dtypes.ClientBlockstore, r repo.LockedRepo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrievalClient creates a new retrieval client attached to the client blockstore
|
// RetrievalClient creates a new retrieval client attached to the client blockstore
|
||||||
func RetrievalClient(h host.Host, bs dtypes.ClientBlockstore, pmgr *paychmgr.Manager, payapi payapi.PaychAPI, resolver retrievalmarket.PeerResolver) retrievalmarket.RetrievalClient {
|
func RetrievalClient(h host.Host, bs dtypes.ClientBlockstore, pmgr *paychmgr.Manager, payapi payapi.PaychAPI, resolver retrievalmarket.PeerResolver, ds dtypes.MetadataDS) (retrievalmarket.RetrievalClient, error) {
|
||||||
adapter := retrievaladapter.NewRetrievalClientNode(pmgr, payapi)
|
adapter := retrievaladapter.NewRetrievalClientNode(pmgr, payapi)
|
||||||
network := rmnet.NewFromLibp2pHost(h)
|
network := rmnet.NewFromLibp2pHost(h)
|
||||||
return retrievalimpl.NewClient(network, bs, adapter, resolver)
|
sc := storedcounter.New(ds, datastore.NewKey("/retr"))
|
||||||
|
return retrievalimpl.NewClient(network, bs, adapter, resolver, ds, sc)
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@ package modules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
dtgraphsync "github.com/filecoin-project/go-data-transfer/impl/graphsync"
|
dtgraphsync "github.com/filecoin-project/go-data-transfer/impl/graphsync"
|
||||||
piecefilestore "github.com/filecoin-project/go-fil-markets/filestore"
|
piecefilestore "github.com/filecoin-project/go-fil-markets/filestore"
|
||||||
@ -21,6 +22,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/go-sectorbuilder/fs"
|
"github.com/filecoin-project/go-sectorbuilder/fs"
|
||||||
"github.com/filecoin-project/go-statestore"
|
"github.com/filecoin-project/go-statestore"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"github.com/ipfs/go-bitswap"
|
"github.com/ipfs/go-bitswap"
|
||||||
"github.com/ipfs/go-bitswap/network"
|
"github.com/ipfs/go-bitswap/network"
|
||||||
@ -61,7 +63,12 @@ func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetParams(sbc *sectorbuilder.Config) error {
|
func GetParams(sbc *sectorbuilder.Config) error {
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(sbc.SectorSize)); err != nil {
|
ssize, err := sbc.SealProofType.SectorSize()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,13 +76,13 @@ func GetParams(sbc *sectorbuilder.Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SectorBuilderConfig(storage []fs.PathConfig, threads uint, noprecommit, nocommit bool) func(dtypes.MetadataDS, api.FullNode) (*sectorbuilder.Config, error) {
|
func SectorBuilderConfig(storage []fs.PathConfig, threads uint, noprecommit, nocommit bool) func(dtypes.MetadataDS, api.FullNode) (*sectorbuilder.Config, error) {
|
||||||
return func(ds dtypes.MetadataDS, api api.FullNode) (*sectorbuilder.Config, error) {
|
return func(ds dtypes.MetadataDS, fnapi api.FullNode) (*sectorbuilder.Config, error) {
|
||||||
minerAddr, err := minerAddrFromDS(ds)
|
minerAddr, err := minerAddrFromDS(ds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize, err := api.StateMinerSectorSize(context.TODO(), minerAddr, types.EmptyTSK)
|
ssize, err := fnapi.StateMinerSectorSize(context.TODO(), minerAddr, types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -91,9 +98,15 @@ func SectorBuilderConfig(storage []fs.PathConfig, threads uint, noprecommit, noc
|
|||||||
return nil, xerrors.Errorf("too many sectorbuilder threads specified: %d, max allowed: %d", threads, math.MaxUint8)
|
return nil, xerrors.Errorf("too many sectorbuilder threads specified: %d, max allowed: %d", threads, math.MaxUint8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppt, spt, err := api.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("bad sector size: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
sb := §orbuilder.Config{
|
sb := §orbuilder.Config{
|
||||||
Miner: minerAddr,
|
Miner: minerAddr,
|
||||||
SectorSize: ssize,
|
SealProofType: spt,
|
||||||
|
PoStProofType: ppt,
|
||||||
|
|
||||||
WorkerThreads: uint8(threads),
|
WorkerThreads: uint8(threads),
|
||||||
NoPreCommit: noprecommit,
|
NoPreCommit: noprecommit,
|
||||||
@ -267,26 +280,21 @@ func SectorBuilder(cfg *sectorbuilder.Config, ds dtypes.MetadataDS) (*sectorbuil
|
|||||||
return sb, nil
|
return sb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SealTicketGen(api api.FullNode) sealing.TicketFn {
|
func SealTicketGen(fapi api.FullNode) sealing.TicketFn {
|
||||||
return func(ctx context.Context) (*sectorbuilder.SealTicket, error) {
|
return func(ctx context.Context) (*api.SealTicket, error) {
|
||||||
ts, err := api.ChainHead(ctx)
|
ts, err := fapi.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("getting head ts for SealTicket failed: %w", err)
|
return nil, xerrors.Errorf("getting head ts for SealTicket failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := api.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_SealRandomness, ts.Height()-build.SealRandomnessLookback, nil)
|
r, err := fapi.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_SealRandomness, ts.Height()-build.SealRandomnessLookback, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("getting randomness for SealTicket failed: %w", err)
|
return nil, xerrors.Errorf("getting randomness for SealTicket failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tkt [sectorbuilder.CommLen]byte
|
return &api.SealTicket{
|
||||||
if n := copy(tkt[:], r); n != sectorbuilder.CommLen {
|
Epoch: ts.Height() - build.SealRandomnessLookback,
|
||||||
return nil, xerrors.Errorf("unexpected randomness len: %d (expected %d)", n, sectorbuilder.CommLen)
|
Value: abi.SealRandomness(r),
|
||||||
}
|
|
||||||
|
|
||||||
return §orbuilder.SealTicket{
|
|
||||||
BlockHeight: uint64(ts.Height() - build.SealRandomnessLookback),
|
|
||||||
TicketBytes: tkt,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,7 +303,7 @@ func NewProviderRequestValidator(deals dtypes.ProviderDealStore) *storageimpl.Pr
|
|||||||
return storageimpl.NewProviderRequestValidator(deals)
|
return storageimpl.NewProviderRequestValidator(deals)
|
||||||
}
|
}
|
||||||
|
|
||||||
func StorageProvider(h host.Host, ds dtypes.MetadataDS, ibs dtypes.StagingBlockstore, r repo.LockedRepo, pieceStore dtypes.ProviderPieceStore, dataTransfer dtypes.ProviderDataTransfer, spn storagemarket.StorageProviderNode) (storagemarket.StorageProvider, error) {
|
func StorageProvider(ctx helpers.MetricsCtx, fapi api.FullNode, h host.Host, ds dtypes.MetadataDS, ibs dtypes.StagingBlockstore, r repo.LockedRepo, pieceStore dtypes.ProviderPieceStore, dataTransfer dtypes.ProviderDataTransfer, spn storagemarket.StorageProviderNode) (storagemarket.StorageProvider, error) {
|
||||||
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
|
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -305,11 +313,23 @@ func StorageProvider(h host.Host, ds dtypes.MetadataDS, ibs dtypes.StagingBlocks
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
minerAddress, err := address.NewFromBytes(addr)
|
minerAddress, err := address.NewFromBytes(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return storageimpl.NewProvider(net, ds, ibs, store, pieceStore, dataTransfer, spn, minerAddress)
|
|
||||||
|
ssize, err := fapi.StateMinerSectorSize(ctx, minerAddress, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rt, _, err := api.ProofTypeFromSectorSize(ssize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageimpl.NewProvider(net, ds, ibs, store, pieceStore, dataTransfer, spn, minerAddress, rt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrievalProvider creates a new retrieval provider attached to the provider blockstore
|
// RetrievalProvider creates a new retrieval provider attached to the provider blockstore
|
||||||
@ -320,5 +340,5 @@ func RetrievalProvider(h host.Host, miner *storage.Miner, sb sectorbuilder.Inter
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
network := rmnet.NewFromLibp2pHost(h)
|
network := rmnet.NewFromLibp2pHost(h)
|
||||||
return retrievalimpl.NewProvider(address, adapter, network, pieceStore, ibs), nil
|
return retrievalimpl.NewProvider(address, adapter, network, pieceStore, ibs, ds)
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
@ -91,7 +89,7 @@ func (s *FPoStScheduler) declareFaults(ctx context.Context, fc uint64, params *m
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.SortedPublicSectorInfo) ([]abi.SectorNumber, error) {
|
func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi []abi.SectorNumber) ([]abi.SectorNumber, error) {
|
||||||
faults := s.sb.Scrub(ssi)
|
faults := s.sb.Scrub(ssi)
|
||||||
|
|
||||||
declaredFaults := map[abi.SectorNumber]struct{}{}
|
declaredFaults := map[abi.SectorNumber]struct{}{}
|
||||||
@ -160,21 +158,23 @@ func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *ty
|
|||||||
"eps", eps,
|
"eps", eps,
|
||||||
"height", ts.Height())
|
"height", ts.Height())
|
||||||
|
|
||||||
faults, err := s.checkFaults(ctx, ssi)
|
var snums []abi.SectorNumber
|
||||||
|
for _, si := range ssi {
|
||||||
|
snums = append(snums, si.SectorNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
faults, err := s.checkFaults(ctx, snums)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to declare faults: %+v", err)
|
log.Errorf("Failed to declare faults: %+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tsStart := time.Now()
|
tsStart := time.Now()
|
||||||
|
|
||||||
var seed [32]byte
|
|
||||||
copy(seed[:], rand)
|
|
||||||
|
|
||||||
log.Infow("generating fPoSt",
|
log.Infow("generating fPoSt",
|
||||||
"sectors", len(ssi.Values()),
|
"sectors", len(ssi),
|
||||||
"faults", len(faults))
|
"faults", len(faults))
|
||||||
|
|
||||||
scandidates, proof, err := s.sb.GenerateFallbackPoSt(ssi, seed, faults)
|
scandidates, proof, err := s.sb.GenerateFallbackPoSt(ssi, abi.PoStRandomness(rand), faults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("running post failed: %w", err)
|
return nil, xerrors.Errorf("running post failed: %w", err)
|
||||||
}
|
}
|
||||||
@ -182,55 +182,43 @@ func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *ty
|
|||||||
elapsed := time.Since(tsStart)
|
elapsed := time.Since(tsStart)
|
||||||
log.Infow("submitting PoSt", "pLen", len(proof), "elapsed", elapsed)
|
log.Infow("submitting PoSt", "pLen", len(proof), "elapsed", elapsed)
|
||||||
|
|
||||||
mid, err := address.IDFromAddress(s.actor)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
candidates := make([]abi.PoStCandidate, len(scandidates))
|
candidates := make([]abi.PoStCandidate, len(scandidates))
|
||||||
for i, sc := range scandidates {
|
for i, sc := range scandidates {
|
||||||
part := make([]byte, 32)
|
part := make([]byte, 32)
|
||||||
copy(part, sc.PartialTicket[:])
|
copy(part, sc.Candidate.PartialTicket[:])
|
||||||
candidates[i] = abi.PoStCandidate{
|
candidates[i] = abi.PoStCandidate{
|
||||||
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
|
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
|
||||||
PartialTicket: part,
|
PartialTicket: part,
|
||||||
SectorID: abi.SectorID{
|
SectorID: sc.Candidate.SectorID,
|
||||||
Miner: abi.ActorID(mid),
|
ChallengeIndex: sc.Candidate.ChallengeIndex,
|
||||||
Number: sc.SectorNum,
|
|
||||||
},
|
|
||||||
ChallengeIndex: int64(sc.SectorChallengeIndex), // TODO: fix spec
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &abi.OnChainPoStVerifyInfo{
|
return &abi.OnChainPoStVerifyInfo{
|
||||||
ProofType: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
|
Proofs: proof,
|
||||||
Proofs: []abi.PoStProof{{proof}},
|
|
||||||
Candidates: candidates,
|
Candidates: candidates,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet) (sectorbuilder.SortedPublicSectorInfo, error) {
|
func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet) ([]abi.SectorInfo, error) {
|
||||||
sset, err := s.api.StateMinerProvingSet(ctx, s.actor, ts.Key())
|
sset, err := s.api.StateMinerProvingSet(ctx, s.actor, ts.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sectorbuilder.SortedPublicSectorInfo{}, xerrors.Errorf("failed to get proving set for miner (tsH: %d): %w", ts.Height(), err)
|
return nil, xerrors.Errorf("failed to get proving set for miner (tsH: %d): %w", ts.Height(), err)
|
||||||
}
|
}
|
||||||
if len(sset) == 0 {
|
if len(sset) == 0 {
|
||||||
log.Warn("empty proving set! (ts.H: %d)", ts.Height())
|
log.Warn("empty proving set! (ts.H: %d)", ts.Height())
|
||||||
}
|
}
|
||||||
|
|
||||||
sbsi := make([]ffi.PublicSectorInfo, len(sset))
|
sbsi := make([]abi.SectorInfo, len(sset))
|
||||||
for k, sector := range sset {
|
for k, sector := range sset {
|
||||||
var commR [sectorbuilder.CommLen]byte
|
|
||||||
scid := sector.Info.Info.SealedCID.Bytes()
|
|
||||||
copy(commR[:], scid[len(scid)-32:])
|
|
||||||
|
|
||||||
sbsi[k] = ffi.PublicSectorInfo{
|
sbsi[k] = abi.SectorInfo{
|
||||||
SectorNum: sector.Info.Info.SectorNumber,
|
SectorNumber: sector.Info.Info.SectorNumber,
|
||||||
CommR: commR,
|
SealedCID: sector.Info.Info.SealedCID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sectorbuilder.NewSortedPublicSectorInfo(sbsi), nil
|
return sbsi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FPoStScheduler) submitPost(ctx context.Context, proof *abi.OnChainPoStVerifyInfo) error {
|
func (s *FPoStScheduler) submitPost(ctx context.Context, proof *abi.OnChainPoStVerifyInfo) error {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
@ -127,13 +128,11 @@ func NewElectionPoStProver(sb sectorbuilder.Interface) *SectorBuilderEpp {
|
|||||||
|
|
||||||
var _ gen.ElectionPoStProver = (*SectorBuilderEpp)(nil)
|
var _ gen.ElectionPoStProver = (*SectorBuilderEpp)(nil)
|
||||||
|
|
||||||
func (epp *SectorBuilderEpp) GenerateCandidates(ctx context.Context, ssi sectorbuilder.SortedPublicSectorInfo, rand []byte) ([]sectorbuilder.EPostCandidate, error) {
|
func (epp *SectorBuilderEpp) GenerateCandidates(ctx context.Context, ssi []abi.SectorInfo, rand abi.PoStRandomness) ([]ffi.PoStCandidateWithTicket, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
var faults []abi.SectorNumber // TODO
|
var faults []abi.SectorNumber // TODO
|
||||||
|
|
||||||
var randbuf [32]byte
|
cds, err := epp.sb.GenerateEPostCandidates(ssi, rand, faults)
|
||||||
copy(randbuf[:], rand)
|
|
||||||
cds, err := epp.sb.GenerateEPostCandidates(ssi, randbuf, faults)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -141,13 +140,19 @@ func (epp *SectorBuilderEpp) GenerateCandidates(ctx context.Context, ssi sectorb
|
|||||||
return cds, nil
|
return cds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (epp *SectorBuilderEpp) ComputeProof(ctx context.Context, ssi sectorbuilder.SortedPublicSectorInfo, rand []byte, winners []sectorbuilder.EPostCandidate) ([]byte, error) {
|
func (epp *SectorBuilderEpp) ComputeProof(ctx context.Context, ssi []abi.SectorInfo, rand []byte, winners []ffi.PoStCandidateWithTicket) ([]abi.PoStProof, error) {
|
||||||
if build.InsecurePoStValidation {
|
if build.InsecurePoStValidation {
|
||||||
log.Warn("Generating fake EPost proof! You should only see this while running tests!")
|
log.Warn("Generating fake EPost proof! You should only see this while running tests!")
|
||||||
return []byte("valid proof"), nil
|
return []abi.PoStProof{{ProofBytes: []byte("valid proof")}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
owins := make([]abi.PoStCandidate, 0, len(winners))
|
||||||
|
for _, w := range winners {
|
||||||
|
owins = append(owins, w.Candidate)
|
||||||
|
}
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
proof, err := epp.sb.ComputeElectionPoSt(ssi, rand, winners)
|
proof, err := epp.sb.ComputeElectionPoSt(ssi, rand, owins)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -13,282 +13,6 @@ import (
|
|||||||
|
|
||||||
var _ = xerrors.Errorf
|
var _ = xerrors.Errorf
|
||||||
|
|
||||||
func (t *SealTicket) MarshalCBOR(w io.Writer) error {
|
|
||||||
if t == nil {
|
|
||||||
_, err := w.Write(cbg.CborNull)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte{162}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.BlockHeight (abi.ChainEpoch) (int64)
|
|
||||||
if len("BlockHeight") > cbg.MaxLength {
|
|
||||||
return xerrors.Errorf("Value in field \"BlockHeight\" was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("BlockHeight")))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte("BlockHeight")); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if t.BlockHeight >= 0 {
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajNegativeInt, uint64(-t.BlockHeight)-1)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.TicketBytes ([]uint8) (slice)
|
|
||||||
if len("TicketBytes") > cbg.MaxLength {
|
|
||||||
return xerrors.Errorf("Value in field \"TicketBytes\" was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("TicketBytes")))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte("TicketBytes")); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(t.TicketBytes) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.TicketBytes was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.TicketBytes); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
|
||||||
br := cbg.GetPeeker(r)
|
|
||||||
|
|
||||||
maj, extra, err := cbg.CborReadHeader(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if maj != cbg.MajMap {
|
|
||||||
return fmt.Errorf("cbor input should be of type map")
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > cbg.MaxLength {
|
|
||||||
return fmt.Errorf("SealTicket: map struct too large (%d)", extra)
|
|
||||||
}
|
|
||||||
|
|
||||||
var name string
|
|
||||||
n := extra
|
|
||||||
|
|
||||||
for i := uint64(0); i < n; i++ {
|
|
||||||
|
|
||||||
{
|
|
||||||
sval, err := cbg.ReadString(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
name = string(sval)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch name {
|
|
||||||
// t.BlockHeight (abi.ChainEpoch) (int64)
|
|
||||||
case "BlockHeight":
|
|
||||||
{
|
|
||||||
maj, extra, err := cbg.CborReadHeader(br)
|
|
||||||
var extraI int64
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch maj {
|
|
||||||
case cbg.MajUnsignedInt:
|
|
||||||
extraI = int64(extra)
|
|
||||||
if extraI < 0 {
|
|
||||||
return fmt.Errorf("int64 positive overflow")
|
|
||||||
}
|
|
||||||
case cbg.MajNegativeInt:
|
|
||||||
extraI = int64(extra)
|
|
||||||
if extraI < 0 {
|
|
||||||
return fmt.Errorf("int64 negative oveflow")
|
|
||||||
}
|
|
||||||
extraI = -1 - extraI
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.BlockHeight = abi.ChainEpoch(extraI)
|
|
||||||
}
|
|
||||||
// t.TicketBytes ([]uint8) (slice)
|
|
||||||
case "TicketBytes":
|
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeader(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > cbg.ByteArrayMaxLen {
|
|
||||||
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
|
|
||||||
}
|
|
||||||
if maj != cbg.MajByteString {
|
|
||||||
return fmt.Errorf("expected byte array")
|
|
||||||
}
|
|
||||||
t.TicketBytes = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (t *SealSeed) MarshalCBOR(w io.Writer) error {
|
|
||||||
if t == nil {
|
|
||||||
_, err := w.Write(cbg.CborNull)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte{162}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.BlockHeight (abi.ChainEpoch) (int64)
|
|
||||||
if len("BlockHeight") > cbg.MaxLength {
|
|
||||||
return xerrors.Errorf("Value in field \"BlockHeight\" was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("BlockHeight")))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte("BlockHeight")); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if t.BlockHeight >= 0 {
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajNegativeInt, uint64(-t.BlockHeight)-1)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.TicketBytes ([]uint8) (slice)
|
|
||||||
if len("TicketBytes") > cbg.MaxLength {
|
|
||||||
return xerrors.Errorf("Value in field \"TicketBytes\" was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("TicketBytes")))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte("TicketBytes")); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(t.TicketBytes) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.TicketBytes was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.TicketBytes); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
|
||||||
br := cbg.GetPeeker(r)
|
|
||||||
|
|
||||||
maj, extra, err := cbg.CborReadHeader(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if maj != cbg.MajMap {
|
|
||||||
return fmt.Errorf("cbor input should be of type map")
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > cbg.MaxLength {
|
|
||||||
return fmt.Errorf("SealSeed: map struct too large (%d)", extra)
|
|
||||||
}
|
|
||||||
|
|
||||||
var name string
|
|
||||||
n := extra
|
|
||||||
|
|
||||||
for i := uint64(0); i < n; i++ {
|
|
||||||
|
|
||||||
{
|
|
||||||
sval, err := cbg.ReadString(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
name = string(sval)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch name {
|
|
||||||
// t.BlockHeight (abi.ChainEpoch) (int64)
|
|
||||||
case "BlockHeight":
|
|
||||||
{
|
|
||||||
maj, extra, err := cbg.CborReadHeader(br)
|
|
||||||
var extraI int64
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch maj {
|
|
||||||
case cbg.MajUnsignedInt:
|
|
||||||
extraI = int64(extra)
|
|
||||||
if extraI < 0 {
|
|
||||||
return fmt.Errorf("int64 positive overflow")
|
|
||||||
}
|
|
||||||
case cbg.MajNegativeInt:
|
|
||||||
extraI = int64(extra)
|
|
||||||
if extraI < 0 {
|
|
||||||
return fmt.Errorf("int64 negative oveflow")
|
|
||||||
}
|
|
||||||
extraI = -1 - extraI
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.BlockHeight = abi.ChainEpoch(extraI)
|
|
||||||
}
|
|
||||||
// t.TicketBytes ([]uint8) (slice)
|
|
||||||
case "TicketBytes":
|
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeader(br)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > cbg.ByteArrayMaxLen {
|
|
||||||
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
|
|
||||||
}
|
|
||||||
if maj != cbg.MajByteString {
|
|
||||||
return fmt.Errorf("expected byte array")
|
|
||||||
}
|
|
||||||
t.TicketBytes = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (t *Piece) MarshalCBOR(w io.Writer) error {
|
func (t *Piece) MarshalCBOR(w io.Writer) error {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
_, err := w.Write(cbg.CborNull)
|
_, err := w.Write(cbg.CborNull)
|
||||||
@ -620,10 +344,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.Seed.MarshalCBOR(w); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.CommitMessage (cid.Cid) (struct)
|
// t.CommitMessage (cid.Cid) (struct)
|
||||||
if len("CommitMessage") > cbg.MaxLength {
|
if len("CommitMessage") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"CommitMessage\" was too long")
|
return xerrors.Errorf("Value in field \"CommitMessage\" was too long")
|
||||||
@ -903,10 +623,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if err := t.Seed.UnmarshalCBOR(br); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// t.CommitMessage (cid.Cid) (struct)
|
// t.CommitMessage (cid.Cid) (struct)
|
||||||
case "CommitMessage":
|
case "CommitMessage":
|
||||||
|
@ -111,8 +111,8 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se
|
|||||||
return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)}
|
return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if int64(head.Height())-int64(si.Ticket.BlockHeight+build.SealRandomnessLookback) > build.SealRandomnessLookbackLimit {
|
if int64(head.Height())-int64(si.Ticket.Epoch+build.SealRandomnessLookback) > build.SealRandomnessLookbackLimit {
|
||||||
return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.Ticket.BlockHeight+build.SealRandomnessLookback, head.Height())}
|
return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.Ticket.Epoch+build.SealRandomnessLookback, head.Height())}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -68,7 +68,7 @@ func (evt SectorPackingFailed) apply(*SectorInfo) {}
|
|||||||
type SectorSealed struct {
|
type SectorSealed struct {
|
||||||
commR cid.Cid
|
commR cid.Cid
|
||||||
commD cid.Cid
|
commD cid.Cid
|
||||||
ticket SealTicket
|
ticket api.SealTicket
|
||||||
}
|
}
|
||||||
|
|
||||||
func (evt SectorSealed) apply(state *SectorInfo) {
|
func (evt SectorSealed) apply(state *SectorInfo) {
|
||||||
@ -96,7 +96,7 @@ func (evt SectorPreCommitted) apply(state *SectorInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SectorSeedReady struct {
|
type SectorSeedReady struct {
|
||||||
seed SealSeed
|
seed api.SealSeed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (evt SectorSeedReady) apply(state *SectorInfo) {
|
func (evt SectorSeedReady) apply(state *SectorInfo) {
|
||||||
|
@ -75,12 +75,12 @@ func TestSeedRevert(t *testing.T) {
|
|||||||
m.planSingle(SectorSeedReady{})
|
m.planSingle(SectorSeedReady{})
|
||||||
require.Equal(m.t, m.state.State, api.Committing)
|
require.Equal(m.t, m.state.State, api.Committing)
|
||||||
|
|
||||||
_, err := m.s.plan([]statemachine.Event{{SectorSeedReady{seed: SealSeed{BlockHeight: 5}}}, {SectorCommitted{}}}, m.state)
|
_, err := m.s.plan([]statemachine.Event{{SectorSeedReady{seed: api.SealSeed{Epoch: 5}}}, {SectorCommitted{}}}, m.state)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(m.t, m.state.State, api.Committing)
|
require.Equal(m.t, m.state.State, api.Committing)
|
||||||
|
|
||||||
// not changing the seed this time
|
// not changing the seed this time
|
||||||
_, err = m.s.plan([]statemachine.Event{{SectorSeedReady{seed: SealSeed{BlockHeight: 5}}}, {SectorCommitted{}}}, m.state)
|
_, err = m.s.plan([]statemachine.Event{{SectorSeedReady{seed: api.SealSeed{Epoch: 5}}}, {SectorCommitted{}}}, m.state)
|
||||||
require.Equal(m.t, m.state.State, api.CommitWait)
|
require.Equal(m.t, m.state.State, api.CommitWait)
|
||||||
|
|
||||||
m.planSingle(SectorProving{})
|
m.planSingle(SectorProving{})
|
||||||
|
@ -28,7 +28,7 @@ const SectorStorePrefix = "/sectors"
|
|||||||
|
|
||||||
var log = logging.Logger("sectors")
|
var log = logging.Logger("sectors")
|
||||||
|
|
||||||
type TicketFn func(context.Context) (SealTicket, error)
|
type TicketFn func(context.Context) (*api.SealTicket, error)
|
||||||
|
|
||||||
type sealingApi interface { // TODO: trim down
|
type sealingApi interface { // TODO: trim down
|
||||||
// Call a read only method on actors (no interaction with the chain required)
|
// Call a read only method on actors (no interaction with the chain required)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -69,7 +70,7 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
return ctx.Send(SectorSealFailed{xerrors.Errorf("getting ticket failed: %w", err)})
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("getting ticket failed: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed, unsealed, err := m.sb.SealPreCommit(ctx.Context(), sector.SectorID, ticket.TicketBytes, sector.pieceInfos())
|
sealed, unsealed, err := m.sb.SealPreCommit(ctx.Context(), sector.SectorID, ticket.Value, sector.pieceInfos())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Send(SectorSealFailed{xerrors.Errorf("seal pre commit failed: %w", err)})
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("seal pre commit failed: %w", err)})
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
return ctx.Send(SectorSealed{
|
return ctx.Send(SectorSealed{
|
||||||
commD: unsealed,
|
commD: unsealed,
|
||||||
commR: sealed,
|
commR: sealed,
|
||||||
ticket: ticket,
|
ticket: *ticket,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
|||||||
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBSeal,
|
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBSeal,
|
||||||
|
|
||||||
SealedCID: *sector.CommR,
|
SealedCID: *sector.CommR,
|
||||||
SealRandEpoch: sector.Ticket.BlockHeight,
|
SealRandEpoch: sector.Ticket.Epoch,
|
||||||
DealIDs: sector.deals(),
|
DealIDs: sector.deals(),
|
||||||
}
|
}
|
||||||
enc, aerr := actors.SerializeParams(params)
|
enc, aerr := actors.SerializeParams(params)
|
||||||
@ -156,9 +157,9 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Send(SectorSeedReady{seed: SealSeed{
|
ctx.Send(SectorSeedReady{seed: api.SealSeed{
|
||||||
BlockHeight: randHeight,
|
Epoch: randHeight,
|
||||||
TicketBytes: abi.InteractiveSealRandomness(rand),
|
Value: abi.InteractiveSealRandomness(rand),
|
||||||
}})
|
}})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -177,9 +178,9 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
||||||
log.Info("scheduling seal proof computation...")
|
log.Info("scheduling seal proof computation...")
|
||||||
|
|
||||||
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorID, sector.Ticket.TicketBytes, sector.Ticket.BlockHeight, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.pieceInfos(), sector.CommR, sector.CommD)
|
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorID, sector.Ticket.Value, sector.Ticket.Epoch, sector.Seed.Value, sector.Seed.Epoch, sector.pieceInfos(), sector.CommR, sector.CommD)
|
||||||
|
|
||||||
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.TicketBytes, sector.Seed.TicketBytes, sector.pieceInfos(), *sector.CommR, *sector.CommD)
|
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.Value, sector.Seed.Value, sector.pieceInfos(), *sector.CommR, *sector.CommD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})
|
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})
|
||||||
}
|
}
|
||||||
@ -231,7 +232,7 @@ func (m *Sealing) handleCommitWait(ctx statemachine.Context, sector SectorInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if mw.Receipt.ExitCode != 0 {
|
if mw.Receipt.ExitCode != 0 {
|
||||||
return ctx.Send(SectorCommitFailed{xerrors.Errorf("submitting sector proof failed (exit=%d, msg=%s) (t:%x; s:%x(%d); p:%x)", mw.Receipt.ExitCode, sector.CommitMessage, sector.Ticket.TicketBytes, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.Proof)})
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("submitting sector proof failed (exit=%d, msg=%s) (t:%x; s:%x(%d); p:%x)", mw.Receipt.ExitCode, sector.CommitMessage, sector.Ticket.Value, sector.Seed.Value, sector.Seed.Epoch, sector.Proof)})
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.Send(SectorProving{})
|
return ctx.Send(SectorProving{})
|
||||||
|
@ -6,20 +6,6 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SealTicket struct {
|
|
||||||
BlockHeight abi.ChainEpoch
|
|
||||||
TicketBytes abi.SealRandomness
|
|
||||||
}
|
|
||||||
|
|
||||||
type SealSeed struct {
|
|
||||||
BlockHeight abi.ChainEpoch
|
|
||||||
TicketBytes abi.InteractiveSealRandomness
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *SealSeed) Equals(o *SealSeed) bool {
|
|
||||||
return string(t.TicketBytes) == string(o.TicketBytes) && t.BlockHeight == o.BlockHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
type Piece struct {
|
type Piece struct {
|
||||||
DealID *abi.DealID
|
DealID *abi.DealID
|
||||||
|
|
||||||
@ -52,12 +38,12 @@ type SectorInfo struct {
|
|||||||
CommD *cid.Cid
|
CommD *cid.Cid
|
||||||
CommR *cid.Cid
|
CommR *cid.Cid
|
||||||
Proof []byte
|
Proof []byte
|
||||||
Ticket SealTicket
|
Ticket api.SealTicket
|
||||||
|
|
||||||
PreCommitMessage *cid.Cid
|
PreCommitMessage *cid.Cid
|
||||||
|
|
||||||
// WaitSeed
|
// WaitSeed
|
||||||
Seed SealSeed
|
Seed api.SealSeed
|
||||||
|
|
||||||
// Committing
|
// Committing
|
||||||
CommitMessage *cid.Cid
|
CommitMessage *cid.Cid
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
@ -28,12 +29,12 @@ func TestSectorInfoSelialization(t *testing.T) {
|
|||||||
CommD: &dummyCid,
|
CommD: &dummyCid,
|
||||||
CommR: nil,
|
CommR: nil,
|
||||||
Proof: nil,
|
Proof: nil,
|
||||||
Ticket: SealTicket{
|
Ticket: api.SealTicket{
|
||||||
BlockHeight: 345,
|
Epoch: 345,
|
||||||
TicketBytes: []byte{87, 78, 7, 87},
|
Value: []byte{87, 78, 7, 87},
|
||||||
},
|
},
|
||||||
PreCommitMessage: nil,
|
PreCommitMessage: nil,
|
||||||
Seed: SealSeed{},
|
Seed: api.SealSeed{},
|
||||||
CommitMessage: nil,
|
CommitMessage: nil,
|
||||||
FaultReportMsg: nil,
|
FaultReportMsg: nil,
|
||||||
LastErr: "hi",
|
LastErr: "hi",
|
||||||
|
Loading…
Reference in New Issue
Block a user