feat(external-signer): emit UploadEvent progress through prepare/finalize - #68
Merged
Merged
Conversation
…nalize
Adds optional `Option<mpsc::Sender<UploadEvent>>` parameters to the
external-signer upload API so applications (ant-gui, others) can drive
a progress bar through both phases of the two-phase flow. Without a
sender, behaviour is identical to before.
New methods (existing methods delegate with `None`):
Client::file_prepare_upload_with_progress(path, visibility, progress)
Client::finalize_upload_with_progress(prepared, tx_hash_map, progress)
Client::finalize_upload_merkle_with_progress(prepared, winner, progress)
Events emitted on the channel:
- `UploadEvent::Encrypting { chunks_done }` — once per 10 spilled chunks
during encryption (forwarded by `encrypt_file_to_spill`).
- `UploadEvent::Encrypted { total_chunks }` — once, after encryption +
the optional public-DataMap chunk are accounted for. This is the first
point where the chunk total is known.
- `UploadEvent::ChunkQuoted { quoted, total }` — once per chunk during
the wave-batch quote-collection phase. Replaces the previous bulk
`.collect()` with a streaming loop so events fire as each completes.
- `UploadEvent::ChunkStored { stored, total }` — once per chunk during
finalize. Wave-batch reuses the existing `store_paid_chunks_with_events`
helper; merkle gets a new `progress` arg on `merkle_upload_chunks` that
emits the same event from its store loop.
Other changes:
- The dead `store_paid_chunks` no-events alias is removed; finalize now
calls `store_paid_chunks_with_events(.., None, 0, total)` directly.
- `merkle_upload_chunks`'s other in-tree caller (`Client::data_upload`)
passes `None` and is unaffected.
Tested:
- cargo check --workspace, cargo clippy -p ant-core --all-targets
-D warnings, cargo fmt --check all clean.
- cargo test -p ant-core --lib: 221 pass; 1 unrelated pre-existing
failure (adaptive::tests::save_snapshot_to_unwritable_dir_does_not_panic,
Windows fs-permission flake — fails identically on main).
- End-to-end on a Sepolia-EVM devnet via a downstream consumer
(ant-gui) that wires the new senders into its Tauri commands.
ChunkQuoted events flow during `file_prepare_upload_with_progress`
with correct cumulative counts (0/9 → 9/9), and ChunkStored events
flow during `finalize_upload_with_progress` (1/9 → 9/9). Confirmed
the JS side receives every event with the right transfer_id and
applies them to the row's state.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jacderida
approved these changes
Apr 29, 2026
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds optional
Option<mpsc::Sender<UploadEvent>>parameters to the external-signer upload API so applications can drive a progress bar through both phases of the two-phase flow. Without a sender, behaviour is identical.The wallet-flow methods (
file_upload_with_progress,file_download_with_progress) already emit these events; this PR closes the symmetry gap so the external-signer flow emits the same events.API additions
Each existing method gains a new sibling that accepts a sender (the existing method delegates with
None):Client::file_prepare_uploadClient::file_prepare_upload_with_progressClient::finalize_uploadClient::finalize_upload_with_progressClient::finalize_upload_merkleClient::finalize_upload_merkle_with_progressEvents emitted
UploadEvent::Encrypting { chunks_done }UploadEvent::Encrypted { total_chunks }UploadEvent::ChunkQuoted { quoted, total }.collect()with a streaming loop so events fire as each completes.UploadEvent::ChunkStored { stored, total }store_paid_chunks_with_eventshelper; merkle gets a newprogressparameter onmerkle_upload_chunksthat emits the same event from its store loop.Other touches
store_paid_chunksno-events alias;finalize_upload_with_progresscallsstore_paid_chunks_with_events(.., None, 0, total)directly.merkle_upload_chunksgains aprogress: Option<&mpsc::Sender<UploadEvent>>parameter. The other in-tree caller (Client::data_upload) passesNoneand is unaffected.Test plan
cargo check --workspacecargo clippy -p ant-core --all-targets -- -D warningscargo fmt --checkcargo test -p ant-core --lib— 221 pass; 1 unrelated pre-existing failure (adaptive::tests::save_snapshot_to_unwritable_dir_does_not_panic, Windows fs-permission flake — fails identically onmain/rc-2026.4.3).ChunkQuotedevent reached the consumer with correct cumulative counts (0/9 → 9/9), and everyChunkStoredevent reached it during finalize (1/9 → 9/9). Confirmed via debug bridge that the receiver applies each event to the row's state.Companion PR
Downstream consumer wiring is on a parallel branch (ant-gui), gated on this PR landing + an ant-core release tag.
🤖 Generated with Claude Code