Multi-copy upload: deposit from `prepare()` can be short by the time a later commit executes (`insufficient funds to cover lockup after function execution`)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend-api-design, blockchain
Research direction
Start by tracing storage.prepare() and the multi-context upload commit flow, including DEFAULT_BUFFER_EPOCHS and DEFAULT_RUNWAY_EPOCHS; inspect the transaction error handling for createDataSetAndAddPieces and addPieces. Reproduce with multiple contexts and verify that preparation covers lockup needs as epochs pass, or that a commit reports the decoded revert reason. The issue names no source or test files, so first locate the relevant code and tests.
Written by the indexing model from the issue text.
Description
Summary
With two contexts (primary store plus SP-to-SP pull to a secondary), storage.prepare() computed and deposited the funds for both copies. The secondary's addPieces was submitted first and succeeded. The primary's createDataSetAndAddPieces, submitted a second later, executed about 4–6 epochs after prepare() read the account state and reverted in Filecoin Pay with insufficient funds to cover lockup after function execution. The shortfall was about 0.00001 USDFC. The upload result was correctly complete: false with one copy, but the only error reported was Commit failed. We found the reason by replaying the reverted transaction with eth_call.
The default deposit buffer is 5 epochs (DEFAULT_BUFFER_EPOCHS). In a multi-copy flow, store, pull and the commits take minutes, and the commits are executed by different providers at different epochs. 5 epochs leaves almost no margin.
Version
@filoz/synapse-sdk2.0.2,@filoz/synapse-core0.10.3,viem2.57.16, Node 24- Calibration (chain 314159)
DEFAULT_BUFFER_EPOCHS = 5nandDEFAULT_RUNWAY_EPOCHS = 0nare unchanged on the default branch as of 2026-11-10.
Steps to reproduce (what we ran)
The client account already had a Filecoin Pay balance and active rails from earlier uploads. Provider 9 got a new data set. Provider 61 reused an existing data set (51317).
Simplified (metadata and callbacks omitted):
const contexts = await synapse.storage.createContexts({ providerIds: [9n, 61n], copies: 2 })
const prep = await synapse.storage.prepare({ context: contexts, pieceSizes: [BigInt(data.byteLength)] }) // 2 MiB
await prep.transaction.execute() // deposit 0.620083151414808445 USDFC (lockup total 0.620009536881776 USDFC)
const up = await synapse.storage.upload(data, { contexts })
Timeline (2026-11-07, UTC):
| Time | Epoch | Event |
|---|---|---|
| 08:55:59 | ≈ 4223845–4223846 | prepare() computes costs: depositNeeded 0.620083151414808445 USDFC |
| 08:57:10 | 4223847 | deposit transaction included |
| 08:57:19 | SP-to-SP pull to provider 61 complete | |
| 08:57:20 | commit at 61 submitted (addPieces to the existing data set). It succeeded: data set 51317 holds the piece |
|
| 08:57:21 | executed in 4223850 | commit at 9 submitted (createDataSetAndAddPieces): 0x48a0c06702359c43ec8b06f51cebd0d89623e9ba5387e17ce5aeb66311995a2c, status 0 |
| 09:02:21 | upload() returns complete: false, copies: [61], failedAttempts: [{ providerId: 9, role: 'primary', error: 'Commit failed' }] |
The reverted transaction: https://calibration.filfox.info/en/message/0x48a0c06702359c43ec8b06f51cebd0d89623e9ba5387e17ce5aeb66311995a2c (exit code 33).
Replaying the reverted transaction with eth_call at its block returned the Filecoin Pay revert insufficient funds to cover lockup after function execution. The shortfall was about 0.00001 USDFC.
We did not retry, to avoid adding a duplicate piece to the existing data set.
Expected
Either:
prepare()deposits enough for all contexts to commit, including the epochs that pass during store, pull and commit, and including the order in which providers execute their commits; or- the SDK checks the account's available funds against the lockup each commit will need just before it signs that commit, and tops up or fails early with a clear message.
And in both cases, a failed commit reports the revert reason, not only Commit failed.
Actual
The second commit to execute reverted, short by about 0.00001 USDFC. The client got a partial placement (1 of 2 copies) with the error Commit failed.
Suggestions
- Use a larger default
bufferEpochswhenprepare()gets more than one context, or scale it with the expected store/pull/commit time. Or document clearly that multi-copy callers should passbufferEpochs/extraRunwayEpochs. - Re-check funds before signing each commit (
createDataSetAndAddPieces/addPiecesextra data) and include the shortfall in the error. - Include the decoded revert reason in
failedAttempts[].errorwhen a commit transaction reverts.
Our workaround
For multi-copy uploads we now pass extraRunwayEpochs: 240n to prepare(), capped at 0.1 USDFC with a hard ceiling of 1 USDFC. With that, a new placement on providers 9 and 61 (data sets 51840 and 51841, 2026-11-08) committed on both. The margin used was about 0.0023 USDFC. Both data sets have since had every ended proving period proven.
Reported by BlockX Labs. This report was written by our AI operations agent from our own run logs and on-chain data, and a human on the team approved posting it. The read-only scripts we use to check proof status and retrieval are at https://github.com/blockxlabs-ai/pdp-evidence-scripts.
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 36
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FilOzone/synapse-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FilOzone/synapse-sdk#1201 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
FilOzone/synapse-sdk#1198 · 1 comment ·
Maintainers usually reply within 1 day
-
Clarify add pieces and create set can be made concurrentlyPossibly taken @hugomrdias claimed this 22 days ago. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
FilOzone/synapse-sdk#749 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Upload to restricted data sets with `read: "restricted"`Possibly taken @JAG-UK claimed this today. Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
FilOzone/synapse-sdk#1197 · 2 comments ·
Maintainers usually reply within 1 day
-
Pull second copies from `/download` with per-piece FOC grantsPossibly taken @JAG-UK claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
FilOzone/synapse-sdk#1196 · 1 comment ·
Maintainers usually reply within 1 day
All issues in FilOzone/synapse-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zabuton-app/meguri#875 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
iruzen-dono/workless#117 ·
Maintainers usually reply within 1 day
-
area:api area:web wave wave:trivial
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vetro-protocol/vetro-monorepo#1321 ·
Maintainers usually reply within 1 day