@@ -1114,43 +1114,6 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
11141114 return
11151115 }
11161116
1117- // Removals can only be drained once the data set has a proving schedule: the
1118- // drain waits for the challenge window to close, and there is no window
1119- // without one. Accepting a removal before then would build a queue that can
1120- // never be drained, while blocking initProvingPeriod from ever succeeding.
1121- var proveAtEpoch sql.NullInt64
1122- err = p .db .QueryRow (ctx , `SELECT prove_at_epoch FROM pdp_data_sets WHERE id = $1` , dataSetId ).Scan (& proveAtEpoch )
1123- if err != nil {
1124- httpServerError (w , http .StatusInternalServerError , "Failed to read data set proving schedule" , err )
1125- return
1126- }
1127- if ! proveAtEpoch .Valid {
1128- http .Error (w , fmt .Sprintf ("data set %d has not started proving yet; retry once its first proving period is initialized" , dataSetId ),
1129- http .StatusTooManyRequests )
1130- return
1131- }
1132-
1133- // A drain transaction in flight means the queue is mid-processing. Adding to
1134- // it now re-fills what is being drained and pushes the proving-period
1135- // rollover further out, so refuse until the drain settles.
1136- //
1137- // Keyed on an in-flight message rather than the mere presence of a drain
1138- // row: the migration seeds a row for every data set, so row existence would
1139- // refuse every deletion until that sweep completed.
1140- var draining bool
1141- err = p .db .QueryRow (ctx , `
1142- SELECT EXISTS (SELECT 1 FROM pdpv0_deletion_drain WHERE data_set = $1 AND msg_hash IS NOT NULL)
1143- ` , dataSetId ).Scan (& draining )
1144- if err != nil {
1145- httpServerError (w , http .StatusInternalServerError , "Failed to read removal drain state" , err )
1146- return
1147- }
1148- if draining {
1149- http .Error (w , fmt .Sprintf ("data set %d is draining previously scheduled removals; retry once they are processed" , dataSetId ),
1150- http .StatusTooManyRequests )
1151- return
1152- }
1153-
11541117 // Soft gate: refuse if the data set's on-chain removal queue is already at our
11551118 // conservative ceiling. This keeps us well clear of the on-chain MAX_ENQUEUED_REMOVALS.
11561119 pdpVerifier , err := contract .NewPDPVerifier (contract .ContractAddresses ().PDPVerifier , p .ethClient )
@@ -1244,18 +1207,6 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
12441207 return false , err
12451208 }
12461209
1247- // PDPVerifier no longer applies scheduled removals inside
1248- // nextProvingPeriod, so the data set needs an explicit drain before it
1249- // can roll over. Enqueue it in the same transaction as the send.
1250- _ , err = tx .Exec (`
1251- INSERT INTO pdpv0_deletion_drain (data_set)
1252- VALUES ($1)
1253- ON CONFLICT (data_set) DO UPDATE SET blocked_at = NULL` , dataSetId )
1254- if err != nil {
1255- log .Errorw ("Failed to enqueue removal drain" , "dataSetId" , dataSetId , "error" , err )
1256- return false , err
1257- }
1258-
12591210 log .Infow ("scheduled user requested deletion" , "dataSetId" , dataSetId , "pieceIDs" , pieceIDsI64 , "txHash" , txHashLower )
12601211
12611212 return true , nil
0 commit comments