Test to reproduce post error after restart

This commit is contained in:
Łukasz Magiera 2019-11-09 11:42:36 +01:00
parent ea13bce02d
commit 81bd0bc517
3 changed files with 44 additions and 4 deletions

View File

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

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

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