Skip to content

Commit

Permalink
fix: handle compatibility issues for legacy deals
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Apr 23, 2024
1 parent b988579 commit a808665
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion damocles-manager/modules/impl/commitmgr/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (p PreCommitProcessor) preCommitInfo(
DealIDs: sector.DealIDs(), // DDO deal will be passed later in the Commit message
}

if len(sector.Pieces) > 0 {
if len(sector.Pieces) > 0 || len(sector.LegacyPieces) > 0 {
params.UnsealedCid = &sector.Pre.CommD
}

Expand Down
17 changes: 14 additions & 3 deletions damocles-manager/modules/sealer/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ func (s *Sealer) ReportFinalized(ctx context.Context, sid abi.SectorID) (core.Me

func (s *Sealer) ReportAborted(ctx context.Context, sid abi.SectorID, reason string) (core.Meta, error) {
err := s.state.Finalize(ctx, sid, func(st *core.SectorState) (bool, error) {
if dealCount := len(st.LegacyPieces); dealCount > 0 {
err := s.deal.ReleaseLegacyDeal(ctx, sid, st.LegacyPieces)
if err != nil {
return false, fmt.Errorf("release legacy deals in sector: %w", err)
}

sectorLogger(sid).Infow("legacy deals released", "count", dealCount)
}

if dealCount := len(st.Pieces); dealCount > 0 {
err := s.deal.Release(ctx, sid, st.Pieces)
if err != nil {
Expand Down Expand Up @@ -616,15 +625,17 @@ func (s *Sealer) SubmitSnapUpProof(
return resp, sectorStateErr(err)
}

if len(state.Pieces) != len(snapupInfo.Pieces) {
desc = fmt.Sprintf("pieces count not match: %d != %d", len(state.Pieces), len(snapupInfo.Pieces))
pieceInfos := state.PieceInfos()

if len(pieceInfos) != len(snapupInfo.Pieces) {
desc = fmt.Sprintf("pieces count not match: %d != %d", len(pieceInfos), len(snapupInfo.Pieces))
resp.Res = core.SubmitRejected
resp.Desc = &desc
return resp, nil
}

for pi, pid := range snapupInfo.Pieces {
if localPID := state.Pieces[pi].Piece.PieceCID; !pid.Equals(state.Pieces[pi].Piece.PieceCID) {
if localPID := pieceInfos[pi].Cid; !pid.Equals(pieceInfos[pi].Cid) {
desc = fmt.Sprintf("#%d piece cid not match: %s != %s", pi, localPID, pid)
resp.Res = core.SubmitRejected
resp.Desc = &desc
Expand Down
2 changes: 1 addition & 1 deletion damocles-manager/modules/sealer/sealer_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Sealer) RestoreSector(ctx context.Context, sid abi.SectorID, forced boo
var onRestore func(st *core.SectorState) (bool, error)
if !forced {
onRestore = func(st *core.SectorState) (bool, error) {
if len(st.Pieces) != 0 {
if len(st.PieceInfos()) != 0 {
return false, fmt.Errorf("sector with deals can not be normally restored")
}

Expand Down
7 changes: 4 additions & 3 deletions damocles-manager/modules/util/piece/piece.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ func ProcessPieces(
lookupID core.LookupID,
forceDDO bool,
) ([]miner13.PieceActivationManifest, []abi.DealID, error) {
pams := make([]miner13.PieceActivationManifest, 0, len(sector.Pieces))
dealIDs := make([]abi.DealID, 0, len(sector.Pieces))

sectorPieces := sector.SectorPiece()

pams := make([]miner13.PieceActivationManifest, 0, len(sectorPieces))
dealIDs := make([]abi.DealID, 0, len(sectorPieces))

hasDDO := forceDDO
if !forceDDO {
for _, piece := range sectorPieces {
Expand Down

0 comments on commit a808665

Please sign in to comment.