Skip to content

ant-ffi external-signer: retry finalize after post-payment storage failure (needs ant-client#140) #201

Description

@Nic-dorman

Summary

Consumer-side follow-up to WithAutonomi/ant-client#140. Once ant-core makes a post-payment finalize failure recoverable, the ant-ffi external-signer surface must be updated to actually retain and retry the paid attempt instead of dropping it.

Background

The external-signer flow (PR #199) works like: prepare_* → external wallet pays payForQuotesfinalize_upload(upload_id, {quote_hash: tx_hash}). Today finalize_inner (ffi/rust/ant-ffi/src/client.rs) removes the PreparedUpload from the in-memory session map and passes it by value into ant-core's finalize_upload_with_progress, which consumes it. Tx-hash syntax is now validated before removal (bad input is retryable), but a genuine network/storage failure after payment still consumes the prepared state and strands the on-chain payment — see ant-client#140 for the root cause (quote hashes are timestamp+signature-derived, so re-prepare yields a non-matching tx map).

As of #199 this is documented as non-retryable after payment (the honest-contract stopgap). This issue tracks the real fix.

What needs doing here (after ant-client#140 lands)

  1. Bump the ant-core rev pin in ffi/rust/ant-ffi/Cargo.toml (ant-core = { git = "...", rev = "..." }) to the commit carrying the retry-state API. Re-verify the ant-protocol = "2.2.2" pin still matches.
  2. Retain the session on failure. In finalize_inner, stop discarding the upload when finalize fails post-payment. Keep the entry keyed by upload_id (or re-insert the returned retry-state) so a subsequent finalize_upload(upload_id, same_tx_map) retries storage of the unstored chunks against the same payment.
  3. Update the docs/comments on finalize_upload / finalize_upload_with_progress and the sessions field to describe the new retryable contract (remove the "non-retryable after payment" language added in feat(ffi): re-add external-signer upload surface (wave-batch) #199).
  4. Add a test exercising a simulated post-payment store failure → retry → success.

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions