Skip to content

Add the ITN client (mina_sdk.itn) and execute_query - #30

Merged
dkijania merged 1 commit into
masterfrom
feat/itn
Oct 2, 2026
Merged

dkijania merged 1 commit into
masterfrom
feat/itn

Conversation

@dkijania

@dkijania dkijania commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds the ITN client to the Python SDK. With it, all four SDKs implement both parts of mina-sdk-spec: the daemon API and the ITN API.

  • ITN client: the new package mina_sdk.itn has ItnClient, ItnKey, the input types and the errors. It uses the documents of spec/itn-operations.graphql. The protocol is the same as in Rust, Go and JS:
    • ed25519 signatures;
    • the auth handshake;
    • sequence numbers, with one request at a time;
    • after HTTP 412, a new auth and one repeat of the request;
    • no repeat after a transport error.
  • Dependency: a new optional extra, itn, adds cryptography. Without the extra, import mina_sdk.itn fails with an error that tells you to install mina-sdk[itn]. The daemon client does not need the extra.
  • Thread safety: the client is safe to share between threads; a lock sends one request at a time.
  • execute_query: MinaDaemonClient.execute_query runs a custom document, as the custom-query methods of the other SDKs do. SPEC.md (v0.1.1) names it.
  • Spec copy: spec/ is mina-sdk-spec v0.1.1. That version of ITN.md still shows "–" in the Python column. Spec v0.1.2 will add the Python ITN names, and then I re-sync the four SDKs.

Test plan

  • ruff, mypy, bandit: pass. 71 unit tests pass on Python 3.12 and 3.10.

  • tests/test_itn.py: a mock ITN server that verifies each signature, the UUID and the sequence number as the daemon does. It covers:

    • the handshake;
    • the wrap of the sequence number at 2^16;
    • 412 recovery;
    • 412 again after a new auth;
    • 401;
    • no repeat after a transport error;
    • the HTTP error cause;
    • the variables of each operation.

    As a check, I changed the client to pack the sequence number little-endian, and the tests failed.

  • Conformance: tests/test_spec.py also checks the ITN documents against spec/itn-operations.graphql.

  • Live, against devnet daemon 4.0.0-6965b50 with ITN_FEATURES=1: the 7 tests of tests/test_itn_integration.py pass. They are the same 7 tests as in the other SDKs. The slotsWon test accepts the GraphQL error that the daemon gives while its VRF evaluation runs, as the Go test does.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E9VzXg2bJYonrX5xBfmLMr

mina_sdk.itn is a client for the daemon's ITN GraphQL server, with the
documents of spec/itn-operations.graphql: ed25519 request signing (ItnKey),
the auth handshake, sequence numbers (one request at a time, a new auth
after HTTP 412) and no repeat after a transport error, as in the Rust, Go
and JS SDKs. It needs the new extra `itn` (cryptography).

MinaDaemonClient.execute_query runs a custom document, as the other SDKs'
custom-query methods do. spec/ is mina-sdk-spec v0.1.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E9VzXg2bJYonrX5xBfmLMr
@dkijania
dkijania merged commit 3b70461 into master Oct 2, 2026
10 checks passed
@dkijania
dkijania deleted the feat/itn branch October 2, 2026 18:49
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