Skip to content

feat(antd-rust): gRPC external-signer prepare/finalize parity with REST - #141

Closed
Nic-dorman wants to merge 1 commit into
nic/v2-284-grpc-external-signer-prepare-finalizefrom
nic/v2-284-antd-rust-grpc-external-signer
Closed

Nic-dorman wants to merge 1 commit into
nic/v2-284-grpc-external-signer-prepare-finalizefrom
nic/v2-284-antd-rust-grpc-external-signer

Conversation

@Nic-dorman

Copy link
Copy Markdown
Member

Summary

Adds 7 new methods on GrpcClient mirroring the existing REST client's external-signer surface, so consumers can swap a REST Client for a GrpcClient without code change in the prepare/finalize flow.

Depends on #140 (antd-side UploadService + chunks prepare/finalize) — that PR ships the proto + daemon handlers this client calls into.

Methods added

method purpose
prepare_upload(path, visibility) external-signer prepare for a file
prepare_upload_public(path) convenience wrapper for visibility = Some("public")
prepare_data_upload(data, visibility) external-signer prepare for in-memory bytes
finalize_upload(upload_id, tx_hashes) finalize wave-batch upload
finalize_merkle_upload(upload_id, winner_pool_hash, store_data_map) finalize merkle-batch upload
prepare_chunk_upload(data) single-chunk external-signer prepare
finalize_chunk_upload(upload_id, tx_hashes) single-chunk finalize, returns address

Implementation notes

  • New upload: UploadServiceClient<Channel> field on GrpcClient, constructed in connect().
  • build.rs picks up antd/v1/upload.proto.
  • Conversion helpers (prepare_response_to_result, finalize_response_to_result, payment_entry_to_info) translate proto3 scalar defaults back into the REST-style Option<_> shape on PrepareUploadResult — merkle-only fields (depth, pool_commitments, merkle_payment_timestamp) are populated only when payment_type == "merkle".

Tests

  • Extends MockChunkService with prepare_chunk (new + already-stored) and finalize_chunk (echoes upload_id into address).
  • New MockUploadService covers wave-batch and merkle response shapes, visibility round-trip via upload_id encoding, and store_data_map true/false branches.
  • 12 new #[tokio::test] cases covering visibility omitted/private/public, wave-batch vs merkle, data_map_address presence on public, merkle store_data_map toggle, chunk prepare already-stored short-circuit, and chunk finalize body forwarding.

Gates passed on dev2

  • cargo check
  • cargo clippy -- -D warnings
  • cargo fmt --check
  • cargo test — 68/68 passing
  • cargo audit — 2 pre-existing upstream warnings, nothing new

Adds 7 new methods on `GrpcClient` mirroring the existing REST client
surface:

* `prepare_upload(path, visibility)` / `prepare_upload_public(path)`
* `prepare_data_upload(data, visibility)`
* `finalize_upload(upload_id, tx_hashes)` (wave-batch)
* `finalize_merkle_upload(upload_id, winner_pool_hash, store_data_map)`
* `prepare_chunk_upload(data)` / `finalize_chunk_upload(upload_id, tx_hashes)`

All call into the new `UploadService` and the extended `ChunkService`
RPCs added on the daemon side. Consumers can now swap a REST `Client`
for a `GrpcClient` without code change in the external-signer flow.

Proto/build:

* `build.rs` picks up `antd/v1/upload.proto`.
* `grpc_client.rs` adds the `upload: UploadServiceClient<Channel>` field
  and constructs it in `connect()`.
* Conversion helpers `prepare_response_to_result` / `finalize_response_to_result`
  / `payment_entry_to_info` map proto3 scalar-default fields back to the
  REST-style `Option<_>` shape on `PrepareUploadResult` (depth /
  pool_commitments / merkle_payment_timestamp populated only when
  `payment_type == "merkle"`).

Tests (`grpc_tests.rs`):

* Extends `MockChunkService` with `prepare_chunk` (new chunk + already-stored
  short-circuit) and `finalize_chunk` (echo upload_id).
* New `MockUploadService` covers wave-batch, merkle, public/private
  visibility round-trip via upload_id encoding, and store_data_map true/false.
* 12 new `#[tokio::test]` cases covering:
  - prepare_upload visibility forwarded / omitted
  - prepare_upload_public convenience wrapper
  - prepare_data_upload wave-batch / merkle
  - finalize_upload data_map_address present / absent
  - finalize_merkle_upload store_data_map true / false
  - prepare_chunk_upload new / already-stored
  - finalize_chunk_upload body forwarding

68/68 tests pass on dev2.

Depends on the antd-side PR (UploadService + chunks prepare/finalize)
to land first so the protos compile against `../antd/proto`.

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.

1 participant