2021-12-08 17:11:19 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2022-02-09 11:41:39 +00:00
|
|
|
"context"
|
|
|
|
"time"
|
2022-01-12 23:10:07 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2022-02-09 16:47:53 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2021-12-08 17:11:19 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2022-04-20 21:34:28 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/builtin"
|
2021-12-08 17:11:19 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/exitcode"
|
2022-06-15 10:06:22 +00:00
|
|
|
"github.com/filecoin-project/go-statemachine"
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
2022-06-16 11:15:49 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2023-08-29 13:16:05 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2022-02-09 11:41:39 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
2022-06-16 09:12:33 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2021-12-08 17:11:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (m *Sealing) handleReplicaUpdate(ctx statemachine.Context, sector SectorInfo) error {
|
2022-09-14 09:35:07 +00:00
|
|
|
// if the sector ended up not having any deals, abort the upgrade
|
|
|
|
if !sector.hasDeals() {
|
|
|
|
return ctx.Send(SectorAbortUpgrade{xerrors.New("sector had no deals")})
|
|
|
|
}
|
|
|
|
|
2022-08-24 19:27:27 +00:00
|
|
|
if err := checkPieces(ctx.Context(), m.maddr, sector.SectorNumber, sector.Pieces, m.Api, true); err != nil { // Sanity check state
|
2022-01-04 00:58:52 +00:00
|
|
|
return handleErrors(ctx, err, sector)
|
2021-12-08 17:11:19 +00:00
|
|
|
}
|
|
|
|
out, err := m.sealer.ReplicaUpdate(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.pieceInfos())
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Send(SectorUpdateReplicaFailed{xerrors.Errorf("replica update failed: %w", err)})
|
|
|
|
}
|
|
|
|
return ctx.Send(SectorReplicaUpdate{
|
|
|
|
Out: out,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) handleProveReplicaUpdate(ctx statemachine.Context, sector SectorInfo) error {
|
|
|
|
if sector.UpdateSealed == nil || sector.UpdateUnsealed == nil {
|
|
|
|
return xerrors.Errorf("invalid sector %d with nil UpdateSealed or UpdateUnsealed output", sector.SectorNumber)
|
|
|
|
}
|
|
|
|
if sector.CommR == nil {
|
|
|
|
return xerrors.Errorf("invalid sector %d with nil CommR", sector.SectorNumber)
|
|
|
|
}
|
2022-02-01 06:09:42 +00:00
|
|
|
// Abort upgrade for sectors that went faulty since being marked for upgrade
|
2022-06-16 11:15:49 +00:00
|
|
|
ts, err := m.Api.ChainHead(ctx.Context())
|
2022-02-01 06:09:42 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleProveReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
2022-06-16 11:15:49 +00:00
|
|
|
active, err := m.sectorActive(ctx.Context(), ts.Key(), sector.SectorNumber)
|
2022-02-01 06:09:42 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("sector active check: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if !active {
|
2022-11-08 14:11:28 +00:00
|
|
|
err := xerrors.Errorf("sector marked for upgrade %d no longer active, aborting upgrade", sector.SectorNumber)
|
|
|
|
log.Errorf(err.Error())
|
|
|
|
return ctx.Send(SectorAbortUpgrade{err})
|
2022-02-01 06:09:42 +00:00
|
|
|
}
|
2022-01-04 00:58:52 +00:00
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
vanillaProofs, err := m.sealer.ProveReplicaUpdate1(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), *sector.CommR, *sector.UpdateSealed, *sector.UpdateUnsealed)
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Send(SectorProveReplicaUpdateFailed{xerrors.Errorf("prove replica update (1) failed: %w", err)})
|
|
|
|
}
|
|
|
|
|
2022-08-24 19:27:27 +00:00
|
|
|
if err := checkPieces(ctx.Context(), m.maddr, sector.SectorNumber, sector.Pieces, m.Api, true); err != nil { // Sanity check state
|
2022-01-04 02:29:48 +00:00
|
|
|
return handleErrors(ctx, err, sector)
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
proof, err := m.sealer.ProveReplicaUpdate2(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), *sector.CommR, *sector.UpdateSealed, *sector.UpdateUnsealed, vanillaProofs)
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Send(SectorProveReplicaUpdateFailed{xerrors.Errorf("prove replica update (2) failed: %w", err)})
|
|
|
|
|
|
|
|
}
|
|
|
|
return ctx.Send(SectorProveReplicaUpdate{
|
|
|
|
Proof: proof,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) handleSubmitReplicaUpdate(ctx statemachine.Context, sector SectorInfo) error {
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
ts, err := m.Api.ChainHead(ctx.Context())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
if err := checkReplicaUpdate(ctx.Context(), m.maddr, sector, ts.Key(), m.Api); err != nil {
|
2021-12-08 17:11:19 +00:00
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
sl, err := m.Api.StateSectorPartition(ctx.Context(), m.maddr, sector.SectorNumber, ts.Key())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
2022-11-07 14:56:53 +00:00
|
|
|
|
|
|
|
dlinfo, err := m.Api.StateMinerProvingDeadline(ctx.Context(), m.maddr, ts.Key())
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %w", err)
|
|
|
|
}
|
|
|
|
// if sector's deadline is immutable wait in a non error state
|
|
|
|
// sector's deadline is immutable if it is the current deadline or the next deadline
|
|
|
|
if sl.Deadline == dlinfo.Index || (dlinfo.Index+1)%dlinfo.WPoStPeriodDeadlines == sl.Deadline {
|
|
|
|
return ctx.Send(SectorDeadlineImmutable{})
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
updateProof, err := sector.SectorType.RegisteredUpdateProof()
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed to get update proof type from seal proof: %+v", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
enc := new(bytes.Buffer)
|
|
|
|
params := &miner.ProveReplicaUpdatesParams{
|
|
|
|
Updates: []miner.ReplicaUpdate{
|
|
|
|
{
|
|
|
|
SectorID: sector.SectorNumber,
|
|
|
|
Deadline: sl.Deadline,
|
|
|
|
Partition: sl.Partition,
|
|
|
|
NewSealedSectorCID: *sector.UpdateSealed,
|
|
|
|
Deals: sector.dealIDs(),
|
|
|
|
UpdateProofType: updateProof,
|
|
|
|
ReplicaProof: sector.ReplicaUpdateProof,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if err := params.MarshalCBOR(enc); err != nil {
|
|
|
|
log.Errorf("failed to serialize update replica params: %w", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg, err := m.getConfig()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting config: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
onChainInfo, err := m.Api.StateSectorGetInfo(ctx.Context(), m.maddr, sector.SectorNumber, ts.Key())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
2022-12-12 15:44:08 +00:00
|
|
|
if onChainInfo == nil {
|
|
|
|
return xerrors.Errorf("sector not found %d", sector.SectorNumber)
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
sp, err := m.currentSealProof(ctx.Context())
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("sealer failed to return current seal proof not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
virtualPCI := miner.SectorPreCommitInfo{
|
|
|
|
SealProof: sp,
|
|
|
|
SectorNumber: sector.SectorNumber,
|
|
|
|
SealedCID: *sector.UpdateSealed,
|
|
|
|
//SealRandEpoch: 0,
|
|
|
|
DealIDs: sector.dealIDs(),
|
|
|
|
Expiration: onChainInfo.Expiration,
|
|
|
|
//ReplaceCapacity: false,
|
|
|
|
//ReplaceSectorDeadline: 0,
|
|
|
|
//ReplaceSectorPartition: 0,
|
|
|
|
//ReplaceSectorNumber: 0,
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
collateral, err := m.Api.StateMinerInitialPledgeCollateral(ctx.Context(), m.maddr, virtualPCI, ts.Key())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting initial pledge collateral: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
collateral = big.Sub(collateral, onChainInfo.InitialPledge)
|
|
|
|
if collateral.LessThan(big.Zero()) {
|
|
|
|
collateral = big.Zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
collateral, err = collateralSendAmount(ctx.Context(), m.Api, m.maddr, cfg, collateral)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("collateral send amount failed not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
goodFunds := big.Add(collateral, big.Int(m.feeCfg.MaxCommitGasFee))
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
mi, err := m.Api.StateMinerInfo(ctx.Context(), m.maddr, ts.Key())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-08-09 10:57:20 +00:00
|
|
|
from, _, err := m.addrSel.AddressFor(ctx.Context(), m.Api, mi, api.CommitAddr, goodFunds, collateral)
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("no good address to send replica update message from: %+v", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
2022-06-16 13:50:41 +00:00
|
|
|
mcid, err := sendMsg(ctx.Context(), m.Api, from, m.maddr, builtin.MethodsMiner.ProveReplicaUpdates, collateral, big.Int(m.feeCfg.MaxCommitGasFee), enc.Bytes())
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleSubmitReplicaUpdate: error sending message: %+v", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctx.Send(SectorReplicaUpdateSubmitted{Message: mcid})
|
|
|
|
}
|
|
|
|
|
2022-11-07 14:56:53 +00:00
|
|
|
func (m *Sealing) handleWaitMutable(ctx statemachine.Context, sector SectorInfo) error {
|
|
|
|
immutable := true
|
|
|
|
for immutable {
|
|
|
|
ts, err := m.Api.ChainHead(ctx.Context())
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleWaitMutable: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
sl, err := m.Api.StateSectorPartition(ctx.Context(), m.maddr, sector.SectorNumber, ts.Key())
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleWaitMutable: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
dlinfo, err := m.Api.StateMinerProvingDeadline(ctx.Context(), m.maddr, ts.Key())
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleWaitMutable: api error, not proceeding: %w", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
sectorDeadlineOpen := sl.Deadline == dlinfo.Index
|
|
|
|
sectorDeadlineNext := (dlinfo.Index+1)%dlinfo.WPoStPeriodDeadlines == sl.Deadline
|
2022-11-08 12:30:53 +00:00
|
|
|
immutable = sectorDeadlineOpen || sectorDeadlineNext
|
2022-11-07 14:56:53 +00:00
|
|
|
|
|
|
|
// Sleep for immutable epochs
|
|
|
|
if immutable {
|
|
|
|
dlineEpochsRemaining := dlinfo.NextOpen() - ts.Height()
|
2022-11-14 15:07:22 +00:00
|
|
|
var targetEpoch abi.ChainEpoch
|
2022-11-07 14:56:53 +00:00
|
|
|
if sectorDeadlineOpen {
|
|
|
|
// sleep for remainder of deadline
|
2022-11-14 15:07:22 +00:00
|
|
|
targetEpoch = ts.Height() + dlineEpochsRemaining
|
2022-11-07 14:56:53 +00:00
|
|
|
} else {
|
|
|
|
// sleep for remainder of deadline and next one
|
2022-11-14 15:07:22 +00:00
|
|
|
targetEpoch = ts.Height() + dlineEpochsRemaining + dlinfo.WPoStChallengeWindow
|
2022-11-07 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 15:07:22 +00:00
|
|
|
atHeight := make(chan struct{})
|
2022-11-14 15:16:37 +00:00
|
|
|
err := m.events.ChainAt(ctx.Context(), func(context.Context, *types.TipSet, abi.ChainEpoch) error {
|
2022-11-14 15:07:22 +00:00
|
|
|
close(atHeight)
|
|
|
|
return nil
|
|
|
|
}, func(ctx context.Context, ts *types.TipSet) error {
|
|
|
|
log.Warn("revert in handleWaitMutable")
|
|
|
|
return nil
|
|
|
|
}, 5, targetEpoch)
|
2022-11-14 15:16:37 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleWaitMutalbe: events error: api error, not proceeding: %w", err)
|
|
|
|
return nil
|
|
|
|
}
|
2022-11-14 15:07:22 +00:00
|
|
|
|
2022-11-07 16:03:22 +00:00
|
|
|
select {
|
2022-11-14 15:07:22 +00:00
|
|
|
case <-atHeight:
|
2022-11-07 16:03:22 +00:00
|
|
|
case <-ctx.Context().Done():
|
|
|
|
return ctx.Context().Err()
|
2022-11-07 14:56:53 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-14 15:07:22 +00:00
|
|
|
|
2022-11-07 14:56:53 +00:00
|
|
|
}
|
|
|
|
return ctx.Send(SectorDeadlineMutable{})
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
func (m *Sealing) handleReplicaUpdateWait(ctx statemachine.Context, sector SectorInfo) error {
|
|
|
|
if sector.ReplicaUpdateMessage == nil {
|
|
|
|
log.Errorf("handleReplicaUpdateWait: no replica update message cid recorded")
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
2022-06-16 10:47:19 +00:00
|
|
|
mw, err := m.Api.StateWaitMsg(ctx.Context(), *sector.ReplicaUpdateMessage, build.MessageConfidence, api.LookbackNoLimit, true)
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("handleReplicaUpdateWait: failed to wait for message: %+v", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
|
|
|
switch mw.Receipt.ExitCode {
|
|
|
|
case exitcode.Ok:
|
|
|
|
//expected
|
|
|
|
case exitcode.SysErrInsufficientFunds:
|
|
|
|
fallthrough
|
|
|
|
case exitcode.SysErrOutOfGas:
|
|
|
|
log.Errorf("gas estimator was wrong or out of funds")
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
default:
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
2022-06-16 10:47:19 +00:00
|
|
|
si, err := m.Api.StateSectorGetInfo(ctx.Context(), m.maddr, sector.SectorNumber, mw.TipSet)
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("api err failed to get sector info: %+v", err)
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
if si == nil {
|
|
|
|
log.Errorf("api err sector not found")
|
|
|
|
return ctx.Send(SectorSubmitReplicaUpdateFailed{})
|
|
|
|
}
|
|
|
|
|
|
|
|
if !si.SealedCID.Equals(*sector.UpdateSealed) {
|
2022-01-21 19:07:11 +00:00
|
|
|
return ctx.Send(SectorAbortUpgrade{xerrors.Errorf("mismatch of expected onchain sealed cid after replica update, expected %s got %s", sector.UpdateSealed, si.SealedCID)})
|
2021-12-08 17:11:19 +00:00
|
|
|
}
|
|
|
|
return ctx.Send(SectorReplicaUpdateLanded{})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) handleFinalizeReplicaUpdate(ctx statemachine.Context, sector SectorInfo) error {
|
2022-02-02 20:23:35 +00:00
|
|
|
cfg, err := m.getConfig()
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting sealing config: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-11-16 16:07:42 +00:00
|
|
|
if err := m.sealer.ReleaseUnsealed(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(sector.Pieces, false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
|
|
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("release unsealed: %w", err)})
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.sealer.FinalizeReplicaUpdate(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber)); err != nil {
|
2022-02-02 20:23:35 +00:00
|
|
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
return ctx.Send(SectorFinalized{})
|
|
|
|
}
|
2022-01-04 00:58:52 +00:00
|
|
|
|
2022-02-09 11:41:39 +00:00
|
|
|
func (m *Sealing) handleUpdateActivating(ctx statemachine.Context, sector SectorInfo) error {
|
2022-09-19 15:32:02 +00:00
|
|
|
if sector.ReplicaUpdateMessage == nil {
|
|
|
|
return xerrors.Errorf("nil sector.ReplicaUpdateMessage!")
|
|
|
|
}
|
|
|
|
|
2022-02-09 11:41:39 +00:00
|
|
|
try := func() error {
|
2022-06-16 10:47:19 +00:00
|
|
|
mw, err := m.Api.StateWaitMsg(ctx.Context(), *sector.ReplicaUpdateMessage, build.MessageConfidence, api.LookbackNoLimit, true)
|
2022-02-09 11:41:39 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
ts, err := m.Api.ChainHead(ctx.Context())
|
2022-02-09 11:41:39 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-16 11:15:49 +00:00
|
|
|
nv, err := m.Api.StateNetworkVersion(ctx.Context(), ts.Key())
|
2022-02-09 11:41:39 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
lb := policy.GetWinningPoStSectorSetLookback(nv)
|
|
|
|
|
2022-11-23 19:38:57 +00:00
|
|
|
targetHeight := mw.Height + lb
|
2022-02-09 11:41:39 +00:00
|
|
|
|
2022-06-16 14:05:56 +00:00
|
|
|
return m.events.ChainAt(context.Background(), func(context.Context, *types.TipSet, abi.ChainEpoch) error {
|
2022-02-09 16:47:53 +00:00
|
|
|
return ctx.Send(SectorUpdateActive{})
|
2022-06-16 14:05:56 +00:00
|
|
|
}, func(ctx context.Context, ts *types.TipSet) error {
|
2022-02-09 16:47:53 +00:00
|
|
|
log.Warn("revert in handleUpdateActivating")
|
|
|
|
return nil
|
|
|
|
}, InteractivePoRepConfidence, targetHeight)
|
2022-02-09 11:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
|
|
|
err := try()
|
|
|
|
if err == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Errorw("error in handleUpdateActivating", "error", err)
|
|
|
|
|
|
|
|
// likely an API issue, sleep for a bit and retry
|
|
|
|
time.Sleep(time.Minute)
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:47:53 +00:00
|
|
|
return nil
|
2022-02-09 11:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) handleReleaseSectorKey(ctx statemachine.Context, sector SectorInfo) error {
|
|
|
|
if err := m.sealer.ReleaseSectorKey(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber)); err != nil {
|
|
|
|
return ctx.Send(SectorReleaseKeyFailed{err})
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctx.Send(SectorKeyReleased{})
|
|
|
|
}
|
|
|
|
|
2022-01-04 00:58:52 +00:00
|
|
|
func handleErrors(ctx statemachine.Context, err error, sector SectorInfo) error {
|
|
|
|
switch err.(type) {
|
|
|
|
case *ErrApi:
|
|
|
|
log.Errorf("handleReplicaUpdate: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
|
|
|
case *ErrInvalidDeals:
|
|
|
|
log.Warnf("invalid deals in sector %d: %v", sector.SectorNumber, err)
|
|
|
|
return ctx.Send(SectorInvalidDealIDs{})
|
|
|
|
case *ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector?
|
|
|
|
return ctx.Send(SectorDealsExpired{xerrors.Errorf("expired dealIDs in sector: %w", err)})
|
|
|
|
default:
|
2022-09-14 10:13:22 +00:00
|
|
|
return xerrors.Errorf("checkPieces sanity check error: %w (%+v)", err, err)
|
2022-01-04 00:58:52 +00:00
|
|
|
}
|
|
|
|
}
|