Skip to content

Commit b5792b6

Browse files
committed
remove notify task, remove double upload path
1 parent 4280feb commit b5792b6

14 files changed

Lines changed: 788 additions & 566 deletions

File tree

cuhttp/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/filecoin-project/curio/cuhttp/servicedeps"
1616
"github.com/filecoin-project/curio/deps"
17+
"github.com/filecoin-project/curio/lib/piecestore"
1718
mhttp "github.com/filecoin-project/curio/market/http"
1819
"github.com/filecoin-project/curio/market/libp2p"
1920
"github.com/filecoin-project/curio/pdp"
@@ -99,6 +100,7 @@ func attachRouters(ctx context.Context, r *chi.Mux, d *deps.Deps, sd *ServiceDep
99100
if err := pdp.MountRoutes(ctx, r, pdp.MountDeps{
100101
DB: d.DB,
101102
LocalStore: d.LocalStore,
103+
PieceIO: piecestore.New(d.Stor, d.LocalStore, d.Si),
102104
EthClient: must.One(d.EthClient.Get()),
103105
Chain: d.Chain,
104106
EthSender: sd.EthSender,

documentation/en/experimental-features/PDPCURIOSPEC.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Harmony tasks are created through three trigger mechanisms:
143143

144144
- **Chain handlers** — Registered via `chainsched.AddHandler`, these callbacks fire on every chain head change. They inspect on-chain state (e.g. transaction receipts, epoch thresholds) and call `AddTask` to insert work into the harmony_task queue when conditions are met. The proving-cycle tasks (InitPP, ProvPeriod, Prove) use this mechanism so they respond immediately to new tipsets.
145145
- **IAmBored** — An optional callback in `TaskTypeDetails` that the task engine invokes when a machine has spare capacity and no queued work exists for that task type. A `passcall.Every(duration, ...)` wrapper rate-limits invocations. Tasks like TerminateFWSS (1 min), DeleteDataSet (1 hour), and Settle (12 hours) use IAmBored because they generate work opportunistically rather than in response to chain events.
146-
- **Polling** — Some tasks use a dedicated poller goroutine that periodically queries the database for pending work and calls `AddTask`. The Notify (2s) and PullPiece (10s) tasks use this pattern because their triggers are purely database-driven (new uploads or pull requests) with no chain dependency.
146+
- **Polling** — Some tasks use a dedicated poller goroutine that periodically queries the database for pending work and calls `AddTask`. PullPiece uses this pattern because its trigger is a database-backed pull request rather than a chain event.
147147

148148
All three mechanisms funnel through `harmonytask.AddTask()`, which atomically inserts a task record. The main poller loop (every 3s) then discovers unowned tasks and assigns them to machines with available resources.
149149

@@ -154,7 +154,6 @@ All three mechanisms funnel through `harmonytask.AddTask()`, which atomically in
154154
| `PDPv0_InitPP` | `InitProvingPeriodTask` | `tasks/pdpv0/task_init_pp.go` | Chain handler |
155155
| `PDPv0_ProvPeriod` | `NextProvingPeriodTask` | `tasks/pdpv0/task_next_pp.go` | Chain handler |
156156
| `PDPv0_Prove` | `ProveTask` | `tasks/pdpv0/task_prove.go` | Chain handler |
157-
| `PDPv0_Notify` | `PDPNotifyTask` | `tasks/pdpv0/notify_task.go` | Polling (2s) |
158157
| `PDPv0_PullPiece` | `PDPPullPieceTask` | `tasks/pdpv0/task_pull_piece.go` | Polling (10s) |
159158
| `PDPv0_Indexing` | `PDPIndexingTask` | `tasks/indexing/task_pdp_v0_indexing.go` | IAmBored (3s) |
160159
| `PDPv0_IPNI` | `PDPIPNITask` | `tasks/indexing/task_pdp_v0_ipni.go` | IAmBored (30s) |
@@ -182,9 +181,10 @@ The sections below describe how tasks and watchers connect to form the PDP lifec
182181

183182
There are two paths for getting pieces into the system:
184183

185-
**Direct upload path:**
186-
1. Client uploads piece data via HTTP. The data is written to `parked_pieces`.
187-
2. When the upload completes (`parked_pieces.complete = TRUE`), **PDPv0_Notify** picks it up, sends an HTTP callback to `notify_url` if configured, and moves the reference from `pdp_piece_uploads` to `pdp_piecerefs`.
184+
**Known-CID direct upload path:**
185+
1. The client posts the PieceCID. If a complete long-term copy already exists, the handler creates its `parked_piece_refs` and `pdp_piecerefs` rows immediately.
186+
2. Otherwise, the client PUTs the bytes to the returned upload URL. The handler claims a `parked_pieces` row, writes the request body once directly to final piece storage while computing CommP, and validates the declared size and PieceCID.
187+
3. After the write succeeds, one database transaction marks the parked piece complete, creates `pdp_piecerefs`, and deletes the upload row. The legacy `notify` request field is accepted for compatibility but this path does not call the URL or schedule a notify task.
188188

189189
**Pull path:**
190190
1. Client submits a pull request via HTTP, creating a row in `pdp_piece_pull_items`.

pdp/handlers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/filecoin-project/curio/harmony/harmonydb"
2727
"github.com/filecoin-project/curio/lib/ethchain"
2828
"github.com/filecoin-project/curio/lib/paths"
29+
"github.com/filecoin-project/curio/lib/piecestore"
2930
ipni_provider "github.com/filecoin-project/curio/market/ipni/ipni-provider"
3031
"github.com/filecoin-project/curio/pdp/contract"
3132
"github.com/filecoin-project/curio/tasks/indexing"
@@ -75,6 +76,7 @@ type PDPService struct {
7576
Auth
7677
db *harmonydb.DB
7778
storage paths.StashStore
79+
pieceIO piecestore.PieceIO
7880

7981
sender ETHTxSender
8082
ethClient ethchain.EthClient
@@ -98,6 +100,7 @@ func NewPDPService(
98100
ctx context.Context,
99101
db *harmonydb.DB,
100102
stor paths.StashStore,
103+
pieceIO piecestore.PieceIO,
101104
ec ethchain.EthClient,
102105
fc PDPServiceNodeApi,
103106
sn ETHTxSender,
@@ -111,6 +114,7 @@ func NewPDPService(
111114
Auth: auth,
112115
db: db,
113116
storage: stor,
117+
pieceIO: pieceIO,
114118

115119
sender: sn,
116120
ethClient: ec,
@@ -1312,6 +1316,10 @@ func (p *PDPService) handleGetDataSetPiece(w http.ResponseWriter, r *http.Reques
13121316

13131317
func (p *PDPService) cleanup(ctx context.Context) {
13141318
rm := func(ctx context.Context, db *harmonydb.DB) {
1319+
if err := p.cleanupExpiredDirectUploadClaims(ctx); err != nil {
1320+
log.Errorw("failed to clean up expired direct upload claims", "error", err)
1321+
}
1322+
13151323
var RefIDs []int64
13161324

13171325
err := db.QueryRow(ctx, `SELECT COALESCE(array_agg(piece_ref), '{}') AS ref_ids

0 commit comments

Comments
 (0)