Skip to content

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

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

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

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Adds 7 new methods on GrpcAntdClient mirroring the existing REST AntdClient external-signer surface. Consumers can swap an AntdClient for a GrpcAntdClient without code change in the prepare/finalize flow.

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

Methods

method purpose
prepareUpload(path, visibility:) external-signer prepare for a file
prepareUploadPublic(path) convenience wrapper for visibility: 'public'
prepareDataUpload(data, visibility:) external-signer prepare for in-memory bytes
finalizeUpload(uploadId, txHashes) finalize wave-batch upload
finalizeMerkleUpload(uploadId, winnerPoolHash, storeDataMap:) finalize merkle-batch upload
prepareChunkUpload(data) single-chunk external-signer prepare
finalizeChunkUpload(uploadId, txHashes) single-chunk finalize, returns address

Proto regen

./tool/generate_proto.sh now includes antd/v1/upload.proto. Per the existing reference_dart_protoc_plugin_pin convention, protoc_plugin must be pinned to 22.3.0; the regen script's header now states that explicitly.

  • New upload.pb.dart / upload.pbgrpc.dart / upload.pbjson.dart.
  • chunks.* gain PrepareChunk / FinalizeChunk; common.* adds PaymentEntry.

Implementation notes

  • New _uploadStub field constructed alongside the existing service clients.
  • Helper _mapPrepareUploadResponse translates the proto into PrepareUploadResult, populating the merkle-only fields (depth, poolCommitments, merklePaymentTimestamp) only when paymentType == "merkle".

Tests

New test/grpc_client_external_signer_test.dart:

  • Spins up a real grpc-dart server bound to 127.0.0.1:0 with mock service implementations, then exercises the real GrpcAntdClient against it. This actually tests the proto wire-shape mapping, in contrast to the existing grpc_client_test.dart which uses a hand-rolled fake that doesn't depend on the generated stubs.
  • _MockChunkService covers prepareChunk (new + already-stored short-circuit) and finalizeChunk (echoes upload_id).
  • _MockUploadService covers prepareFileUpload / prepareDataUpload / finalizeUpload with visibility round-trip via upload_id encoding and merkle vs wave-batch branches.
  • 12 new tests parallel to the antd-rust / antd-go / antd-py / antd-java / antd-kotlin / antd-csharp / antd-ruby suites.

Gates passed on dev2

  • dart analyze lib/ — 1 pre-existing warning (_doHead unused); no new issues from this PR.
  • dart test — 63/63 passing (51 existing + 12 new).

Adds 7 new methods on `GrpcAntdClient` mirroring the existing REST
`AntdClient` external-signer surface:

* `prepareUpload(path, visibility:)` / `prepareUploadPublic(path)`
* `prepareDataUpload(data, visibility:)`
* `finalizeUpload(uploadId, txHashes)` (wave-batch)
* `finalizeMerkleUpload(uploadId, winnerPoolHash, storeDataMap:)`
* `prepareChunkUpload(data)` / `finalizeChunkUpload(uploadId, txHashes)`

Consumers can swap a `AntdClient` for a `GrpcAntdClient` without code
change in the external-signer flow.

Proto regen:

* `./tool/generate_proto.sh` now includes `antd/v1/upload.proto`. Per
  reference_dart_protoc_plugin_pin, protoc_plugin must be pinned to
  22.3.0; the regen script header now states that explicitly.
* New `upload.pb.dart` / `upload.pbgrpc.dart` / `upload.pbjson.dart`.
  `chunks.*` gain `PrepareChunk` / `FinalizeChunk`; `common.*` adds
  `PaymentEntry`.

Client (`lib/src/grpc_client.dart`):

* New `_uploadStub` field constructed alongside the existing service
  clients.
* Helper `_mapPrepareUploadResponse` translates the proto into
  `PrepareUploadResult`, populating the merkle-only fields (`depth`,
  `poolCommitments`, `merklePaymentTimestamp`) only when
  `paymentType == "merkle"`.

Tests (`test/grpc_client_external_signer_test.dart`):

* New file. Spins up a real `grpc-dart` server bound to 127.0.0.1:0
  with mock service implementations, then exercises the real
  `GrpcAntdClient` against it — covers the actual proto wire-shape
  mapping (in contrast to the existing `grpc_client_test.dart` which
  uses a hand-rolled fake to avoid the proto dependency).
* `_MockChunkService` covers `prepareChunk` (new + already-stored
  short-circuit) and `finalizeChunk` (echoes `upload_id`).
* `_MockUploadService` covers `prepareFileUpload` /
  `prepareDataUpload` / `finalizeUpload` with visibility round-trip
  via `upload_id` encoding and merkle vs wave-batch branches.
* 12 new tests parallel to the antd-rust / antd-go / antd-py /
  antd-java / antd-kotlin / antd-csharp / antd-ruby suites.

Gates on dev2:

* `dart analyze lib/` — 1 pre-existing warning (`_doHead` unused);
  no new issues from this PR.
* `dart test` — 63/63 passing (51 existing + 12 new).

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