feat(antd-elixir): gRPC external-signer prepare/finalize parity with REST#153
Closed
Nic-dorman wants to merge 1 commit into
Closed
Conversation
…REST
Adds 7 V2-284 functions on Antd.GrpcClient mirroring the existing REST
Antd.Client external-signer surface:
* prepare_upload(client, path, opts) /
prepare_upload_public(client, path)
* prepare_data_upload(client, data, opts)
* finalize_upload(client, upload_id, tx_hashes) (wave-batch)
* finalize_merkle_upload(client, upload_id, winner_pool_hash, opts)
* prepare_chunk_upload(client, data) /
finalize_chunk_upload(client, upload_id, tx_hashes)
Bang variants (!/N) included throughout. Full canonical 12-test matrix
including the store_data_map=true variant.
Proto regen:
* New lib/antd/v1/upload.pb.ex (UploadService + request/response
messages + PoolCommitmentEntry + CandidateNodeEntry).
* lib/antd/v1/chunks.pb.ex extended with PrepareChunk + FinalizeChunk
RPCs and request/response messages.
* lib/antd/v1/common.pb.ex extended with PaymentEntry.
* All .pb.ex regenerated with protoc-gen-elixir 0.16.0 (was 0.13.0).
This bump fixes a latent runtime bug: protobuf 0.16 dropped the
generated .new/1 constructor — all calls inside Antd.GrpcClient have
been converted to %Module{...} struct literals, the forward-
compatible idiom. Existing gRPC functions did not exercise this at
runtime because the test suite simulates rather than calls the
protobuf modules.
Implementation notes:
* 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
fields entirely on wave-batch and the model layer expects them
empty/zero there.
* visibility is forwarded as the proto3 default "" when not supplied
via opts, preserving the wire shape for daemons that predate the
public-prepare addition.
* prepare_chunk_upload short-circuits the wave-batch mapping when
already_stored == true.
Tests (test/antd/grpc_external_signer_test.exs, new):
* Spins up a real grpc-elixir server on 127.0.0.1:0 via
GRPC.Server.start_endpoint(TestEndpoint, 0) with MockUploadServer +
MockChunkServer, 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 / antd-cpp suites.
* The suite starts GRPC.Client.Supervisor in setup_all — grpc-elixir
0.11 does not start it as part of its application supervision tree,
and Antd.GrpcClient.new/1 calls GRPC.Stub.connect/1 which requires
it. async: false because the global supervisor is shared.
Gates on dev2:
* mix compile — clean.
* mix test — 86/86 passing (74 existing + 12 new V2-284).
Depends on the antd-side daemon PR landing first.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
Nic-dorman
added a commit
that referenced
this pull request
May 28, 2026
Adds 3 new functions on Antd.GrpcClient mirroring REST Antd.Client:
* wallet_address(client) -> {:ok, WalletAddress} | {:error, Exception}
* wallet_balance(client) -> {:ok, WalletBalance} | {:error, Exception}
* wallet_approve(client) -> {:ok, boolean} | {:error, Exception}
Bang variants (!/N) included throughout.
Implementation notes:
* New lib/antd/v1/wallet.pb.ex generated via protoc-gen-elixir 0.16.0
(matches the existing files regen'd in V2-284 PR #153).
* Request types constructed via %Antd.V1.X{} struct literal syntax
(.new/1 was dropped in protobuf 0.16 per the recipe gotcha noted by
the V2-284 elixir PR).
* A missing daemon wallet emits gRPC FailedPrecondition; the existing
translate_error/1 surfaces it as PaymentError (established
FailedPrecondition->Payment convention across all SDKs).
Tests (test/antd/grpc_wallet_test.exs, new):
* Spins up a real grpc-elixir server on 127.0.0.1:0 via
GRPC.Server.start_endpoint with two endpoints: HappyEndpoint
(MockWalletServer) and UnconfiguredEndpoint (raises
FailedPrecondition).
* setup_all starts GRPC.Client.Supervisor (grpc-elixir 0.11 doesn't
auto-start it).
* 4 tests: address, balance, approve, plus the unconfigured-wallet
PaymentError path.
Gates on dev2:
* mix compile — clean.
* mix test — 78/78 passing (74 existing + 4 new wallet).
Depends on the antd-side daemon PR landing first.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 7 V2-284 functions on
Antd.GrpcClientmirroring the existing RESTAntd.Clientexternal-signer surface:prepare_upload(client, path, opts)/prepare_upload_public(client, path)prepare_data_upload(client, data, opts)finalize_upload(client, upload_id, tx_hashes)(wave-batch)finalize_merkle_upload(client, upload_id, winner_pool_hash, opts)prepare_chunk_upload(client, data)/finalize_chunk_upload(client, upload_id, tx_hashes)Bang variants throughout. Full canonical 12-test matrix including
store_data_map: true.Depends on #140.
Proto regen
lib/antd/v1/upload.pb.ex—UploadService+ request/response messages +PoolCommitmentEntry+CandidateNodeEntry.lib/antd/v1/chunks.pb.exextended withPrepareChunk+FinalizeChunkRPCs and request/response messages.lib/antd/v1/common.pb.exextended withPaymentEntry..pb.exregenerated withprotoc-gen-elixir0.16.0 (was 0.13.0). The bump fixes a latent runtime bug: protobuf 0.16 dropped the generated.new/1constructor. All calls insideAntd.GrpcClientare now%Module{...}struct literals (the forward-compatible idiom). The existing gRPC functions did not exercise this at runtime because the test suite simulates rather than calls the protobuf modules.Implementation notes
depth,pool_commitments,merkle_payment_timestamp) are gated onpayment_type == "merkle"— proto3 scalar defaults are not enough because REST omits these fields entirely on wave-batch.visibilityis forwarded as the proto3 default""when not supplied viaopts.prepare_chunk_uploadshort-circuits the wave-batch mapping whenalready_stored == true.Tests
New file
test/antd/grpc_external_signer_test.exs. Spins up a real grpc-elixir server on127.0.0.1:0viaGRPC.Server.start_endpoint(TestEndpoint, 0)withMockUploadServer+MockChunkServer, then dials with a realAntd.GrpcClient. Exercises the actual proto wire-shape mapping (visibility round-trip viaupload_idencoding, 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 / antd-cpp suites.
The suite starts
GRPC.Client.Supervisorinsetup_all— grpc-elixir 0.11 does not start it as part of its application supervision tree, andAntd.GrpcClient.new/1callsGRPC.Stub.connect/1which requires it.async: falsebecause the supervisor is process-global.Gates passed on dev2
mix compile— cleanmix test— 86/86 passing (74 existing + 12 new V2-284)Test plan
mix testagainst the real daemon protosprotoc_gen_elixir_versionbump (0.13 → 0.16) does not break downstream applications that depend onantdand construct request types directly (none expected — generated*.pb.exmodules are not part of the public surface)