Skip to content

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

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

feat(antd-cpp): gRPC external-signer prepare/finalize parity with REST#152
Nic-dorman wants to merge 1 commit into
nic/v2-284-grpc-external-signer-prepare-finalizefrom
nic/v2-284-antd-cpp-grpc-external-signer

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Adds 7 V2-284 methods on antd::GrpcClient mirroring the existing REST antd::Client external-signer surface:

  • prepare_upload(path, visibility=nullopt) / prepare_upload_public(path)
  • prepare_data_upload(data, visibility=nullopt)
  • finalize_upload(upload_id, tx_hashes, store_data_map=false) (wave-batch)
  • finalize_merkle_upload(upload_id, winner_pool_hash, store_data_map=false)
  • prepare_chunk_upload(data) / finalize_chunk_upload(upload_id, tx_hashes)

Includes the canonical store_data_map=true variant — cpp keeps that param (unlike kotlin/swift).

Depends on #140.

Implementation notes

  • New UploadService::Stub on the existing pimpl. Two free helpers (map_prepare_upload_response, map_finalize_upload_response) isolate the wire-shape mapping.
  • Merkle-only fields (depth, pool_commitments, merkle_payment_timestamp) are gated on payment_type == "merkle" — proto3 scalar defaults are not enough because REST omits these entirely on wave-batch and the model layer expects them empty/zero there.
  • visibility is sent only when std::optional has a value, preserving the proto3 empty-default wire shape for daemons predating the public-prepare addition.
  • prepare_chunk_upload short-circuits the wave-batch mapping when already_stored == true.

Tests

New file tests/test_grpc_external_signer.cpp. Spins up a real grpc++ server on 127.0.0.1:0 with MockUploadService + MockChunkService, then dials with a real antd::GrpcClient. Exercises the actual proto wire-shape mapping (visibility round-trip via upload_id encoding, MERKLE vs wave-batch branch, EXISTS short-circuit).

12 new tests parallel to the antd-rust / antd-go / antd-py / antd-java / antd-kotlin / antd-csharp / antd-ruby / antd-dart / antd-swift suites — full canonical matrix including store_data_map=true.

Gated on -DANTD_BUILD_GRPC=ON since they link against the grpc++ service stubs. The existing isolated antd_grpc_tests stays unchanged and still runs on the default config.

Gates passed on dev2

cmake -B build -DANTD_BUILD_GRPC=ON -DProtobuf_PROTOC_EXECUTABLE=/usr/bin/protoc
cmake --build build
ctest --test-dir build
  • cmake --build — clean
  • ctest — 4/4 passing (antd_tests, antd_async_tests, antd_grpc_tests isolated, antd_grpc_external_signer_tests 12/12 V2-284 mock-server wire-mapping tests)
  • Default config (no flags) still builds and passes 3/3 tests — the new test target is fully gated on ANTD_BUILD_GRPC

Note: on dev2, point CMake at the apt-installed protoc — there is also a newer /usr/local/bin/protoc 25.x for swift codegen, which would produce stubs incompatible with the apt-installed libprotobuf 3.21.x runtime.

Test plan

Adds 7 V2-284 methods on antd::GrpcClient mirroring the existing REST
antd::Client external-signer surface:

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

Implementation notes:

* New `UploadService::Stub` on the existing pimpl. Two free helpers
  (`map_prepare_upload_response`, `map_finalize_upload_response`)
  isolate the wire-shape mapping. Merkle-only fields (depth,
  pool_commitments, merkle_payment_timestamp) are gated on
  payment_type == "merkle" — proto3 scalar defaults are not enough
  because REST omits these entirely on wave-batch and the model layer
  expects them empty/zero there.
* visibility is sent only when std::optional has a value, preserving
  the proto3 empty-default wire shape for daemons that predate the
  public-prepare addition.
* prepare_chunk_upload short-circuits the wave-batch mapping when
  already_stored == true.

Tests (tests/test_grpc_external_signer.cpp, new):

* Spins up a real grpc++ server on 127.0.0.1:0 with MockUploadService
  + MockChunkService, then dials with a real antd::GrpcClient.
  Exercises the actual proto wire-shape mapping (visibility round-trip
  via upload_id encoding, MERKLE vs wave-batch branch, EXISTS
  short-circuit).
* 12 new tests parallel to the antd-rust / antd-go / antd-py /
  antd-java / antd-kotlin / antd-csharp / antd-ruby / antd-dart /
  antd-swift suites — includes the canonical store_data_map=true
  variant since cpp keeps that param (unlike kotlin/swift).
* Gated on -DANTD_BUILD_GRPC=ON since they link against the grpc++
  service stubs. The existing isolated antd_grpc_tests stays
  unchanged and still runs on the default config.

Gates on dev2:

* cmake -DANTD_BUILD_GRPC=ON -DProtobuf_PROTOC_EXECUTABLE=/usr/bin/protoc
  (must point CMake at the apt-installed protoc — dev2 also has a
  newer /usr/local/bin/protoc 25.x for swift codegen, which would
  produce stubs incompatible with the apt-installed libprotobuf 3.21.x
  runtime).
* cmake --build — clean.
* ctest — 4/4 passing: antd_tests, antd_async_tests, antd_grpc_tests
  (isolated, no gRPC linkage), antd_grpc_external_signer_tests
  (12/12 V2-284 mock-server wire-mapping tests).
* Default config (no flags) still builds and passes 3/3 tests — the
  new test target is fully gated on ANTD_BUILD_GRPC.

Depends on the antd-side daemon PR landing first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman
Nic-dorman deleted the branch nic/v2-284-grpc-external-signer-prepare-finalize May 28, 2026 15:47
@Nic-dorman Nic-dorman closed this May 28, 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.

1 participant