Skip to content

feat(external-signer): emit UploadEvent progress through prepare/finalize - #68

Merged
jacderida merged 1 commit into
rc-2026.4.3from
feat/external-signer-progress-events
Apr 29, 2026
Merged

feat(external-signer): emit UploadEvent progress through prepare/finalize#68
jacderida merged 1 commit into
rc-2026.4.3from
feat/external-signer-progress-events

Conversation

@Nic-dorman

Copy link
Copy Markdown
Contributor

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):

existing new
Client::file_prepare_upload Client::file_prepare_upload_with_progress
Client::finalize_upload Client::finalize_upload_with_progress
Client::finalize_upload_merkle Client::finalize_upload_merkle_with_progress

Events emitted

event when
UploadEvent::Encrypting { chunks_done } once per 10 spilled chunks during encryption
UploadEvent::Encrypted { total_chunks } once after encryption + the optional public DataMap chunk are accounted for — first point where the 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 parameter on merkle_upload_chunks that emits the same event from its store loop.

Other touches

  • Removed the dead store_paid_chunks no-events alias; finalize_upload_with_progress calls store_paid_chunks_with_events(.., None, 0, total) directly.
  • merkle_upload_chunks gains a progress: Option<&mpsc::Sender<UploadEvent>> parameter. The other in-tree caller (Client::data_upload) passes None and is unaffected.

Test plan

  • cargo check --workspace
  • cargo clippy -p ant-core --all-targets -- -D warnings
  • cargo fmt --check
  • 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 / rc-2026.4.3).
  • End-to-end against a Sepolia-EVM devnet via a downstream consumer (ant-gui) wiring the new senders into its Tauri commands. Multiple 9-chunk uploads — every ChunkQuoted event reached the consumer with correct cumulative counts (0/9 → 9/9), and every ChunkStored event 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

…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>
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.

2 participants