Skip to content

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

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

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

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Adds 7 new methods on Antd::GrpcClient mirroring the existing REST Antd::Client external-signer surface. Consumers can now swap Antd::Client for Antd::GrpcClient without code change in the prepare/finalize flow.

Depends on #140 (antd-side UploadService + chunks prepare/finalize).

Methods

method purpose
prepare_upload(path, visibility:) external-signer prepare for a file
prepare_upload_public(path) convenience wrapper for visibility: "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

Proto regen

grpc_tools_ruby_protoc -I../antd/proto --ruby_out=lib --grpc_out=lib antd/v1/{common,health,data,chunks,files,upload}.proto:

  • New upload_pb.rb / upload_services_pb.rb.
  • chunks_pb.rb / chunks_services_pb.rb gain PrepareChunk / FinalizeChunk.
  • common_pb.rb adds PaymentEntry.

Implementation notes

  • New @upload_stub = Antd::V1::UploadService::Stub.new(...) field on GrpcClient.
  • Private build_prepare_upload_result(resp) helper maps PrepareUploadResponse proto into the existing PrepareUploadResult struct, populating merkle-only fields (depth, pool_commitments, merkle_payment_timestamp) only when payment_type == "merkle".

Tests

test/test_grpc_client.rb:

  • FakeGrpc::ChunkStub gains prepare_chunk (new + already-stored short-circuit) and finalize_chunk (echoes upload_id into address).
  • New FakeGrpc::UploadStub covers prepare_file_upload / prepare_data_upload / finalize_upload with visibility round-trip via upload_id encoding and merkle vs wave-batch branches.
  • build_fake_client / build_error_client updated to inject @upload_stub.
  • 12 new test cases parallel to the antd-rust / antd-go / antd-py / antd-java / antd-kotlin / antd-csharp suites.

Gates on dev2

  • All 12 new tests pass
  • Pre-existing baseline has 4 failures in the cost mocks (test_data_cost, test_file_cost, etc.) where the fake cost stub returns a partial OpenStruct; unrelated to this PR (verified by running tests on the parent commit).

Adds 7 new methods on `Antd::GrpcClient` mirroring the existing REST
`Antd::Client` external-signer 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)`

Consumers can now swap `Antd::Client` for `Antd::GrpcClient` without
code change in the external-signer flow.

Proto regen:

* `grpc_tools_ruby_protoc -I../antd/proto --ruby_out=lib --grpc_out=lib
  antd/v1/{common,health,data,chunks,files,upload}.proto`
* New `upload_pb.rb` / `upload_services_pb.rb`. `chunks_pb.rb` /
  `chunks_services_pb.rb` gain `PrepareChunk` / `FinalizeChunk`
  messages and RPCs. `common_pb.rb` adds `PaymentEntry`.

Client (`lib/antd/grpc_client.rb`):

* New `@upload_stub = Antd::V1::UploadService::Stub.new(...)` field.
* Private `build_prepare_upload_result(resp)` helper maps the
  `PrepareUploadResponse` proto into the `PrepareUploadResult` struct,
  populating the merkle-only fields (`depth`, `pool_commitments`,
  `merkle_payment_timestamp`) only when `payment_type == "merkle"`.

Tests (`test/test_grpc_client.rb`):

* `FakeGrpc::ChunkStub` gains `prepare_chunk` (new + already-stored
  short-circuit) and `finalize_chunk` (echoes `upload_id`).
* New `FakeGrpc::UploadStub` covers `prepare_file_upload` /
  `prepare_data_upload` / `finalize_upload` with visibility round-trip
  via `upload_id` encoding and merkle vs wave-batch branches.
* `build_fake_client` / `build_error_client` updated to inject
  `@upload_stub`.
* 12 new test cases parallel to the antd-rust / antd-go / antd-py /
  antd-java / antd-kotlin / antd-csharp suites.

Gates on dev2:

* `bundle exec ruby -Ilib -Itest test/test_grpc_client.rb` — 12 new
  cases pass; 4 pre-existing baseline failures in the cost mocks are
  unrelated to this PR (verified by running on the parent commit).

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