sealing: wire up checkPieces and checkSeal
This commit is contained in:
parent
052b090bbf
commit
ba5a5d1248
@ -45,7 +45,7 @@ const (
|
|||||||
PreCommitFailed
|
PreCommitFailed
|
||||||
SealCommitFailed
|
SealCommitFailed
|
||||||
CommitFailed
|
CommitFailed
|
||||||
_
|
PackingFailed
|
||||||
_
|
_
|
||||||
_
|
_
|
||||||
_
|
_
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkPieces(ctx context.Context, si *SectorInfo, api sealingApi) error {
|
func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error {
|
||||||
for i, piece := range si.Pieces {
|
for i, piece := range si.Pieces {
|
||||||
deal, err := api.StateMarketStorageDeal(ctx, piece.DealID, nil)
|
deal, err := api.StateMarketStorageDeal(ctx, piece.DealID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -29,7 +29,7 @@ func checkPieces(ctx context.Context, si *SectorInfo, api sealingApi) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSeal(ctx context.Context, maddr address.Address, si *SectorInfo, api sealingApi) (err error) {
|
func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api sealingApi) (err error) {
|
||||||
ssize, err := api.StateMinerSectorSize(ctx, maddr, nil)
|
ssize, err := api.StateMinerSectorSize(ctx, maddr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -45,7 +45,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si *SectorInfo, api s
|
|||||||
|
|
||||||
ccmt := &types.Message{
|
ccmt := &types.Message{
|
||||||
To: actors.StorageMarketAddress,
|
To: actors.StorageMarketAddress,
|
||||||
From: actors.StorageMarketAddress,
|
From: maddr,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
GasPrice: types.NewInt(0),
|
GasPrice: types.NewInt(0),
|
||||||
GasLimit: types.NewInt(9999999999),
|
GasLimit: types.NewInt(9999999999),
|
||||||
@ -57,7 +57,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si *SectorInfo, api s
|
|||||||
return xerrors.Errorf("calling ComputeDataCommitment: %w", err)
|
return xerrors.Errorf("calling ComputeDataCommitment: %w", err)
|
||||||
}
|
}
|
||||||
if r.ExitCode != 0 {
|
if r.ExitCode != 0 {
|
||||||
return xerrors.Errorf("receipt for ComputeDataCommitment han exit code %d", r.ExitCode)
|
return xerrors.Errorf("receipt for ComputeDataCommitment had exit code %d", r.ExitCode)
|
||||||
}
|
}
|
||||||
if string(r.Return) != string(si.CommD) {
|
if string(r.Return) != string(si.CommD) {
|
||||||
return xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)
|
return xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)
|
||||||
|
@ -34,8 +34,10 @@ var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{
|
|||||||
api.Unsealed: planOne(
|
api.Unsealed: planOne(
|
||||||
on(SectorSealed{}, api.PreCommitting),
|
on(SectorSealed{}, api.PreCommitting),
|
||||||
on(SectorSealFailed{}, api.SealFailed),
|
on(SectorSealFailed{}, api.SealFailed),
|
||||||
|
on(SectorPackingFailed{}, api.PackingFailed),
|
||||||
),
|
),
|
||||||
api.PreCommitting: planOne(
|
api.PreCommitting: planOne(
|
||||||
|
on(SectorSealFailed{}, api.SealFailed),
|
||||||
on(SectorPreCommitted{}, api.WaitSeed),
|
on(SectorPreCommitted{}, api.WaitSeed),
|
||||||
on(SectorPreCommitFailed{}, api.PreCommitFailed),
|
on(SectorPreCommitFailed{}, api.PreCommitFailed),
|
||||||
),
|
),
|
||||||
@ -221,7 +223,7 @@ func planOne(ts ...func() (mut mutator, next api.SectorState)) func(events []sta
|
|||||||
return func(events []statemachine.Event, state *SectorInfo) error {
|
return func(events []statemachine.Event, state *SectorInfo) error {
|
||||||
if len(events) != 1 {
|
if len(events) != 1 {
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
if gm, ok := event.User.(globalMutator); !ok {
|
if gm, ok := event.User.(globalMutator); ok {
|
||||||
gm.applyGlobal(state)
|
gm.applyGlobal(state)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -229,7 +231,7 @@ func planOne(ts ...func() (mut mutator, next api.SectorState)) func(events []sta
|
|||||||
return xerrors.Errorf("planner for state %s only has a plan for a single event only, got %+v", api.SectorStates[state.State], events)
|
return xerrors.Errorf("planner for state %s only has a plan for a single event only, got %+v", api.SectorStates[state.State], events)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gm, ok := events[0].User.(globalMutator); !ok {
|
if gm, ok := events[0].User.(globalMutator); ok {
|
||||||
gm.applyGlobal(state)
|
gm.applyGlobal(state)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ func (evt SectorPacked) apply(state *SectorInfo) {
|
|||||||
state.Pieces = append(state.Pieces, evt.pieces...)
|
state.Pieces = append(state.Pieces, evt.pieces...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SectorPackingFailed struct{ error }
|
||||||
|
|
||||||
|
func (evt SectorPackingFailed) apply(*SectorInfo) {}
|
||||||
|
|
||||||
type SectorSealed struct {
|
type SectorSealed struct {
|
||||||
commR []byte
|
commR []byte
|
||||||
commD []byte
|
commD []byte
|
||||||
|
@ -44,6 +44,10 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) error {
|
func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) error {
|
||||||
|
if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state
|
||||||
|
return ctx.Send(SectorPackingFailed{xerrors.Errorf("checkPieces error: %w", err)})
|
||||||
|
}
|
||||||
|
|
||||||
log.Infow("performing sector replication...", "sector", sector.SectorID)
|
log.Infow("performing sector replication...", "sector", sector.SectorID)
|
||||||
ticket, err := m.tktFn(ctx.Context())
|
ticket, err := m.tktFn(ctx.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,6 +70,10 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
||||||
|
if err := checkSeal(ctx.Context(), m.maddr, sector, m.api); err != nil {
|
||||||
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("checkPieces error: %w", err)})
|
||||||
|
}
|
||||||
|
|
||||||
params := &actors.SectorPreCommitInfo{
|
params := &actors.SectorPreCommitInfo{
|
||||||
SectorNumber: sector.SectorID,
|
SectorNumber: sector.SectorID,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user