Merge pull request #556 from filecoin-project/fix/post-restart

Fix PoSt after storage miner restart
This commit is contained in:
Łukasz Magiera 2019-11-11 18:33:33 +01:00 committed by GitHub
commit 55697209a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 10 deletions

View File

@ -64,13 +64,17 @@ var infoCmd = &cli.Command{
if err != nil {
return err
}
head, err := api.ChainHead(ctx)
if err != nil {
return err
if ppe != 0 {
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
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)
} else {
fmt.Printf("Proving Period: Not Proving\n")
}
pdiff := ppe-head.Height()
pdifft := pdiff * build.BlockDelay
fmt.Printf("Proving Period: %d, in %d Blocks (~%dm %ds)\n", ppe, pdiff, pdifft / 60, pdifft % 60)
sinfo, err := sectorsInfo(ctx, nodeApi)
if err != nil {

@ -1 +1 @@
Subproject commit e198d9050b5dde6c19bef3593506597afe00b6cb
Subproject commit d94675a704d5f4c4bed30ec16538352f4d8cdc4b

View File

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

View File

@ -148,6 +148,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
@ -182,7 +186,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
@ -272,7 +276,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)