2019-11-28 17:44:49 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2020-03-11 06:30:48 +00:00
|
|
|
"bytes"
|
2019-11-28 17:44:49 +00:00
|
|
|
"context"
|
2020-04-22 19:16:19 +00:00
|
|
|
"errors"
|
2019-11-28 18:08:10 +00:00
|
|
|
"time"
|
|
|
|
|
2020-05-28 15:45:34 +00:00
|
|
|
"github.com/filecoin-project/go-bitfield"
|
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-02-12 22:12:11 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-04-16 20:11:07 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
2019-11-28 18:08:10 +00:00
|
|
|
"go.opencensus.io/trace"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2020-05-26 03:43:17 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2019-11-28 17:44:49 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2020-04-22 19:16:19 +00:00
|
|
|
var errNoPartitions = errors.New("no partitions")
|
|
|
|
|
2020-04-20 17:34:08 +00:00
|
|
|
func (s *WindowPoStScheduler) failPost(deadline *miner.DeadlineInfo) {
|
2020-04-07 19:55:34 +00:00
|
|
|
log.Errorf("TODO")
|
|
|
|
/*s.failLk.Lock()
|
2019-12-08 19:48:17 +00:00
|
|
|
if eps > s.failed {
|
|
|
|
s.failed = eps
|
|
|
|
}
|
2020-04-07 19:55:34 +00:00
|
|
|
s.failLk.Unlock()*/
|
2019-12-08 19:48:17 +00:00
|
|
|
}
|
|
|
|
|
2020-04-20 17:34:08 +00:00
|
|
|
func (s *WindowPoStScheduler) doPost(ctx context.Context, deadline *miner.DeadlineInfo, ts *types.TipSet) {
|
2019-11-28 17:44:49 +00:00
|
|
|
ctx, abort := context.WithCancel(ctx)
|
|
|
|
|
|
|
|
s.abort = abort
|
2020-04-07 19:55:34 +00:00
|
|
|
s.activeDeadline = deadline
|
2019-11-28 17:44:49 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer abort()
|
|
|
|
|
2020-04-07 17:41:41 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "WindowPoStScheduler.doPost")
|
2019-11-28 17:44:49 +00:00
|
|
|
defer span.End()
|
|
|
|
|
2020-04-10 21:07:18 +00:00
|
|
|
proof, err := s.runPost(ctx, *deadline, ts)
|
2020-04-22 19:16:19 +00:00
|
|
|
switch err {
|
|
|
|
case errNoPartitions:
|
2019-11-28 17:44:49 +00:00
|
|
|
return
|
2020-04-22 19:16:19 +00:00
|
|
|
case nil:
|
|
|
|
if err := s.submitPost(ctx, proof); err != nil {
|
|
|
|
log.Errorf("submitPost failed: %+v", err)
|
|
|
|
s.failPost(deadline)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
log.Errorf("runPost failed: %+v", err)
|
2020-04-07 19:55:34 +00:00
|
|
|
s.failPost(deadline)
|
2019-11-28 17:44:49 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2020-05-16 21:50:50 +00:00
|
|
|
func (s *WindowPoStScheduler) checkRecoveries(ctx context.Context, deadline uint64, ts *types.TipSet) error {
|
|
|
|
faults, err := s.api.StateMinerFaults(ctx, s.actor, ts.Key())
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting on-chain faults: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fc, err := faults.Count()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("counting faulty sectors: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if fc == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
recov, err := s.api.StateMinerRecoveries(ctx, s.actor, ts.Key())
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting on-chain recoveries: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
unrecovered, err := bitfield.SubtractBitField(faults, recov)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("subtracting recovered set from fault set: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
uc, err := unrecovered.Count()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("counting unrecovered sectors: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if uc == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
spt, err := s.proofType.RegisteredSealProof()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting seal proof type: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mid, err := address.IDFromAddress(s.actor)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-17 01:36:22 +00:00
|
|
|
sectors := make(map[abi.SectorID]struct{})
|
2020-05-16 21:50:50 +00:00
|
|
|
var tocheck []abi.SectorID
|
|
|
|
err = unrecovered.ForEach(func(snum uint64) error {
|
|
|
|
s := abi.SectorID{
|
|
|
|
Miner: abi.ActorID(mid),
|
|
|
|
Number: abi.SectorNumber(snum),
|
|
|
|
}
|
|
|
|
|
|
|
|
tocheck = append(tocheck, s)
|
|
|
|
sectors[s] = struct{}{}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("iterating over unrecovered bitfield: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
bad, err := s.faultTracker.CheckProvable(ctx, spt, tocheck)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("checking provable sectors: %w", err)
|
|
|
|
}
|
|
|
|
for _, id := range bad {
|
|
|
|
delete(sectors, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Warnw("Recoverable sectors", "faulty", len(tocheck), "recoverable", len(sectors))
|
|
|
|
|
|
|
|
if len(sectors) == 0 { // nothing to recover
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
sbf := bitfield.New()
|
|
|
|
for s := range sectors {
|
|
|
|
(&sbf).Set(uint64(s.Number))
|
|
|
|
}
|
|
|
|
|
|
|
|
params := &miner.DeclareFaultsRecoveredParams{
|
|
|
|
Recoveries: []miner.RecoveryDeclaration{{Deadline: deadline, Sectors: &sbf}},
|
|
|
|
}
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
if aerr != nil {
|
|
|
|
return xerrors.Errorf("could not serialize declare recoveries parameters: %w", aerr)
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: s.actor,
|
|
|
|
From: s.worker,
|
|
|
|
Method: builtin.MethodsMiner.DeclareFaultsRecovered,
|
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0),
|
|
|
|
GasLimit: 10000000, // i dont know help
|
|
|
|
GasPrice: types.NewInt(2),
|
|
|
|
}
|
|
|
|
|
|
|
|
sm, err := s.api.MpoolPushMessage(ctx, msg)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("pushing message to mpool: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Warnw("declare faults recovered Message CID", "cid", sm.Cid())
|
|
|
|
|
|
|
|
rec, err := s.api.StateWaitMsg(context.TODO(), sm.Cid())
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("declare faults recovered wait error: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-05-28 15:45:34 +00:00
|
|
|
if rec.Receipt.ExitCode != 0 {
|
2020-05-16 21:50:50 +00:00
|
|
|
return xerrors.Errorf("declare faults recovered wait non-0 exit code: %d", rec.Receipt.ExitCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-04-07 17:41:41 +00:00
|
|
|
func (s *WindowPoStScheduler) checkFaults(ctx context.Context, ssi []abi.SectorNumber) ([]abi.SectorNumber, error) {
|
2020-04-07 19:55:34 +00:00
|
|
|
//faults := s.prover.Scrub(ssi)
|
2020-03-03 22:19:22 +00:00
|
|
|
log.Warnf("Stub checkFaults")
|
2019-12-17 22:23:43 +00:00
|
|
|
|
2020-05-16 21:50:50 +00:00
|
|
|
/*declaredFaults := map[abi.SectorNumber]struct{}{}
|
2019-12-17 22:23:43 +00:00
|
|
|
|
2020-01-30 00:50:58 +00:00
|
|
|
{
|
2020-02-11 23:29:45 +00:00
|
|
|
chainFaults, err := s.api.StateMinerFaults(ctx, s.actor, types.EmptyTSK)
|
2020-01-30 00:50:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("checking on-chain faults: %w", err)
|
|
|
|
}
|
2019-12-17 22:23:43 +00:00
|
|
|
|
2020-01-30 00:50:58 +00:00
|
|
|
for _, fault := range chainFaults {
|
|
|
|
declaredFaults[fault] = struct{}{}
|
2019-12-17 22:23:43 +00:00
|
|
|
}
|
2020-05-16 21:50:50 +00:00
|
|
|
}*/
|
2019-12-17 22:23:43 +00:00
|
|
|
|
2020-04-21 21:38:26 +00:00
|
|
|
return nil, nil
|
2019-12-17 22:23:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-26 09:58:20 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2020-04-20 17:34:08 +00:00
|
|
|
func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo, ts *types.TipSet) (*miner.SubmitWindowedPoStParams, error) {
|
2019-11-28 17:44:49 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "storage.runPost")
|
|
|
|
defer span.End()
|
|
|
|
|
2020-05-17 23:18:02 +00:00
|
|
|
// check recoveries for the *next* deadline. It's already too late to
|
|
|
|
// declare them for this deadline
|
|
|
|
if err := s.checkRecoveries(ctx, (di.Index+1)%miner.WPoStPeriodDeadlines, ts); err != nil {
|
2020-05-16 21:50:50 +00:00
|
|
|
// TODO: This is potentially quite bad, but not even trying to post when this fails is objectively worse
|
2020-05-17 23:18:02 +00:00
|
|
|
log.Errorf("checking sector recoveries: %v", err)
|
2020-05-16 21:50:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 06:30:48 +00:00
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
if err := s.actor.MarshalCBOR(buf); err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to marshal address to cbor: %w", err)
|
|
|
|
}
|
2020-04-20 17:34:08 +00:00
|
|
|
rand, err := s.api.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_WindowedPoStChallengeSeed, di.Challenge, buf.Bytes())
|
2019-11-28 17:44:49 +00:00
|
|
|
if err != nil {
|
2020-04-16 20:11:07 +00:00
|
|
|
return nil, xerrors.Errorf("failed to get chain randomness for windowPost (ts=%d; deadline=%d): %w", ts.Height(), di, err)
|
2019-11-28 17:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
deadlines, err := s.api.StateMinerDeadlines(ctx, s.actor, ts.Key())
|
2020-04-07 19:55:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-04-29 18:06:05 +00:00
|
|
|
firstPartition, _, err := miner.PartitionsForDeadline(deadlines, s.partitionSectors, di.Index)
|
2020-04-16 20:11:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("getting partitions for deadline: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-04-29 18:06:05 +00:00
|
|
|
partitionCount, _, err := miner.DeadlineCount(deadlines, s.partitionSectors, di.Index)
|
2020-04-16 20:11:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("getting deadline partition count: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:22:53 +00:00
|
|
|
dc, err := deadlines.Due[di.Index].Count()
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("get deadline count: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("di: %+v", di)
|
|
|
|
log.Infof("dc: %+v", dc)
|
|
|
|
log.Infof("fp: %+v", firstPartition)
|
|
|
|
log.Infof("pc: %+v", partitionCount)
|
|
|
|
log.Infof("ts: %+v (%d)", ts.Key(), ts.Height())
|
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
if partitionCount == 0 {
|
2020-04-22 19:16:19 +00:00
|
|
|
return nil, errNoPartitions
|
2020-04-16 20:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
partitions := make([]uint64, partitionCount)
|
|
|
|
for i := range partitions {
|
|
|
|
partitions[i] = firstPartition + uint64(i)
|
|
|
|
}
|
|
|
|
|
2020-05-26 09:58:20 +00:00
|
|
|
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)
|
2019-11-28 17:44:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("getting sorted sector info: %w", err)
|
|
|
|
}
|
2020-04-16 20:11:07 +00:00
|
|
|
|
2020-03-07 05:26:00 +00:00
|
|
|
if len(ssi) == 0 {
|
2020-04-07 17:41:41 +00:00
|
|
|
log.Warn("attempted to run windowPost without any sectors...")
|
|
|
|
return nil, xerrors.Errorf("no sectors to run windowPost on")
|
2020-03-07 05:26:00 +00:00
|
|
|
}
|
2019-11-28 17:44:49 +00:00
|
|
|
|
2020-04-07 17:41:41 +00:00
|
|
|
log.Infow("running windowPost",
|
2020-01-21 15:01:42 +00:00
|
|
|
"chain-random", rand,
|
2020-04-16 20:11:07 +00:00
|
|
|
"deadline", di,
|
2020-01-21 15:01:42 +00:00
|
|
|
"height", ts.Height())
|
2019-11-28 17:44:49 +00:00
|
|
|
|
2020-02-27 21:45:31 +00:00
|
|
|
var snums []abi.SectorNumber
|
|
|
|
for _, si := range ssi {
|
|
|
|
snums = append(snums, si.SectorNumber)
|
|
|
|
}
|
|
|
|
|
|
|
|
faults, err := s.checkFaults(ctx, snums)
|
2019-12-17 22:23:43 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("Failed to declare faults: %+v", err)
|
|
|
|
}
|
|
|
|
|
2019-11-28 17:44:49 +00:00
|
|
|
tsStart := time.Now()
|
|
|
|
|
2020-04-07 17:41:41 +00:00
|
|
|
log.Infow("generating windowPost",
|
2020-02-27 21:45:31 +00:00
|
|
|
"sectors", len(ssi),
|
2020-01-21 15:01:42 +00:00
|
|
|
"faults", len(faults))
|
|
|
|
|
2020-03-17 20:19:52 +00:00
|
|
|
mid, err := address.IDFromAddress(s.actor)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:07:18 +00:00
|
|
|
// TODO: Faults!
|
2020-04-16 20:11:07 +00:00
|
|
|
postOut, err := s.prover.GenerateWindowPoSt(ctx, abi.ActorID(mid), ssi, abi.PoStRandomness(rand))
|
2019-11-28 17:44:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("running post failed: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:07:18 +00:00
|
|
|
if len(postOut) == 0 {
|
|
|
|
return nil, xerrors.Errorf("received proofs back from generate window post")
|
2020-03-11 06:30:48 +00:00
|
|
|
}
|
|
|
|
|
2019-11-28 17:44:49 +00:00
|
|
|
elapsed := time.Since(tsStart)
|
2020-04-21 17:22:53 +00:00
|
|
|
log.Infow("submitting window PoSt", "elapsed", elapsed)
|
2019-11-28 17:44:49 +00:00
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
return &miner.SubmitWindowedPoStParams{
|
2020-05-27 09:01:48 +00:00
|
|
|
Deadline: di.Index,
|
2020-04-16 20:11:07 +00:00
|
|
|
Partitions: partitions,
|
|
|
|
Proofs: postOut,
|
|
|
|
Skipped: *abi.NewBitField(), // TODO: Faults here?
|
2019-11-28 17:44:49 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
func (s *WindowPoStScheduler) sortedSectorInfo(ctx context.Context, deadlineSectors *abi.BitField, ts *types.TipSet) ([]abi.SectorInfo, error) {
|
2020-04-21 17:22:53 +00:00
|
|
|
sset, err := s.api.StateMinerSectors(ctx, s.actor, deadlineSectors, false, ts.Key())
|
2019-11-28 17:44:49 +00:00
|
|
|
if err != nil {
|
2020-04-07 19:55:34 +00:00
|
|
|
return nil, err
|
2019-11-28 17:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 21:45:31 +00:00
|
|
|
sbsi := make([]abi.SectorInfo, len(sset))
|
2019-11-28 17:44:49 +00:00
|
|
|
for k, sector := range sset {
|
2020-02-27 21:45:31 +00:00
|
|
|
sbsi[k] = abi.SectorInfo{
|
2020-04-16 20:11:07 +00:00
|
|
|
SectorNumber: sector.ID,
|
|
|
|
SealedCID: sector.Info.Info.SealedCID,
|
|
|
|
RegisteredProof: sector.Info.Info.RegisteredProof,
|
2019-11-28 17:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-27 21:45:31 +00:00
|
|
|
return sbsi, nil
|
2019-11-28 17:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 20:11:07 +00:00
|
|
|
func (s *WindowPoStScheduler) submitPost(ctx context.Context, proof *miner.SubmitWindowedPoStParams) error {
|
2019-11-28 17:44:49 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "storage.commitPost")
|
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(proof)
|
|
|
|
if aerr != nil {
|
|
|
|
return xerrors.Errorf("could not serialize submit post parameters: %w", aerr)
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
2020-05-26 03:43:17 +00:00
|
|
|
To: s.actor,
|
|
|
|
From: s.worker,
|
|
|
|
Method: builtin.MethodsMiner.SubmitWindowedPoSt,
|
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late
|
|
|
|
// TODO: Gaslimit needs to be calculated accurately. Before that, use the largest Gaslimit
|
|
|
|
GasLimit: build.BlockGasLimit,
|
2019-11-28 17:44:49 +00:00
|
|
|
GasPrice: types.NewInt(1),
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: consider maybe caring about the output
|
|
|
|
sm, err := s.api.MpoolPushMessage(ctx, msg)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("pushing message to mpool: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:22:53 +00:00
|
|
|
log.Infof("Submitted window post: %s", sm.Cid())
|
2019-11-28 17:44:49 +00:00
|
|
|
|
2020-01-29 22:47:28 +00:00
|
|
|
go func() {
|
|
|
|
rec, err := s.api.StateWaitMsg(context.TODO(), sm.Cid())
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if rec.Receipt.ExitCode == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:22:53 +00:00
|
|
|
log.Errorf("Submitting window post %s failed: exit %d", sm.Cid(), rec.Receipt.ExitCode)
|
2020-01-29 22:47:28 +00:00
|
|
|
}()
|
|
|
|
|
2019-11-28 17:44:49 +00:00
|
|
|
return nil
|
|
|
|
}
|