diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 864050170..aed867c1e 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -68,7 +68,7 @@ var infoCmd = &cli.Command{ if err != nil { return err } - pdiff := ppe-head.Height() + pdiff := int64(ppe-head.Height()) pdifft := pdiff * build.BlockDelay fmt.Printf("Proving Period: %d, in %d Blocks (~%dm %ds)\n", ppe, pdiff, pdifft / 60, pdifft % 60) diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index e02368913..bb965c2bb 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -27,10 +27,23 @@ func TestSealAndVerify(t *testing.T) { t.Fatalf("%+v", err) } - sb, cleanup, err := sectorbuilder.TempSectorbuilder(sectorSize, datastore.NewMapDatastore()) + ds := datastore.NewMapDatastore() + + dir, err := ioutil.TempDir("", "sbtest") + if err != nil { + t.Fatal(err) + } + + sb, err := sectorbuilder.TempSectorbuilderDir(dir, sectorSize, ds) if err != nil { t.Fatalf("%+v", err) } + cleanup := func() { + sb.Destroy() + if err := os.RemoveAll(dir); err != nil { + t.Error(err) + } + } defer cleanup() dlen := sectorbuilder.UserBytesForSectorSize(sectorSize) @@ -94,6 +107,26 @@ func TestSealAndVerify(t *testing.T) { if !ok { t.Fatal("bad post") } + + // Restart sectorbuilder, re-run post + sb.Destroy() + sb, err = sectorbuilder.TempSectorbuilderDir(dir, sectorSize, ds) + if err != nil { + t.Fatalf("%+v", err) + } + + postProof, err = sb.GeneratePoSt(ssi, cSeed, []uint64{}) + if err != nil { + t.Fatalf("%+v", err) + } + + ok, err = sectorbuilder.VerifyPost(sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) + if err != nil { + t.Fatalf("%+v", err) + } + if !ok { + t.Fatal("bad post") + } } func TestAcquireID(t *testing.T) { diff --git a/storage/post.go b/storage/post.go index 3d6ac56b3..0bcd66bb5 100644 --- a/storage/post.go +++ b/storage/post.go @@ -147,6 +147,10 @@ func (p *post) preparePost(ctx context.Context) error { if err != nil { return xerrors.Errorf("failed to get proving set for miner: %w", err) } + if len(sset) == 0 { + log.Warn("empty proving set! (ts.H: %d)", p.ts.Height()) + } + p.sset = sset // Compute how many blocks back we have to look from the given tipset for the PoSt challenge @@ -181,7 +185,7 @@ func (p *post) runPost(ctx context.Context) error { log.Infow("running PoSt", "delayed-by", int64(p.ts.Height())-(int64(p.ppe)-int64(build.PoStChallangeTime)), - "chain-random", p.r, "ppe", p.ppe, "height", p.ts.Height()) + "chain-random", p.r, "ppe", p.ppe, "height", p.ts.Height(), "sectors", len(p.sset)) tsStart := time.Now() var faults []uint64 // TODO @@ -189,6 +193,9 @@ func (p *post) runPost(ctx context.Context) error { var seed [32]byte copy(seed[:], p.r) + vals := p.sortedSectorInfo() + log.Infof("SSI: %+v", vals.Values()) + proof, err := p.m.sb.GeneratePoSt(p.sortedSectorInfo(), seed, faults) if err != nil { return xerrors.Errorf("running post failed: %w", err) @@ -270,7 +277,7 @@ func (m *Miner) computePost(ppe uint64) func(ctx context.Context, ts *types.TipS ts: ts, }).doPost(ctx) if err != nil { - return err + return xerrors.Errorf("doPost: %w", err) } m.scheduleNextPost(ppe + build.ProvingPeriodDuration)