Skip to content

Commit b3501af

Browse files
committed
Some cleanup
1 parent c469484 commit b3501af

3 files changed

Lines changed: 1 addition & 187 deletions

File tree

pdp/contract/removals.go

Lines changed: 0 additions & 128 deletions
This file was deleted.

pdp/handlers.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tasks/pdpv0/watch_proving_period.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func clearFailedProvingPeriodReconciliations(ctx context.Context, db *harmonydb.
192192
//
193193
// A zero next challenge epoch is ambiguous since FilOzone/pdp#297:
194194
// processPieceDeletions also clears it, on a perfectly healthy data set that
195-
// still has leaves and is simply due a fresh challenge at the next rollover.
195+
// still has leaves and is simply due a fresh challenge at the next proving period.
196196
// Leaf count is the discriminator -- only a zero challenge with zero leaves is a
197197
// genuinely emptied data set.
198198
func processEmptyProvingPeriods(ctx context.Context, db *harmonydb.DB, ethClient ethchain.EthClient, periods []confirmedProvingPeriod) error {
@@ -225,9 +225,6 @@ func processEmptyProvingPeriods(ctx context.Context, db *harmonydb.DB, ethClient
225225
return xerrors.Errorf("failed to get leaf count for data set %d: %w", period.DataSetID, err)
226226
}
227227
if leafCount.Sign() > 0 {
228-
// Leaves remain, so the challenge was cleared by a processed
229-
// deletion rather than by the data set emptying. The proving
230-
// schedule is still valid and nextProvingPeriod will resample.
231228
log.Debugw("skipping empty-period reset; challenge cleared by processed deletions",
232229
"dataSetId", period.DataSetID, "leafCount", leafCount.String())
233230
continue
@@ -273,9 +270,3 @@ func clearProvingPeriodReconcileNeeded(ctx context.Context, db *harmonydb.DB, pe
273270
}
274271
return nil
275272
}
276-
277-
// processPendingPieceDeletes, and its helpers, moved to
278-
// watch_process_deletions.go: removals are now applied by their own
279-
// transaction rather than by nextProvingPeriod. It is still called from here as
280-
// well, because the reconciliation is chain-authoritative and therefore correct
281-
// against a PDPVerifier that predates processPieceDeletions.

0 commit comments

Comments
 (0)