Merge pull request #3160 from filecoin-project/asr/cc-upgrade-fixes

cc upgrade fixes
This commit is contained in:
Łukasz Magiera 2020-08-19 01:29:05 +02:00 committed by GitHub
commit ec4603e55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -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 { func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error {
tok, height, err := m.api.ChainHead(ctx.Context()) tok, height, err := m.api.ChainHead(ctx.Context())
if err != nil { 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) 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()) mcid, err := m.api.SendMsg(ctx.Context(), waddr, m.maddr, builtin.MethodsMiner.PreCommitSector, deposit, m.feeCfg.MaxPreCommitGasFee, enc.Bytes())
if err != nil { if err != nil {
if params.ReplaceCapacity {
m.remarkForUpgrade(params.ReplaceSectorNumber)
}
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) 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")}) 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) log.Info("Sector precommitted: ", sector.SectorNumber)
mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage) mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage)
if err != nil { if err != nil {

View File

@ -57,18 +57,18 @@ func (m *Sealing) tryUpgradeSector(ctx context.Context, params *miner.SectorPreC
params.ReplaceSectorDeadline = loc.Deadline params.ReplaceSectorDeadline = loc.Deadline
params.ReplaceSectorPartition = loc.Partition params.ReplaceSectorPartition = loc.Partition
ri, err := m.GetSectorInfo(*replace) ri, err := m.api.StateSectorGetInfo(ctx, m.maddr, *replace, nil)
if err != 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() return big.Zero()
} }
if params.Expiration < ri.PreCommitInfo.Expiration { if params.Expiration < ri.Expiration {
// TODO: Some limit on this // TODO: Some limit on this
params.Expiration = ri.PreCommitInfo.Expiration params.Expiration = ri.Expiration
} }
return ri.PreCommitDeposit return ri.InitialPledge
} }
return big.Zero() return big.Zero()