Commit db61c7a
feat(fine-tuning): storage-first delivery flow with TEE fallback (#354)
* feat: storage-first flow - upload to 0G Storage + keep local backup
- Finalizer now always encrypts locally first (TEE backup)
- Then attempts upload to 0G Storage (unless skipStorageUpload=true)
- If storage upload fails, falls back to local hash gracefully
- Encrypted file is always retained for TEE download fallback
- Removes old encryptAndUploadModel (split into encrypt + upload)
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: handle raw JSONL files downloaded from 0G Storage
Previously DownloadFromStorage always assumed ZIP format, causing
"zip: not a valid zip file" when CLI uploads raw JSONL to 0G Storage.
Changes:
- Detect file type via magic bytes before attempting unzip
- For non-ZIP files (raw JSONL), move directly to target path
- Convert raw JSONL to HuggingFace DatasetDict format after download
(required by token counter and training executor)
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: handle raw JSONL from 0G Storage and auto-calculate fee
- DownloadFromStorage: detect file type via magic bytes, handle non-ZIP
- Clean up existing target before rename on retry
- Convert raw JSONL to HF DatasetDict format after download
- Auto-calculate fee when fee=0 (broker-calculated fee mode)
- Verify signature with original fee to avoid mismatch
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: address code review feedback for storage client
- [HIGH] Use passed ctx instead of context.Background() in Download call
for proper cancellation/timeout propagation
- [HIGH] Add defer cleanup for temp download file to prevent disk leaks
on early error returns
- [MEDIUM] Improve isZipFile() to return errors on I/O failures instead
of silently treating them as non-ZIP files
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: upgrade 0g-storage-client to v1.2.2 and fix root hash encoding
- Upgrade 0g-storage-client v1.2.1 → v1.2.2 to fix ABI incompatibility
with testnet Flow contract (was causing `execution reverted; data: 0x`)
- Remove deprecated WithRoutines() calls (now set internally via
UploaderConfig in v1.2.2)
- Fix uploadModel() to return raw 32-byte hash (hash.Bytes()) instead of
hex string bytes ([]byte(hash.Hex())), which caused double-encoding
via hexutil.Encode and prevented client from downloading model via
0G Storage
Tested: Full flow verified with Qwen2.5-0.5B and Qwen3-32B (1.1GB model)
— broker upload, client download from 0G Storage, decrypt, LoRA verified.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Wuying Created Local Users <zeyu@hoexzqc9b0fyi8p.US-EAST-1-198-1-1.WUYING.LOCAL>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent bed782d commit db61c7a
File tree
5 files changed
+228
-97
lines changed- api
- fine-tuning/internal
- services
- storage
5 files changed
+228
-97
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
95 | 108 | | |
96 | | - | |
97 | | - | |
98 | 109 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | | - | |
107 | | - | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
114 | | - | |
| 120 | + | |
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| |||
190 | 196 | | |
191 | 197 | | |
192 | 198 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
251 | 202 | | |
252 | 203 | | |
253 | 204 | | |
254 | 205 | | |
255 | 206 | | |
256 | 207 | | |
257 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
258 | 216 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 217 | + | |
| 218 | + | |
264 | 219 | | |
265 | 220 | | |
266 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| |||
331 | 334 | | |
332 | 335 | | |
333 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
334 | 455 | | |
335 | 456 | | |
336 | 457 | | |
| |||
0 commit comments