Skip to content

feat(upload): use ant-core estimate_upload_cost for pre-upload quotes#47

Merged
Nic-dorman merged 2 commits intomainfrom
feat/upstream-cost-estimate
Apr 22, 2026
Merged

feat(upload): use ant-core estimate_upload_cost for pre-upload quotes#47
Nic-dorman merged 2 commits intomainfrom
feat/upstream-cost-estimate

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

Summary

  • Both the Estimate Cost button and the Upload dialog pre-quote used to call start_uploadfile_prepare_upload, which encrypts the whole file to disk and parks a PreparedUpload for 30 minutes. Every cancelled estimate leaked hundreds of encrypted chunks into memory.
  • Switch both to the new lightweight Client::estimate_upload_cost (ant-core PR fix(wallet): direct-key + Arbitrum One mainnet payments #44, merge b0c501a): samples a single network quote for a representative chunk and extrapolates. No encryption-to-spill, no parked upload, no wallet required.
  • Multi-file estimates now run in parallel (Promise.all), so dialog-open latency tracks the slowest single quote instead of the sum.
  • Confirm click still runs the real start_upload via startRealUpload, so the heavy work happens only on commit. Dropped the preQuote handoff plumbing and the pendingQuotes map.
  • Renamed the 'quoting' status label to "Preparing upload…" now that the heavy phase sits post-Confirm.
  • Removed utils/payment.ts::estimatePaymentGasCost — PR fix(wallet): direct-key + Arbitrum One mainnet payments #44's gas heuristic replaces it. Its leftover GAS_* constants and getGasPrice import go with it.

Dependency bump

ant-core pin f88c95db0c501a (PR #44 merge). Cascades to ant-node 0.10.0 → 0.10.1 and saorsa-core 0.23.0 → 0.23.1 via the resolver.

Test plan

  • cargo check clean
  • vitest — 19/19 pass
  • Dev app smoke test on live network before tomorrow's release:
    • Estimate Cost (top-bar) on 3 files shows a cost within ~5 s and leaves pending_uploads empty
    • Open Upload dialog → see "Estimating cost…" → cost appears → Cancel → pending_uploads empty
    • Open Upload dialog → Confirm → "Preparing upload…" visible → upload lands on network
    • Indelible path: estimate is skipped (Indelible is server-driven cost) — verify nothing regressed
    • Tiny file (<3 bytes) rejection surfaces with a sensible error, not a crash

Known follow-ups

  • If public-uploads (Visibility arg) merges upstream, estimate_file_cost needs a visibility hint so the chunk count includes the DataMap chunk for public uploads.
  • CostEstimationInconclusive error path currently reaches the frontend as a generic warn + null return. A friendlier toast ("Cost estimate unavailable, try another file") would be nicer.

🤖 Generated with Claude Code

Nic-dorman and others added 2 commits April 22, 2026 09:43
Both the Estimate Cost top-bar button and the Upload dialog's pre-quote
used to call start_upload (file_prepare_upload), which encrypts the
whole file to a spill and parks a PreparedUpload in pending_uploads for
30 minutes. Every dialog open or estimate click paid that full cost
even if the user cancelled, leaving hundreds of encrypted chunks in
memory until the GC loop expired them.

Switch both paths to the new estimate_upload_cost API (ant-core #44):
samples a single network quote for a representative chunk and
extrapolates total cost. No encryption-to-spill, no parked upload, no
wallet required. Estimates now run in parallel too — each is
independent, so multi-file dialog latency drops to the slowest sample.

Confirm click still runs the real start_upload via startRealUpload,
so the actual encryption + quote collection happens only when the user
commits. Drop the preQuote handoff plumbing and the pendingQuotes map;
startRealUpload's fresh-quote branch already does the right thing.

Rename the 'quoting' status label to "Preparing upload..." since the
heavy work now happens post-confirm.

Drop utils/payment.ts::estimatePaymentGasCost — PR #44's gas heuristic
replaces it. Its leftover GAS_* constants and getGasPrice import go
with it.

Bump ant-core pin f88c95d -> b0c501a (PR #44 merge).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Before the PR #44 rework, this comment was accurate — the dialog
called getUploadQuote directly. After the rework, the dialog uses
estimateFileCost and getUploadQuote is only reached via startRealUpload
once the user has committed. Update the comment to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman merged commit 748edb4 into main Apr 22, 2026
4 checks passed
@Nic-dorman Nic-dorman deleted the feat/upstream-cost-estimate branch April 22, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant