Skip to content

Commit 4ac5aa6

Browse files
committed
feat(pdp): support create and upload
Signed-off-by: Jakub Sztandera <[email protected]>
1 parent e46803e commit 4ac5aa6

File tree

7 files changed

+783
-585
lines changed

7 files changed

+783
-585
lines changed

pdp/contract/PDPVerifier.abi

Lines changed: 99 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
"inputs": [],
55
"stateMutability": "nonpayable"
66
},
7-
{
8-
"type": "function",
9-
"name": "BURN_ACTOR",
10-
"inputs": [],
11-
"outputs": [
12-
{
13-
"name": "",
14-
"type": "address",
15-
"internalType": "address"
16-
}
17-
],
18-
"stateMutability": "view"
19-
},
207
{
218
"type": "function",
229
"name": "EXTRA_DATA_MAX_SIZE",
@@ -30,32 +17,6 @@
3017
],
3118
"stateMutability": "view"
3219
},
33-
{
34-
"type": "function",
35-
"name": "FIL_USD_PRICE_FEED_ID",
36-
"inputs": [],
37-
"outputs": [
38-
{
39-
"name": "",
40-
"type": "bytes32",
41-
"internalType": "bytes32"
42-
}
43-
],
44-
"stateMutability": "view"
45-
},
46-
{
47-
"type": "function",
48-
"name": "LEAF_SIZE",
49-
"inputs": [],
50-
"outputs": [
51-
{
52-
"name": "",
53-
"type": "uint256",
54-
"internalType": "uint256"
55-
}
56-
],
57-
"stateMutability": "view"
58-
},
5920
{
6021
"type": "function",
6122
"name": "MAX_ENQUEUED_REMOVALS",
@@ -108,45 +69,6 @@
10869
],
10970
"stateMutability": "view"
11071
},
111-
{
112-
"type": "function",
113-
"name": "PYTH",
114-
"inputs": [],
115-
"outputs": [
116-
{
117-
"name": "",
118-
"type": "address",
119-
"internalType": "contract IPyth"
120-
}
121-
],
122-
"stateMutability": "view"
123-
},
124-
{
125-
"type": "function",
126-
"name": "RANDOMNESS_PRECOMPILE",
127-
"inputs": [],
128-
"outputs": [
129-
{
130-
"name": "",
131-
"type": "address",
132-
"internalType": "address"
133-
}
134-
],
135-
"stateMutability": "view"
136-
},
137-
{
138-
"type": "function",
139-
"name": "SECONDS_IN_DAY",
140-
"inputs": [],
141-
"outputs": [
142-
{
143-
"name": "",
144-
"type": "uint256",
145-
"internalType": "uint256"
146-
}
147-
],
148-
"stateMutability": "view"
149-
},
15072
{
15173
"type": "function",
15274
"name": "UPGRADE_INTERFACE_VERSION",
@@ -182,6 +104,11 @@
182104
"type": "uint256",
183105
"internalType": "uint256"
184106
},
107+
{
108+
"name": "listenerAddr",
109+
"type": "address",
110+
"internalType": "address"
111+
},
185112
{
186113
"name": "pieceData",
187114
"type": "tuple[]",
@@ -207,7 +134,7 @@
207134
"internalType": "uint256"
208135
}
209136
],
210-
"stateMutability": "nonpayable"
137+
"stateMutability": "payable"
211138
},
212139
{
213140
"type": "function",
@@ -217,9 +144,23 @@
217144
"name": "setId",
218145
"type": "uint256",
219146
"internalType": "uint256"
220-
},
147+
}
148+
],
149+
"outputs": [
150+
{
151+
"name": "",
152+
"type": "uint256",
153+
"internalType": "uint256"
154+
}
155+
],
156+
"stateMutability": "view"
157+
},
158+
{
159+
"type": "function",
160+
"name": "calculateProofFeeForSize",
161+
"inputs": [
221162
{
222-
"name": "estimatedGasFee",
163+
"name": "rawSize",
223164
"type": "uint256",
224165
"internalType": "uint256"
225166
}
@@ -312,6 +253,32 @@
312253
"outputs": [],
313254
"stateMutability": "nonpayable"
314255
},
256+
{
257+
"type": "function",
258+
"name": "feeEffectiveTime",
259+
"inputs": [],
260+
"outputs": [
261+
{
262+
"name": "",
263+
"type": "uint64",
264+
"internalType": "uint64"
265+
}
266+
],
267+
"stateMutability": "view"
268+
},
269+
{
270+
"type": "function",
271+
"name": "feePerTiB",
272+
"inputs": [],
273+
"outputs": [
274+
{
275+
"name": "",
276+
"type": "uint96",
277+
"internalType": "uint96"
278+
}
279+
],
280+
"stateMutability": "view"
281+
},
315282
{
316283
"type": "function",
317284
"name": "findPieceIds",
@@ -531,24 +498,6 @@
531498
],
532499
"stateMutability": "view"
533500
},
534-
{
535-
"type": "function",
536-
"name": "getFILUSDPrice",
537-
"inputs": [],
538-
"outputs": [
539-
{
540-
"name": "",
541-
"type": "uint64",
542-
"internalType": "uint64"
543-
},
544-
{
545-
"name": "",
546-
"type": "int32",
547-
"internalType": "int32"
548-
}
549-
],
550-
"stateMutability": "view"
551-
},
552501
{
553502
"type": "function",
554503
"name": "getNextChallengeEpoch",
@@ -815,6 +764,19 @@
815764
"outputs": [],
816765
"stateMutability": "nonpayable"
817766
},
767+
{
768+
"type": "function",
769+
"name": "proposedFeePerTiB",
770+
"inputs": [],
771+
"outputs": [
772+
{
773+
"name": "",
774+
"type": "uint96",
775+
"internalType": "uint96"
776+
}
777+
],
778+
"stateMutability": "view"
779+
},
818780
{
819781
"type": "function",
820782
"name": "provePossession",
@@ -901,6 +863,19 @@
901863
"outputs": [],
902864
"stateMutability": "nonpayable"
903865
},
866+
{
867+
"type": "function",
868+
"name": "updateProofFee",
869+
"inputs": [
870+
{
871+
"name": "newFeePerTiB",
872+
"type": "uint256",
873+
"internalType": "uint256"
874+
}
875+
],
876+
"outputs": [],
877+
"stateMutability": "nonpayable"
878+
},
904879
{
905880
"type": "function",
906881
"name": "upgradeToAndCall",
@@ -989,6 +964,31 @@
989964
],
990965
"anonymous": false
991966
},
967+
{
968+
"type": "event",
969+
"name": "FeeUpdateProposed",
970+
"inputs": [
971+
{
972+
"name": "currentFee",
973+
"type": "uint256",
974+
"indexed": false,
975+
"internalType": "uint256"
976+
},
977+
{
978+
"name": "newFee",
979+
"type": "uint256",
980+
"indexed": false,
981+
"internalType": "uint256"
982+
},
983+
{
984+
"name": "effectiveTime",
985+
"type": "uint256",
986+
"indexed": false,
987+
"internalType": "uint256"
988+
}
989+
],
990+
"anonymous": false
991+
},
992992
{
993993
"type": "event",
994994
"name": "Initialized",
@@ -1143,18 +1143,6 @@
11431143
"type": "uint256",
11441144
"indexed": false,
11451145
"internalType": "uint256"
1146-
},
1147-
{
1148-
"name": "price",
1149-
"type": "uint64",
1150-
"indexed": false,
1151-
"internalType": "uint64"
1152-
},
1153-
{
1154-
"name": "expo",
1155-
"type": "int32",
1156-
"indexed": false,
1157-
"internalType": "int32"
11581146
}
11591147
],
11601148
"anonymous": false

pdp/contract/PDPVerifier.go

Lines changed: 303 additions & 242 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdp/contract/PDPVerifier.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

pdp/handlers.go

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func Routes(r *chi.Mux, p *PDPService) {
7474
// POST /pdp/data-sets - Create a new data set
7575
r.Post("/", p.handleCreateDataSet)
7676

77+
// POST /pdp/data-sets/create-and-add - Create a new data set and add pieces at the same time
78+
r.Post("/create-and-add", p.handleCreateDataSetAndAddPieces)
79+
7780
// GET /pdp/data-sets/created/{txHash} - Get the status of a data set creation
7881
r.Get("/created/{txHash}", p.handleGetDataSetCreationStatus)
7982

@@ -285,53 +288,6 @@ func (p *PDPService) getSenderAddress(ctx context.Context) (common.Address, erro
285288
return address, nil
286289
}
287290

288-
// insertMessageWaitsAndDataSetCreate inserts records into message_waits_eth and pdp_data_set_creates
289-
func (p *PDPService) insertMessageWaitsAndDataSetCreate(ctx context.Context, txHashHex string, serviceLabel string) error {
290-
// Begin a database transaction
291-
_, err := p.db.BeginTransaction(ctx, func(tx *harmonydb.Tx) (bool, error) {
292-
// Insert into message_waits_eth
293-
log.Debugw("Inserting into message_waits_eth",
294-
"txHash", txHashHex,
295-
"status", "pending")
296-
_, err := tx.Exec(`
297-
INSERT INTO message_waits_eth (signed_tx_hash, tx_status)
298-
VALUES ($1, $2)
299-
`, txHashHex, "pending")
300-
if err != nil {
301-
log.Errorw("Failed to insert into message_waits_eth",
302-
"txHash", txHashHex,
303-
"error", err)
304-
return false, err // Return false to rollback the transaction
305-
}
306-
307-
// Insert into pdp_data_set_creates
308-
log.Debugw("Inserting into pdp_data_set_creates",
309-
"txHash", txHashHex,
310-
"service", serviceLabel)
311-
_, err = tx.Exec(`
312-
INSERT INTO pdp_data_set_creates (create_message_hash, service)
313-
VALUES ($1, $2)
314-
`, txHashHex, serviceLabel)
315-
if err != nil {
316-
log.Errorw("Failed to insert into pdp_data_set_creates",
317-
"txHash", txHashHex,
318-
"error", err)
319-
return false, err // Return false to rollback the transaction
320-
}
321-
322-
log.Infow("Successfully inserted orphaned transaction for watching",
323-
"txHash", txHashHex,
324-
"service", serviceLabel,
325-
"waiter_machine_id", "NULL")
326-
// Return true to commit the transaction
327-
return true, nil
328-
}, harmonydb.OptionRetry())
329-
if err != nil {
330-
return err
331-
}
332-
return nil
333-
}
334-
335291
// handleGetDataSetCreationStatus handles the GET request to retrieve the status of a data set creation
336292
func (p *PDPService) handleGetDataSetCreationStatus(w http.ResponseWriter, r *http.Request) {
337293
ctx := r.Context()

0 commit comments

Comments
 (0)