Skip to content

feat(external-signer): add Visibility arg to file_prepare_upload (rc-2026.4.2)#54

Merged
jacderida merged 2 commits intorc-2026.4.2from
feat/external-signer-public-upload-rc
Apr 22, 2026
Merged

feat(external-signer): add Visibility arg to file_prepare_upload (rc-2026.4.2)#54
jacderida merged 2 commits intorc-2026.4.2from
feat/external-signer-public-upload-rc

Conversation

@jacderida
Copy link
Copy Markdown
Contributor

Backport of #39 onto the rc-2026.4.2 release branch.

#39 was accidentally merged into main; this PR cherry-picks its two
commits onto rc-2026.4.2 so the Visibility work lands in the RC.

Summary

  • feat(external-signer): add Visibility arg to file_prepare_upload (2da81fc)
  • test: add round-trip coverage + polish FileUploadResult/PreparedUpload (586a129)

Conflicts with rc-2026.4.2 resolved in:

  • ant-core/Cargo.toml — kept both rmp-serde and saorsa-core dev-deps
  • ant-core/src/data/client/file.rs — kept both Visibility enum and UploadCostEstimate struct
  • ant-core/src/data/mod.rs — merged re-export list to include both UploadCostEstimate and Visibility

Test plan

  • cargo check --all-targets passes locally
  • CI green
  • Existing round-trip tests still cover private/public visibility behaviour

🤖 Generated with Claude Code

Nic-dorman and others added 2 commits April 22, 2026 23:50
Adds an external-signer path for public uploads. When a PreparedUpload
is prepared with Visibility::Public, the serialized DataMap is bundled
into the payment batch (wave-batch or merkle) as an additional chunk.
FileUploadResult::data_map_address then carries the chunk address of
the stored DataMap, giving the uploader a single network address to
share for retrieval.

Motivation: ant-gui (the Autonomi desktop GUI) currently has to block
its Public upload option in the UI because no external-signer pathway
exists for publishing the data map — `data_map_store` internally calls
`pay_for_storage`, which hard-requires a wallet, and the chunk-storage
plumbing (`store_paid_chunks`, `chunk_put_to_close_group`,
`merkle_upload_chunks`) is pub(crate), so consumers on the
external-signer path cannot hand-roll it. Bundling the data map chunk
into the existing payment batch reuses the one-signature flow that
wave-batch and merkle already use for file chunks, which lets ant-gui
thread a `visibility` flag through its existing code path and re-enable
the Public option with no extra wallet round-trip.

- `Visibility::{Private, Public}` enum (default Private)
- `Client::file_prepare_upload_with_visibility(path, visibility)`;
  the existing `file_prepare_upload(path)` now delegates with Private
  for backward compatibility
- `PreparedUpload.data_map_address: Option<[u8; 32]>` carries the
  address between prepare and finalize
- `FileUploadResult.data_map_address` is Some for public uploads
- Both `finalize_upload` and `finalize_upload_merkle` propagate the
  field; no separate network call is needed because the data map chunk
  is stored alongside the rest of the batch
- e2e test verifies Private leaves the address unset, Public records
  it, and the recorded address matches the serialized data map

The internal-wallet path (`file_upload_with_mode`) is unchanged —
ant-cli continues to use `file_upload` followed by `data_map_store`
for its public upload flow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses review feedback:

- **End-to-end round-trip test (wave-batch)**: a small file is prepared as
  `Visibility::Public`, signed via the testnet wallet, finalized, then
  retrieved using only `data_map_fetch(&data_map_address)` + `file_download`.
  Asserts the downloaded bytes match the original. This is the half of the
  contract the existing test didn't cover: not just that the address is
  recorded, but that it actually refers to a retrievable DataMap.

- **`#[non_exhaustive]` on `FileUploadResult` and `PreparedUpload`**: adding
  `data_map_address` was already technically a breaking change for any
  downstream that struct-literal-constructed these; `#[non_exhaustive]`
  forecloses the same concern for the next field.

- **`AlreadyStored` data-map-chunk visibility**: when the serialized
  `DataMap` hashes to a chunk that's already on the network (same file
  uploaded twice — plausible under deterministic self-encryption), the
  prepare step silently drops it from `prepared_chunks` while keeping
  `data_map_address = Some(addr)`. An `info!` now explicitly logs this,
  and the `data_map_address` doc comments clarify that `Some` means
  "retrievable", not "we paid to store it".

Merkle-path round-trip was attempted but blocked on an upstream
`WrongPoolCount` contract revert between `pay_for_merkle_tree` and the
`PaymentVaultV2` contract — reproduces outside this PR's changes and is
not caused by anything here. Removing the failing test; calling it out
separately for follow-up so the pool-commitment / depth relationship can
be investigated without holding up this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jacderida jacderida merged commit cde397a into rc-2026.4.2 Apr 22, 2026
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