Skip to content

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

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

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

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

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 throughout. Full canonical 12-test matrix including store_data_map: true.

Depends on #140.

Proto regen

  • New lib/antd/v1/upload.pb.exUploadService + 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). The bump fixes a latent runtime bug: protobuf 0.16 dropped the generated .new/1 constructor. All calls inside Antd.GrpcClient are 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

  • 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.
  • visibility is forwarded as the proto3 default "" when not supplied via opts.
  • prepare_chunk_upload short-circuits the wave-batch mapping when already_stored == true.

Tests

New file test/antd/grpc_external_signer_test.exs. 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 supervisor is process-global.

Gates passed on dev2

  • mix compile — clean
  • mix test — 86/86 passing (74 existing + 12 new V2-284)

Test plan

  • Once feat(antd): gRPC UploadService + chunks prepare/finalize #140 lands: rebase and re-run mix test against the real daemon protos
  • Confirm the protoc_gen_elixir_version bump (0.13 → 0.16) does not break downstream applications that depend on antd and construct request types directly (none expected — generated *.pb.ex modules are not part of the public surface)

…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>
@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
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>
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