Get interactive porep sector sealing mostly working
This commit is contained in:
parent
3cde267a2a
commit
fc9091cc89
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
"github.com/filecoin-project/lotus/chain/address"
|
"github.com/filecoin-project/lotus/chain/address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StorageMarketActor struct{}
|
type StorageMarketActor struct{}
|
||||||
@ -605,6 +606,7 @@ func (sma StorageMarketActor) ComputeDataCommitment(act *types.Actor, vmctx type
|
|||||||
return nil, aerrors.HandleExternalError(err, "loading deals amt")
|
return nil, aerrors.HandleExternalError(err, "loading deals amt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pieces []sectorbuilder.PublicPieceInfo
|
||||||
for _, deal := range params.DealIDs {
|
for _, deal := range params.DealIDs {
|
||||||
var dealInfo OnChainDeal
|
var dealInfo OnChainDeal
|
||||||
if err := deals.Get(deal, &dealInfo); err != nil {
|
if err := deals.Get(deal, &dealInfo); err != nil {
|
||||||
@ -614,13 +616,21 @@ func (sma StorageMarketActor) ComputeDataCommitment(act *types.Actor, vmctx type
|
|||||||
return nil, aerrors.HandleExternalError(err, "getting deal info failed")
|
return nil, aerrors.HandleExternalError(err, "getting deal info failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = dealInfo
|
var commP [32]byte
|
||||||
|
copy(commP[:], dealInfo.Deal.Proposal.PieceRef)
|
||||||
|
|
||||||
|
pieces = append(pieces, sectorbuilder.PublicPieceInfo{
|
||||||
|
Size: dealInfo.Deal.Proposal.PieceSize,
|
||||||
|
CommP: commP,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rust-fil-proofs-magic
|
commd, err := sectorbuilder.GenerateDataCommitment(params.SectorSize, pieces)
|
||||||
var commDoutput [32]byte
|
if err != nil {
|
||||||
|
return nil, aerrors.Absorb(err, 4, "failed to generate data commitment from pieces")
|
||||||
|
}
|
||||||
|
|
||||||
return commDoutput[:], nil
|
return commd[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
|
||||||
sectorstate "github.com/filecoin-project/go-sectorbuilder/sealing_state"
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
@ -50,10 +49,13 @@ var infoCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fmt.Println("Sealed Sectors:\t", sinfo.SealedCount)
|
fmt.Println("Sealed Sectors:\t", sinfo.SealedCount)
|
||||||
fmt.Println("Sealing Sectors:\t", sinfo.SealingCount)
|
fmt.Println("Sealing Sectors:\t", sinfo.SealingCount)
|
||||||
fmt.Println("Pending Sectors:\t", sinfo.PendingCount)
|
fmt.Println("Pending Sectors:\t", sinfo.PendingCount)
|
||||||
fmt.Println("Failed Sectors:\t", sinfo.FailedCount)
|
fmt.Println("Failed Sectors:\t", sinfo.FailedCount)
|
||||||
|
*/
|
||||||
|
fmt.Println(sinfo)
|
||||||
|
|
||||||
// TODO: grab actr state / info
|
// TODO: grab actr state / info
|
||||||
// * Sector size
|
// * Sector size
|
||||||
@ -63,22 +65,14 @@ var infoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectorsInfo struct {
|
func sectorsInfo(ctx context.Context, napi api.StorageMiner) (map[string]int, error) {
|
||||||
TotalCount int
|
|
||||||
SealingCount int
|
|
||||||
FailedCount int
|
|
||||||
SealedCount int
|
|
||||||
PendingCount int
|
|
||||||
}
|
|
||||||
|
|
||||||
func sectorsInfo(ctx context.Context, napi api.StorageMiner) (*SectorsInfo, error) {
|
|
||||||
sectors, err := napi.SectorsList(ctx)
|
sectors, err := napi.SectorsList(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
out := SectorsInfo{
|
out := map[string]int{
|
||||||
TotalCount: len(sectors),
|
"Total": len(sectors),
|
||||||
}
|
}
|
||||||
for _, s := range sectors {
|
for _, s := range sectors {
|
||||||
st, err := napi.SectorsStatus(ctx, s)
|
st, err := napi.SectorsStatus(ctx, s)
|
||||||
@ -86,18 +80,8 @@ func sectorsInfo(ctx context.Context, napi api.StorageMiner) (*SectorsInfo, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch st.State {
|
out[st.State.String()]++
|
||||||
case sectorstate.Sealed:
|
|
||||||
out.SealedCount++
|
|
||||||
case sectorstate.Pending:
|
|
||||||
out.PendingCount++
|
|
||||||
case sectorstate.Sealing:
|
|
||||||
out.SealingCount++
|
|
||||||
case sectorstate.Failed:
|
|
||||||
out.FailedCount++
|
|
||||||
case sectorstate.Unknown:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/lotus/peermgr"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/peermgr"
|
||||||
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
2
extern/go-sectorbuilder
vendored
2
extern/go-sectorbuilder
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e8231db9dc64e79f7049e25c538b77b88eef54dc
|
Subproject commit 06775780d8e4db7ba123a7c76073e10d7785b076
|
1
go.sum
1
go.sum
@ -749,6 +749,7 @@ golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 h1:ng0gs1AKnRRuEMZoTLLlbOd+C17zUDepwGQBb/n+JVg=
|
||||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
@ -142,10 +142,7 @@ func VerifySeal(sectorSize uint64, commR, commD []byte, proverID address.Address
|
|||||||
copy(seeda[:], seed)
|
copy(seeda[:], seed)
|
||||||
proverIDa := addressToProverID(proverID)
|
proverIDa := addressToProverID(proverID)
|
||||||
|
|
||||||
return sectorbuilder.VerifySeal(sectorSize, commRa, commDa, proverIDa, ticketa, seeda, sectorID, proof, []sectorbuilder.PublicPieceInfo{{
|
return sectorbuilder.VerifySeal(sectorSize, commRa, commDa, proverIDa, ticketa, seeda, sectorID, proof)
|
||||||
Size: UserBytesForSectorSize(sectorSize), // TODO: Provide the real piece size?
|
|
||||||
CommP: commDa,
|
|
||||||
}})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSortedSectorInfo(sectors []SectorInfo) SortedSectorInfo {
|
func NewSortedSectorInfo(sectors []SectorInfo) SortedSectorInfo {
|
||||||
@ -170,6 +167,10 @@ func GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [CommLen]
|
|||||||
return commP, werr()
|
return commP, werr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateDataCommitment(ssize uint64, pieces []PublicPieceInfo) ([CommLen]byte, error) {
|
||||||
|
return sectorbuilder.GenerateDataCommitment(ssize, pieces)
|
||||||
|
}
|
||||||
|
|
||||||
func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
|
func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
|
||||||
f, ok := r.(*os.File)
|
f, ok := r.(*os.File)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -242,7 +242,6 @@ func Online() Option {
|
|||||||
Override(new(*deals.Provider), deals.NewProvider),
|
Override(new(*deals.Provider), deals.NewProvider),
|
||||||
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
||||||
Override(HandleDealsKey, modules.HandleDeals),
|
Override(HandleDealsKey, modules.HandleDeals),
|
||||||
Override(RunSectorServiceKey, modules.RunSectorService),
|
|
||||||
Override(RegisterMinerKey, modules.RegisterMiner),
|
Override(RegisterMinerKey, modules.RegisterMiner),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||||
"github.com/filecoin-project/lotus/peermgr"
|
"github.com/filecoin-project/lotus/peermgr"
|
||||||
"github.com/filecoin-project/lotus/retrieval/discovery"
|
"github.com/filecoin-project/lotus/retrieval/discovery"
|
||||||
"github.com/filecoin-project/lotus/storage/sector"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) {
|
func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) {
|
||||||
@ -79,19 +78,6 @@ func RunDealClient(mctx helpers.MetricsCtx, lc fx.Lifecycle, c *deals.Client) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunSectorService(lc fx.Lifecycle, secst *sector.Store) {
|
|
||||||
lc.Append(fx.Hook{
|
|
||||||
OnStart: func(context.Context) error {
|
|
||||||
secst.Service()
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
OnStop: func(context.Context) error {
|
|
||||||
secst.Stop()
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func RetrievalResolver(l *discovery.Local) discovery.PeerResolver {
|
func RetrievalResolver(l *discovery.Local) discovery.PeerResolver {
|
||||||
return discovery.Multi(l)
|
return discovery.Multi(l)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.uber.org/fx"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"go.uber.org/fx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option is a functional option which can be used with the New function to
|
// Option is a functional option which can be used with the New function to
|
||||||
|
@ -2,10 +2,11 @@ package peermgr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
|
||||||
host "github.com/libp2p/go-libp2p-core/host"
|
host "github.com/libp2p/go-libp2p-core/host"
|
||||||
net "github.com/libp2p/go-libp2p-core/network"
|
net "github.com/libp2p/go-libp2p-core/network"
|
||||||
peer "github.com/libp2p/go-libp2p-core/peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
@ -43,6 +44,7 @@ type PeerMgr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPeerMgr(h host.Host, dht *dht.IpfsDHT, bootstrap dtypes.BootstrapPeers) *PeerMgr {
|
func NewPeerMgr(h host.Host, dht *dht.IpfsDHT, bootstrap dtypes.BootstrapPeers) *PeerMgr {
|
||||||
|
bootstrap = nil
|
||||||
pm := &PeerMgr{
|
pm := &PeerMgr{
|
||||||
h: h,
|
h: h,
|
||||||
dht: dht,
|
dht: dht,
|
||||||
|
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"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"
|
||||||
@ -12,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
|
func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
|
||||||
log.Info("committing sector")
|
log.Info("committing sector: ", sid)
|
||||||
|
|
||||||
ssize, err := m.SectorSize(ctx)
|
ssize, err := m.SectorSize(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -21,6 +22,11 @@ func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
|
|||||||
|
|
||||||
_ = ssize
|
_ = ssize
|
||||||
|
|
||||||
|
log.Info("performing sector replication...")
|
||||||
|
if err := m.secst.SealPreCommit(ctx, sid); err != nil {
|
||||||
|
return xerrors.Errorf("seal pre commit failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
sinfo, err := m.secst.SectorStatus(sid)
|
sinfo, err := m.secst.SectorStatus(sid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to check status for sector %d: %w", sid, err)
|
return xerrors.Errorf("failed to check status for sector %d: %w", sid, err)
|
||||||
@ -49,6 +55,7 @@ func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
|
|||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("submitting precommit for sector: ", sid)
|
||||||
smsg, err := m.api.MpoolPushMessage(ctx, msg)
|
smsg, err := m.api.MpoolPushMessage(ctx, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "pushing message to mpool")
|
return errors.Wrap(err, "pushing message to mpool")
|
||||||
@ -67,7 +74,13 @@ func (m *Miner) waitForPreCommitMessage(ctx context.Context, sid uint64, mcid ci
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mw.Receipt.ExitCode != 0 {
|
||||||
|
log.Error("sector precommit failed: ", mw.Receipt.ExitCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
randHeight := mw.TipSet.Height() + build.InteractivePoRepDelay
|
randHeight := mw.TipSet.Height() + build.InteractivePoRepDelay
|
||||||
|
log.Infof("precommit for sector %d made it on chain, will start post computation at height %d", sid, randHeight)
|
||||||
|
|
||||||
err = m.events.ChainAt(func(ts *types.TipSet, curH uint64) error {
|
err = m.events.ChainAt(func(ts *types.TipSet, curH uint64) error {
|
||||||
return m.scheduleComputeProof(ctx, sid, ts, randHeight)
|
return m.scheduleComputeProof(ctx, sid, ts, randHeight)
|
||||||
@ -81,16 +94,17 @@ func (m *Miner) waitForPreCommitMessage(ctx context.Context, sid uint64, mcid ci
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) scheduleComputeProof(ctx context.Context, sid uint64, ts *types.TipSet, rheight uint64) error {
|
func (m *Miner) scheduleComputeProof(ctx context.Context, sid uint64, ts *types.TipSet, rheight uint64) error {
|
||||||
|
log.Info("scheduling post computation...")
|
||||||
go func() {
|
go func() {
|
||||||
rand, err := m.api.ChainGetRandomness(ctx, ts, nil, int(ts.Height()-rheight))
|
rand, err := m.api.ChainGetRandomness(ctx, ts, nil, int(ts.Height()-rheight))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(errors.Errorf("failed to get randomness for computing seal proof: %w", err))
|
log.Error(fmt.Errorf("failed to get randomness for computing seal proof: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proof, err := m.secst.SealComputeProof(ctx, sid, rand)
|
proof, err := m.secst.SealComputeProof(ctx, sid, rheight, rand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(errors.Errorf("computing seal proof failed: %w", err))
|
log.Error(fmt.Errorf("computing seal proof failed: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +191,18 @@ func (s *Store) SealPreCommit(ctx context.Context, sectorID uint64) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) SealComputeProof(ctx context.Context, sectorID uint64, rand []byte) ([]byte, error) {
|
func (s *Store) SealComputeProof(ctx context.Context, sectorID uint64, height uint64, rand []byte) ([]byte, error) {
|
||||||
panic("TODO")
|
var tick [32]byte
|
||||||
|
copy(tick[:], rand)
|
||||||
|
|
||||||
|
sco, err := s.sb.SealCommit(sectorID, sectorbuilder.SealSeed{
|
||||||
|
BlockHeight: height,
|
||||||
|
TicketBytes: tick,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sco.Proof, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) WaitSeal(ctx context.Context, sector uint64) (sectorbuilder.SectorSealingStatus, error) {
|
func (s *Store) WaitSeal(ctx context.Context, sector uint64) (sectorbuilder.SectorSealingStatus, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user