Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: split window PoST submission into multiple messages #3689

Merged
merged 2 commits into from
Sep 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: storage - move rand generation after proofs
  • Loading branch information
dirkmc committed Sep 15, 2020
commit db998e9c0f06d9282ef7751cf384253f3b7c2d2c
31 changes: 17 additions & 14 deletions storage/wdpost_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ func (s *WindowPoStScheduler) doPost(ctx context.Context, deadline *dline.Info,

for i := range posts {
post := &posts[i]
sm, err := s.submitPost(ctx, &posts[i])
sm, err := s.submitPost(ctx, post)
if err != nil {
log.Errorf("submitPost failed: %+v", err)
s.failPost(err, deadline)
} else {
recordProofsEvent(post.Partitions, sm.Cid())
}
recordProofsEvent(post.Partitions, sm.Cid())
}

journal.J.RecordEvent(s.evtTypes[evtTypeWdPoStScheduler], func() interface{} {
Expand Down Expand Up @@ -412,6 +413,7 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
return nil, err
}

// Generate proofs in batches
posts := make([]miner.SubmitWindowedPoStParams, 0, len(partitionBatches))
for batchIdx, batch := range partitionBatches {
batchPartitionStartIdx := 0
Expand All @@ -425,18 +427,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
Proofs: nil,
}

//var sinfos []proof.SectorInfo
//sidToPart := map[abi.SectorNumber]uint64{}
//skipCount := uint64(0)

skipCount := uint64(0)
postSkipped := bitfield.New()
var postOut []proof.PoStProof
var sinfos []proof.SectorInfo

somethingToProve := true
for retries := 0; retries < 5; retries++ {
sinfos = make([]proof.SectorInfo, 0)

var sinfos []proof.SectorInfo
for partIdx, partition := range batch {
// TODO: Can do this in parallel
toProve, err := partition.ActiveSectors()
Expand Down Expand Up @@ -488,11 +484,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
}

if len(sinfos) == 0 {
// nothing to prove..
//return nil, errNoPartitions
// nothing to prove for this batch
somethingToProve = false
break
}

// Generate proof
log.Infow("running windowPost",
"chain-random", rand,
"deadline", di,
Expand All @@ -513,9 +510,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
log.Infow("computing window PoSt", "batch", batchIdx, "elapsed", elapsed)

if err == nil {
// Proof generation successful, stop retrying
break
}

// Proof generation failed, so retry

if len(ps) == 0 {
return nil, xerrors.Errorf("running post failed: %w", err)
}
Expand All @@ -528,7 +528,8 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
}
}

if len(sinfos) == 0 {
// Nothing to prove for this batch, try the next batch
if !somethingToProve {
continue
}

Expand All @@ -541,10 +542,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
posts = append(posts, params)
}

// Compute randomness after generating proofs so as to reduce the impact
// of chain reorgs (which change randomness)
commEpoch := di.Open
commRand, err := s.api.ChainGetRandomnessFromTickets(ctx, ts.Key(), crypto.DomainSeparationTag_PoStChainCommit, commEpoch, nil)
if err != nil {
return nil, xerrors.Errorf("failed to get chain randomness for windowPost (ts=%d; deadline=%d): %w", ts.Height(), di, err)
return nil, xerrors.Errorf("failed to get chain randomness for windowPost (ts=%d; deadline=%d): %w", ts.Height(), commEpoch, err)
}

for i := range posts {
Expand Down