compat: ZK-tier input commitment, two-step pool exit, and refund claims for current compute contracts - #12
Merged
Merged
Conversation
- post_job: jobs verified under the ZK tier (tier "ZK", or "Commitment" above 10 SALT) post the circuit's 32-byte BN254 input commitment as inputHash via the new input_commitment argument; the client checks it is a non-zero scalar below the field modulus (and the model hash is too) before sending. Other tiers are unchanged. - ComputePool exit is two steps: request_leave(), then leave_pool() once LEAVE_COOLDOWN (150 blocks) has elapsed; leave_status() reports it. join_pool() takes the required stake. - Refund claims: claim_refund / refund_owed (InferenceRouter), claim_native_refund / native_refund_owed (ComputeMarketplace), claim_requester_refund / requester_refund_pending (ComputePoolTraining). - postJob targets computeMarketplace when configured (falls back to computePool). - Env-gated end-to-end test against the contracts on a local anvil. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cD3fDq5vhh2YWZPU2SV6H
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cD3fDq5vhh2YWZPU2SV6H
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cD3fDq5vhh2YWZPU2SV6H
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.
Compat update of
citrate_sdk.computefor the current compute contracts oncitrate-chainmain.What changes
post_job(..., input_commitment=...): a job verified under the ZK tier (tier"ZK", or"Commitment"withmax_pricestrictly above 10 SALT) posts the inference circuit's 32-byte BN254 input commitment asinputHash. The client checks that the commitment is a non-zero scalar below the field modulus, and that the model hash is below it too, before sending. A job without a valid commitment raisesZKCommitmentErrorand no transaction is sent. Commitment and TEE jobs at or under the threshold are unchanged.effective_tier()is exported.postJobtargetscomputeMarketplacewhen configured, and falls back tocomputePoolotherwise.request_leave()is followed byleave_pool()onceLEAVE_COOLDOWN(150 blocks) has passed.leave_status()reports the pending exit. If no exit is pending,leave_pool()sendsrequestLeave; inside the cooldown it raisesLeaveNotReadyError.join_pool()takes the requiredstake.claim_refundandrefund_owed(InferenceRouter),claim_native_refundandnative_refund_owed(ComputeMarketplace), andclaim_requester_refundandrequester_refund_pending(ComputePoolTraining). Each claim reads the owed amount first and raisesNothingToClaimErrorrather than sending a call that reverts.Evidence
tests/test_r2_compute_compat.py(ZK, >10 SALT, boundary at exactly 10 SALT, non-canonical/zero/short/non-hex commitments, model hash at r, messages),tests/test_compute.py, anviltests/test_r2_compute_anvil.pycompute.py: survivors in changed functions are equivalent (int.from_bytesdefault byteorder,"UTF-8",cast(None, …),NonevsFalse) or message-only, and the user-facing messages are now pinnedLEAVE_COOLDOWN_BLOCKSpinnedThe anvil tests are env-gated (
CITRATE_R2_ANVIL_ADDRS, optionalCITRATE_R2_ANVIL_RPC). They ran 6/6 against a local deploy of the chain-main contracts.Local CI (same commands as
ci.yml)uv lock --checkuv run --frozen ruff check .uv run --frozen mypy .uv run --frozen pytest -qThe one failure is
test_economics_simulation.py::TestPerformance::test_10year_medium_under_60s. It fails on main too: it is a wall-clock test, and the local machine is shared and under load.🤖 Generated with Claude Code
https://claude.ai/code/session_012cD3fDq5vhh2YWZPU2SV6H