@@ -3,6 +3,7 @@ package unseal
3
3
import (
4
4
"context"
5
5
"github.com/filecoin-project/curio/lib/passcall"
6
+ "github.com/filecoin-project/go-commp-utils/nonffi"
6
7
"math/rand/v2"
7
8
"time"
8
9
@@ -65,12 +66,13 @@ func (t *TaskUnsealDecode) Do(taskID harmonytask.TaskID, stillOwned func() bool)
65
66
sectorParams := sectorParamsArr [0 ]
66
67
67
68
var sectorMeta []struct {
68
- TicketValue []byte `db:"ticket_value"`
69
- OrigSealedCID string `db:"orig_sealed_cid"`
70
- CurSealedCID string `db:"cur_sealed_cid"`
69
+ TicketValue []byte `db:"ticket_value"`
70
+ OrigSealedCID string `db:"orig_sealed_cid"`
71
+ CurSealedCID string `db:"cur_sealed_cid"`
72
+ CurUnsealedCID string `db:"cur_unsealed_cid"`
71
73
}
72
74
err = t .db .Select (ctx , & sectorMeta , `
73
- SELECT ticket_value, orig_sealed_cid, cur_sealed_cid
75
+ SELECT ticket_value, orig_sealed_cid, cur_sealed_cid, cur_unsealed_cid
74
76
FROM sectors_meta
75
77
WHERE sp_id = $1 AND sector_num = $2` , sectorParams .SpID , sectorParams .SectorNumber )
76
78
if err != nil {
@@ -90,6 +92,53 @@ func (t *TaskUnsealDecode) Do(taskID harmonytask.TaskID, stillOwned func() bool)
90
92
if err != nil {
91
93
return false , xerrors .Errorf ("decoding CurSealedCID: %w" , err )
92
94
}
95
+ var commD cid.Cid
96
+ if smeta .CurUnsealedCID == "" || smeta .CurUnsealedCID == "b" {
97
+ // https://github.com/filecoin-project/curio/issues/191
98
+ // <workaround>
99
+
100
+ var sectorPieces []struct {
101
+ PieceNum int64 `db:"piece_num"`
102
+ PieceCID string `db:"piece_cid"`
103
+ PieceSize int64 `db:"piece_size"` // padded
104
+ }
105
+ err = t .db .Select (ctx , & sectorPieces , `
106
+ SELECT piece_num, piece_cid, piece_size
107
+ FROM sectors_meta_pieces
108
+ WHERE sp_id = $1 AND sector_num = $2
109
+ ORDER BY piece_num` , sectorParams .SpID , sectorParams .SectorNumber )
110
+ if err != nil {
111
+ return false , xerrors .Errorf ("getting sector pieces: %w" , err )
112
+ }
113
+
114
+ spt := abi .RegisteredSealProof (sectorParams .RegSealProof )
115
+ var pieceInfos []abi.PieceInfo
116
+ for _ , p := range sectorPieces {
117
+ c , err := cid .Decode (p .PieceCID )
118
+ if err != nil {
119
+ return false , xerrors .Errorf ("decoding piece cid: %w" , err )
120
+ }
121
+
122
+ pieceInfos = append (pieceInfos , abi.PieceInfo {
123
+ Size : abi .PaddedPieceSize (p .PieceSize ),
124
+ PieceCID : c ,
125
+ })
126
+ }
127
+
128
+ commD , err = nonffi .GenerateUnsealedCID (spt , pieceInfos )
129
+ if err != nil {
130
+ return false , xerrors .Errorf ("generating unsealed cid: %w" , err )
131
+ }
132
+
133
+ log .Warnw ("workaround for issue #191" , "task" , taskID , "commD" , commD , "commK" , commK , "commR" , commR )
134
+
135
+ // </workaround>
136
+ } else {
137
+ commD , err = cid .Decode (smeta .CurUnsealedCID )
138
+ if err != nil {
139
+ return false , xerrors .Errorf ("decoding CurUnsealedCID: %w" , err )
140
+ }
141
+ }
93
142
94
143
sref := storiface.SectorRef {
95
144
ID : abi.SectorID {
@@ -100,9 +149,9 @@ func (t *TaskUnsealDecode) Do(taskID harmonytask.TaskID, stillOwned func() bool)
100
149
}
101
150
102
151
isSnap := commK != commR
103
- log .Infow ("unseal decode" , "snap" , isSnap , "task" , taskID , "commK" , commK , "commR" , commR )
152
+ log .Infow ("unseal decode" , "snap" , isSnap , "task" , taskID , "commK" , commK , "commR" , commR , "commD" , commD )
104
153
if isSnap {
105
- err := t .sc .DecodeSnap (ctx , taskID , commR , commK , sref )
154
+ err := t .sc .DecodeSnap (ctx , taskID , commD , commK , sref )
106
155
if err != nil {
107
156
return false , xerrors .Errorf ("DecodeSnap: %w" , err )
108
157
}
0 commit comments