Fix:the input sectors of wpost must match with the minerActor

This commit is contained in:
waynewyang 2020-05-26 17:58:20 +08:00
parent 9641d93615
commit b799af3e9a

View File

@ -198,6 +198,49 @@ func (s *WindowPoStScheduler) checkFaults(ctx context.Context, ssi []abi.SectorN
return nil, nil
}
// the input sectors must match with the miner actor
func (s *WindowPoStScheduler) getNeedProveSectors(ctx context.Context, deadlineSectors *abi.BitField, ts *types.TipSet) (*abi.BitField, error) {
faults, err := s.api.StateMinerFaults(ctx, s.actor, ts.Key())
if err != nil {
return nil, xerrors.Errorf("getting on-chain faults: %w", err)
}
declaredFaults, err := bitfield.IntersectBitField(deadlineSectors, faults)
if err != nil {
return nil, xerrors.Errorf("failed to intersect proof sectors with faults: %w", err)
}
recoveries, err := s.api.StateMinerRecoveries(ctx, s.actor, ts.Key())
if err != nil {
return nil, xerrors.Errorf("getting on-chain recoveries: %w", err)
}
expectedRecoveries, err := bitfield.IntersectBitField(declaredFaults, recoveries)
if err != nil {
return nil, xerrors.Errorf("failed to intersect recoveries with faults: %w", err)
}
expectedFaults, err := bitfield.SubtractBitField(declaredFaults, expectedRecoveries)
if err != nil {
return nil, xerrors.Errorf("failed to subtract recoveries from faults: %w", err)
}
nonFaults, err := bitfield.SubtractBitField(deadlineSectors, expectedFaults)
if err != nil {
return nil, xerrors.Errorf("failed to diff bitfields: %w", err)
}
empty, err := nonFaults.IsEmpty()
if err != nil {
return nil, xerrors.Errorf("failed to check if bitfield was empty: %w", err)
}
if empty {
return nil, xerrors.Errorf("no non-faulty sectors in partitions: %w", err)
}
return nonFaults, nil
}
func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo, ts *types.TipSet) (*miner.SubmitWindowedPoStParams, error) {
ctx, span := trace.StartSpan(ctx, "storage.runPost")
defer span.End()
@ -253,7 +296,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo
partitions[i] = firstPartition + uint64(i)
}
ssi, err := s.sortedSectorInfo(ctx, deadlines.Due[di.Index], ts)
nps, err := s.getNeedProveSectors(ctx, deadlines.Due[di.Index], ts)
if err != nil {
return nil, xerrors.Errorf("get need prove sectors: %w", err)
}
ssi, err := s.sortedSectorInfo(ctx, nps, ts)
if err != nil {
return nil, xerrors.Errorf("getting sorted sector info: %w", err)
}