feat(ant-core): Client::finalize_chunk for external-signer single-chunk publish#89
Merged
Nic-dorman merged 2 commits intoMay 13, 2026
Conversation
Add --port and --listen-addr flags to `ant node daemon start` and the hidden `daemon run` so the node-management HTTP API can be pinned to a predictable bind. Default behaviour is unchanged (loopback, OS-assigned). Flags are forwarded from the detached `start` path through to the spawned `run` child via a new `daemon_run_args` helper. Use case: running the daemon inside a container with a `-p` mapping. Example: `ant node daemon start --listen-addr 0.0.0.0 --port 8765`. The daemon has no authentication, so the README and clap help text flag the security implications of binding to a non-loopback address. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mickvandijke
approved these changes
May 13, 2026
5 tasks
Nic-dorman
added a commit
to WithAutonomi/ant-sdk
that referenced
this pull request
May 13, 2026
* ci: authenticate arduino/setup-protoc on ci.yml too Mirrors PR #31's release.yml fix — without `repo-token`, the action issues the GitHub release-list API call anonymously and shares the ~60/hr per-IP quota with every other runner on the same egress IP. release.yml has had the auth since 2026-04-28; ci.yml didn't, and PR #57's post-merge CI run flaked here on 2026-05-06 (run 25447450352 job 'API contract tests (antd-rust)' — exact `arduino/setup-protoc@v3 ... API rate limit exceeded` message reproduced from PR #31's investigation). Adds `repo-token: \${{ secrets.GITHUB_TOKEN }}` to both occurrences in ci.yml — the Check (antd) job at line 33 and the API contract tests job at line 75. No semantic change to either workflow; just shifts the action onto our 5,000/hr token quota. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(antd, antd-go): external-signer single-chunk publish Adds `POST /v1/chunks/prepare` + `POST /v1/chunks/finalize` to the antd REST surface and `PrepareChunkUpload` + `FinalizeChunkUpload` to antd-go, giving external signers a way to publish a single chunk paid through their own EVM wallet rather than the daemon's. ## antd (Rust) - `state.rs`: new `pending_chunks: Mutex<HashMap<String, TimestampedChunk>>` map alongside `pending_uploads`, with matching `cleanup_stale_chunks`. Single periodic cleanup task in `main.rs` now sweeps both. - `types.rs`: `PrepareChunkRequest/Response` + `FinalizeChunkRequest/Response`. Response uses `skip_serializing_if` heavily so an already-on-network reply (`already_stored: true`) carries only `address` — no upload_id, no payments. - `rest/chunks.rs::chunk_prepare`: calls `Client::prepare_chunk_payment`, computes the BLAKE3 address up-front (so the already-stored exit can still return it), filters zero-amount quotes from the external-signer payment list, and stashes the PreparedChunk under a fresh upload_id. - `rest/chunks.rs::chunk_finalize`: looks up by upload_id, parses tx_hashes, calls the new `Client::finalize_chunk`, returns the chunk address. Unlike `POST /v1/chunks` (which requires `AUTONOMI_WALLET_KEY` on the daemon), neither new endpoint touches the daemon's wallet — funds flow through the external signer. ## antd-go - New `PrepareChunkResult` type mirroring the response shape. - `PrepareChunkUpload(ctx, content)` + `FinalizeChunkUpload(ctx, uploadID, txHashes)`. - `boolField` helper joins the existing `str`/`num64`/`unum64` helpers. - Three new httptest-backed tests: happy-path prepare, already-stored prepare, finalize round-trip. ## Dep pin `antd/Cargo.toml` pins ant-core to the merge commit of WithAutonomi/ant-client#89 (`c0f6a81`) which adds the `Client::finalize_chunk` primitive this PR consumes. The pin should be bumped to a tag once ant-core cuts a release containing that commit; the rev pin keeps reproducibility in the meantime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * style: cargo fmt fixes for chunks prepare/finalize --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Client::finalize_chunk(prepared, tx_hash_map) -> XorNameonant-core's data client. Single-chunk analogue ofClient::finalize_upload: takes aPreparedChunk(fromprepare_chunk_payment) and aquote_hash -> tx_hashmap, builds thePaymentProofvia the existingfinalize_batch_paymenthelper, stores onCLOSE_GROUP_MAJORITYpeers via the existingchunk_put_to_close_groupprimitive, and returns the BLAKE3 address.Wave-batch only. Single-chunk publishes don't need merkle batching — one chunk's worth of quotes is well below the wave-batch threshold.
Why
prepare_chunk_paymentalready exists publicly (ant-core/src/data/client/batch.rs:167) but the second half of the external-signer flow — paying then storing — is gated behindpub(crate)helpers (chunk_put_to_close_group,store_paid_chunks_with_events). Downstream daemons can collect quotes but can't finish the upload without re-implementing the close-group fallback logic. This PR exposes the composition under a single public method that mirrors the file-levelfinalize_upload.Concrete consumer:
WithAutonomi/ant-sdkwill addPOST /v1/chunks/prepare+POST /v1/chunks/finalizeREST endpoints on top of this, so daemons running wallet-less (e.g. Indelible) can publish single chunks paid by their own EVM signer rather than the daemon's.What's not in this PR
PreparedChunk,finalize_batch_payment,chunk_put_to_close_groupthat already exist.ant-sdk.Test plan
cargo build -p ant-corecleancargo test -p ant-core --lib data::client::chunk— 3 existing chunk tests passcargo test -p ant-core— 248 tests pass🤖 Generated with Claude Code