From 98f00b510f774144e61cc21c273784a8c8c42985 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 18 Aug 2020 18:53:56 -0400 Subject: [PATCH 1/2] re-mark replaced sectors as for upgrade if precommit fails --- extern/storage-sealing/states_sealing.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 110a73ac0..791aba290 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -123,6 +123,14 @@ func (m *Sealing) handlePreCommit2(ctx statemachine.Context, sector SectorInfo) }) } +// TODO: We should probably invoke this method in most (if not all) state transition failures after handlePreCommitting +func (m *Sealing) remarkForUpgrade(sid abi.SectorNumber) { + err := m.MarkForUpgrade(sid) + if err != nil { + log.Errorf("error re-marking sector %d as for upgrade: %+v", sid, err) + } +} + func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error { tok, height, err := m.api.ChainHead(ctx.Context()) if err != nil { @@ -197,6 +205,9 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf log.Infof("submitting precommit for sector %d (deposit: %s): ", sector.SectorNumber, deposit) mcid, err := m.api.SendMsg(ctx.Context(), waddr, m.maddr, builtin.MethodsMiner.PreCommitSector, deposit, m.feeCfg.MaxPreCommitGasFee, enc.Bytes()) if err != nil { + if params.ReplaceSectorDeadline > 0 { + m.remarkForUpgrade(params.ReplaceSectorNumber) + } return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) } @@ -208,7 +219,7 @@ func (m *Sealing) handlePreCommitWait(ctx statemachine.Context, sector SectorInf return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("precommit message was nil")}) } - // would be ideal to just use the events.Called handler, but it wouldnt be able to handle individual message timeouts + // would be ideal to just use the events.Called handler, but it wouldn't be able to handle individual message timeouts log.Info("Sector precommitted: ", sector.SectorNumber) mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage) if err != nil { From 7de7e65dbc5c13347c4f0e82d0bd8ae6162e356a Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 18 Aug 2020 18:55:18 -0400 Subject: [PATCH 2/2] Calculate depositMinimum for upgrading as replaced sector's Initialpledge --- extern/storage-sealing/states_sealing.go | 2 +- extern/storage-sealing/upgrade_queue.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 791aba290..1ac22e20f 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -205,7 +205,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf log.Infof("submitting precommit for sector %d (deposit: %s): ", sector.SectorNumber, deposit) mcid, err := m.api.SendMsg(ctx.Context(), waddr, m.maddr, builtin.MethodsMiner.PreCommitSector, deposit, m.feeCfg.MaxPreCommitGasFee, enc.Bytes()) if err != nil { - if params.ReplaceSectorDeadline > 0 { + if params.ReplaceCapacity { m.remarkForUpgrade(params.ReplaceSectorNumber) } return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) diff --git a/extern/storage-sealing/upgrade_queue.go b/extern/storage-sealing/upgrade_queue.go index ed60e55d4..bb7bccd13 100644 --- a/extern/storage-sealing/upgrade_queue.go +++ b/extern/storage-sealing/upgrade_queue.go @@ -57,18 +57,18 @@ func (m *Sealing) tryUpgradeSector(ctx context.Context, params *miner.SectorPreC params.ReplaceSectorDeadline = loc.Deadline params.ReplaceSectorPartition = loc.Partition - ri, err := m.GetSectorInfo(*replace) + ri, err := m.api.StateSectorGetInfo(ctx, m.maddr, *replace, nil) if err != nil { - log.Errorf("error calling GetSectorInfo for replaced sector: %+v", err) + log.Errorf("error calling StateSectorGetInfo for replaced sector: %+v", err) return big.Zero() } - if params.Expiration < ri.PreCommitInfo.Expiration { + if params.Expiration < ri.Expiration { // TODO: Some limit on this - params.Expiration = ri.PreCommitInfo.Expiration + params.Expiration = ri.Expiration } - return ri.PreCommitDeposit + return ri.InitialPledge } return big.Zero()