From 425c426b58fe280443c1eb397f133858ba3358c5 Mon Sep 17 00:00:00 2001 From: han0110 Date: Sat, 2 May 2026 05:25:53 +0000 Subject: [PATCH 01/15] feat: update ere-verifier-zisk --- crates/catalog/build.rs | 2 +- crates/verifier/zisk/Cargo.toml | 2 - crates/verifier/zisk/build.rs | 2 +- crates/verifier/zisk/src/error.rs | 6 +- crates/verifier/zisk/src/lib.rs | 2 +- crates/verifier/zisk/src/proof.rs | 130 ++++++++++++++------- crates/verifier/zisk/src/verifier.rs | 31 +++-- scripts/sdk_installers/install_zisk_sdk.sh | 8 +- 8 files changed, 119 insertions(+), 64 deletions(-) diff --git a/crates/catalog/build.rs b/crates/catalog/build.rs index a392666f..2c9916c0 100644 --- a/crates/catalog/build.rs +++ b/crates/catalog/build.rs @@ -40,7 +40,7 @@ fn generate_zkvm_sdk_version_impl() { "openvm-sdk", "risc0-zkvm", "sp1-sdk", - "zisk-sdk", + "ziskos", ] .map(detect_sdk_version); diff --git a/crates/verifier/zisk/Cargo.toml b/crates/verifier/zisk/Cargo.toml index 9176ddcc..7b65a35a 100644 --- a/crates/verifier/zisk/Cargo.toml +++ b/crates/verifier/zisk/Cargo.toml @@ -9,11 +9,9 @@ license.workspace = true bincode = { workspace = true, features = ["alloc", "serde"] } bytemuck.workspace = true serde = { workspace = true, features = ["derive"] } -serde-big-array.workspace = true thiserror.workspace = true # ZisK dependencies -proofman-util.workspace = true proofman-verifier.workspace = true # Local dependencies diff --git a/crates/verifier/zisk/build.rs b/crates/verifier/zisk/build.rs index 646ca43d..1dbb7fa5 100644 --- a/crates/verifier/zisk/build.rs +++ b/crates/verifier/zisk/build.rs @@ -1,5 +1,5 @@ use ere_util_build::detect_and_generate_name_and_sdk_version; fn main() { - detect_and_generate_name_and_sdk_version("zisk", "zisk-sdk"); + detect_and_generate_name_and_sdk_version("zisk", "ziskos"); } diff --git a/crates/verifier/zisk/src/error.rs b/crates/verifier/zisk/src/error.rs index 00e7039e..29e7fa9e 100644 --- a/crates/verifier/zisk/src/error.rs +++ b/crates/verifier/zisk/src/error.rs @@ -12,7 +12,11 @@ pub enum Error { #[error("Invalid ProgramVk length, expected: {expected}, got: {got}")] InvalidProgramVkLength { expected: usize, got: usize }, - /// `verify_vadcop_final` returned false. + /// Proof did not match the expected layout. + #[error("Invalid proof format: {0}")] + InvalidProofFormat(String), + + /// `verify_vadcop_final_proof` returned false. #[error("Invalid proof")] InvalidProof, diff --git a/crates/verifier/zisk/src/lib.rs b/crates/verifier/zisk/src/lib.rs index 4893b35f..5a849e2e 100644 --- a/crates/verifier/zisk/src/lib.rs +++ b/crates/verifier/zisk/src/lib.rs @@ -8,6 +8,6 @@ pub use ere_verifier_core::*; pub use crate::{ error::Error, program_vk::ZiskProgramVk, - proof::{PUBLIC_VALUES_SIZE, ZiskProof}, + proof::{PUBLIC_VALUES_BYTES, ZiskProof}, verifier::{ZiskVerifier, ensure_program_vk_matches}, }; diff --git a/crates/verifier/zisk/src/proof.rs b/crates/verifier/zisk/src/proof.rs index e2f3cd72..1d8711cc 100644 --- a/crates/verifier/zisk/src/proof.rs +++ b/crates/verifier/zisk/src/proof.rs @@ -1,57 +1,105 @@ -use core::mem::ManuallyDrop; +use std::iter; -use proofman_util::VadcopFinalProof; +use bytemuck::cast_slice; use serde::{Deserialize, Serialize}; use crate::{Error, ZiskProgramVk}; -/// Size of the public values in bytes (64 slots * 4 bytes each). -pub const PUBLIC_VALUES_SIZE: usize = 256; +const PROGRAM_VK_OFFSET: usize = 1; +const PROGRAM_VK_WORDS: usize = 4; +const PUBLIC_VALUES_OFFSET: usize = PROGRAM_VK_OFFSET + PROGRAM_VK_WORDS; +const PUBLIC_VALUES_WORDS: usize = 64; +pub const PUBLIC_VALUES_BYTES: usize = 4 * PUBLIC_VALUES_WORDS; +const PROOF_PREFIX_WORDS: usize = PROGRAM_VK_WORDS + PUBLIC_VALUES_WORDS; +const PROOF_BODY_WORDS: usize = 32594; +const PROOF_BODY_BYTES: usize = 8 * PROOF_BODY_WORDS; +const PROOF_WORDS: usize = 1 + PROOF_PREFIX_WORDS + PROOF_BODY_WORDS; -/// Zisk VadcopFinalProof with strong type of `program_vk` and `public_values`. +/// Zisk VadcopFinalMinimal proof in u64 words. #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct ZiskProof { - pub proof: Vec, - pub program_vk: ZiskProgramVk, - #[serde(with = "serde_big_array::BigArray")] - pub public_values: [u8; PUBLIC_VALUES_SIZE], -} +#[serde(transparent)] +pub struct ZiskProof(pub Vec); impl ZiskProof { - /// Returns the program verifying key embedded in this proof. - pub fn program_vk(&self) -> ZiskProgramVk { - self.program_vk + /// Construct VadcopFinalMinimal proof in u64 words from parts. + pub fn from_parts( + program_vk: &ZiskProgramVk, + public_values: &[u8; PUBLIC_VALUES_BYTES], + proof_body: &[u8], + ) -> Result { + if proof_body.len() != PROOF_BODY_BYTES { + return Err(Error::InvalidProofFormat(format!( + "proof body has {} bytes, expected to be {PROOF_BODY_BYTES}", + proof_body.len() + ))); + } + + let proof = iter::empty() + .chain([PROOF_PREFIX_WORDS as u64]) + .chain(program_vk.0) + .chain( + public_values + .chunks_exact(4) + .map(|bytes| u32::from_le_bytes(bytes.try_into().unwrap()) as u64), + ) + .chain( + proof_body + .chunks_exact(8) + .map(|bytes| u64::from_le_bytes(bytes.try_into().unwrap())), + ) + .collect(); + + Ok(Self(proof)) } - /// Converts this proof into the `VadcopFinalProof` format expected by the proofman verifier. - pub fn vadcop_final_proof(&self) -> Result { - let proof = cast_bytes(self.proof.clone()); - - let public_values = { - let program_vk = self.program_vk.0; - let public_values_words = self - .public_values - .chunks_exact(4) - .map(|bytes| u32::from_le_bytes(bytes.try_into().unwrap()) as u64); - cast_bytes(program_vk.into_iter().chain(public_values_words).collect()) - }; - - Ok(VadcopFinalProof { - proof, - public_values, - compressed: false, - }) + /// Returns the program verifying key and public values. + pub fn to_parts(&self) -> Result<(ZiskProgramVk, [u8; PUBLIC_VALUES_BYTES]), Error> { + self.validate_format()?; + Ok((self.program_vk(), self.public_values()?)) + } + + /// Returns the proof in bytes to be verified by [`verify_vadcop_final_compressed_bytes`]. + /// + /// [`verify_vadcop_final_compressed_bytes`]: proofman_verifier::verify_vadcop_final_compressed_bytes + pub fn as_bytes(&self) -> Result<&[u8], Error> { + self.validate_format()?; + Ok(cast_slice(&self.0)) } -} -/// Converts a `Vec` into a `Vec` preserving the u64-aligned allocation. -fn cast_bytes(data: Vec) -> Vec { - let mut data = ManuallyDrop::new(data); - let ptr = data.as_mut_ptr().cast::(); - let len = data.len() * size_of::(); - let cap = data.capacity() * size_of::(); - // SAFETY: `ptr` came from a `Vec` allocation. - unsafe { Vec::from_raw_parts(ptr, len, cap) } + fn program_vk(&self) -> ZiskProgramVk { + let words = &self.0[PROGRAM_VK_OFFSET..PROGRAM_VK_OFFSET + PROGRAM_VK_WORDS]; + ZiskProgramVk(words.try_into().unwrap()) + } + + fn public_values(&self) -> Result<[u8; PUBLIC_VALUES_BYTES], Error> { + let mut bytes = [0u8; PUBLIC_VALUES_BYTES]; + let words = &self.0[PUBLIC_VALUES_OFFSET..PUBLIC_VALUES_OFFSET + PUBLIC_VALUES_WORDS]; + for (chunk, &word) in bytes.chunks_exact_mut(4).zip(words) { + let word = u32::try_from(word).map_err(|_| { + Error::InvalidProofFormat( + "public value words are expected to be in u32".to_string(), + ) + })?; + chunk.copy_from_slice(&word.to_le_bytes()); + } + Ok(bytes) + } + + fn validate_format(&self) -> Result<(), Error> { + if self.0.len() != PROOF_WORDS { + return Err(Error::InvalidProofFormat(format!( + "proof has {} u64 words, expected to be {PROOF_WORDS}", + self.0.len(), + ))); + } + if self.0[0] != PROOF_PREFIX_WORDS as u64 { + return Err(Error::InvalidProofFormat(format!( + "proof n_publics is {}, expected to be {PROOF_PREFIX_WORDS}", + self.0[0], + ))); + } + Ok(()) + } } ere_verifier_core::codec::impl_codec_by_bincode_legacy!(ZiskProof); diff --git a/crates/verifier/zisk/src/verifier.rs b/crates/verifier/zisk/src/verifier.rs index 71b1c14c..f6e33e70 100644 --- a/crates/verifier/zisk/src/verifier.rs +++ b/crates/verifier/zisk/src/verifier.rs @@ -1,17 +1,24 @@ use bytemuck::cast_slice; use ere_verifier_core::{PublicValues, zkVMVerifier}; -use proofman_verifier::verify_vadcop_final; +use proofman_verifier::verify_vadcop_final_compressed_bytes; use crate::{Error, ZiskProgramVk, ZiskProof}; include!(concat!(env!("OUT_DIR"), "/name_and_sdk_version.rs")); -/// Verifying key of the aggregation proof. -const VADCOP_FINAL_VK: [u64; 4] = [ - 9211010158316595036, - 7055235338110277438, - 2391371252028311145, - 10691781997660262077, +/// Aggregation verifying key for VadcopFinalMinimal proofs in zisk v0.17.0. +/// +/// To reproduce: +/// +/// ```bash +/// python3 -c "import struct,sys; print(list(struct.unpack('<4Q',open(sys.argv[1],'rb').read())))" \ +/// $HOME/.zisk/provingKey/zisk/vadcop_final_compressed/vadcop_final_compressed.verkey.bin +/// ``` +const VADCOP_FINAL_MINIMAL_VK: [u64; 4] = [ + 371850295254322978, + 2764832171281751502, + 14747498303081942412, + 8181136173693786776, ]; /// Verifier bound to a specific compiled guest program. @@ -40,13 +47,17 @@ impl zkVMVerifier for ZiskVerifier { } fn verify(&self, proof: &ZiskProof) -> Result { - ensure_program_vk_matches(self.program_vk, proof.program_vk())?; + let (progam_vk, public_values) = proof.to_parts()?; + + ensure_program_vk_matches(self.program_vk, progam_vk)?; - if !verify_vadcop_final(&proof.vadcop_final_proof()?, cast_slice(&VADCOP_FINAL_VK)) { + let proof_bytes = proof.as_bytes()?; + let vk_bytes = cast_slice(&VADCOP_FINAL_MINIMAL_VK); + if !verify_vadcop_final_compressed_bytes(proof_bytes, vk_bytes) { return Err(Error::InvalidProof); } - Ok(proof.public_values.as_slice().into()) + Ok(public_values.into()) } fn name(&self) -> &'static str { diff --git a/scripts/sdk_installers/install_zisk_sdk.sh b/scripts/sdk_installers/install_zisk_sdk.sh index cb894262..dd089e74 100755 --- a/scripts/sdk_installers/install_zisk_sdk.sh +++ b/scripts/sdk_installers/install_zisk_sdk.sh @@ -32,7 +32,7 @@ ensure_tool_installed "cargo" "to pre-build lib-c" # Step 1: Download and run the script that installs the ziskup binary itself. # Export SETUP_KEY=proving-no-consttree to download proving key without doing setup. -export ZISK_VERSION="0.16.1" +export ZISK_VERSION="0.17.0" export SETUP_KEY=${SETUP_KEY:=proving-no-consttree} curl "https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh" | bash unset SETUP_KEY @@ -50,9 +50,3 @@ cargo init "$WORKSPACE" --name build-lib-c cargo add lib-c --git https://github.com/han0110/zisk.git --branch "patch/v$ZISK_VERSION" --manifest-path "$WORKSPACE/Cargo.toml" cargo build --manifest-path "$WORKSPACE/Cargo.toml" rm -rf "$WORKSPACE" - -# FIXME: Remove this step when upgrading to `v0.17.0` -# Step 3: Rebuild `ziskemu` using the patched repo -cargo install --git https://github.com/han0110/zisk.git --branch "patch/v$ZISK_VERSION" --locked ziskemu -CARGO_BIN="${CARGO_HOME:-$HOME/.cargo}/bin" -mv $CARGO_BIN/ziskemu $HOME/.zisk/bin/ziskemu From 2b9271eb196e6dc9a1ca75640c68dc2a3af88990 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 02:55:17 +0000 Subject: [PATCH 02/15] feat: update ere-cluster-client-zisk --- crates/cluster-client/zisk/Cargo.toml | 8 +- .../zisk/proto/zisk_coordinator_api.proto | 364 ++++++ .../zisk/proto/zisk_distributed_api.proto | 387 ------ crates/cluster-client/zisk/src/api.rs | 1056 +++++++---------- crates/cluster-client/zisk/src/client.rs | 380 +++--- crates/cluster-client/zisk/src/error.rs | 20 +- crates/cluster-client/zisk/src/lib.rs | 2 +- crates/cluster-client/zisk/src/test.rs | 4 +- 8 files changed, 994 insertions(+), 1227 deletions(-) create mode 100644 crates/cluster-client/zisk/proto/zisk_coordinator_api.proto delete mode 100644 crates/cluster-client/zisk/proto/zisk_distributed_api.proto diff --git a/crates/cluster-client/zisk/Cargo.toml b/crates/cluster-client/zisk/Cargo.toml index 82ac9435..e002fe40 100644 --- a/crates/cluster-client/zisk/Cargo.toml +++ b/crates/cluster-client/zisk/Cargo.toml @@ -6,19 +6,19 @@ rust-version.workspace = true license.workspace = true [dependencies] -futures-util.workspace = true +bincode = { workspace = true, features = ["alloc", "serde"] } http.workspace = true prost.workspace = true prost-types.workspace = true +serde = { workspace = true, features = ["derive"] } thiserror.workspace = true +tokio = { workspace = true, features = ["time"] } tonic.workspace = true tonic-prost.workspace = true -tracing.workspace = true -uuid = { workspace = true, features = ["v4"] } # Local dependencies +ere-compiler-core.workspace = true ere-prover-core.workspace = true -ere-util-tokio.workspace = true ere-verifier-zisk.workspace = true [dev-dependencies] diff --git a/crates/cluster-client/zisk/proto/zisk_coordinator_api.proto b/crates/cluster-client/zisk/proto/zisk_coordinator_api.proto new file mode 100644 index 00000000..a06b1073 --- /dev/null +++ b/crates/cluster-client/zisk/proto/zisk_coordinator_api.proto @@ -0,0 +1,364 @@ +// Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.17.0/distributed/crates/coordinator-api/proto/zisk_coordinator_api.proto. + +syntax = "proto3"; + +package zisk.coordinator.v1; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; + +// ============================================================================ +// ZisK Coordinator API +// +// Public interface for clients to register guest programs and manage proving +// jobs. All methods are idempotent or safely retryable as documented. +// ============================================================================ + +service ZiskCoordinatorApi { + // Register a new guest program. Idempotent: the same ELF always returns + // the same hash_id. + rpc RegisterGuestProgram(RegisterGuestProgramRequest) + returns (RegisterGuestProgramResponse); + + // Submit a new job (setup, prove, wrap, or execute). + rpc JobRequest(JobRequestMessage) + returns (JobResponse); + + // Long-poll: block until the job reaches a terminal state or the server-side + // timeout elapses, then return the current status. Loop on this to poll to + // completion without application-level sleep. + rpc WaitJobResult(WaitJobResultRequest) + returns (WaitJobResultResponse); + + // Subscribe to live state-transition events for a job. The stream closes + // after the terminal event. Safe to call after the job has already finished. + rpc WatchJob(WatchJobRequest) + returns (stream JobEvent); + + // Stream additional input chunks to a running job. + // Close the stream to signal end-of-input (EOF). + rpc PushJobInput(stream PushJobInputRequest) + returns (google.protobuf.Empty); + + // Stream additional hints chunks to a running job. + // Close the stream to signal end-of-hints (EOF). + rpc PushJobHintsInput(stream PushJobHintsInputRequest) + returns (google.protobuf.Empty); + + // Cancel a running or queued job. Blocks until the job reaches a terminal + // state (Cancelled or another terminal if it completed first). + // Idempotent: returns cancelled=false if the job is already in a terminal state. + rpc CancelJob(CancelJobRequest) + returns (CancelJobResponse); +} + +// ============================================================================ +// Common data types +// ============================================================================ + +message CostPerType { + uint64 main = 1; + uint64 opcode = 2; + uint64 memory = 3; + uint64 precompile = 4; + uint64 tables = 5; + uint64 other = 6; +} + +message ExecutionStats { + uint64 steps = 1; + uint64 duration_nanos = 2; + CostPerType cost_per_type = 3; +} + +enum ProofKind { + PROOF_KIND_UNSPECIFIED = 0; + PROOF_KIND_STARK = 1; + PROOF_KIND_STARK_MINIMAL = 2; + PROOF_KIND_PLONK = 3; +} + +enum JobPhase { + JOB_PHASE_UNSPECIFIED = 0; + JOB_PHASE_CONTRIBUTIONS = 1; // witness generation and partial contributions + JOB_PHASE_PROVE = 2; // proof generation + JOB_PHASE_AGGREGATE = 3; // proof aggregation +} + +message InputChunk { + bytes data = 1; +} + +message InputKind { + oneof kind { + InputChunk inline = 1; // first chunk; use PushJobInput for additional chunks + string stream_uri = 2; // file:// unix:// quic:// + } +} + +message Proof { + string proof_id = 1; // UUID + string hash_id = 2; + bytes verification_key = 3; + ProofKind proof_kind = 4; + bytes data = 5; + bytes public_inputs = 6; + google.protobuf.Timestamp started_at = 7; + google.protobuf.Timestamp completed_at = 8; +} + +// RPC-level error — returned in Status details for programmatic inspection. +message ApiError { + uint32 code = 1; // stable numeric code (see error table) + string name = 2; // e.g. "JOB_NOT_FOUND" + string message = 3; // human-readable detail +} + +// Job-level failure (the job ran but did not complete successfully). +message JobFailure { + oneof kind { + JobFailureTimeout timeout = 1; + JobFailureInput input = 2; + JobFailureExecution execution = 3; + JobFailureInternal internal = 4; + JobFailureCancelled cancelled = 5; + } +} + +message JobFailureTimeout { + optional JobPhase phase = 1; + google.protobuf.Duration limit = 2; +} + +message JobFailureInput { + string reason = 1; +} + +message JobFailureExecution { + string reason = 1; +} + +message JobFailureInternal { + string trace_id = 1; +} + +message JobFailureCancelled {} + +// ============================================================================ +// Program Management +// ============================================================================ + +message RegisterGuestProgramRequest { + bytes zisk_elf = 1; +} + +message RegisterGuestProgramResponse { + string hash_id = 1; // blake3 content hash of zisk_elf +} + +// ============================================================================ +// Job submission +// ============================================================================ + +message JobRequestMessage { + JobKind job_kind = 1; +} + +message JobResponse { + string job_id = 1; // UUID +} + +message JobKind { + oneof kind { + SetupRequest setup = 1; + ProveRequest prove = 2; + WrapRequest wrap = 3; + // AggregateRequest aggregate = 4; // TODO: not yet defined + ExecuteRequest execute = 5; + } +} + +// ============================================================================ +// Job kind requests and responses +// ============================================================================ + +message SetupRequest { + string hash_id = 1; + bool with_hints = 2; + string program_name = 3; +} + +message SetupResponse { + bytes vk = 1; +} + +message ProveRequest { + string hash_id = 1; + InputKind input = 2; + optional google.protobuf.Timestamp proof_timeout = 3; + ProofKind proof_dest = 4; + optional InputKind hints = 5; +} + +message ProveResponse { + Proof proof = 1; + ExecutionStats stats = 2; +} + +message WrapRequest { + Proof proof = 1; + ProofKind proof_dest = 2; + optional google.protobuf.Timestamp wrap_timeout = 3; +} + +message WrapResponse { + Proof proof = 1; +} + +// TODO: AggregateRequest / AggregateResponse — to be defined +// message AggregateRequest { … } +// message AggregateResponse { … } + +message ExecuteRequest { + string hash_id = 1; + InputKind input = 2; + optional google.protobuf.Timestamp execute_timeout = 3; + optional InputKind hints = 4; +} + +message ExecuteResponse { + ExecutionStats stats = 1; + bytes public_outputs = 2; +} + +message JobKindResponse { + oneof kind { + SetupResponse setup = 1; + ProveResponse prove = 2; + WrapResponse wrap = 3; + ExecuteResponse execute = 4; + } +} + +// ============================================================================ +// WaitJobResult +// ============================================================================ + +message WaitJobResultRequest { + string job_id = 1; + optional uint32 timeout_seconds = 2; // server-side hold duration; min 1s, default 5s +} + +message WaitJobResultResponse { + string job_id = 1; + JobStatus job_status = 2; + optional JobKindResponse result = 3; // present when job_status is Completed +} + +message JobStatus { + oneof status { + JobStatusQueued queued = 1; + JobStatusRunning running = 2; + JobStatusWaitingForInput waiting_for_input = 3; + JobStatusCompleted completed = 4; + JobStatusFailed failed = 5; + JobStatusCancelled cancelled = 6; + } +} + +message JobStatusQueued {} +message JobStatusRunning { optional JobPhase phase = 1; } +message JobStatusWaitingForInput {} +message JobStatusCompleted {} +message JobStatusFailed { JobFailure failure = 1; } +message JobStatusCancelled {} + +// ============================================================================ +// WatchJob +// ============================================================================ + +message WatchJobRequest { + string job_id = 1; +} + +message JobEvent { + oneof event { + JobEventQueued queued = 1; + JobEventStarted started = 2; + JobEventProgress progress = 3; + JobEventWaitingForInput waiting_for_input = 4; + JobEventCompleted completed = 5; + JobEventCancelled cancelled = 6; + JobEventFailed failed = 7; + } +} + +message JobEventQueued { + string job_id = 1; + google.protobuf.Timestamp timestamp = 2; +} + +message JobEventStarted { + string job_id = 1; + google.protobuf.Timestamp timestamp = 2; +} + +message JobEventProgress { + string job_id = 1; + JobPhase phase = 2; + google.protobuf.Timestamp timestamp = 3; +} + +message JobEventWaitingForInput { + string job_id = 1; + google.protobuf.Timestamp timestamp = 2; +} + +message JobEventCompleted { + string job_id = 1; + JobKindResponse result = 2; + google.protobuf.Timestamp timestamp = 3; +} + +message JobEventCancelled { + string job_id = 1; + google.protobuf.Timestamp timestamp = 2; +} + +message JobEventFailed { + string job_id = 1; + JobFailure failure = 2; + google.protobuf.Timestamp timestamp = 3; +} + +// ============================================================================ +// PushJobInput +// ============================================================================ + +message PushJobInputRequest { + string job_id = 1; + InputChunk chunk = 2; +} + +// ============================================================================ +// PushJobHintsInput +// ============================================================================ + +message PushJobHintsInputRequest { + string job_id = 1; + InputChunk chunk = 2; +} + +// ============================================================================ +// CancelJob +// ============================================================================ + +message CancelJobRequest { + string job_id = 1; +} + +message CancelJobResponse { + string job_id = 1; + bool cancelled = 2; // true if cancelled; false if already terminal +} diff --git a/crates/cluster-client/zisk/proto/zisk_distributed_api.proto b/crates/cluster-client/zisk/proto/zisk_distributed_api.proto deleted file mode 100644 index 402755f4..00000000 --- a/crates/cluster-client/zisk/proto/zisk_distributed_api.proto +++ /dev/null @@ -1,387 +0,0 @@ -// Copied from https://github.com/han0110/zisk/blob/patch/v0.16.1/distributed/crates/grpc-api/proto/zisk_distributed_api.proto. - -syntax = "proto3"; - -package zisk.distributed.api.v1; - -import "google/protobuf/timestamp.proto"; - -// ============================================================================ -// gRPC Service Definition -// ============================================================================ - -service ZiskDistributedApi { - // Bidirectional stream between worker(s) and coordinator - rpc WorkerStream(stream WorkerMessage) returns (stream CoordinatorMessage); - - // Admin endpoints (optional, for monitoring) - rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse); - rpc SystemStatus(SystemStatusRequest) returns (SystemStatusResponse); - rpc StatusInfo(StatusInfoRequest) returns (StatusInfoResponse); - rpc JobsList(JobsListRequest) returns (JobsListResponse); - rpc JobStatus(JobStatusRequest) returns (JobStatusResponse); - rpc WorkersList(WorkersListRequest) returns (WorkersListResponse); - - // Coordinator control - rpc LaunchProof(LaunchProofRequest) returns (LaunchProofResponse); - - // Client subscription to job completion - rpc SubscribeToProof(SubscribeToProofRequest) returns (stream ProofStatusUpdate); -} - -// Standardized error response -message ErrorResponse { - string code = 1; // Error code - string message = 2; // Human-readable error message -} - -// ============================================================================ -// Admin Commands Request Messages -// ============================================================================ - -message HealthCheckRequest {} - -message SystemStatusRequest {} - -message StatusInfoRequest {} - -message JobsListRequest { - bool active_only = 1; -} - -message JobStatusRequest { - string job_id = 1; -} - -message WorkersListRequest { - bool available_only = 1; -} - -message LaunchProofRequest { - string data_id = 1; - uint32 compute_capacity = 2; - uint32 minimal_compute_capacity = 3; - InputMode inputs_mode = 4; - optional string inputs_uri = 5; - HintsMode hints_mode = 6; - optional string hints_uri = 7; - optional uint32 simulated_node = 8; // If set, indicates this is a simulated worker - optional bytes input_data = 9; -} - -enum InputMode { - INPUT_MODE_NONE = 0; // No input provided - INPUT_MODE_PATH = 1; // Input will be provided as a PATH - INPUT_MODE_DATA = 2; // Input data will be sent directly -} - -enum HintsMode { - HINTS_MODE_NONE = 0; // No hints provided - HINTS_MODE_PATH = 1; // Hints will be provided as a PATH - HINTS_MODE_STREAM = 2; // Hints will be sent as a stream -} - - -// ============================================================================ -// Admin Commands Response Messages -// ============================================================================ - -message HealthCheckResponse {} - -message SystemStatusResponse { - oneof result { - SystemStatus status = 1; - ErrorResponse error = 2; - } -} - -message SystemStatus { - uint32 total_workers = 1; - uint32 compute_capacity = 2; - uint32 idle_workers = 3; - uint32 busy_workers = 4; - uint32 active_jobs = 5; -} - -message StatusInfoResponse { - string service_name = 1; - string version = 2; - uint64 uptime_seconds = 3; - google.protobuf.Timestamp start_time = 4; - Metrics metrics = 5; -} - -// Metrics information -message Metrics { - uint32 active_connections = 1; -} - -message JobsListResponse { - oneof result { - JobsList jobs_list = 1; // Success case - ErrorResponse error = 2; // Error case (e.g., system unavailable) - } -} - -message JobsList { - repeated JobStatus jobs = 1; -} - -message JobStatusResponse { - oneof result { - JobStatus job = 1; // Success case - ErrorResponse error = 2; // Error case (e.g., job not found) - } -} - -message JobStatus { - string job_id = 1; - string data_id = 2; - string phase = 3; - string state = 4; - repeated string assigned_workers = 5; - uint64 start_time = 6; - uint64 duration_ms = 7; -} - -message WorkersListResponse { - oneof result { - WorkersList workers_list = 1; - ErrorResponse error = 2; - } -} - -message WorkersList { - repeated WorkerInfo workers = 1; -} - -message WorkerInfo { - string worker_id = 1; - string state = 2; - ComputeCapacity compute_capacity = 3; - google.protobuf.Timestamp connected_at = 4; - google.protobuf.Timestamp last_heartbeat = 5; -} - -message LaunchProofResponse { - oneof result { - string job_id = 1; - ErrorResponse error = 2; - } -} - -// ============================================================================ -// Client Subscription Messages -// ============================================================================ - -message SubscribeToProofRequest { - string job_id = 1; -} - -message ProofStatusUpdate { - string job_id = 1; - ProofStatusType status = 2; - optional FinalProof final_proof = 3; - optional ErrorResponse error = 4; - uint64 duration_ms = 5; -} - -enum ProofStatusType { - PROOF_STATUS_COMPLETED = 0; - PROOF_STATUS_FAILED = 1; -} - -// ============================================================================ -// STREAM MESSAGES from COORDINATOR <-> WORKER -// ============================================================================ - -// Messages from coordinator to worker -message CoordinatorMessage { - oneof payload { - Heartbeat heartbeat = 1; - Shutdown shutdown = 2; - WorkerRegisterResponse register_response = 3; - ExecuteTaskRequest execute_task = 4; - JobCancelled job_cancelled = 5; - StreamData stream_data = 6; - } -} - -// Messages from worker to coordinator -message WorkerMessage { - oneof payload { - HeartbeatAck heartbeat_ack = 1; - WorkerError error = 2; - WorkerRegisterRequest register = 3; - WorkerReconnectRequest reconnect = 4; - ExecuteTaskResponse execute_task_response = 5; - } -} - -message Heartbeat { - google.protobuf.Timestamp timestamp = 1; -} - -message HeartbeatAck { - string worker_id = 1; -} - -message Shutdown { - string reason = 1; - uint32 grace_period_seconds = 2; -} - -message WorkerRegisterRequest { - string worker_id = 1; - ComputeCapacity compute_capacity = 2; // Maximum compute capacity of a node/cluster -} - -message WorkerReconnectRequest { - string worker_id = 1; - ComputeCapacity compute_capacity = 2; // Maximum compute capacity of a node/cluster - string last_known_job_id = 3; -} - -message WorkerRegisterResponse { - string worker_id = 1; - bool accepted = 2; - string message = 3; - google.protobuf.Timestamp registered_at = 4; -} - -message ExecuteTaskRequest { - string worker_id = 1; - string job_id = 2; - TaskType task_type = 3; - oneof params { - ContributionParams contribution_params = 4; - ProveParams prove_params = 5; - AggParams agg_params = 6; - } -} - -enum TaskType { - PARTIAL_CONTRIBUTION = 0; - PROVE = 1; - AGGREGATE = 2; -} - -message ContributionParams { - string data_id = 1; - oneof input_source { - string input_path = 2; - bytes input_data = 3; - } - optional string hints_path = 4; - bool hints_stream = 5; // Indicates whether hints will be streamed - uint32 rank_id = 6; - uint32 total_workers = 7; - repeated uint32 worker_allocation = 8; - uint32 job_compute_units = 9; -} - -message ProveParams { - repeated Challenges challenges = 1; -} - -message AggParams { - ProofList agg_proofs = 1; - bool last_proof = 2; - bool final_proof = 3; - bool compressed = 4; -} - -// Stream type enumeration -enum StreamType { - STREAM_TYPE_START = 0; - STREAM_TYPE_DATA = 1; - STREAM_TYPE_END = 2; -} - -// Streaming messages for data transfer -message StreamData { - string job_id = 1; - StreamType stream_type = 2; - optional StreamPayload payload = 3; -} - -message StreamPayload { - uint32 sequence_number = 3; - bytes payload = 4; -} - -message ExecuteTaskResponse { - string job_id = 1; - string worker_id = 2; - TaskType task_type = 3; - bool success = 4; - string error_message = 5; // Optional error message if success is false - oneof result_data { - ChallengesList challenges = 6; - ProofList proofs = 7; - FinalProof final_proof = 8; - } -} - -message WitnessExecInfo { - float witness_time = 1; - repeated uint64 publics = 2; - repeated uint64 proof_values = 3; - string summary_info = 4; -} - -message AsmExecuteInfo { - float time = 1; - float mhz = 2; -} - -message ZiskExecuteTime { - float total_duration = 1; - float execution_duration = 2; - float count_and_plan_duration = 3; - float count_and_plan_mo_duration = 4; - optional AsmExecuteInfo asm_execution_duration = 5; - double task_received_time = 6; // Time when task was received by worker (in milliseconds since UNIX epoch) -} - -message ChallengesList { - repeated Challenges challenges = 1; - WitnessExecInfo witness_info = 2; - ZiskExecuteTime zisk_execution_time = 3; -} - -message Challenges { - uint32 worker_index = 1; - uint32 airgroup_id = 2; - repeated uint64 challenge = 3; -} - -message ProofList { - repeated Proof proofs = 1; -} - -message Proof { - uint32 worker_idx = 1; - uint64 airgroup_id = 2; - repeated uint64 values = 3; -} - -message FinalProof { - repeated uint64 values = 1; - uint64 executed_steps = 2; -} - -message WorkerError { - string worker_id = 1; - string job_id = 2; - string error_message = 3; -} - -message ComputeCapacity { - uint32 compute_units = 1; -} - -message JobCancelled { - string job_id = 1; - string reason = 2; -} diff --git a/crates/cluster-client/zisk/src/api.rs b/crates/cluster-client/zisk/src/api.rs index 8aadcfd8..ba54d1fc 100644 --- a/crates/cluster-client/zisk/src/api.rs +++ b/crates/cluster-client/zisk/src/api.rs @@ -1,679 +1,496 @@ // This file is @generated by prost-build. -/// Standardized error response -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ErrorResponse { - /// Error code - #[prost(string, tag = "1")] - pub code: ::prost::alloc::string::String, - /// Human-readable error message - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, -} #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct HealthCheckRequest {} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SystemStatusRequest {} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct StatusInfoRequest {} +pub struct CostPerType { + #[prost(uint64, tag = "1")] + pub main: u64, + #[prost(uint64, tag = "2")] + pub opcode: u64, + #[prost(uint64, tag = "3")] + pub memory: u64, + #[prost(uint64, tag = "4")] + pub precompile: u64, + #[prost(uint64, tag = "5")] + pub tables: u64, + #[prost(uint64, tag = "6")] + pub other: u64, +} #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct JobsListRequest { - #[prost(bool, tag = "1")] - pub active_only: bool, +pub struct ExecutionStats { + #[prost(uint64, tag = "1")] + pub steps: u64, + #[prost(uint64, tag = "2")] + pub duration_nanos: u64, + #[prost(message, optional, tag = "3")] + pub cost_per_type: ::core::option::Option, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct JobStatusRequest { - #[prost(string, tag = "1")] - pub job_id: ::prost::alloc::string::String, +pub struct InputChunk { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkersListRequest { - #[prost(bool, tag = "1")] - pub available_only: bool, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct InputKind { + #[prost(oneof = "input_kind::Kind", tags = "1, 2")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `InputKind`. +pub mod input_kind { + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] + pub enum Kind { + /// first chunk; use PushJobInput for additional chunks + #[prost(message, tag = "1")] + Inline(super::InputChunk), + /// file:// unix:// quic:// + #[prost(string, tag = "2")] + StreamUri(::prost::alloc::string::String), + } } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct LaunchProofRequest { +pub struct Proof { + /// UUID #[prost(string, tag = "1")] - pub data_id: ::prost::alloc::string::String, - #[prost(uint32, tag = "2")] - pub compute_capacity: u32, - #[prost(uint32, tag = "3")] - pub minimal_compute_capacity: u32, - #[prost(enumeration = "InputMode", tag = "4")] - pub inputs_mode: i32, - #[prost(string, optional, tag = "5")] - pub inputs_uri: ::core::option::Option<::prost::alloc::string::String>, - #[prost(enumeration = "HintsMode", tag = "6")] - pub hints_mode: i32, - #[prost(string, optional, tag = "7")] - pub hints_uri: ::core::option::Option<::prost::alloc::string::String>, - /// If set, indicates this is a simulated worker - #[prost(uint32, optional, tag = "8")] - pub simulated_node: ::core::option::Option, - #[prost(bytes = "vec", optional, tag = "9")] - pub input_data: ::core::option::Option<::prost::alloc::vec::Vec>, + pub proof_id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub hash_id: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "3")] + pub verification_key: ::prost::alloc::vec::Vec, + #[prost(enumeration = "ProofKind", tag = "4")] + pub proof_kind: i32, + #[prost(bytes = "vec", tag = "5")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "6")] + pub public_inputs: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "7")] + pub started_at: ::core::option::Option<::prost_types::Timestamp>, + #[prost(message, optional, tag = "8")] + pub completed_at: ::core::option::Option<::prost_types::Timestamp>, +} +/// RPC-level error — returned in Status details for programmatic inspection. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ApiError { + /// stable numeric code (see error table) + #[prost(uint32, tag = "1")] + pub code: u32, + /// e.g. "JOB_NOT_FOUND" + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, + /// human-readable detail + #[prost(string, tag = "3")] + pub message: ::prost::alloc::string::String, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct HealthCheckResponse {} +/// Job-level failure (the job ran but did not complete successfully). #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SystemStatusResponse { - #[prost(oneof = "system_status_response::Result", tags = "1, 2")] - pub result: ::core::option::Option, +pub struct JobFailure { + #[prost(oneof = "job_failure::Kind", tags = "1, 2, 3, 4, 5")] + pub kind: ::core::option::Option, } -/// Nested message and enum types in `SystemStatusResponse`. -pub mod system_status_response { +/// Nested message and enum types in `JobFailure`. +pub mod job_failure { #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Result { + pub enum Kind { #[prost(message, tag = "1")] - Status(super::SystemStatus), + Timeout(super::JobFailureTimeout), #[prost(message, tag = "2")] - Error(super::ErrorResponse), + Input(super::JobFailureInput), + #[prost(message, tag = "3")] + Execution(super::JobFailureExecution), + #[prost(message, tag = "4")] + Internal(super::JobFailureInternal), + #[prost(message, tag = "5")] + Cancelled(super::JobFailureCancelled), } } #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SystemStatus { - #[prost(uint32, tag = "1")] - pub total_workers: u32, - #[prost(uint32, tag = "2")] - pub compute_capacity: u32, - #[prost(uint32, tag = "3")] - pub idle_workers: u32, - #[prost(uint32, tag = "4")] - pub busy_workers: u32, - #[prost(uint32, tag = "5")] - pub active_jobs: u32, +pub struct JobFailureTimeout { + #[prost(enumeration = "JobPhase", optional, tag = "1")] + pub phase: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub limit: ::core::option::Option<::prost_types::Duration>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct StatusInfoResponse { +pub struct JobFailureInput { #[prost(string, tag = "1")] - pub service_name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub version: ::prost::alloc::string::String, - #[prost(uint64, tag = "3")] - pub uptime_seconds: u64, - #[prost(message, optional, tag = "4")] - pub start_time: ::core::option::Option<::prost_types::Timestamp>, - #[prost(message, optional, tag = "5")] - pub metrics: ::core::option::Option, + pub reason: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobFailureExecution { + #[prost(string, tag = "1")] + pub reason: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobFailureInternal { + #[prost(string, tag = "1")] + pub trace_id: ::prost::alloc::string::String, } -/// Metrics information #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Metrics { - #[prost(uint32, tag = "1")] - pub active_connections: u32, +pub struct JobFailureCancelled {} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RegisterGuestProgramRequest { + #[prost(bytes = "vec", tag = "1")] + pub zisk_elf: ::prost::alloc::vec::Vec, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct JobsListResponse { - #[prost(oneof = "jobs_list_response::Result", tags = "1, 2")] - pub result: ::core::option::Option, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RegisterGuestProgramResponse { + /// blake3 content hash of zisk_elf + #[prost(string, tag = "1")] + pub hash_id: ::prost::alloc::string::String, } -/// Nested message and enum types in `JobsListResponse`. -pub mod jobs_list_response { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Result { - /// Success case - #[prost(message, tag = "1")] - JobsList(super::JobsList), - /// Error case (e.g., system unavailable) - #[prost(message, tag = "2")] - Error(super::ErrorResponse), - } +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobRequestMessage { + #[prost(message, optional, tag = "1")] + pub job_kind: ::core::option::Option, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct JobsList { - #[prost(message, repeated, tag = "1")] - pub jobs: ::prost::alloc::vec::Vec, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobResponse { + /// UUID + #[prost(string, tag = "1")] + pub job_id: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct JobStatusResponse { - #[prost(oneof = "job_status_response::Result", tags = "1, 2")] - pub result: ::core::option::Option, +pub struct JobKind { + #[prost(oneof = "job_kind::Kind", tags = "1, 2, 3, 5")] + pub kind: ::core::option::Option, } -/// Nested message and enum types in `JobStatusResponse`. -pub mod job_status_response { +/// Nested message and enum types in `JobKind`. +pub mod job_kind { #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Result { - /// Success case + pub enum Kind { #[prost(message, tag = "1")] - Job(super::JobStatus), - /// Error case (e.g., job not found) + Setup(super::SetupRequest), #[prost(message, tag = "2")] - Error(super::ErrorResponse), + Prove(super::ProveRequest), + #[prost(message, tag = "3")] + Wrap(super::WrapRequest), + /// AggregateRequest aggregate = 4; // TODO: not yet defined + #[prost(message, tag = "5")] + Execute(super::ExecuteRequest), } } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct JobStatus { +pub struct SetupRequest { #[prost(string, tag = "1")] - pub job_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub data_id: ::prost::alloc::string::String, + pub hash_id: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub with_hints: bool, #[prost(string, tag = "3")] - pub phase: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub state: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "5")] - pub assigned_workers: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(uint64, tag = "6")] - pub start_time: u64, - #[prost(uint64, tag = "7")] - pub duration_ms: u64, + pub program_name: ::prost::alloc::string::String, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WorkersListResponse { - #[prost(oneof = "workers_list_response::Result", tags = "1, 2")] - pub result: ::core::option::Option, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct SetupResponse { + #[prost(bytes = "vec", tag = "1")] + pub vk: ::prost::alloc::vec::Vec, } -/// Nested message and enum types in `WorkersListResponse`. -pub mod workers_list_response { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Result { - #[prost(message, tag = "1")] - WorkersList(super::WorkersList), - #[prost(message, tag = "2")] - Error(super::ErrorResponse), - } +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ProveRequest { + #[prost(string, tag = "1")] + pub hash_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub input: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub proof_timeout: ::core::option::Option<::prost_types::Timestamp>, + #[prost(enumeration = "ProofKind", tag = "4")] + pub proof_dest: i32, + #[prost(message, optional, tag = "5")] + pub hints: ::core::option::Option, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WorkersList { - #[prost(message, repeated, tag = "1")] - pub workers: ::prost::alloc::vec::Vec, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ProveResponse { + #[prost(message, optional, tag = "1")] + pub proof: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub stats: ::core::option::Option, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkerInfo { +pub struct WrapRequest { + #[prost(message, optional, tag = "1")] + pub proof: ::core::option::Option, + #[prost(enumeration = "ProofKind", tag = "2")] + pub proof_dest: i32, + #[prost(message, optional, tag = "3")] + pub wrap_timeout: ::core::option::Option<::prost_types::Timestamp>, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct WrapResponse { + #[prost(message, optional, tag = "1")] + pub proof: ::core::option::Option, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ExecuteRequest { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub state: ::prost::alloc::string::String, + pub hash_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub input: ::core::option::Option, #[prost(message, optional, tag = "3")] - pub compute_capacity: ::core::option::Option, + pub execute_timeout: ::core::option::Option<::prost_types::Timestamp>, #[prost(message, optional, tag = "4")] - pub connected_at: ::core::option::Option<::prost_types::Timestamp>, - #[prost(message, optional, tag = "5")] - pub last_heartbeat: ::core::option::Option<::prost_types::Timestamp>, + pub hints: ::core::option::Option, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ExecuteResponse { + #[prost(message, optional, tag = "1")] + pub stats: ::core::option::Option, + #[prost(bytes = "vec", tag = "2")] + pub public_outputs: ::prost::alloc::vec::Vec, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct LaunchProofResponse { - #[prost(oneof = "launch_proof_response::Result", tags = "1, 2")] - pub result: ::core::option::Option, +pub struct JobKindResponse { + #[prost(oneof = "job_kind_response::Kind", tags = "1, 2, 3, 4")] + pub kind: ::core::option::Option, } -/// Nested message and enum types in `LaunchProofResponse`. -pub mod launch_proof_response { +/// Nested message and enum types in `JobKindResponse`. +pub mod job_kind_response { #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Result { - #[prost(string, tag = "1")] - JobId(::prost::alloc::string::String), + pub enum Kind { + #[prost(message, tag = "1")] + Setup(super::SetupResponse), #[prost(message, tag = "2")] - Error(super::ErrorResponse), + Prove(super::ProveResponse), + #[prost(message, tag = "3")] + Wrap(super::WrapResponse), + #[prost(message, tag = "4")] + Execute(super::ExecuteResponse), } } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SubscribeToProofRequest { +pub struct WaitJobResultRequest { #[prost(string, tag = "1")] pub job_id: ::prost::alloc::string::String, + /// server-side hold duration; min 1s, default 5s + #[prost(uint32, optional, tag = "2")] + pub timeout_seconds: ::core::option::Option, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ProofStatusUpdate { +pub struct WaitJobResultResponse { #[prost(string, tag = "1")] pub job_id: ::prost::alloc::string::String, - #[prost(enumeration = "ProofStatusType", tag = "2")] - pub status: i32, + #[prost(message, optional, tag = "2")] + pub job_status: ::core::option::Option, + /// present when job_status is Completed #[prost(message, optional, tag = "3")] - pub final_proof: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub error: ::core::option::Option, - #[prost(uint64, tag = "5")] - pub duration_ms: u64, + pub result: ::core::option::Option, } -/// Messages from coordinator to worker -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CoordinatorMessage { - #[prost(oneof = "coordinator_message::Payload", tags = "1, 2, 3, 4, 5, 6")] - pub payload: ::core::option::Option, +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatus { + #[prost(oneof = "job_status::Status", tags = "1, 2, 3, 4, 5, 6")] + pub status: ::core::option::Option, } -/// Nested message and enum types in `CoordinatorMessage`. -pub mod coordinator_message { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Payload { +/// Nested message and enum types in `JobStatus`. +pub mod job_status { + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] + pub enum Status { #[prost(message, tag = "1")] - Heartbeat(super::Heartbeat), + Queued(super::JobStatusQueued), #[prost(message, tag = "2")] - Shutdown(super::Shutdown), + Running(super::JobStatusRunning), #[prost(message, tag = "3")] - RegisterResponse(super::WorkerRegisterResponse), + WaitingForInput(super::JobStatusWaitingForInput), #[prost(message, tag = "4")] - ExecuteTask(super::ExecuteTaskRequest), + Completed(super::JobStatusCompleted), #[prost(message, tag = "5")] - JobCancelled(super::JobCancelled), + Failed(super::JobStatusFailed), #[prost(message, tag = "6")] - StreamData(super::StreamData), + Cancelled(super::JobStatusCancelled), } } -/// Messages from worker to coordinator -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WorkerMessage { - #[prost(oneof = "worker_message::Payload", tags = "1, 2, 3, 4, 5")] - pub payload: ::core::option::Option, -} -/// Nested message and enum types in `WorkerMessage`. -pub mod worker_message { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Payload { - #[prost(message, tag = "1")] - HeartbeatAck(super::HeartbeatAck), - #[prost(message, tag = "2")] - Error(super::WorkerError), - #[prost(message, tag = "3")] - Register(super::WorkerRegisterRequest), - #[prost(message, tag = "4")] - Reconnect(super::WorkerReconnectRequest), - #[prost(message, tag = "5")] - ExecuteTaskResponse(super::ExecuteTaskResponse), - } +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatusQueued {} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatusRunning { + #[prost(enumeration = "JobPhase", optional, tag = "1")] + pub phase: ::core::option::Option, } #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Heartbeat { +pub struct JobStatusWaitingForInput {} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatusCompleted {} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatusFailed { #[prost(message, optional, tag = "1")] - pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + pub failure: ::core::option::Option, } +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct JobStatusCancelled {} #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct HeartbeatAck { +pub struct WatchJobRequest { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, + pub job_id: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Shutdown { - #[prost(string, tag = "1")] - pub reason: ::prost::alloc::string::String, - #[prost(uint32, tag = "2")] - pub grace_period_seconds: u32, +pub struct JobEvent { + #[prost(oneof = "job_event::Event", tags = "1, 2, 3, 4, 5, 6, 7")] + pub event: ::core::option::Option, +} +/// Nested message and enum types in `JobEvent`. +pub mod job_event { + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] + pub enum Event { + #[prost(message, tag = "1")] + Queued(super::JobEventQueued), + #[prost(message, tag = "2")] + Started(super::JobEventStarted), + #[prost(message, tag = "3")] + Progress(super::JobEventProgress), + #[prost(message, tag = "4")] + WaitingForInput(super::JobEventWaitingForInput), + #[prost(message, tag = "5")] + Completed(super::JobEventCompleted), + #[prost(message, tag = "6")] + Cancelled(super::JobEventCancelled), + #[prost(message, tag = "7")] + Failed(super::JobEventFailed), + } } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkerRegisterRequest { +pub struct JobEventQueued { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - /// Maximum compute capacity of a node/cluster + pub job_id: ::prost::alloc::string::String, #[prost(message, optional, tag = "2")] - pub compute_capacity: ::core::option::Option, + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkerReconnectRequest { +pub struct JobEventStarted { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - /// Maximum compute capacity of a node/cluster + pub job_id: ::prost::alloc::string::String, #[prost(message, optional, tag = "2")] - pub compute_capacity: ::core::option::Option, - #[prost(string, tag = "3")] - pub last_known_job_id: ::prost::alloc::string::String, + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkerRegisterResponse { - #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - #[prost(bool, tag = "2")] - pub accepted: bool, - #[prost(string, tag = "3")] - pub message: ::prost::alloc::string::String, - #[prost(message, optional, tag = "4")] - pub registered_at: ::core::option::Option<::prost_types::Timestamp>, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExecuteTaskRequest { +pub struct JobEventProgress { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] pub job_id: ::prost::alloc::string::String, - #[prost(enumeration = "TaskType", tag = "3")] - pub task_type: i32, - #[prost(oneof = "execute_task_request::Params", tags = "4, 5, 6")] - pub params: ::core::option::Option, -} -/// Nested message and enum types in `ExecuteTaskRequest`. -pub mod execute_task_request { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Params { - #[prost(message, tag = "4")] - ContributionParams(super::ContributionParams), - #[prost(message, tag = "5")] - ProveParams(super::ProveParams), - #[prost(message, tag = "6")] - AggParams(super::AggParams), - } + #[prost(enumeration = "JobPhase", tag = "2")] + pub phase: i32, + #[prost(message, optional, tag = "3")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ContributionParams { +pub struct JobEventWaitingForInput { #[prost(string, tag = "1")] - pub data_id: ::prost::alloc::string::String, - #[prost(string, optional, tag = "4")] - pub hints_path: ::core::option::Option<::prost::alloc::string::String>, - /// Indicates whether hints will be streamed - #[prost(bool, tag = "5")] - pub hints_stream: bool, - #[prost(uint32, tag = "6")] - pub rank_id: u32, - #[prost(uint32, tag = "7")] - pub total_workers: u32, - #[prost(uint32, repeated, tag = "8")] - pub worker_allocation: ::prost::alloc::vec::Vec, - #[prost(uint32, tag = "9")] - pub job_compute_units: u32, - #[prost(oneof = "contribution_params::InputSource", tags = "2, 3")] - pub input_source: ::core::option::Option, -} -/// Nested message and enum types in `ContributionParams`. -pub mod contribution_params { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum InputSource { - #[prost(string, tag = "2")] - InputPath(::prost::alloc::string::String), - #[prost(bytes, tag = "3")] - InputData(::prost::alloc::vec::Vec), - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ProveParams { - #[prost(message, repeated, tag = "1")] - pub challenges: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AggParams { - #[prost(message, optional, tag = "1")] - pub agg_proofs: ::core::option::Option, - #[prost(bool, tag = "2")] - pub last_proof: bool, - #[prost(bool, tag = "3")] - pub final_proof: bool, - #[prost(bool, tag = "4")] - pub compressed: bool, + pub job_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } -/// Streaming messages for data transfer #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct StreamData { +pub struct JobEventCompleted { #[prost(string, tag = "1")] pub job_id: ::prost::alloc::string::String, - #[prost(enumeration = "StreamType", tag = "2")] - pub stream_type: i32, + #[prost(message, optional, tag = "2")] + pub result: ::core::option::Option, #[prost(message, optional, tag = "3")] - pub payload: ::core::option::Option, + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct StreamPayload { - #[prost(uint32, tag = "3")] - pub sequence_number: u32, - #[prost(bytes = "vec", tag = "4")] - pub payload: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExecuteTaskResponse { +pub struct JobEventCancelled { #[prost(string, tag = "1")] pub job_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub worker_id: ::prost::alloc::string::String, - #[prost(enumeration = "TaskType", tag = "3")] - pub task_type: i32, - #[prost(bool, tag = "4")] - pub success: bool, - /// Optional error message if success is false - #[prost(string, tag = "5")] - pub error_message: ::prost::alloc::string::String, - #[prost(oneof = "execute_task_response::ResultData", tags = "6, 7, 8")] - pub result_data: ::core::option::Option, -} -/// Nested message and enum types in `ExecuteTaskResponse`. -pub mod execute_task_response { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum ResultData { - #[prost(message, tag = "6")] - Challenges(super::ChallengesList), - #[prost(message, tag = "7")] - Proofs(super::ProofList), - #[prost(message, tag = "8")] - FinalProof(super::FinalProof), - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WitnessExecInfo { - #[prost(float, tag = "1")] - pub witness_time: f32, - #[prost(uint64, repeated, tag = "2")] - pub publics: ::prost::alloc::vec::Vec, - #[prost(uint64, repeated, tag = "3")] - pub proof_values: ::prost::alloc::vec::Vec, - #[prost(string, tag = "4")] - pub summary_info: ::prost::alloc::string::String, -} -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct AsmExecuteInfo { - #[prost(float, tag = "1")] - pub time: f32, - #[prost(float, tag = "2")] - pub mhz: f32, -} -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ZiskExecuteTime { - #[prost(float, tag = "1")] - pub total_duration: f32, - #[prost(float, tag = "2")] - pub execution_duration: f32, - #[prost(float, tag = "3")] - pub count_and_plan_duration: f32, - #[prost(float, tag = "4")] - pub count_and_plan_mo_duration: f32, - #[prost(message, optional, tag = "5")] - pub asm_execution_duration: ::core::option::Option, - /// Time when task was received by worker (in milliseconds since UNIX epoch) - #[prost(double, tag = "6")] - pub task_received_time: f64, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ChallengesList { - #[prost(message, repeated, tag = "1")] - pub challenges: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "2")] - pub witness_info: ::core::option::Option, - #[prost(message, optional, tag = "3")] - pub zisk_execution_time: ::core::option::Option, + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Challenges { - #[prost(uint32, tag = "1")] - pub worker_index: u32, - #[prost(uint32, tag = "2")] - pub airgroup_id: u32, - #[prost(uint64, repeated, tag = "3")] - pub challenge: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ProofList { - #[prost(message, repeated, tag = "1")] - pub proofs: ::prost::alloc::vec::Vec, +pub struct JobEventFailed { + #[prost(string, tag = "1")] + pub job_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub failure: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Proof { - #[prost(uint32, tag = "1")] - pub worker_idx: u32, - #[prost(uint64, tag = "2")] - pub airgroup_id: u64, - #[prost(uint64, repeated, tag = "3")] - pub values: ::prost::alloc::vec::Vec, +pub struct PushJobInputRequest { + #[prost(string, tag = "1")] + pub job_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub chunk: ::core::option::Option, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct FinalProof { - #[prost(uint64, repeated, tag = "1")] - pub values: ::prost::alloc::vec::Vec, - #[prost(uint64, tag = "2")] - pub executed_steps: u64, +pub struct PushJobHintsInputRequest { + #[prost(string, tag = "1")] + pub job_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub chunk: ::core::option::Option, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct WorkerError { +pub struct CancelJobRequest { #[prost(string, tag = "1")] - pub worker_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] pub job_id: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub error_message: ::prost::alloc::string::String, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ComputeCapacity { - #[prost(uint32, tag = "1")] - pub compute_units: u32, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct JobCancelled { +pub struct CancelJobResponse { #[prost(string, tag = "1")] pub job_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub reason: ::prost::alloc::string::String, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum InputMode { - /// No input provided - None = 0, - /// Input will be provided as a PATH - Path = 1, - /// Input data will be sent directly - Data = 2, -} -impl InputMode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::None => "INPUT_MODE_NONE", - Self::Path => "INPUT_MODE_PATH", - Self::Data => "INPUT_MODE_DATA", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "INPUT_MODE_NONE" => Some(Self::None), - "INPUT_MODE_PATH" => Some(Self::Path), - "INPUT_MODE_DATA" => Some(Self::Data), - _ => None, - } - } -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum HintsMode { - /// No hints provided - None = 0, - /// Hints will be provided as a PATH - Path = 1, - /// Hints will be sent as a stream - Stream = 2, -} -impl HintsMode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::None => "HINTS_MODE_NONE", - Self::Path => "HINTS_MODE_PATH", - Self::Stream => "HINTS_MODE_STREAM", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "HINTS_MODE_NONE" => Some(Self::None), - "HINTS_MODE_PATH" => Some(Self::Path), - "HINTS_MODE_STREAM" => Some(Self::Stream), - _ => None, - } - } -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum ProofStatusType { - ProofStatusCompleted = 0, - ProofStatusFailed = 1, -} -impl ProofStatusType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::ProofStatusCompleted => "PROOF_STATUS_COMPLETED", - Self::ProofStatusFailed => "PROOF_STATUS_FAILED", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "PROOF_STATUS_COMPLETED" => Some(Self::ProofStatusCompleted), - "PROOF_STATUS_FAILED" => Some(Self::ProofStatusFailed), - _ => None, - } - } + /// true if cancelled; false if already terminal + #[prost(bool, tag = "2")] + pub cancelled: bool, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] -pub enum TaskType { - PartialContribution = 0, - Prove = 1, - Aggregate = 2, +pub enum ProofKind { + Unspecified = 0, + Stark = 1, + StarkMinimal = 2, + Plonk = 3, } -impl TaskType { +impl ProofKind { /// String value of the enum field names used in the ProtoBuf definition. /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Self::PartialContribution => "PARTIAL_CONTRIBUTION", - Self::Prove => "PROVE", - Self::Aggregate => "AGGREGATE", + Self::Unspecified => "PROOF_KIND_UNSPECIFIED", + Self::Stark => "PROOF_KIND_STARK", + Self::StarkMinimal => "PROOF_KIND_STARK_MINIMAL", + Self::Plonk => "PROOF_KIND_PLONK", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "PARTIAL_CONTRIBUTION" => Some(Self::PartialContribution), - "PROVE" => Some(Self::Prove), - "AGGREGATE" => Some(Self::Aggregate), + "PROOF_KIND_UNSPECIFIED" => Some(Self::Unspecified), + "PROOF_KIND_STARK" => Some(Self::Stark), + "PROOF_KIND_STARK_MINIMAL" => Some(Self::StarkMinimal), + "PROOF_KIND_PLONK" => Some(Self::Plonk), _ => None, } } } -/// Stream type enumeration #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] -pub enum StreamType { - Start = 0, - Data = 1, - End = 2, -} -impl StreamType { +pub enum JobPhase { + Unspecified = 0, + /// witness generation and partial contributions + Contributions = 1, + /// proof generation + Prove = 2, + /// proof aggregation + Aggregate = 3, +} +impl JobPhase { /// String value of the enum field names used in the ProtoBuf definition. /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Self::Start => "STREAM_TYPE_START", - Self::Data => "STREAM_TYPE_DATA", - Self::End => "STREAM_TYPE_END", + Self::Unspecified => "JOB_PHASE_UNSPECIFIED", + Self::Contributions => "JOB_PHASE_CONTRIBUTIONS", + Self::Prove => "JOB_PHASE_PROVE", + Self::Aggregate => "JOB_PHASE_AGGREGATE", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "STREAM_TYPE_START" => Some(Self::Start), - "STREAM_TYPE_DATA" => Some(Self::Data), - "STREAM_TYPE_END" => Some(Self::End), + "JOB_PHASE_UNSPECIFIED" => Some(Self::Unspecified), + "JOB_PHASE_CONTRIBUTIONS" => Some(Self::Contributions), + "JOB_PHASE_PROVE" => Some(Self::Prove), + "JOB_PHASE_AGGREGATE" => Some(Self::Aggregate), _ => None, } } } /// Generated client implementations. -pub mod zisk_distributed_api_client { +pub mod zisk_coordinator_api_client { #![allow( unused_variables, dead_code, @@ -684,10 +501,10 @@ pub mod zisk_distributed_api_client { use tonic::codegen::*; use tonic::codegen::http::Uri; #[derive(Debug, Clone)] - pub struct ZiskDistributedApiClient { + pub struct ZiskCoordinatorApiClient { inner: tonic::client::Grpc, } - impl ZiskDistributedApiClient { + impl ZiskCoordinatorApiClient { /// Attempt to create a new client by connecting to a given endpoint. pub async fn connect(dst: D) -> Result where @@ -698,7 +515,7 @@ pub mod zisk_distributed_api_client { Ok(Self::new(conn)) } } - impl ZiskDistributedApiClient + impl ZiskCoordinatorApiClient where T: tonic::client::GrpcService, T::Error: Into, @@ -716,7 +533,7 @@ pub mod zisk_distributed_api_client { pub fn with_interceptor( inner: T, interceptor: F, - ) -> ZiskDistributedApiClient> + ) -> ZiskCoordinatorApiClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, @@ -730,7 +547,7 @@ pub mod zisk_distributed_api_client { http::Request, >>::Error: Into + std::marker::Send + std::marker::Sync, { - ZiskDistributedApiClient::new(InterceptedService::new(inner, interceptor)) + ZiskCoordinatorApiClient::new(InterceptedService::new(inner, interceptor)) } /// Compress requests with the given encoding. /// @@ -763,42 +580,13 @@ pub mod zisk_distributed_api_client { self.inner = self.inner.max_encoding_message_size(limit); self } - /// Bidirectional stream between worker(s) and coordinator - pub async fn worker_stream( - &mut self, - request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/WorkerStream", - ); - let mut req = request.into_streaming_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "WorkerStream", - ), - ); - self.inner.streaming(req, path, codec).await - } - /// Admin endpoints (optional, for monitoring) - pub async fn health_check( + /// Register a new guest program. Idempotent: the same ELF always returns + /// the same hash_id. + pub async fn register_guest_program( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -811,25 +599,23 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/HealthCheck", + "/zisk.coordinator.v1.ZiskCoordinatorApi/RegisterGuestProgram", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "HealthCheck", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "RegisterGuestProgram", ), ); self.inner.unary(req, path, codec).await } - pub async fn system_status( + /// Submit a new job (setup, prove, wrap, or execute). + pub async fn job_request( &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -840,23 +626,26 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/SystemStatus", + "/zisk.coordinator.v1.ZiskCoordinatorApi/JobRequest", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "SystemStatus", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "JobRequest", ), ); self.inner.unary(req, path, codec).await } - pub async fn status_info( + /// Long-poll: block until the job reaches a terminal state or the server-side + /// timeout elapses, then return the current status. Loop on this to poll to + /// completion without application-level sleep. + pub async fn wait_job_result( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -869,23 +658,25 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/StatusInfo", + "/zisk.coordinator.v1.ZiskCoordinatorApi/WaitJobResult", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "StatusInfo", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "WaitJobResult", ), ); self.inner.unary(req, path, codec).await } - pub async fn jobs_list( + /// Subscribe to live state-transition events for a job. The stream closes + /// after the terminal event. Safe to call after the job has already finished. + pub async fn watch_job( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response>, tonic::Status, > { self.inner @@ -898,25 +689,23 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/JobsList", + "/zisk.coordinator.v1.ZiskCoordinatorApi/WatchJob", ); let mut req = request.into_request(); req.extensions_mut() .insert( - GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "JobsList", - ), + GrpcMethod::new("zisk.coordinator.v1.ZiskCoordinatorApi", "WatchJob"), ); - self.inner.unary(req, path, codec).await + self.inner.server_streaming(req, path, codec).await } - pub async fn job_status( + /// Stream additional input chunks to a running job. + /// Close the stream to signal end-of-input (EOF). + pub async fn push_job_input( &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + request: impl tonic::IntoStreamingRequest< + Message = super::PushJobInputRequest, + >, + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -927,25 +716,26 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/JobStatus", + "/zisk.coordinator.v1.ZiskCoordinatorApi/PushJobInput", ); - let mut req = request.into_request(); + let mut req = request.into_streaming_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "JobStatus", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "PushJobInput", ), ); - self.inner.unary(req, path, codec).await + self.inner.client_streaming(req, path, codec).await } - pub async fn workers_list( + /// Stream additional hints chunks to a running job. + /// Close the stream to signal end-of-hints (EOF). + pub async fn push_job_hints_input( &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + request: impl tonic::IntoStreamingRequest< + Message = super::PushJobHintsInputRequest, + >, + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -956,24 +746,26 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/WorkersList", + "/zisk.coordinator.v1.ZiskCoordinatorApi/PushJobHintsInput", ); - let mut req = request.into_request(); + let mut req = request.into_streaming_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "WorkersList", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "PushJobHintsInput", ), ); - self.inner.unary(req, path, codec).await + self.inner.client_streaming(req, path, codec).await } - /// Coordinator control - pub async fn launch_proof( + /// Cancel a running or queued job. Blocks until the job reaches a terminal + /// state (Cancelled or another terminal if it completed first). + /// Idempotent: returns cancelled=false if the job is already in a terminal state. + pub async fn cancel_job( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -986,47 +778,17 @@ pub mod zisk_distributed_api_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/LaunchProof", + "/zisk.coordinator.v1.ZiskCoordinatorApi/CancelJob", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "LaunchProof", + "zisk.coordinator.v1.ZiskCoordinatorApi", + "CancelJob", ), ); self.inner.unary(req, path, codec).await } - /// Client subscription to job completion - pub async fn subscribe_to_proof( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/zisk.distributed.api.v1.ZiskDistributedApi/SubscribeToProof", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "zisk.distributed.api.v1.ZiskDistributedApi", - "SubscribeToProof", - ), - ); - self.inner.server_streaming(req, path, codec).await - } } } diff --git a/crates/cluster-client/zisk/src/client.rs b/crates/cluster-client/zisk/src/client.rs index 9ed7f750..fcfd2bb1 100644 --- a/crates/cluster-client/zisk/src/client.rs +++ b/crates/cluster-client/zisk/src/client.rs @@ -1,40 +1,44 @@ //! Remote ZisK cluster proving. -use std::time::Duration; - -use ere_prover_core::{Input, PublicValues, RemoteProverConfig, zkVMVerifier}; -use ere_util_tokio::block_on; -use ere_verifier_zisk::{ - PUBLIC_VALUES_SIZE, ZiskProgramVk, ZiskProof, ZiskVerifier, ensure_program_vk_matches, -}; -use futures_util::StreamExt; +use core::time::Duration; + +use bincode::error::DecodeError; +use ere_compiler_core::Elf; +use ere_prover_core::{Input, RemoteProverConfig, zkVMVerifier}; +use ere_verifier_zisk::{ZiskProgramVk, ZiskProof, ZiskVerifier}; +use serde::{Deserialize, Serialize}; +use tokio::time::Instant; use tonic::transport::Channel; -use tracing::debug; use crate::{ api::{ - ErrorResponse, HintsMode, InputMode, LaunchProofRequest, ProofStatusType, - SubscribeToProofRequest, SystemStatusRequest, launch_proof_response, - system_status_response, zisk_distributed_api_client::ZiskDistributedApiClient, + CancelJobRequest, InputChunk, InputKind, JobKind, JobKindResponse, JobRequestMessage, + ProofKind, ProveRequest, RegisterGuestProgramRequest, SetupRequest, WaitJobResultRequest, + input_kind, job_kind, job_kind_response, job_status, + zisk_coordinator_api_client::ZiskCoordinatorApiClient, }, error::Error, }; /// Wrapper for the ZisK cluster client. -/// -/// Connects to the ZisK cluster via gRPC and submits proof jobs. #[derive(Debug)] pub struct ZiskClusterClient { - client: ZiskDistributedApiClient, + client: ZiskCoordinatorApiClient, + hash_id: String, verifier: ZiskVerifier, } impl ZiskClusterClient { - /// Create a new `ZiskClusterClient` that connects to the cluster. - pub fn new(config: &RemoteProverConfig, program_vk: ZiskProgramVk) -> Result { - let client = block_on(connect(&config.endpoint))?; + /// Connect to the coordinator and run setup for the `elf`. + pub async fn new(config: &RemoteProverConfig, elf: Elf) -> Result { + let mut client = ZiskCoordinatorApiClient::connect(config.endpoint.clone()).await?; + let (hash_id, program_vk) = setup(&mut client, elf).await?; let verifier = ZiskVerifier::new(program_vk); - Ok(Self { client, verifier }) + Ok(Self { + client, + hash_id, + verifier, + }) } /// Returns a reference to the verifier. @@ -42,132 +46,160 @@ impl ZiskClusterClient { &self.verifier } - /// Send proof request to cluster and wait for completion. - /// - /// Returns the proof with public values and proving time reported by the cluster. - pub async fn prove(&self, input: &Input) -> Result<(ZiskProof, Duration), Error> { - let mut client = self.client.clone(); - - // Check system status to get available compute capacity - - debug!("Checking system status..."); - - let status_response = client.system_status(SystemStatusRequest {}).await?; - - let compute_capacity = match status_response.into_inner().result { - Some(system_status_response::Result::Status(status)) => { - debug!( - total_workers = status.total_workers, - compute_capacity = status.compute_capacity, - idle_workers = status.idle_workers, - busy_workers = status.busy_workers, - active_jobs = status.active_jobs, - "System status", - ); - - if status.total_workers == 0 || status.compute_capacity == 0 { - return Err(cluster_error("No worker available in the cluster")); - } - if status.active_jobs != 0 { - return Err(cluster_error("Cluster is busy with another proof job")); - } + /// Returns the program vk. + pub fn program_vk(&self) -> ZiskProgramVk { + *self.verifier.program_vk() + } - status.compute_capacity - } - Some(system_status_response::Result::Error(res)) => { - return Err(cluster_error_from_response("System status error", res)); - } - None => { - return Err(cluster_error("Received empty system status response")); - } + /// Submits a prove job and returns its `job_id` immediately, without waiting for completion. + pub async fn create_prove_job(&self, input: &Input) -> Result { + let mut client = self.client.clone(); + let job = JobKind { + kind: Some(job_kind::Kind::Prove(ProveRequest { + hash_id: self.hash_id.clone(), + input: Some(InputKind { + kind: Some(input_kind::Kind::Inline(InputChunk { + data: framed_stdin(input.stdin()), + })), + }), + proof_dest: ProofKind::StarkMinimal as i32, + proof_timeout: None, + hints: None, + })), }; - - // Launch proof - - let data_id = uuid::Uuid::new_v4().to_string(); - - debug!(data_id = data_id, "Launching proof..."); - - let launch_request = LaunchProofRequest { - data_id, - compute_capacity, - minimal_compute_capacity: compute_capacity, - inputs_mode: InputMode::Data.into(), - inputs_uri: None, - input_data: Some(framed_stdin(input.stdin())), - hints_mode: HintsMode::None.into(), - hints_uri: None, - simulated_node: None, + let req = JobRequestMessage { + job_kind: Some(job), }; + let job_id = client.job_request(req).await?.into_inner().job_id; + Ok(job_id) + } - let launch_response = client.launch_proof(launch_request).await?; - - let job_id = match launch_response.into_inner().result { - Some(launch_proof_response::Result::JobId(job_id)) => { - debug!(job_id = job_id, "Proof launched successfully"); - - job_id - } - Some(launch_proof_response::Result::Error(res)) => { - return Err(cluster_error_from_response("Launch proof error", res)); - } - None => { - return Err(cluster_error("Received empty launch proof response")); - } + /// Waits for a prove job to reach a terminal state and returns the proof along with the + /// self-reported proving time. + pub async fn wait_prove_job(&self, job_id: &str) -> Result<(ZiskProof, Duration), Error> { + let mut client = self.client.clone(); + let resp = match wait_job(&mut client, job_id).await?.kind { + Some(job_kind_response::Kind::Prove(resp)) => resp, + _ => Err(Error::MissingField("kind::prove"))?, }; + let proof = parse_proof(&resp.proof.ok_or(Error::MissingField("proof"))?.data)?; + let proving_time = Duration::from_nanos( + resp.stats + .ok_or(Error::MissingField("stats"))? + .duration_nanos, + ); + Ok((proof, proving_time)) + } - // Subscribe to proof status updates - - debug!(job_id = job_id, "Subscribing to proof status updates..."); - - let stream = client - .subscribe_to_proof(SubscribeToProofRequest { job_id }) - .await?; - - // Wait for proof status update (completion or failure) - - debug!("Waiting for proof status update (completion or failure)..."); - - let Some(update) = stream.into_inner().next().await else { - return Err(cluster_error("Stream ended without completion status")); + /// Cancels a prove job. + /// + /// Returns `false` if the job is already in a terminal state. + pub async fn cancel_prove_job(&self, job_id: &str) -> Result { + let mut client = self.client.clone(); + let req = CancelJobRequest { + job_id: job_id.to_string(), }; - - let update = update.map_err(cluster_error)?; - - let proof = match ProofStatusType::try_from(update.status) { - Ok(ProofStatusType::ProofStatusCompleted) => match update.final_proof { - Some(proof) => Ok(proof), - None => Err(cluster_error("Missing final proof")), - }, - Ok(ProofStatusType::ProofStatusFailed) => Err(update - .error - .map(|res| cluster_error_from_response("Proof generation error", res)) - .unwrap_or_else(|| cluster_error("Unknown error"))), - Err(err) => Err(cluster_error(err)), - }?; - - let proof = parse_proof(&proof.values)?; - let proving_time = Duration::from_millis(update.duration_ms); - - debug!(?proving_time, "Proof generated successfully"); - - ensure_program_vk_matches(*self.verifier.program_vk(), proof.program_vk)?; - - Ok((proof, proving_time)) + let cancelled = client.cancel_job(req).await?.into_inner().cancelled; + Ok(cancelled) } - /// Verify `proof` against the [`ZiskProgramVk`] this client was constructed with. - pub fn verify(&self, proof: &ZiskProof) -> Result { - Ok(self.verifier.verify(proof)?) + /// Submit a prove job, wait up to `timeout` for completion, cancel the job on timeout. + /// + /// Returns `Error::ProveTimeout` if the deadline expires before the job terminates. + pub async fn prove( + &self, + input: &Input, + deadline: Option, + ) -> Result<(ZiskProof, Duration), Error> { + let job_id = self.create_prove_job(input).await?; + + match deadline { + Some(deadline) => { + match tokio::time::timeout_at(deadline, self.wait_prove_job(&job_id)).await { + Ok(result) => result, + Err(_) => { + let _ = self.cancel_prove_job(&job_id).await; + Err(Error::ProveTimeout { job_id }) + } + } + } + _ => self.wait_prove_job(&job_id).await, + } } } -/// Connect to the ZisK cluster at the given gRPC endpoint. -async fn connect(endpoint: &str) -> Result, Error> { - let channel = Channel::from_shared(endpoint.to_string())? - .connect() - .await?; - Ok(ZiskDistributedApiClient::new(channel)) +async fn setup( + client: &mut ZiskCoordinatorApiClient, + elf: Elf, +) -> Result<(String, ZiskProgramVk), Error> { + /// Timeout for setup job. + const TIMEOUT: Duration = Duration::from_secs(600); + + let hash_id = client + .register_guest_program(RegisterGuestProgramRequest { zisk_elf: elf.0 }) + .await? + .into_inner() + .hash_id; + + let job = JobKind { + kind: Some(job_kind::Kind::Setup(SetupRequest { + hash_id: hash_id.clone(), + with_hints: false, + program_name: String::new(), + })), + }; + let req = JobRequestMessage { + job_kind: Some(job), + }; + let job_id = client.job_request(req).await?.into_inner().job_id; + + let resp = match tokio::time::timeout(TIMEOUT, wait_job(client, &job_id)).await { + Ok(resp) => match resp?.kind { + Some(job_kind_response::Kind::Setup(resp)) => resp, + _ => Err(Error::MissingField("kind::setup"))?, + }, + Err(_) => Err(Error::SetupTimeout { job_id })?, + }; + let program_vk = ZiskProgramVk::try_from(resp.vk.as_slice())?; + Ok((hash_id, program_vk)) +} + +async fn wait_job( + client: &mut ZiskCoordinatorApiClient, + job_id: &str, +) -> Result { + /// Server-side hold per `WaitJobResult`. + const TIMEOUT_SECS: u32 = 5; + + let req = WaitJobResultRequest { + job_id: job_id.to_string(), + timeout_seconds: Some(TIMEOUT_SECS), + }; + loop { + let resp = client.wait_job_result(req.clone()).await?.into_inner(); + + let status = resp + .job_status + .and_then(|s| s.status) + .ok_or(Error::MissingField("job_status"))?; + match status { + job_status::Status::Completed(_) => { + return resp.result.ok_or(Error::MissingField("result")); + } + job_status::Status::Failed(failed) => { + return Err(Error::JobFailed { + job_id: job_id.to_string(), + reason: format!("{failed:?}"), + }); + } + job_status::Status::Cancelled(_) => { + return Err(Error::JobCancelled(job_id.to_string())); + } + job_status::Status::Queued(_) + | job_status::Status::Running(_) + | job_status::Status::WaitingForInput(_) => continue, + } + } } /// Returns `data` with a LE u64 length prefix and padding to multiple of 8. @@ -182,59 +214,43 @@ fn framed_stdin(data: &[u8]) -> Vec { buf } -fn parse_proof(values: &[u64]) -> Result { - const PROGRAM_VK_WORDS: usize = 4; - const PUBLIC_VALUES_WORDS: usize = PUBLIC_VALUES_SIZE / 4; - const N_PUBLICS: usize = PROGRAM_VK_WORDS + PUBLIC_VALUES_WORDS; - - let n_publics = values - .first() - .copied() - .ok_or_else(|| Error::InvalidProofFormat("proof values are empty".to_string()))? - as usize; - if n_publics != N_PUBLICS { - return Err(Error::InvalidProofFormat(format!( - "unexpected publics word count: expected {N_PUBLICS}, got {n_publics}" - ))); +fn parse_proof(bytes: &[u8]) -> Result { + #[derive(Default, Serialize, Deserialize)] + pub struct Proof<'a> { + pub proof_kind: ProofKind, + pub proof_bytes: &'a [u8], + pub publics: PublicValues, + pub program_vk: ProgramVK, + pub zisk_vk: Vec, } - if values.len() < 1 + n_publics { - return Err(Error::InvalidProofFormat(format!( - "proof values too short: {} words", - values.len() - ))); - } - - let (program_vk, public_values_words) = values[1..1 + N_PUBLICS].split_at(PROGRAM_VK_WORDS); - let proof = values[1 + N_PUBLICS..].to_vec(); - let program_vk = ZiskProgramVk(program_vk.try_into().unwrap()); - - let mut public_values = [0u8; PUBLIC_VALUES_SIZE]; - for (chunk, word) in public_values.chunks_exact_mut(4).zip(public_values_words) { - let word = u32::try_from(*word).map_err(|_| { - Error::InvalidProofFormat(format!("public value word does not fit in u32: {word}")) - })?; - chunk.copy_from_slice(&word.to_le_bytes()); + #[derive(Default, Serialize, Deserialize)] + pub enum ProofKind { + #[default] + VadcopFinal, + VadcopFinalMinimal, + Plonk, } - Ok(ZiskProof { - proof, - program_vk, - public_values, - }) -} + #[derive(Default, Serialize, Deserialize)] + pub struct ProgramVK { + pub vk: Vec, + } -/// Returns `Error::Cluster`. -fn cluster_error(s: impl ToString) -> Error { - Error::Cluster(s.to_string()) -} + #[derive(Default, Serialize, Deserialize)] + pub struct PublicValues { + pub data: Vec, + } -/// Returns `Error::Cluster` formatted with error code and message. -fn cluster_error_from_response(s: impl ToString, res: ErrorResponse) -> Error { - Error::Cluster(format!( - "{}, code: {}, message: {}", - s.to_string(), - res.code, - res.message - )) + let (proof, _): (Proof, _) = + bincode::serde::borrow_decode_from_slice(bytes, bincode::config::legacy())?; + + let program_vk = ZiskProgramVk::try_from(proof.program_vk.vk.as_slice())?; + let public_values = <[u8; _]>::try_from(proof.publics.data) + .map_err(|_| DecodeError::Other("invalid public values length"))?; + Ok(ZiskProof::from_parts( + &program_vk, + &public_values, + proof.proof_bytes, + )?) } diff --git a/crates/cluster-client/zisk/src/error.rs b/crates/cluster-client/zisk/src/error.rs index 7af9b704..ef30300f 100644 --- a/crates/cluster-client/zisk/src/error.rs +++ b/crates/cluster-client/zisk/src/error.rs @@ -11,11 +11,23 @@ pub enum Error { #[error("Failed to connect to cluster: {0}")] ConnectionFailed(#[from] tonic::transport::Error), - #[error("Cluster error: {0}")] - Cluster(String), + #[error("Cluster job {job_id} failed: {reason}")] + JobFailed { job_id: String, reason: String }, - #[error("Invalid proof format: {0}")] - InvalidProofFormat(String), + #[error("Cluster job {0} was cancelled")] + JobCancelled(String), + + #[error("Setup job {job_id} timed out")] + SetupTimeout { job_id: String }, + + #[error("Prove job {job_id} timed out")] + ProveTimeout { job_id: String }, + + #[error("Cluster response missing field: {0}")] + MissingField(&'static str), + + #[error("Decode cluster proof failed: {0}")] + DecodeProof(#[from] bincode::error::DecodeError), #[error(transparent)] Verifier(#[from] ere_verifier_zisk::Error), diff --git a/crates/cluster-client/zisk/src/lib.rs b/crates/cluster-client/zisk/src/lib.rs index 96fabef1..89c8cace 100644 --- a/crates/cluster-client/zisk/src/lib.rs +++ b/crates/cluster-client/zisk/src/lib.rs @@ -2,8 +2,8 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] +#[allow(clippy::enum_variant_names, clippy::large_enum_variant, dead_code)] #[rustfmt::skip] -#[allow(clippy::enum_variant_names)] mod api; mod client; diff --git a/crates/cluster-client/zisk/src/test.rs b/crates/cluster-client/zisk/src/test.rs index c0d1054a..1478e4e7 100644 --- a/crates/cluster-client/zisk/src/test.rs +++ b/crates/cluster-client/zisk/src/test.rs @@ -15,12 +15,12 @@ fn api_generation() { .build_client(true) .out_dir(tempdir.path()) .compile_protos( - &[dir.join("proto").join("zisk_distributed_api.proto")], + &[dir.join("proto").join("zisk_coordinator_api.proto")], &[dir.join("proto")], ) .unwrap(); - let latest = tempdir.path().join("zisk.distributed.api.v1.rs"); + let latest = tempdir.path().join("zisk.coordinator.v1.rs"); let current = dir.join("src").join("api.rs"); // If it's in CI env, don't overwrite but only check if it's up-to-date. From 260f1b17cb46bfd0f5c59bb10cbaf3a1931007f0 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 03:50:45 +0000 Subject: [PATCH 03/15] feat: update ere-platform-zisk --- crates/platform/zisk/Cargo.toml | 3 - crates/platform/zisk/src/lib.rs | 5 +- crates/platform/zisk/src/platform.rs | 26 ++-- crates/platform/zisk/src/profile.rs | 210 --------------------------- 4 files changed, 18 insertions(+), 226 deletions(-) delete mode 100644 crates/platform/zisk/src/profile.rs diff --git a/crates/platform/zisk/Cargo.toml b/crates/platform/zisk/Cargo.toml index 4d4adfc6..3dfaf886 100644 --- a/crates/platform/zisk/Cargo.toml +++ b/crates/platform/zisk/Cargo.toml @@ -6,8 +6,6 @@ rust-version.workspace = true license.workspace = true [dependencies] -fnv.workspace = true - # ZisK dependencies ziskos.workspace = true @@ -23,7 +21,6 @@ zisk-embedded-alloc = ["ziskos/zisk-embedded-alloc"] zisk-embedded-dlmalloc-alloc = ["ziskos/zisk-embedded-dlmalloc-alloc"] zisk-embedded-talc-alloc = ["ziskos/zisk-embedded-talc-alloc"] zisk-embedded-tlfs-alloc = ["ziskos/zisk-embedded-tlfs-alloc"] -check-cycle-scope = [] [lints] workspace = true diff --git a/crates/platform/zisk/src/lib.rs b/crates/platform/zisk/src/lib.rs index 149ee1a3..172f4ab1 100644 --- a/crates/platform/zisk/src/lib.rs +++ b/crates/platform/zisk/src/lib.rs @@ -1,12 +1,9 @@ #![no_std] #![cfg_attr(not(test), warn(unused_crate_dependencies))] -extern crate alloc; - mod platform; -mod profile; pub use ere_platform_core::Platform; pub use ziskos; -pub use crate::{platform::ZiskPlatform, profile::check_cycle_scope_names}; +pub use crate::platform::ZiskPlatform; diff --git a/crates/platform/zisk/src/platform.rs b/crates/platform/zisk/src/platform.rs index 6f8837f8..abef6115 100644 --- a/crates/platform/zisk/src/platform.rs +++ b/crates/platform/zisk/src/platform.rs @@ -3,8 +3,6 @@ use core::ops::Deref; use ere_platform_core::{LengthPrefixedStdin, Platform}; use ziskos::ziskos_definitions::ziskos_config::UART_ADDR; -use crate::profile::{SCOPE_REGISTRY, dispatch_profile}; - /// ZisK [`Platform`] implementation. /// /// Note that the maximum output size is 256 bytes, and output size will be @@ -22,7 +20,7 @@ impl Platform for ZiskPlatform { "Maximum output size is 256 bytes, got {}", output.len() ); - ziskos::io::write(output); + ziskos::io::commit_slice(output); } fn print(message: &str) { @@ -34,13 +32,23 @@ impl Platform for ZiskPlatform { } } - fn cycle_scope_start(name: &str) { - let tag = SCOPE_REGISTRY.get_or_assign_tag(name); - dispatch_profile!(start, tag); + fn cycle_scope_start(_name: &str) { + // FIXME: Uncomment when ZisK support profile opcode in program setup + // #[cfg(all(target_os = "zkvm", target_vendor = "zisk"))] + // ziskos::ziskos_syscall!( + // ziskos::SYSCALL_PROFILE_ID, + // ziskos::PROFILE_REPORT_START_COST_ID, + // &_name as *const &str as usize + // ); } - fn cycle_scope_end(name: &str) { - let tag = SCOPE_REGISTRY.get_or_assign_tag(name); - dispatch_profile!(end, tag); + fn cycle_scope_end(_name: &str) { + // FIXME: Uncomment when ZisK support profile opcode in program setup + // #[cfg(all(target_os = "zkvm", target_vendor = "zisk"))] + // ziskos::ziskos_syscall!( + // ziskos::SYSCALL_PROFILE_ID, + // ziskos::PROFILE_REPORT_END_COST_ID, + // &_name as *const &str as usize + // ) } } diff --git a/crates/platform/zisk/src/profile.rs b/crates/platform/zisk/src/profile.rs deleted file mode 100644 index e8526565..00000000 --- a/crates/platform/zisk/src/profile.rs +++ /dev/null @@ -1,210 +0,0 @@ -#[cfg(feature = "check-cycle-scope")] -use alloc::string::String; -use core::{cell::UnsafeCell, hash::Hasher}; - -use fnv::FnvHasher; - -pub(crate) static SCOPE_REGISTRY: ScopeRegistry = ScopeRegistry::new(); - -/// Global registry mapping scope name hashes to sequential tag IDs. -/// -/// Each unique scope name gets a unique tag ID (0, 1, 2, ...) on first use. -/// Panics if more than 256 distinct scope names are registered. -pub(crate) struct ScopeRegistry { - entries: UnsafeCell<[u64; 256]>, // name hashes; tag = index - count: UnsafeCell, - #[cfg(feature = "check-cycle-scope")] - names: UnsafeCell<[String; 256]>, -} - -// SAFETY: ZiskPlatform runs in a single-threaded zkVM environment. -unsafe impl Sync for ScopeRegistry {} - -impl ScopeRegistry { - const fn new() -> Self { - Self { - entries: UnsafeCell::new([0; 256]), - count: UnsafeCell::new(0), - #[cfg(feature = "check-cycle-scope")] - names: UnsafeCell::new([const { String::new() }; 256]), - } - } - - /// Looks up or assigns a tag ID for the given scope name. - pub(crate) fn get_or_assign_tag(&self, name: &str) -> u8 { - let name_hash = hash_name(name); - // SAFETY: Single-threaded zkVM - no concurrent access. - unsafe { - let entries = &mut *self.entries.get(); - let count = &mut *self.count.get(); - #[cfg(feature = "check-cycle-scope")] - let names = &mut *self.names.get(); - - if let Some(i) = entries[..*count as usize] - .iter() - .position(|entry| *entry == name_hash) - { - return i as u8; - } - - assert!( - (*count as u16) < 256, - "Too many profiling scopes (max 256), cannot assign tag for scope" - ); - entries[*count as usize] = name_hash; - #[cfg(feature = "check-cycle-scope")] - { - names[*count as usize] = name.into(); - } - let tag = *count; - *count += 1; - tag - } - } - - #[cfg(feature = "check-cycle-scope")] - fn names(&self) -> &[String] { - // SAFETY: Single-threaded zkVM - no concurrent access. - unsafe { - let names = &*self.names.get(); - let count = *self.count.get(); - &names[..count as usize] - } - } -} - -/// Hashes a scope name to a `u64` for use as a lookup key in the scope registry. -#[inline] -fn hash_name(name: &str) -> u64 { - let mut hasher = FnvHasher::default(); - hasher.write(name.as_bytes()); - hasher.finish() -} - -/// Dispatches a runtime `u8` tag to a const-generic ziskos profiling function. -/// Generates a 256-arm match to bridge the runtime value to compile-time const generics. -macro_rules! dispatch_profile { - (start, $tag:expr) => { - dispatch_profile!(@start $tag, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255) - }; - (end, $tag:expr) => { - dispatch_profile!(@end $tag, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255) - }; - (@start $tag:expr, $($n:literal),+) => { - match $tag { - $($n => ziskos::ziskos_profile_start::<$n>(),)+ - } - }; - (@end $tag:expr, $($n:literal),+) => { - match $tag { - $($n => ziskos::ziskos_profile_end::<$n>(),)+ - } - }; -} - -pub(crate) use dispatch_profile; - -/// Check explicitly exported names match cycle scope entries, panics with expected output on -/// mismatch. -#[doc(hidden)] -pub fn check_cycle_scope_names(_names: &[&str]) { - #[cfg(feature = "check-cycle-scope")] - if SCOPE_REGISTRY.names() != _names { - panic!( - "Cycle scope names mismatch with the registered entries, expect:\n\nexport_cycle_scope_names!(\n {},\n);", - SCOPE_REGISTRY.names().join(",\n ") - ); - } -} - -/// Exports cycle scope names as symbols for `ziskemu` to display human-readable names. -/// -/// The declared scope names must be declared in the order they are _executed_ -/// in your code. Not doing so can dangerously name a scope incorrectly. Be -/// careful if you have lambda functions or conditionals since it is easy to -/// confuse the right order. -/// -/// Enable feature `check-cycle-scope` to verify correctness at runtime -/// automatically (panics on mismatch with expected output to copy-paste). -#[macro_export] -macro_rules! export_cycle_scope_names { - ($($name:ident),* $(,)?) => {{ - $crate::__export_cycle_scope_names!( - [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 - 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 - 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 - 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 - 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 - 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 - 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 - 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 - 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 - 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 - 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 - 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 - 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 - 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255] - [] [$($name)*] - ); - }}; -} - -#[macro_export] -#[doc(hidden)] -macro_rules! __export_cycle_scope_names { - // Take one tag from the pool for each name - ([$tag:tt $($tags:tt)*] [$($acc:tt)*] [$name:ident $($rest:ident)*]) => { - $crate::__export_cycle_scope_names!([$($tags)*] [$($acc)* [$name $tag]] [$($rest)*]); - }; - - // All names have tags, emit the static variable. - ([$($tags:tt)*] [$([$name:ident $idx:tt])*] []) => {{ - $( - #[unsafe(export_name = ziskos::__ziskos_profile_export_name!($idx, $name))] - #[used] - #[allow(non_upper_case_globals)] - static $name: u16 = $idx; - )* - - $crate::check_cycle_scope_names(&[$(stringify!($name),)*]); - }}; - - // Empty - ([$($tags:tt)*] [] []) => {{ - $crate::check_cycle_scope_names(&[]); - }}; -} From 151b4aa8d6a3cc6a3e5517e0bc13ff1e1d33d448 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 03:51:20 +0000 Subject: [PATCH 04/15] chore: add cycle scope to Program for testing --- crates/util/test/src/program.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/util/test/src/program.rs b/crates/util/test/src/program.rs index f8fe2c2a..67a4ba32 100644 --- a/crates/util/test/src/program.rs +++ b/crates/util/test/src/program.rs @@ -32,10 +32,27 @@ pub trait Program { fn run_inner>( output_bytes_modifier: impl Fn(Vec) -> T, ) { + P::cycle_scope_start("read_input"); let input_bytes = P::read_whole_input(); + P::cycle_scope_end("read_input"); + + P::cycle_scope_start("decode_input"); let input = G::Input::decode_from_slice(&input_bytes).unwrap(); + P::cycle_scope_end("decode_input"); + + P::cycle_scope_start("compute"); let output = G::compute(input); + P::cycle_scope_end("compute"); + + P::cycle_scope_start("encode_output"); let output_bytes = output.encode_to_vec().unwrap(); + P::cycle_scope_end("encode_output"); + + P::cycle_scope_start("postprocess_output"); let modified_output_bytes = output_bytes_modifier(output_bytes); + P::cycle_scope_end("postprocess_output"); + + P::cycle_scope_start("write_output"); P::write_whole_output(modified_output_bytes.as_ref()); + P::cycle_scope_end("write_output"); } From 1109f35ce667ba86eef73a410b7c8bc6b2fbff4c Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 07:58:19 +0000 Subject: [PATCH 05/15] feat: update ere-prover-zisk --- Cargo.toml | 16 +- crates/dockerized/src/prover.rs | 5 +- crates/prover/zisk/Cargo.toml | 15 +- crates/prover/zisk/src/error.rs | 30 +--- crates/prover/zisk/src/lib.rs | 3 +- crates/prover/zisk/src/prover.rs | 77 +++----- crates/prover/zisk/src/sdk.rs | 174 +++++++----------- crates/prover/zisk/src/sdk/local.rs | 268 ++++++++++------------------ 8 files changed, 205 insertions(+), 383 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ddf5ff5..c2f9a409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,16 +142,12 @@ sp1-sdk = "6.1.0" sp1-zkvm = { version = "6.1.0", default-features = false } # ZisK dependencies -proofman-common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.1" } -proofman-fields = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.1", package = "fields" } -proofman-starks-lib-c = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.1" } -proofman-util = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.1" } -proofman-verifier = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.1" } -zisk-core = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.1" } -zisk-rom-setup = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.1", package = "rom-setup" } -zisk-sdk = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.1" } -ziskemu = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.1" } -ziskos = { git = "https://github.com/0xPolygonHermez/zisk.git", tag = "v0.16.1", default-features = false } +proofman-verifier = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.17.0" } +zisk-prover-backend = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.17.0" } +zisk-common = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.17.0" } +zisk-core = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.17.0" } +ziskemu = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.17.0" } +ziskos = { git = "https://github.com/0xPolygonHermez/zisk.git", tag = "v0.17.0", default-features = false } # Local dependencies ere-compiler = { path = "crates/compiler/cli" } diff --git a/crates/dockerized/src/prover.rs b/crates/dockerized/src/prover.rs index f3e5bde1..b5a6af0f 100644 --- a/crates/dockerized/src/prover.rs +++ b/crates/dockerized/src/prover.rs @@ -228,11 +228,10 @@ impl ServerContainer { .inherit_env("ERE_ZISK_SETUP_ON_INIT") .inherit_env("ERE_ZISK_UNLOCK_MAPPED_MEMORY") .inherit_env("ERE_ZISK_MINIMAL_MEMORY") - .inherit_env("ERE_ZISK_PREALLOCATE") - .inherit_env("ERE_ZISK_SHARED_TABLES") .inherit_env("ERE_ZISK_MAX_STREAMS") .inherit_env("ERE_ZISK_NUMBER_THREADS_WITNESS") - .inherit_env("ERE_ZISK_MAX_WITNESS_STORED"), + .inherit_env("ERE_ZISK_MAX_WITNESS_STORED") + .inherit_env("ERE_ZISK_CLUSTER_PROVE_TIMEOUT_SECS"), _ => cmd, }; diff --git a/crates/prover/zisk/Cargo.toml b/crates/prover/zisk/Cargo.toml index a2f8d892..4e1f455d 100644 --- a/crates/prover/zisk/Cargo.toml +++ b/crates/prover/zisk/Cargo.toml @@ -7,21 +7,15 @@ license.workspace = true [dependencies] anyhow.workspace = true -blake3.workspace = true -bytemuck.workspace = true -mpi.workspace = true parking_lot.workspace = true -tempfile.workspace = true thiserror.workspace = true +tokio = { workspace = true, features = ["time"] } tracing.workspace = true # ZisK dependencies -proofman-common.workspace = true -proofman-fields.workspace = true -proofman-starks-lib-c.workspace = true +zisk-common.workspace = true zisk-core.workspace = true -zisk-rom-setup.workspace = true -zisk-sdk = { workspace = true, features = ["disable_distributed"] } +zisk-prover-backend.workspace = true ziskemu.workspace = true # Local dependencies @@ -34,10 +28,11 @@ ere-verifier-zisk.workspace = true [dev-dependencies] ere-compiler-zisk.workspace = true ere-util-test = { workspace = true, features = ["host"] } +tempfile.workspace = true [features] default = [] -cuda = ["zisk-sdk/gpu"] +cuda = [] [lints] workspace = true diff --git a/crates/prover/zisk/src/error.rs b/crates/prover/zisk/src/error.rs index 433734be..e0483638 100644 --- a/crates/prover/zisk/src/error.rs +++ b/crates/prover/zisk/src/error.rs @@ -1,5 +1,4 @@ use ere_prover_core::CommonError; -use proofman_common::ProofmanError; use thiserror::Error; #[derive(Debug, Error)] @@ -11,12 +10,6 @@ pub enum Error { #[error("Invalid env variable {key}, expected usize, got {value}")] InvalidEnvVar { key: &'static str, value: String }, - #[error("Enable `cuda` feature to use `ProverResource::Gpu`")] - CudaFeatureDisabled, - - #[error("Disable `cuda` feature to use `ProverResource::Cpu`")] - CudaFeatureEnabled, - // Emulator #[error("ROM transpilation failed: {0}")] Riscv2zisk(String), @@ -31,20 +24,11 @@ pub enum Error { EmulatorPanic(String), // SDK - #[error("Create ProofCtx failed: {0}")] - ProofCtx(#[source] ProofmanError), - - #[error("Generate assembly failed: {0}")] - GenerateAssembly(String), - - #[error("Compute ProgramVk failed: {0}")] - ComputeProgramVk(#[source] anyhow::Error), + #[error("Build prover failed: {0}")] + BuildProver(#[source] anyhow::Error), - #[error("Initialize prover failed: {0}")] - InitProver(#[source] anyhow::Error), - - #[error("Setup prover failed: {0}")] - SetupProver(#[source] anyhow::Error), + #[error("Setup failed: {0}")] + Setup(#[source] anyhow::Error), #[error("Prove failed: {0}")] Prove(#[source] anyhow::Error), @@ -52,12 +36,6 @@ pub enum Error { #[error("Prove panicked: {0}")] ProvePanic(String), - #[error("Expected VadcopFinal but got {0}")] - UnexpectedProofKind(&'static str), - - #[error("Invalid proof format: {0}")] - InvalidProofFormat(String), - // Cluster #[error(transparent)] Cluster(#[from] ere_cluster_client_zisk::Error), diff --git a/crates/prover/zisk/src/lib.rs b/crates/prover/zisk/src/lib.rs index 60d54368..08683f90 100644 --- a/crates/prover/zisk/src/lib.rs +++ b/crates/prover/zisk/src/lib.rs @@ -33,11 +33,10 @@ //! | `ERE_ZISK_SETUP_ON_INIT` | Flag | | Setup local prover on initialization instead of lazily | //! | `ERE_ZISK_UNLOCK_MAPPED_MEMORY` | Flag | | Configure the prover to unlock mapped memory | //! | `ERE_ZISK_MINIMAL_MEMORY` | Flag | | Configure the prover to use minimal memory | -//! | `ERE_ZISK_PREALLOCATE` | Flag | | Configure the prover to preallocate memory | -//! | `ERE_ZISK_SHARED_TABLES` | Flag | | Configure the prover to use shared tables | //! | `ERE_ZISK_MAX_STREAMS` | Value | | Configure the prover max streams | //! | `ERE_ZISK_NUMBER_THREADS_WITNESS` | Value | | Configure the prover number of witness threads | //! | `ERE_ZISK_MAX_WITNESS_STORED` | Value | | Configure the prover max witness stored | +//! | `ERE_ZISK_CLUSTER_PROVE_TIMEOUT_SECS` | Value | | Timeout for the cluster client prove job | //! //! [`install_zisk_sdk.sh`]: https://github.com/eth-act/ere/blob/master/scripts/sdk_installers/install_zisk_sdk.sh //! [`ziskup`]: https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh diff --git a/crates/prover/zisk/src/prover.rs b/crates/prover/zisk/src/prover.rs index 01e14679..541440ed 100644 --- a/crates/prover/zisk/src/prover.rs +++ b/crates/prover/zisk/src/prover.rs @@ -6,7 +6,6 @@ use ere_prover_core::{ zkVMProver, }; use ere_verifier_zisk::{ZiskProof, ZiskVerifier}; -use mpi as _; // Import symbols referenced by starks_api.cpp use crate::{error::Error, sdk::ZiskSdk}; @@ -17,7 +16,7 @@ pub struct ZiskProver { impl ZiskProver { pub fn new(elf: Elf, resource: ProverResource) -> Result { - let sdk = ZiskSdk::new(elf.0, resource)?; + let sdk = ZiskSdk::new(elf, resource)?; let verifier = ZiskVerifier::new(sdk.program_vk()); Ok(Self { sdk, verifier }) } @@ -37,7 +36,7 @@ impl zkVMProver for ZiskProver { } let start = Instant::now(); - let (public_values, total_num_cycles) = self.sdk.execute(input.stdin())?; + let (public_values, total_num_cycles) = self.sdk.execute(input)?; let execution_duration = start.elapsed(); Ok(( @@ -70,7 +69,7 @@ impl zkVMProver for ZiskProver { #[cfg(test)] pub(crate) mod tests { - use std::sync::{Mutex, OnceLock}; + use std::sync::{Mutex, MutexGuard, OnceLock}; use ere_compiler_core::{Compiler, Elf}; use ere_compiler_zisk::ZiskRustRv64imaCustomized; @@ -83,8 +82,6 @@ pub(crate) mod tests { use crate::prover::ZiskProver; - static PROVE_LOCK: Mutex<()> = Mutex::new(()); - pub(crate) fn basic_elf() -> Elf { static ELF: OnceLock = OnceLock::new(); ELF.get_or_init(|| { @@ -95,10 +92,23 @@ pub(crate) mod tests { .clone() } + pub(crate) fn basic_elf_zkvm() -> MutexGuard<'static, ZiskProver> { + static ZKVM: OnceLock> = OnceLock::new(); + ZKVM.get_or_init(|| { + let resource = if cfg!(feature = "cuda") { + ProverResource::Gpu + } else { + ProverResource::Cpu + }; + Mutex::new(ZiskProver::new(basic_elf(), resource).unwrap()) + }) + .lock() + .unwrap() + } + #[test] fn test_execute() { - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Cpu).unwrap(); + let zkvm = &*basic_elf_zkvm(); let test_case = BasicProgram::::valid_test_case(); run_zkvm_execute(&zkvm, &test_case); @@ -106,8 +116,7 @@ pub(crate) mod tests { #[test] fn test_execute_invalid_test_case() { - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Cpu).unwrap(); + let zkvm = &*basic_elf_zkvm(); for input in [ Input::new(), @@ -117,57 +126,17 @@ pub(crate) mod tests { } } - #[cfg(not(feature = "cuda"))] #[test] fn test_prove() { - let _guard = PROVE_LOCK.lock().unwrap(); - - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Cpu).unwrap(); + let zkvm = &*basic_elf_zkvm(); let test_case = BasicProgram::::valid_test_case(); run_zkvm_prove(&zkvm, &test_case); } - #[cfg(not(feature = "cuda"))] #[test] fn test_prove_invalid_test_case() { - let _guard = PROVE_LOCK.lock().unwrap(); - - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Cpu).unwrap(); - - for input in [ - Input::new(), - BasicProgram::::invalid_test_case().input(), - ] { - assert!(zkvm.prove(&input).is_err()); - } - - // Should be able to recover - let test_case = BasicProgram::::valid_test_case(); - run_zkvm_prove(&zkvm, &test_case); - } - - #[cfg(feature = "cuda")] - #[test] - fn test_prove_gpu() { - let _guard = PROVE_LOCK.lock().unwrap(); - - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Gpu).unwrap(); - - let test_case = BasicProgram::::valid_test_case(); - run_zkvm_prove(&zkvm, &test_case); - } - - #[cfg(feature = "cuda")] - #[test] - fn test_prove_invalid_test_case_gpu() { - let _guard = PROVE_LOCK.lock().unwrap(); - - let elf = basic_elf(); - let zkvm = ZiskProver::new(elf, ProverResource::Gpu).unwrap(); + let zkvm = &*basic_elf_zkvm(); for input in [ Input::new(), @@ -188,14 +157,12 @@ pub(crate) mod tests { let zkvm = ZiskProver::new( elf, ProverResource::Cluster(RemoteProverConfig { - endpoint: "http://127.0.0.1:50051".to_string(), + endpoint: "http://127.0.0.1:7000".to_string(), ..Default::default() }), ) .unwrap(); - let _guard = PROVE_LOCK.lock().unwrap(); - let test_case = BasicProgram::::valid_test_case(); run_zkvm_prove(&zkvm, &test_case); } diff --git a/crates/prover/zisk/src/sdk.rs b/crates/prover/zisk/src/sdk.rs index d2bb53e4..ca7c17bb 100644 --- a/crates/prover/zisk/src/sdk.rs +++ b/crates/prover/zisk/src/sdk.rs @@ -1,83 +1,85 @@ -use core::{any::Any, panic::AssertUnwindSafe, time::Duration}; -use std::{env, panic, path::PathBuf, sync::Arc}; +use std::{ + any::Any, + env, + panic::{self, AssertUnwindSafe}, + time::Duration, +}; use ere_cluster_client_zisk::ZiskClusterClient; +use ere_compiler_core::Elf; use ere_prover_core::{CommonError, Input, ProverResource, ProverResourceKind, PublicValues}; use ere_util_tokio::block_on; -use ere_verifier_zisk::{ZiskProgramVk, ZiskProof}; -use proofman_common::{ - MpiCtx, ParamsGPU, ProofCtx, ProofType, SetupCtx, SetupsVadcop, VerboseMode, -}; -use proofman_fields::Goldilocks; -use proofman_starks_lib_c::free_device_buffers_c; -use tempfile::tempdir; +use ere_verifier_zisk::{ZiskProgramVk, ZiskProof, ensure_program_vk_matches}; +use tokio::time::Instant; use zisk_core::{Riscv2zisk, ZiskRom}; -use zisk_rom_setup::rom_merkle_setup; -use zisk_sdk::ElfBinaryFromFile; use ziskemu::{Emu, EmuOptions}; use crate::{error::Error, sdk::local::LocalProver}; mod local; -/// Prover backend - either local or cluster. #[allow(clippy::large_enum_variant)] -pub enum ZiskProver { +enum Backend { Local(LocalProver), - Cluster(ZiskClusterClient), + Cluster { + client: ZiskClusterClient, + prove_timeout: Option, + }, } pub struct ZiskSdk { - resource: ProverResource, + backend: Backend, rom: ZiskRom, - program_vk: ZiskProgramVk, - prover: ZiskProver, } impl ZiskSdk { - /// Returns SDK for the ELF. - pub fn new(elf: Vec, resource: ProverResource) -> Result { + pub fn new(elf: Elf, resource: ProverResource) -> Result { // Convert ELF to ZisK ROM let rom = Riscv2zisk::new(&elf) .run() - .map_err(|e| Error::Riscv2zisk(e.to_string()))?; - - // Compute ProgramVk - let program_vk = compute_program_vk(&elf)?; + .map_err(|err| Error::Riscv2zisk(err.to_string()))?; // Initialize prover - let prover = match &resource { + let backend = match &resource { ProverResource::Cpu | ProverResource::Gpu => { - ZiskProver::Local(LocalProver::new(elf, program_vk)?) + Backend::Local(LocalProver::new(elf, &resource)?) } ProverResource::Cluster(config) => { - ZiskProver::Cluster(ZiskClusterClient::new(config, program_vk)?) + let client = block_on(ZiskClusterClient::new(config, elf))?; + let prove_timeout = env::var("ERE_ZISK_CLUSTER_PROVE_TIMEOUT_SECS") + .ok() + .and_then(|val| val.parse::().ok().map(Duration::from_secs)); + Backend::Cluster { + client, + prove_timeout, + } + } + ProverResource::Network(_) => { + return Err(CommonError::unsupported_prover_resource_kind( + resource.kind(), + [ + ProverResourceKind::Cpu, + ProverResourceKind::Gpu, + ProverResourceKind::Cluster, + ], + ) + .into()); } - ProverResource::Network(_) => Err(CommonError::unsupported_prover_resource_kind( - resource.kind(), - [ - ProverResourceKind::Cpu, - ProverResourceKind::Gpu, - ProverResourceKind::Cluster, - ], - ))?, }; - Ok(Self { - resource, - rom, - program_vk, - prover, - }) + Ok(Self { backend, rom }) } pub fn program_vk(&self) -> ZiskProgramVk { - self.program_vk + match &self.backend { + Backend::Local(local) => local.program_vk(), + Backend::Cluster { client, .. } => client.program_vk(), + } } /// Execute the ELF with the given `stdin`. - pub fn execute(&self, stdin: &[u8]) -> Result<(PublicValues, u64), Error> { - let stdin = framed_stdin(stdin); + pub fn execute(&self, input: &Input) -> Result<(PublicValues, u64), Error> { + let stdin = framed_stdin(input.stdin()); let mut emu = Emu::new(&self.rom); emu.ctx = emu.create_emu_context(stdin, &EmuOptions::default()); @@ -99,53 +101,23 @@ impl ZiskSdk { } pub fn prove(&self, input: &Input) -> Result<(PublicValues, ZiskProof, Duration), Error> { - match &self.resource { - ProverResource::Cpu if cfg!(feature = "cuda") => Err(Error::CudaFeatureEnabled)?, - ProverResource::Gpu if cfg!(not(feature = "cuda")) => Err(Error::CudaFeatureDisabled)?, - _ => {} - }; - - let (proof, proving_time) = match &self.prover { - ZiskProver::Local(local) => local.prove(&framed_stdin(input.stdin()))?, - ZiskProver::Cluster(client) => block_on(client.prove(input))?, - }; - - Ok((proof.public_values.into(), proof, proving_time)) - } -} - -fn compute_program_vk(elf: &[u8]) -> Result { - let mpi_ctx = Arc::new(MpiCtx::new()); - let mut pctx = ProofCtx::create_ctx(proving_key_dir(), false, VerboseMode::Info, mpi_ctx) - .map_err(Error::ProofCtx)?; - let mut params = ParamsGPU::new(false); - params.with_max_number_streams(1); - let sctx = SetupCtx::new(&pctx.global_info, &ProofType::Basic, false, ¶ms, &[]); - let setups_vadcop = SetupsVadcop::new(&pctx.global_info, false, false, ¶ms, &[]); - - let result = (|| { - pctx.set_device_buffers(&sctx, &setups_vadcop, false, ¶ms) - .map_err(Error::ProofCtx)?; - - let elf = ElfBinaryFromFile { - elf: elf.to_vec(), - name: String::new(), - with_hints: false, - path: None, + let (proof, proving_time) = match &self.backend { + Backend::Local(local) => local.prove(input)?, + Backend::Cluster { + client, + prove_timeout, + } => block_on(async { + let deadline = prove_timeout.map(|timeout| Instant::now() + timeout); + client.prove(input, deadline).await.map_err(Error::Cluster) + })?, }; - let tempdir = tempdir().map_err(CommonError::tempdir)?; - - let (_, program_vk) = - rom_merkle_setup::(&pctx, &elf, &Some(tempdir.path().to_path_buf())) - .map_err(Error::ComputeProgramVk)?; + let (progam_vk, public_values) = proof.to_parts()?; - Ok(program_vk) - })(); + ensure_program_vk_matches(self.program_vk(), progam_vk)?; - free_device_buffers_c(pctx.get_device_buffers_ptr()); - - result.and_then(|program_vk| Ok(program_vk.try_into()?)) + Ok((public_values.into(), proof, proving_time)) + } } /// Returns `data` with a LE u64 length prefix and padding to multiple of 8. @@ -166,40 +138,26 @@ fn panic_msg(err: Box) -> String { .unwrap_or_else(|| "unknown panic msg".to_string()) } -/// Returns path to `~/.zisk` directory. -fn dot_zisk_dir() -> PathBuf { - PathBuf::from(env::var("HOME").expect("env `$HOME` should be set")).join(".zisk") -} - -/// Returns path to `~/.zisk/provingKey` directory. -fn proving_key_dir() -> PathBuf { - dot_zisk_dir().join("provingKey") -} - #[cfg(test)] mod tests { - use std::{fs, process::Command}; + use std::{env, fs, path::PathBuf, process::Command}; + use ere_prover_core::zkVMProver; use ere_verifier_zisk::ZiskProgramVk; use tempfile::tempdir; - use crate::{ - prover::tests::basic_elf, - sdk::{compute_program_vk, dot_zisk_dir}, - }; + use crate::prover::tests::{basic_elf, basic_elf_zkvm}; #[test] - fn compute_program_vk_matches_cargo_zisk_rom_setup() { - let elf = basic_elf(); - + fn program_vk_matches_cargo_zisk_program_setup() { let program_vk = { let tempdir = tempdir().unwrap(); let elf_path = tempdir.path().join("guest.elf"); - fs::write(&elf_path, &elf.0).unwrap(); + fs::write(&elf_path, &basic_elf().0).unwrap(); - let cargo_zisk = dot_zisk_dir().join("bin").join("cargo-zisk"); + let cargo_zisk = PathBuf::from(env::var("HOME").unwrap()).join(".zisk/bin/cargo-zisk"); let status = Command::new(&cargo_zisk) - .arg("rom-setup") + .arg("program-setup") .arg("-e") .arg(&elf_path) .arg("-o") @@ -223,6 +181,6 @@ mod tests { ZiskProgramVk::try_from(fs::read(&verkey_paths[0]).unwrap().as_slice()).unwrap() }; - assert_eq!(compute_program_vk(&elf).unwrap(), program_vk); + assert_eq!(*basic_elf_zkvm().program_vk(), program_vk); } } diff --git a/crates/prover/zisk/src/sdk/local.rs b/crates/prover/zisk/src/sdk/local.rs index 192b1cf4..2463ef44 100644 --- a/crates/prover/zisk/src/sdk/local.rs +++ b/crates/prover/zisk/src/sdk/local.rs @@ -1,31 +1,28 @@ -use std::{env, fs, panic, path::PathBuf, process::Command, thread::sleep, time::Duration}; +use std::{ + env, + panic::{self, AssertUnwindSafe}, + time::{Duration, Instant}, +}; -use blake3::Hash; -use bytemuck::checked::try_cast_slice; -use ere_prover_core::CommonError; -use ere_verifier_zisk::{PUBLIC_VALUES_SIZE, ZiskProgramVk, ZiskProof, ensure_program_vk_matches}; +use ere_compiler_core::Elf; +use ere_prover_core::{Input, ProverResource}; +use ere_verifier_zisk::{PUBLIC_VALUES_BYTES, ZiskProgramVk, ZiskProof}; use parking_lot::{Mutex, MutexGuard}; -use proofman_common::ParamsGPU; -use tempfile::tempdir; -use tracing::info; -use zisk_rom_setup::generate_assembly; -use zisk_sdk::{ - Asm, ElfBinaryFromFile, ProofOpts, ProverClientBuilder, ZiskProgramPK, - ZiskProofWithPublicValues, ZiskProver, ZiskStdin, +use tracing::warn; +use zisk_common::{Proof, ProofKind, io::ZiskStdin}; +use zisk_prover_backend::{ + Asm, AsmOptions, BackendProverOpts, GuestProgram, ProverClientBuilder, ZiskProver, }; use crate::{ error::Error, - sdk::{dot_zisk_dir, panic_msg}, + sdk::{framed_stdin, panic_msg}, }; -const ELF_NAME: &str = "elf"; - struct Config { - preallocate: bool, + setup_on_init: bool, unlock_mapped_memory: bool, minimal_memory: bool, - shared_tables: bool, max_streams: Option, number_threads_witness: Option, max_witness_stored: Option, @@ -43,198 +40,131 @@ impl Config { }) .transpose() }; - let preallocate = env::var_os("ERE_ZISK_PREALLOCATE").is_some(); - let unlock_mapped_memory = env::var_os("ERE_ZISK_UNLOCK_MAPPED_MEMORY").is_some(); - let minimal_memory = env::var_os("ERE_ZISK_MINIMAL_MEMORY").is_some(); - let shared_tables = env::var_os("ERE_ZISK_SHARED_TABLES").is_some(); - let max_streams = parse_usize("ERE_ZISK_MAX_STREAMS")?; - let number_threads_witness = parse_usize("ERE_ZISK_NUMBER_THREADS_WITNESS")?; - let max_witness_stored = parse_usize("ERE_ZISK_MAX_WITNESS_STORED")?; Ok(Self { - preallocate, - unlock_mapped_memory, - minimal_memory, - shared_tables, - max_streams, - number_threads_witness, - max_witness_stored, + setup_on_init: env::var_os("ERE_ZISK_SETUP_ON_INIT").is_some(), + unlock_mapped_memory: env::var_os("ERE_ZISK_UNLOCK_MAPPED_MEMORY").is_some(), + minimal_memory: env::var_os("ERE_ZISK_MINIMAL_MEMORY").is_some(), + max_streams: parse_usize("ERE_ZISK_MAX_STREAMS")?, + number_threads_witness: parse_usize("ERE_ZISK_NUMBER_THREADS_WITNESS")?, + max_witness_stored: parse_usize("ERE_ZISK_MAX_WITNESS_STORED")?, }) } } pub struct LocalProver { - config: Config, - elf: Vec, - elf_hash: Hash, + prover: ZiskProver, + program: GuestProgram, program_vk: ZiskProgramVk, - prover_and_pk: Mutex, ZiskProgramPK)>>, + initialized: Mutex, } impl LocalProver { - pub fn new(elf: Vec, program_vk: ZiskProgramVk) -> Result { + pub fn new(elf: Elf, resource: &ProverResource) -> Result { let config = Config::from_env()?; - let elf_hash = blake3::hash(&elf); + let prover = build_prover(&config, resource)?; - let prover_and_pk = env::var_os("ERE_ZISK_SETUP_ON_INIT") - .map(|_| initialize(&config, &elf, elf_hash)) - .transpose()?; + let program = GuestProgram::from_bytes("guest", elf.0); + let program_vk = prover + .prover + .program_vk(&program, false) + .map_err(Error::Setup)?; + let program_vk = ZiskProgramVk::try_from(program_vk.vk.as_slice())?; + + if config.setup_on_init { + prover.setup(&program).run().map_err(Error::Setup)?; + } Ok(Self { - config, - elf, - elf_hash, + prover, + program, program_vk, - prover_and_pk: Mutex::new(prover_and_pk), + initialized: Mutex::new(config.setup_on_init), }) } - pub fn prove(&self, stdin: &[u8]) -> Result<(ZiskProof, Duration), Error> { - let mut guard = self.prover_and_pk.lock(); - - if guard.is_none() { - *guard = Some(initialize(&self.config, &self.elf, self.elf_hash)?) - } + pub fn program_vk(&self) -> ZiskProgramVk { + self.program_vk + } - let (prover, pk) = guard.as_ref().unwrap(); + pub fn prove(&self, input: &Input) -> Result<(ZiskProof, Duration), Error> { + let mut initialized = self.initialized.lock(); - let stdin = ZiskStdin::from_vec(stdin.to_vec()); - let tempdir = tempdir().map_err(CommonError::tempdir)?; - let mut opts = ProofOpts::default().output_dir(tempdir.path().to_path_buf()); - if self.config.minimal_memory { - opts = opts.minimal_memory(); + if !*initialized { + self.prover + .setup(&self.program) + .run() + .map_err(Error::Setup)?; + *initialized = true; } - let result = panic::catch_unwind(|| prover.prove(pk, stdin).with_proof_options(opts).run()); + let stdin = ZiskStdin::from_vec(framed_stdin(input.stdin())); - let (proof, proving_time) = match result { - Err(err) => { - uninitialize(guard); - Err(Error::ProvePanic(panic_msg(err))) - } + let started = Instant::now(); + let result = panic::catch_unwind(AssertUnwindSafe(|| { + self.prover + .prove(&self.program, stdin) + .wrap_proof(ProofKind::VadcopFinalMinimal) + .run() + })); + let proving_time = started.elapsed(); + + match result { + Ok(Ok(output)) => Ok((parse_proof(output.get_proof())?, proving_time)), Ok(Err(err)) => { - uninitialize(guard); + uninitialize(&self.prover, initialized); Err(Error::Prove(err)) } - Ok(Ok(result)) => Ok(( - extract_proof(result.get_proof_with_publics())?, - result.get_duration(), - )), - }?; - - ensure_program_vk_matches(self.program_vk, proof.program_vk)?; - - Ok((proof, proving_time)) + Err(panic) => { + uninitialize(&self.prover, initialized); + Err(Error::ProvePanic(panic_msg(panic))) + } + } } } -fn assembly_files_exist(elf_hash: Hash) -> bool { - ["mt", "rh", "mo"].into_iter().all(|suffix| { - let bin = cache_dir().join(format!("{ELF_NAME}-{elf_hash}-{suffix}.bin")); - bin.exists() - }) -} - -fn initialize( - config: &Config, - elf: &[u8], - elf_hash: Hash, -) -> Result<(ZiskProver, ZiskProgramPK), Error> { - info!("Initializing ZisK prover..."); - - fs::create_dir_all(cache_dir()) - .map_err(|err| CommonError::create_dir("cache", cache_dir(), err))?; - - if !assembly_files_exist(elf_hash) { - generate_assembly(elf, ELF_NAME, &cache_dir(), false, false) - .map_err(|error| Error::GenerateAssembly(error.to_string()))?; - }; - - let mut params_gpu = ParamsGPU::new(config.preallocate); +fn build_prover(config: &Config, resource: &ProverResource) -> Result, Error> { + let mut opts = BackendProverOpts::default(); + if matches!(resource, ProverResource::Gpu) { + opts = opts.gpu(); + } + if config.minimal_memory { + opts = opts.minimal_memory(); + } if let Some(max_streams) = config.max_streams { - params_gpu.with_max_number_streams(max_streams); + opts = opts.max_streams(max_streams); } if let Some(number_threads_witness) = config.number_threads_witness { - params_gpu.with_number_threads_pools_witness(number_threads_witness); + opts = opts.number_threads_witness(number_threads_witness); } if let Some(max_witness_stored) = config.max_witness_stored { - params_gpu.with_max_witness_stored(max_witness_stored); + opts = opts.max_witness_stored(max_witness_stored); } - let prover = ProverClientBuilder::new() + let mut asm_options = AsmOptions::default(); + if config.unlock_mapped_memory { + asm_options = asm_options.unlock_mapped_memory(); + } + opts = opts.with_asm_options(asm_options); + + ProverClientBuilder::new() .asm() - .gpu(Some(params_gpu)) - .unlock_mapped_memory(config.unlock_mapped_memory) - .shared_tables(config.shared_tables) + .with_prover_options(opts) .build() - .map_err(Error::InitProver)?; - - let elf_binary = ElfBinaryFromFile { - elf: elf.to_vec(), - name: ELF_NAME.to_string(), - with_hints: false, - path: None, - }; - let (pk, _) = prover.setup(&elf_binary).map_err(Error::SetupProver)?; - - info!("ZisK prover initialized"); - - Ok((prover, pk)) -} - -fn uninitialize(mut prover_and_pk: MutexGuard, ZiskProgramPK)>>) { - info!("Uninitializing ZisK prover..."); - - let _ = Command::new("fuser") - .args(["-k", "-9", "23115/tcp", "23116/tcp", "23117/tcp"]) - .output(); - sleep(Duration::from_secs(1)); - - drop(prover_and_pk.take()); - - info!("ZisK prover uninitialized"); + .map_err(Error::BuildProver) } -/// Extracts a typed [`ZiskProof`] from the SDK's [`ZiskProofWithPublicValues`]. -fn extract_proof(proof_with_publics: &ZiskProofWithPublicValues) -> Result { - let proof = if let zisk_sdk::ZiskProof::VadcopFinal(proof) = &proof_with_publics.proof { - if !proof.len().is_multiple_of(8) { - return Err(Error::InvalidProofFormat(format!( - "proof byte length {} is not a multiple of 8", - proof.len() - ))); - } - try_cast_slice(proof) - .map(<[u64]>::to_vec) - .unwrap_or_else(|_| { - proof - .chunks_exact(8) - .map(|bytes| u64::from_le_bytes(bytes.try_into().unwrap())) - .collect() - }) - } else { - return Err(Error::UnexpectedProofKind( - match &proof_with_publics.proof { - zisk_sdk::ZiskProof::Null() => "Null", - zisk_sdk::ZiskProof::VadcopFinalCompressed(_) => "VadcopFinalCompressed", - zisk_sdk::ZiskProof::Plonk(_) => "Plonk", - zisk_sdk::ZiskProof::Fflonk(_) => "Fflonk", - _ => "Unknown", - }, - )); - }; - - let program_vk = ZiskProgramVk::try_from(&proof_with_publics.program_vk.vk)?; - let mut public_values = [0u8; PUBLIC_VALUES_SIZE]; - proof_with_publics.publics.read_slice(&mut public_values); - - Ok(ZiskProof { - proof, - program_vk, - public_values, - }) +/// Clear the program cache so the next `setup` spawns fresh ASM services. +fn uninitialize(prover: &ZiskProver, mut initialized: MutexGuard) { + *initialized = false; + if let Err(err) = prover.prover.clear_program() { + warn!("failed to clear_program: {err}"); + } } -/// Returns path to `~/.zisk/cache` directory. -fn cache_dir() -> PathBuf { - dot_zisk_dir().join("cache") +fn parse_proof(proof: &Proof) -> Result { + let program_vk = ZiskProgramVk::try_from(proof.program_vk.vk.as_slice())?; + let mut public_values = [0u8; PUBLIC_VALUES_BYTES]; + proof.publics.head(); + proof.publics.read_slice(&mut public_values); + ZiskProof::from_parts(&program_vk, &public_values, &proof.proof_bytes) } From 844d56f69f92bfb168400ef7de893df5de948967 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 07:58:41 +0000 Subject: [PATCH 06/15] chore: update test guest --- tests/zisk/stock_nightly_no_std/src/memcpy.s | 2 +- tests/zisk/stock_nightly_no_std/src/memmove.s | 2 +- tests/zisk/stock_nightly_no_std/src/zisk.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/zisk/stock_nightly_no_std/src/memcpy.s b/tests/zisk/stock_nightly_no_std/src/memcpy.s index 662ea6de..4a5138ff 100644 --- a/tests/zisk/stock_nightly_no_std/src/memcpy.s +++ b/tests/zisk/stock_nightly_no_std/src/memcpy.s @@ -1,4 +1,4 @@ -# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.16.1/ziskos/entrypoint/src/dma/memcpy.s +# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.17.0/ziskos/entrypoint/src/dma/memcpy.s .section ".note.GNU-stack","",@progbits .text diff --git a/tests/zisk/stock_nightly_no_std/src/memmove.s b/tests/zisk/stock_nightly_no_std/src/memmove.s index e14adae2..30a4823a 100644 --- a/tests/zisk/stock_nightly_no_std/src/memmove.s +++ b/tests/zisk/stock_nightly_no_std/src/memmove.s @@ -1,4 +1,4 @@ -# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.16.1/ziskos/entrypoint/src/dma/memmove.s +# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.17.0/ziskos/entrypoint/src/dma/memmove.s .section ".note.GNU-stack","",@progbits .text diff --git a/tests/zisk/stock_nightly_no_std/src/zisk.rs b/tests/zisk/stock_nightly_no_std/src/zisk.rs index 6c620359..f4bb671c 100644 --- a/tests/zisk/stock_nightly_no_std/src/zisk.rs +++ b/tests/zisk/stock_nightly_no_std/src/zisk.rs @@ -5,7 +5,7 @@ unsafe extern "C" fn _zisk_main() { crate::main(); } -// According to https://github.com/0xPolygonHermez/zisk/blob/v0.16.1/ziskos/entrypoint/src/lib.rs#L232 +// According to https://github.com/0xPolygonHermez/zisk/blob/v0.17.0/ziskos/entrypoint/src/lib.rs#L294 core::arch::global_asm!( r#" .section .text.init @@ -46,7 +46,7 @@ unsafe impl GlobalAlloc for SimpleAlloc { #[global_allocator] static HEAP: SimpleAlloc = SimpleAlloc; -// According to https://github.com/0xPolygonHermez/zisk/blob/v0.16.1/ziskos/entrypoint/src/lib.rs#L241 +// According to https://github.com/0xPolygonHermez/zisk/blob/v0.17.0/ziskos/entrypoint/src/alloc/alloc.rs#L27 #[no_mangle] pub unsafe extern "C" fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8 { use core::arch::asm; From 0ccfab87272908bef6f18d221e2942c7b32e28d0 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 08:01:20 +0000 Subject: [PATCH 07/15] feat: update zisk cluster docker image and example --- .github/scripts/build-image.sh | 4 -- docker/zisk/Dockerfile.cluster | 86 ++---------------------- examples/zisk/docker-compose.cluster.yml | 72 ++++++++------------ 3 files changed, 33 insertions(+), 129 deletions(-) diff --git a/.github/scripts/build-image.sh b/.github/scripts/build-image.sh index 8913024a..aac5fec6 100755 --- a/.github/scripts/build-image.sh +++ b/.github/scripts/build-image.sh @@ -128,13 +128,11 @@ BASE_BUILD_ARGS=() BASE_ZKVM_BUILD_ARGS=(--build-arg "BASE_IMAGE=$BASE_IMAGE") COMPILER_ZKVM_BUILD_ARGS=(--build-arg "BASE_ZKVM_IMAGE=$BASE_ZKVM_IMAGE") SERVER_ZKVM_BUILD_ARGS=(--build-arg "BASE_ZKVM_IMAGE=$BASE_ZKVM_IMAGE") -CLUSTER_ZKVM_BUILD_ARGS=() if [ "$CUDA" = true ]; then BASE_BUILD_ARGS+=(--build-arg "CUDA=1") BASE_ZKVM_BUILD_ARGS+=(--build-arg "CUDA=1") SERVER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA=1") - CLUSTER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA=1") fi # Default CUDA_ARCHS when --cuda is set but --cuda-archs not specified @@ -167,7 +165,6 @@ if [ "$CUDA" = true ] && [ -n "$CUDA_ARCHS" ]; then zisk) BASE_ZKVM_BUILD_ARGS+=(--build-arg "CUDA_ARCHS=$CUDA_ARCHS") SERVER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA_ARCHS=$CUDA_ARCHS") - CLUSTER_ZKVM_BUILD_ARGS+=(--build-arg "CUDA_ARCHS=$CUDA_ARCHS") ;; *) ;; @@ -220,7 +217,6 @@ if [ "$BUILD_CLUSTER" = true ]; then docker build \ --file "docker/${ZKVM}/Dockerfile.cluster" \ --tag "$CLUSTER_ZKVM_IMAGE" \ - "${CLUSTER_ZKVM_BUILD_ARGS[@]}" \ . fi diff --git a/docker/zisk/Dockerfile.cluster b/docker/zisk/Dockerfile.cluster index c5280e29..94b37bc4 100644 --- a/docker/zisk/Dockerfile.cluster +++ b/docker/zisk/Dockerfile.cluster @@ -1,18 +1,7 @@ -ARG BASE_IMAGE=ubuntu:24.04 -ARG BASE_CUDA_IMAGE=nvidia/cuda:12.9.1-devel-ubuntu24.04 -ARG RUNTIME_IMAGE=ubuntu:24.04 -ARG RUNTIME_CUDA_IMAGE=nvidia/cuda:12.9.1-runtime-ubuntu24.04 - -# Whether to enable CUDA feature or not. -ARG CUDA - -FROM $BASE_IMAGE AS base -FROM $BASE_CUDA_IMAGE AS base_cuda -FROM base${CUDA:+_cuda} AS build_stage +FROM nvidia/cuda:12.9.1-runtime-ubuntu24.04 # Taken from https://0xpolygonhermez.github.io/zisk/getting_started/installation.html RUN apt-get update && apt-get install -y --no-install-recommends \ - git \ xz-utils \ jq \ curl \ @@ -34,80 +23,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libclang-dev \ clang \ gcc-riscv64-unknown-elf \ - libprotobuf-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* -# Install rustup -ARG RUST_VERSION=1.88.0 - ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_VERSION} --no-modify-path - -# Clone repo -WORKDIR /app - -RUN git clone https://github.com/han0110/zisk.git --depth 1 --branch patch/v0.16.1 /app - -# Whether to enable CUDA feature or not. -ARG CUDA - -# Env variable read by ZisK crate `proofman-starks-lib-c`, comma-separated numeric arch IDs (e.g. "120" or "89,120") -ARG CUDA_ARCHS=120 - -# Build binaries -RUN cargo build --release ${CUDA:+--features gpu} - -FROM $RUNTIME_IMAGE AS runtime -FROM $RUNTIME_CUDA_IMAGE AS runtime_cuda -FROM runtime${CUDA:+_cuda} AS runtime_stage - -# Taken from https://0xpolygonhermez.github.io/zisk/getting_started/installation.html -RUN apt-get update && apt-get install -y --no-install-recommends \ - xz-utils \ - jq \ - curl \ - build-essential \ - qemu-system \ - libomp-dev \ - libgmp-dev \ - nlohmann-json3-dev \ - protobuf-compiler \ - uuid-dev \ - libgrpc++-dev \ - libsecp256k1-dev \ - libsodium-dev \ - libpqxx-dev \ - nasm \ - libopenmpi-dev \ - openmpi-bin \ - openmpi-common \ - libclang-dev \ - clang \ - gcc-riscv64-unknown-elf \ - libprotobuf-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN curl -sSL https://github.com/fullstorydev/grpcurl/releases/download/v1.9.3/grpcurl_1.9.3_linux_x86_64.tar.gz \ - | tar -xz -C /usr/local/bin grpcurl - -WORKDIR /app - -# Copy script -COPY --from=build_stage /app/ziskup/ziskup /app/ziskup/ziskup - -# Copy binaries (to /usr/local/bin instead of ~/.zisk/bin because we want to mount ~/.zisk later) -COPY --from=build_stage /app/target/release/cargo-zisk /usr/local/bin/cargo-zisk -COPY --from=build_stage /app/target/release/zisk-coordinator /usr/local/bin/zisk-coordinator -COPY --from=build_stage /app/target/release/zisk-worker /usr/local/bin/zisk-worker - -# Copy proto for health check -COPY --from=build_stage /app/distributed/crates/grpc-api/proto/zisk_distributed_api.proto /app/proto/zisk_distributed_api.proto +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && \ + curl https://raw.githubusercontent.com/0xPolygonHermez/zisk/v0.17.0/ziskup/ziskup | USE_GPU=true SETUP_KEY=proving-no-consttree bash && \ + rm -rf /root/.zisk/provingKey && \ + rustup self uninstall -y -# Copy configs -COPY --from=build_stage /app/distributed/crates/coordinator/config/ /app/config/coordinator/ -COPY --from=build_stage /app/distributed/crates/worker/config/ /app/config/worker/ +ENV PATH=/root/.zisk/bin:$PATH CMD ["/bin/bash"] diff --git a/examples/zisk/docker-compose.cluster.yml b/examples/zisk/docker-compose.cluster.yml index b856315a..96e1d9d2 100644 --- a/examples/zisk/docker-compose.cluster.yml +++ b/examples/zisk/docker-compose.cluster.yml @@ -1,42 +1,36 @@ services: - zisk-setup: + zisk-download-proving-key: image: ghcr.io/eth-act/ere/ere-cluster-zisk:latest-cuda entrypoint: ["/bin/bash", "-c"] command: - | - set -e + set -euo pipefail - if [ ! -d "/root/.zisk/provingKey" ]; then - echo "Install rustup temporarily for ziskup..." - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none - source "$$HOME/.cargo/env" + if [ ! -d "/root/.zisk/provingKey/zisk" ]; then + ZISK_VERSION="0.17.0" + KEY_FILE="zisk-provingkey-$${ZISK_VERSION}.tar.gz" + BUCKET="https://storage.googleapis.com/zisk-setup" - echo "Download proving key..." - SETUP_KEY=proving-no-consttree /app/ziskup/ziskup + echo "Downloading proving key $${ZISK_VERSION}..." + cd /tmp + curl -fsSL -o "$${KEY_FILE}" "$${BUCKET}/$${KEY_FILE}" + curl -fsSL -o "$${KEY_FILE}.md5" "$${BUCKET}/$${KEY_FILE}.md5" + md5sum -c "$${KEY_FILE}.md5" - echo "Cleaning up rustup, cargo, toolchains and binaries..." - rustup self uninstall -y - rm -rf /root/.zisk/toolchains - rm /root/.zisk/bin/cargo-zisk - rm /root/.zisk/bin/riscv2zisk - rm /root/.zisk/bin/zisk-coordinator - rm /root/.zisk/bin/ziskemu - rm /root/.zisk/bin/ziskup - rm /root/.zisk/bin/zisk-worker + rm -rf /root/.zisk/provingKey/* /root/.zisk/provingKey/.[!.]* 2>/dev/null || true + rm -rf /root/.zisk/cache/* /root/.zisk/cache/.[!.]* 2>/dev/null || true - echo "Generating constant tree files (GPU). This may take a while..." - cargo-zisk check-setup -a + echo "Extracting proving key..." + tar --overwrite -xf "$${KEY_FILE}" -C /root/.zisk + rm -f "$${KEY_FILE}" "$${KEY_FILE}.md5" + + echo "Generating constant tree files..." + cargo-zisk check-setup --gpu else echo "Proving key already exists, skipping" fi - - echo "Running rom-setup..." - cargo-zisk rom-setup -e /app/elf - - echo "Setup complete" volumes: - - zisk-setup:/root/.zisk - - ${ELF_PATH}:/app/elf:ro + - zisk-proving-key:/root/.zisk/provingKey deploy: resources: reservations: @@ -49,18 +43,13 @@ services: image: ghcr.io/eth-act/ere/ere-cluster-zisk:latest-cuda command: - "zisk-coordinator" - - "--config" - - "/app/config/coordinator/prod.toml" ports: - - "50051:50051" - # volumes: - # Uncomment to override config - # - ./coordinator-config:/app/config/coordinator/prod.toml:ro + - "7000:7000" environment: - RUST_LOG=info - restart: unless-stopped + restart: unless-stopped healthcheck: - test: ["CMD", "grpcurl", "-plaintext", "-import-path", "/app/proto", "-proto", "zisk_distributed_api.proto", "localhost:50051", "zisk.distributed.api.v1.ZiskDistributedApi/HealthCheck"] + test: ["CMD", "curl", "-fsS", "http://localhost:9090/health"] interval: 30s timeout: 10s retries: 3 @@ -70,24 +59,17 @@ services: image: ghcr.io/eth-act/ere/ere-cluster-zisk:latest-cuda command: - "zisk-worker" - - "--config" - - "/app/config/worker/prod.toml" - "--coordinator-url" - "http://zisk-coordinator:50051" - - "--elf" - - "/app/elf" + - "--gpu" volumes: - # Mount proving key - - zisk-setup:/root/.zisk:ro - # Mount ELF + - zisk-proving-key:/root/.zisk/provingKey - ${ELF_PATH}:/app/elf:ro - # Uncomment to override config - # - ./worker-config:/app/config/worker/prod.toml:ro environment: - RUST_LOG=info restart: unless-stopped depends_on: - zisk-setup: + zisk-download-proving-key: condition: service_completed_successfully zisk-coordinator: condition: service_healthy @@ -122,7 +104,7 @@ services: # capabilities: [gpu] volumes: - zisk-setup: + zisk-proving-key: networks: default: From 1727c18c1b4fe50da36baa4316033dca5a8e62d6 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 08:01:36 +0000 Subject: [PATCH 08/15] chore: udpate README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c58f1721..bc379232 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Different zkVMs handles public values in different approaches: | OpenVM | [`1.4.3`](https://github.com/openvm-org/openvm/tree/v1.4.3) | `RV32IMA` | V | | | | Risc0 | [`3.0.5`](https://github.com/risc0/risc0/tree/v3.0.5) | `RV32IMA` | V | V | | | SP1 | [`6.1.0`](https://github.com/succinctlabs/sp1/tree/v6.1.0) | `RV64IMA` | V | | | -| Zisk | [`0.16.1`](https://github.com/0xPolygonHermez/zisk/tree/v0.16.1) | `RV64IMA` | V | V | V | +| Zisk | [`0.17.0`](https://github.com/0xPolygonHermez/zisk/tree/v0.17.0) | `RV64IMA` | V | V | V | ## Examples From d2a2c117091a0fe75c702df9bb812c4b60d09f8b Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 08:02:00 +0000 Subject: [PATCH 09/15] chore: sync Cargo.lock --- Cargo.lock | 606 ++++++++++++++++++++++++++++------------------------- 1 file changed, 326 insertions(+), 280 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f2a558a..7ddb5819 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,7 +293,7 @@ dependencies = [ "k256", "once_cell", "rand 0.8.6", - "secp256k1", + "secp256k1 0.30.0", "serde", "serde_json", "serde_with", @@ -1181,8 +1181,8 @@ dependencies = [ [[package]] name = "asm-runner" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", "libc", @@ -1193,8 +1193,8 @@ dependencies = [ "rayon", "thiserror 2.0.18", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] @@ -1304,6 +1304,16 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "aurora-engine-modexp" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "518bc5745a6264b5fd7b09dffb9667e400ee9e2bbe18555fac75e1fe9afa0df9" +dependencies = [ + "hex", + "num", +] + [[package]] name = "auto_impl" version = "1.3.0" @@ -1952,6 +1962,26 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.11.0", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.1", + "shlex", + "syn 2.0.117", +] + [[package]] name = "bit-set" version = "0.8.0" @@ -2327,16 +2357,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cargo-platform" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87a0c0e6148f11f01f32650a2ea02d532b2ad4e81d8bd41e6e565b5adc5e6082" -dependencies = [ - "serde", - "serde_core", -] - [[package]] name = "cargo_metadata" version = "0.18.1" @@ -2344,7 +2364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", - "cargo-platform 0.1.9", + "cargo-platform", "semver 1.0.27", "serde", "serde_json", @@ -2358,21 +2378,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" dependencies = [ "camino", - "cargo-platform 0.1.9", - "semver 1.0.27", - "serde", - "serde_json", - "thiserror 2.0.18", -] - -[[package]] -name = "cargo_metadata" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" -dependencies = [ - "camino", - "cargo-platform 0.3.2", + "cargo-platform", "semver 1.0.27", "serde", "serde_json", @@ -2461,13 +2467,13 @@ dependencies = [ [[package]] name = "circuit" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" [[package]] name = "circuit" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" [[package]] name = "clang-sys" @@ -2970,8 +2976,8 @@ dependencies = [ [[package]] name = "curves" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "fields", "num-bigint 0.4.6", @@ -3184,11 +3190,11 @@ dependencies = [ [[package]] name = "data-bus" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] @@ -3832,20 +3838,20 @@ dependencies = [ name = "ere-cluster-client-zisk" version = "0.8.1" dependencies = [ + "bincode 2.0.1", + "ere-compiler-core", "ere-prover-core", - "ere-util-tokio", "ere-verifier-zisk", - "futures-util", "http 1.4.0", "prost 0.14.3", "prost-types 0.14.3", + "serde", "tempfile", "thiserror 2.0.18", + "tokio", "tonic 0.14.5", "tonic-prost", "tonic-prost-build", - "tracing", - "uuid", ] [[package]] @@ -4010,7 +4016,6 @@ name = "ere-platform-zisk" version = "0.8.1" dependencies = [ "ere-platform-core", - "fnv", "ziskos", ] @@ -4107,8 +4112,6 @@ name = "ere-prover-zisk" version = "0.8.1" dependencies = [ "anyhow", - "blake3", - "bytemuck", "ere-cluster-client-zisk", "ere-compiler-core", "ere-compiler-zisk", @@ -4116,17 +4119,14 @@ dependencies = [ "ere-util-test", "ere-util-tokio", "ere-verifier-zisk", - "fields", - "mpi", "parking_lot", - "proofman-common", - "proofman-starks-lib-c", - "rom-setup", "tempfile", "thiserror 2.0.18", + "tokio", "tracing", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-sdk", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-prover-backend", "ziskemu", ] @@ -4298,10 +4298,8 @@ dependencies = [ "bytemuck", "ere-util-build", "ere-verifier-core", - "proofman-util", "proofman-verifier", "serde", - "serde-big-array", "thiserror 2.0.18", ] @@ -4349,8 +4347,8 @@ dependencies = [ [[package]] name = "executor" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", "asm-runner", @@ -4384,8 +4382,8 @@ dependencies = [ "sm-rom", "tracing", "witness", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", "ziskemu", ] @@ -4510,8 +4508,8 @@ dependencies = [ [[package]] name = "fields" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "cfg-if", "num-bigint 0.4.6", @@ -5922,23 +5920,23 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "lib-c" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" [[package]] name = "lib-c" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" [[package]] name = "lib-float" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" [[package]] name = "lib-float" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" [[package]] name = "libc" @@ -6278,8 +6276,8 @@ dependencies = [ [[package]] name = "mem-common" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "clap", "fields", @@ -6291,21 +6289,21 @@ dependencies = [ "rayon", "static_assertions", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "mem-planner-cpp" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "mem-common", "proofman-common", "proofman-util", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] @@ -6506,7 +6504,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f655543f54b263cbc3d2456bf714bd807d66a33eff8f70136687f0776d34f76" dependencies = [ - "bindgen", + "bindgen 0.69.5", "build-probe-mpi", "cc", ] @@ -8869,8 +8867,8 @@ dependencies = [ [[package]] name = "pil-std-lib" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "colored", "fields", @@ -9000,8 +8998,8 @@ dependencies = [ [[package]] name = "precomp-arith-eq" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "ark-bn254", "ark-ff 0.5.0", @@ -9010,14 +9008,14 @@ dependencies = [ "ark-std 0.5.0", "fields", "lazy_static", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "mem-common", "num-bigint 0.4.6", "num-traits", "path-clean", "pil-std-lib", "precompiles-common", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "proofman-common", "proofman-macros", "proofman-util", @@ -9030,15 +9028,15 @@ dependencies = [ "tracing", "typenum", "witness", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-arith-eq-384" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -9047,7 +9045,7 @@ dependencies = [ "ark-std 0.5.0", "fields", "lazy_static", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "mem-common", "num-bigint 0.4.6", "num-traits", @@ -9055,7 +9053,7 @@ dependencies = [ "pil-std-lib", "precomp-arith-eq", "precompiles-common", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "proofman-common", "proofman-macros", "proofman-util", @@ -9067,19 +9065,19 @@ dependencies = [ "tracing", "typenum", "witness", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-big-int" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "generic-array 0.14.9", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "mem-common", "pil-std-lib", "precompiles-common", @@ -9089,15 +9087,15 @@ dependencies = [ "rayon", "sm-mem", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-blake2" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", @@ -9109,23 +9107,23 @@ dependencies = [ "rayon", "sm-mem", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-dma" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "generic-array 0.14.9", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "mem-common", "pil-std-lib", "precompiles-common", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "proofman", "proofman-common", "proofman-macros", @@ -9133,37 +9131,37 @@ dependencies = [ "rayon", "sm-mem", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-keccakf" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ - "circuit 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "circuit 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "fields", "path-clean", "pil-std-lib", "precompiles-common", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "proofman-common", "proofman-macros", "proofman-util", "rayon", "tiny-keccak", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-poseidon2" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", @@ -9176,15 +9174,15 @@ dependencies = [ "sha2", "sm-mem", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precomp-sha256f" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", @@ -9196,27 +9194,27 @@ dependencies = [ "rayon", "sm-mem", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "precompiles-common" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", "sm-mem", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] name = "precompiles-helpers" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -9225,16 +9223,17 @@ dependencies = [ "ark-secp256r1", "ark-std 0.5.0", "cfg-if", - "circuit 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", - "lib-c 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "circuit 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "crunchy", + "lib-c 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "num-bigint 0.4.6", "num-traits", ] [[package]] name = "precompiles-helpers" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -9243,27 +9242,28 @@ dependencies = [ "ark-secp256r1", "ark-std 0.5.0", "cfg-if", - "circuit 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "circuit 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "crunchy", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "num-bigint 0.4.6", "num-traits", ] [[package]] name = "precompiles-hints" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", "borsh", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "rayon", "rustls 0.23.37", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-distributed-common", - "ziskos-hints 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-cluster-common", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "ziskos-hints 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] @@ -9348,8 +9348,8 @@ dependencies = [ [[package]] name = "proofman" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "bincode 1.3.3", "blake3", @@ -9383,8 +9383,8 @@ dependencies = [ [[package]] name = "proofman-common" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "bincode 1.3.3", "borsh", @@ -9415,8 +9415,8 @@ dependencies = [ [[package]] name = "proofman-hints" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "fields", "itoa", @@ -9428,8 +9428,8 @@ dependencies = [ [[package]] name = "proofman-macros" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "proc-macro2", "quote", @@ -9438,8 +9438,8 @@ dependencies = [ [[package]] name = "proofman-starks-lib-c" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "crossbeam-channel", "tracing", @@ -9447,8 +9447,8 @@ dependencies = [ [[package]] name = "proofman-util" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "bincode 1.3.3", "bytemuck", @@ -9459,8 +9459,8 @@ dependencies = [ [[package]] name = "proofman-verifier" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "bytemuck", "fields", @@ -10502,13 +10502,13 @@ dependencies = [ [[package]] name = "riscv" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" [[package]] name = "riscv" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" [[package]] name = "riscv-decode" @@ -10573,8 +10573,8 @@ dependencies = [ [[package]] name = "rom-setup" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", "blake3", @@ -10583,8 +10583,8 @@ dependencies = [ "proofman-common", "sm-rom", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] @@ -11039,10 +11039,21 @@ checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252" dependencies = [ "bitcoin_hashes", "rand 0.8.6", - "secp256k1-sys", + "secp256k1-sys 0.10.1", "serde", ] +[[package]] +name = "secp256k1" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2" +dependencies = [ + "bitcoin_hashes", + "rand 0.9.4", + "secp256k1-sys 0.11.0", +] + [[package]] name = "secp256k1-sys" version = "0.10.1" @@ -11052,6 +11063,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "3.7.0" @@ -11911,8 +11931,8 @@ dependencies = [ [[package]] name = "sm-arith" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "num-bigint 0.4.6", @@ -11925,15 +11945,15 @@ dependencies = [ "sm-frequent-ops", "static_assertions", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "sm-binary" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "num-bigint 0.4.6", @@ -11945,15 +11965,15 @@ dependencies = [ "sm-frequent-ops", "static_assertions", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "sm-frequent-ops" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "clap", "fields", @@ -11963,13 +11983,13 @@ dependencies = [ "rayon", "static_assertions", "tracing", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] name = "sm-main" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", @@ -11980,16 +12000,16 @@ dependencies = [ "proofman-util", "rayon", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", "ziskemu", ] [[package]] name = "sm-mem" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "mem-common", @@ -12002,16 +12022,17 @@ dependencies = [ "rayon", "tracing", "witness", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "sm-rom" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ + "anyhow", "asm-runner", "fields", "itertools 0.14.0", @@ -12020,8 +12041,8 @@ dependencies = [ "proofman-util", "rayon", "tracing", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] @@ -14941,8 +14962,8 @@ dependencies = [ [[package]] name = "witness" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.1#971209423e8fa53fa32dc747744d68c65aafa6c7" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.17.0#ff0e33a9b40f2467b35ef26aa2aabb4a624dfed3" dependencies = [ "colored", "fields", @@ -15162,143 +15183,134 @@ dependencies = [ ] [[package]] -name = "zisk-build" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +name = "zisk-cluster-common" +version = "0.1.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", - "cargo_metadata 0.23.1", - "clap", - "rom-setup", + "borsh", + "chrono", + "proofman", + "proofman-common", + "proofman-util", + "serde", + "serde_json", + "thiserror 2.0.18", "tracing", - "vergen-git2", + "tracing-appender", + "tracing-subscriber 0.3.23", + "uuid", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] name = "zisk-common" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ + "alloy-sol-types", "anyhow", "bincode 1.3.3", "fields", "libc", - "mpi", "proofman", "proofman-common", "proofman-util", + "proofman-verifier", "quinn", "rcgen", "rustls 0.23.37", "serde", "serde_json", + "sha2", "thiserror 2.0.18", "tokio", "tracing", "tracing-subscriber 0.3.23", - "zisk-core 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "zisk-core 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", ] [[package]] name = "zisk-common" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ + "alloy-sol-types", "anyhow", "bincode 1.3.3", "fields", "libc", - "mpi", "proofman", "proofman-common", "proofman-util", + "proofman-verifier", "quinn", "rcgen", "rustls 0.23.37", "serde", "serde_json", + "sha2", "thiserror 2.0.18", "tokio", "tracing", "tracing-subscriber 0.3.23", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] name = "zisk-core" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ "elf", "fields", - "lib-c 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", - "lib-float 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "lib-c 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "lib-float 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "paste", - "precompiles-helpers 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "rayon", - "riscv 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "riscv 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "serde", "sha2", "tiny-keccak", - "zisk-definitions 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", - "ziskos-hints 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "zisk-definitions 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "ziskos-hints 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", ] [[package]] name = "zisk-core" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "elf", "fields", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "lib-float 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "lib-float 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "paste", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "rayon", - "riscv 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "riscv 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "serde", "sha2", "tiny-keccak", - "zisk-definitions 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "ziskos-hints 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-definitions 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "ziskos-hints 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] name = "zisk-definitions" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" [[package]] name = "zisk-definitions" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" - -[[package]] -name = "zisk-distributed-common" -version = "0.1.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" -dependencies = [ - "anyhow", - "borsh", - "chrono", - "proofman", - "proofman-common", - "proofman-util", - "serde", - "serde_json", - "thiserror 2.0.18", - "tracing", - "tracing-appender", - "tracing-subscriber 0.3.23", - "uuid", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", -] +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" [[package]] name = "zisk-pil" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "fields", "proofman-common", @@ -15309,13 +15321,16 @@ dependencies = [ ] [[package]] -name = "zisk-sdk" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +name = "zisk-prover-backend" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ + "alloy-sol-types", "anyhow", "asm-runner", "bincode 1.3.3", + "blake3", + "borsh", "colored", "executor", "fields", @@ -15328,37 +15343,37 @@ dependencies = [ "serde", "sha2", "tracing", - "zisk-build", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-distributed-common", + "zisk-cluster-common", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "ziskemu", ] [[package]] name = "zisk-verifier" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ "proofman-verifier", ] [[package]] name = "zisk-verifier" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "proofman-verifier", ] [[package]] name = "ziskemu" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "clap", "data-bus", "fields", + "flate2", "mem-common", "memmap2", "num-format", @@ -15366,25 +15381,33 @@ dependencies = [ "proofman-common", "rayon", "regex", - "riscv 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "riscv 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "serde_json", "sm-arith", "sm-binary", "symbolic-common", "symbolic-demangle", "sysinfo 0.38.4", "vergen-git2", - "zisk-common 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", - "zisk-core 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-core 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zisk-definitions 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "zisk-pil", ] [[package]] name = "ziskos" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ "anyhow", + "ark-bn254", + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "aurora-engine-modexp", "bincode 1.3.3", + "blst", "bytes", "cfg-if", "critical-section", @@ -15394,28 +15417,31 @@ dependencies = [ "fields", "getrandom 0.2.17", "lazy_static", - "lib-c 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "lib-c 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "num-bigint 0.4.6", "num-integer", "num-traits", "once_cell", "paste", - "precompiles-helpers 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "rand 0.8.6", + "ripemd", + "secp256k1 0.31.1", "serde", "sha2", "talc", "tiny-keccak", "tokio", - "zisk-common 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", - "zisk-definitions 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", - "zisk-verifier 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "zisk-common 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "zisk-definitions 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "zisk-verifier 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "zkvm-interface 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", ] [[package]] name = "ziskos-hints" -version = "0.16.1" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1#48cf7ccefb5ed62261abf6bfb007b5be8a23c547" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" dependencies = [ "anyhow", "bincode 1.3.3", @@ -15423,23 +15449,25 @@ dependencies = [ "fields", "getrandom 0.2.17", "lazy_static", - "lib-c 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "lib-c 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "num-bigint 0.4.6", "num-integer", "num-traits", "paste", - "precompiles-helpers 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", "rand 0.8.6", + "ripemd", "serde", "sha2", "tiny-keccak", - "zisk-verifier 0.16.1 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.16.1)", + "zisk-verifier 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", + "zkvm-interface 0.17.0 (git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0)", ] [[package]] name = "ziskos-hints" -version = "0.16.1" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1#a5a5e21d2861bc49f5357e243ea72a839403416d" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" dependencies = [ "anyhow", "bincode 1.3.3", @@ -15447,17 +15475,19 @@ dependencies = [ "fields", "getrandom 0.2.17", "lazy_static", - "lib-c 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "lib-c 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "num-bigint 0.4.6", "num-integer", "num-traits", "paste", - "precompiles-helpers 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "precompiles-helpers 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", "rand 0.8.6", + "ripemd", "serde", "sha2", "tiny-keccak", - "zisk-verifier 0.16.1 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.1)", + "zisk-verifier 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", + "zkvm-interface 0.17.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0)", ] [[package]] @@ -15513,6 +15543,22 @@ dependencies = [ "subtle", ] +[[package]] +name = "zkvm-interface" +version = "0.17.0" +source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.17.0#b63274507a040bf9e09d22214df43066e8f80cb7" +dependencies = [ + "bindgen 0.72.1", +] + +[[package]] +name = "zkvm-interface" +version = "0.17.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.17.0#4019fa3ef32cabef4c93188029956c1efaba6654" +dependencies = [ + "bindgen 0.72.1", +] + [[package]] name = "zmij" version = "1.0.21" From c09e714f4820915b0c81f10cf4b3bc1e05d06a37 Mon Sep 17 00:00:00 2001 From: han0110 Date: Mon, 4 May 2026 09:59:05 +0000 Subject: [PATCH 10/15] fix: review --- crates/cluster-client/zisk/src/client.rs | 4 +- crates/prover/zisk/src/error.rs | 3 ++ crates/prover/zisk/src/sdk.rs | 4 +- crates/prover/zisk/src/sdk/local.rs | 12 +++++- crates/verifier/zisk/src/error.rs | 2 +- crates/verifier/zisk/src/proof.rs | 2 + crates/verifier/zisk/src/verifier.rs | 4 +- docker/zisk/Dockerfile.cluster | 1 - docker/zisk/Dockerfile.compiler | 2 + docker/zisk/Dockerfile.server | 2 +- examples/zisk/docker-compose.cluster.yml | 48 ---------------------- scripts/sdk_installers/install_zisk_sdk.sh | 8 +++- 12 files changed, 32 insertions(+), 60 deletions(-) diff --git a/crates/cluster-client/zisk/src/client.rs b/crates/cluster-client/zisk/src/client.rs index fcfd2bb1..2b8ede27 100644 --- a/crates/cluster-client/zisk/src/client.rs +++ b/crates/cluster-client/zisk/src/client.rs @@ -5,7 +5,7 @@ use core::time::Duration; use bincode::error::DecodeError; use ere_compiler_core::Elf; use ere_prover_core::{Input, RemoteProverConfig, zkVMVerifier}; -use ere_verifier_zisk::{ZiskProgramVk, ZiskProof, ZiskVerifier}; +use ere_verifier_zisk::{PUBLIC_VALUES_BYTES, ZiskProgramVk, ZiskProof, ZiskVerifier}; use serde::{Deserialize, Serialize}; use tokio::time::Instant; use tonic::transport::Channel; @@ -246,7 +246,7 @@ fn parse_proof(bytes: &[u8]) -> Result { bincode::serde::borrow_decode_from_slice(bytes, bincode::config::legacy())?; let program_vk = ZiskProgramVk::try_from(proof.program_vk.vk.as_slice())?; - let public_values = <[u8; _]>::try_from(proof.publics.data) + let public_values = <[u8; PUBLIC_VALUES_BYTES]>::try_from(proof.publics.data) .map_err(|_| DecodeError::Other("invalid public values length"))?; Ok(ZiskProof::from_parts( &program_vk, diff --git a/crates/prover/zisk/src/error.rs b/crates/prover/zisk/src/error.rs index e0483638..9284ba0a 100644 --- a/crates/prover/zisk/src/error.rs +++ b/crates/prover/zisk/src/error.rs @@ -27,6 +27,9 @@ pub enum Error { #[error("Build prover failed: {0}")] BuildProver(#[source] anyhow::Error), + #[error("Compute program VK failed: {0}")] + ComputeProgramVk(#[source] anyhow::Error), + #[error("Setup failed: {0}")] Setup(#[source] anyhow::Error), diff --git a/crates/prover/zisk/src/sdk.rs b/crates/prover/zisk/src/sdk.rs index ca7c17bb..dacadecf 100644 --- a/crates/prover/zisk/src/sdk.rs +++ b/crates/prover/zisk/src/sdk.rs @@ -112,9 +112,9 @@ impl ZiskSdk { })?, }; - let (progam_vk, public_values) = proof.to_parts()?; + let (program_vk, public_values) = proof.to_parts()?; - ensure_program_vk_matches(self.program_vk(), progam_vk)?; + ensure_program_vk_matches(self.program_vk(), program_vk)?; Ok((public_values.into(), proof, proving_time)) } diff --git a/crates/prover/zisk/src/sdk/local.rs b/crates/prover/zisk/src/sdk/local.rs index 2463ef44..248eefe2 100644 --- a/crates/prover/zisk/src/sdk/local.rs +++ b/crates/prover/zisk/src/sdk/local.rs @@ -1,6 +1,8 @@ use std::{ env, panic::{self, AssertUnwindSafe}, + process::Command, + thread::sleep, time::{Duration, Instant}, }; @@ -67,7 +69,7 @@ impl LocalProver { let program_vk = prover .prover .program_vk(&program, false) - .map_err(Error::Setup)?; + .map_err(Error::ComputeProgramVk)?; let program_vk = ZiskProgramVk::try_from(program_vk.vk.as_slice())?; if config.setup_on_init { @@ -153,12 +155,18 @@ fn build_prover(config: &Config, resource: &ProverResource) -> Result, mut initialized: MutexGuard) { *initialized = false; if let Err(err) = prover.prover.clear_program() { warn!("failed to clear_program: {err}"); } + let pid = std::process::id(); + let _ = Command::new("pkill") + .args(["-f", "--", &format!("--shm_prefix ZISK_{pid}_")]) + .output(); + sleep(Duration::from_secs(1)); } fn parse_proof(proof: &Proof) -> Result { diff --git a/crates/verifier/zisk/src/error.rs b/crates/verifier/zisk/src/error.rs index 29e7fa9e..f347c6bf 100644 --- a/crates/verifier/zisk/src/error.rs +++ b/crates/verifier/zisk/src/error.rs @@ -16,7 +16,7 @@ pub enum Error { #[error("Invalid proof format: {0}")] InvalidProofFormat(String), - /// `verify_vadcop_final_proof` returned false. + /// `verify_vadcop_final_compressed_bytes` returned false. #[error("Invalid proof")] InvalidProof, diff --git a/crates/verifier/zisk/src/proof.rs b/crates/verifier/zisk/src/proof.rs index 1d8711cc..28aa4813 100644 --- a/crates/verifier/zisk/src/proof.rs +++ b/crates/verifier/zisk/src/proof.rs @@ -16,6 +16,8 @@ const PROOF_BODY_BYTES: usize = 8 * PROOF_BODY_WORDS; const PROOF_WORDS: usize = 1 + PROOF_PREFIX_WORDS + PROOF_BODY_WORDS; /// Zisk VadcopFinalMinimal proof in u64 words. +/// +/// Proof layout in `[n_publics (1), program_vk (4), public_values (64), proof_body (32594)]`. #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(transparent)] pub struct ZiskProof(pub Vec); diff --git a/crates/verifier/zisk/src/verifier.rs b/crates/verifier/zisk/src/verifier.rs index f6e33e70..d62c83d2 100644 --- a/crates/verifier/zisk/src/verifier.rs +++ b/crates/verifier/zisk/src/verifier.rs @@ -47,9 +47,9 @@ impl zkVMVerifier for ZiskVerifier { } fn verify(&self, proof: &ZiskProof) -> Result { - let (progam_vk, public_values) = proof.to_parts()?; + let (program_vk, public_values) = proof.to_parts()?; - ensure_program_vk_matches(self.program_vk, progam_vk)?; + ensure_program_vk_matches(self.program_vk, program_vk)?; let proof_bytes = proof.as_bytes()?; let vk_bytes = cast_slice(&VADCOP_FINAL_MINIMAL_VK); diff --git a/docker/zisk/Dockerfile.cluster b/docker/zisk/Dockerfile.cluster index 94b37bc4..f6395407 100644 --- a/docker/zisk/Dockerfile.cluster +++ b/docker/zisk/Dockerfile.cluster @@ -31,7 +31,6 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && \ curl https://raw.githubusercontent.com/0xPolygonHermez/zisk/v0.17.0/ziskup/ziskup | USE_GPU=true SETUP_KEY=proving-no-consttree bash && \ - rm -rf /root/.zisk/provingKey && \ rustup self uninstall -y ENV PATH=/root/.zisk/bin:$PATH diff --git a/docker/zisk/Dockerfile.compiler b/docker/zisk/Dockerfile.compiler index c0e32f80..6ccc6018 100644 --- a/docker/zisk/Dockerfile.compiler +++ b/docker/zisk/Dockerfile.compiler @@ -21,6 +21,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ nasm \ libgmp-dev \ + libclang-dev \ + clang \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Copy Rust diff --git a/docker/zisk/Dockerfile.server b/docker/zisk/Dockerfile.server index e19f5174..498530cc 100644 --- a/docker/zisk/Dockerfile.server +++ b/docker/zisk/Dockerfile.server @@ -53,7 +53,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libclang-dev \ clang \ # Used to kill the ASM services when prover panics - psmisc \ + procps \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Copy ZisK SDK diff --git a/examples/zisk/docker-compose.cluster.yml b/examples/zisk/docker-compose.cluster.yml index 96e1d9d2..ca6c68d5 100644 --- a/examples/zisk/docker-compose.cluster.yml +++ b/examples/zisk/docker-compose.cluster.yml @@ -1,44 +1,4 @@ services: - zisk-download-proving-key: - image: ghcr.io/eth-act/ere/ere-cluster-zisk:latest-cuda - entrypoint: ["/bin/bash", "-c"] - command: - - | - set -euo pipefail - - if [ ! -d "/root/.zisk/provingKey/zisk" ]; then - ZISK_VERSION="0.17.0" - KEY_FILE="zisk-provingkey-$${ZISK_VERSION}.tar.gz" - BUCKET="https://storage.googleapis.com/zisk-setup" - - echo "Downloading proving key $${ZISK_VERSION}..." - cd /tmp - curl -fsSL -o "$${KEY_FILE}" "$${BUCKET}/$${KEY_FILE}" - curl -fsSL -o "$${KEY_FILE}.md5" "$${BUCKET}/$${KEY_FILE}.md5" - md5sum -c "$${KEY_FILE}.md5" - - rm -rf /root/.zisk/provingKey/* /root/.zisk/provingKey/.[!.]* 2>/dev/null || true - rm -rf /root/.zisk/cache/* /root/.zisk/cache/.[!.]* 2>/dev/null || true - - echo "Extracting proving key..." - tar --overwrite -xf "$${KEY_FILE}" -C /root/.zisk - rm -f "$${KEY_FILE}" "$${KEY_FILE}.md5" - - echo "Generating constant tree files..." - cargo-zisk check-setup --gpu - else - echo "Proving key already exists, skipping" - fi - volumes: - - zisk-proving-key:/root/.zisk/provingKey - deploy: - resources: - reservations: - devices: - - driver: nvidia - device_ids: ['0'] - capabilities: [gpu] - zisk-coordinator: image: ghcr.io/eth-act/ere/ere-cluster-zisk:latest-cuda command: @@ -62,15 +22,10 @@ services: - "--coordinator-url" - "http://zisk-coordinator:50051" - "--gpu" - volumes: - - zisk-proving-key:/root/.zisk/provingKey - - ${ELF_PATH}:/app/elf:ro environment: - RUST_LOG=info restart: unless-stopped depends_on: - zisk-download-proving-key: - condition: service_completed_successfully zisk-coordinator: condition: service_healthy shm_size: 32G @@ -103,8 +58,5 @@ services: # device_ids: ['x'] # capabilities: [gpu] -volumes: - zisk-proving-key: - networks: default: diff --git a/scripts/sdk_installers/install_zisk_sdk.sh b/scripts/sdk_installers/install_zisk_sdk.sh index dd089e74..83735d6a 100755 --- a/scripts/sdk_installers/install_zisk_sdk.sh +++ b/scripts/sdk_installers/install_zisk_sdk.sh @@ -30,6 +30,12 @@ ensure_tool_installed "bash" "to run the ziskup installer" ensure_tool_installed "rustup" "for managing Rust toolchains (ZisK installs its own)" ensure_tool_installed "cargo" "to pre-build lib-c" +if [ -n "$CUDA" ]; then + export USE_GPU=true +else + export USE_GPU=fasle +fi + # Step 1: Download and run the script that installs the ziskup binary itself. # Export SETUP_KEY=proving-no-consttree to download proving key without doing setup. export ZISK_VERSION="0.17.0" @@ -47,6 +53,6 @@ unset SETUP_KEY # re-used as long as the `ziskos` has the same version. WORKSPACE=$(mktemp -d) cargo init "$WORKSPACE" --name build-lib-c -cargo add lib-c --git https://github.com/han0110/zisk.git --branch "patch/v$ZISK_VERSION" --manifest-path "$WORKSPACE/Cargo.toml" +cargo add lib-c --git https://github.com/0xPolygonHermez/zisk.git --tag "v$ZISK_VERSION" --manifest-path "$WORKSPACE/Cargo.toml" cargo build --manifest-path "$WORKSPACE/Cargo.toml" rm -rf "$WORKSPACE" From 39b0534d3b325e77f2841fa120c15b9dd6d766f3 Mon Sep 17 00:00:00 2001 From: han0110 Date: Tue, 5 May 2026 02:56:46 +0000 Subject: [PATCH 11/15] fix: multiple zisk prover instances --- Cargo.lock | 1 + Cargo.toml | 1 + crates/prover/zisk/Cargo.toml | 1 + crates/prover/zisk/src/sdk/local.rs | 13 +++++++++---- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ddb5819..d288d2a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4119,6 +4119,7 @@ dependencies = [ "ere-util-test", "ere-util-tokio", "ere-verifier-zisk", + "once_cell", "parking_lot", "tempfile", "thiserror 2.0.18", diff --git a/Cargo.toml b/Cargo.toml index c2f9a409..fbd11470 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,6 +75,7 @@ indexmap = "2.10.0" metrics = "0.24" metrics-exporter-prometheus = { version = "0.18", default-features = false } mpi = "0.8.0" +once_cell = "1.21" opentelemetry = "0.31" opentelemetry-otlp = "0.31" opentelemetry_sdk = "0.31" diff --git a/crates/prover/zisk/Cargo.toml b/crates/prover/zisk/Cargo.toml index 4e1f455d..f1f156c0 100644 --- a/crates/prover/zisk/Cargo.toml +++ b/crates/prover/zisk/Cargo.toml @@ -7,6 +7,7 @@ license.workspace = true [dependencies] anyhow.workspace = true +once_cell.workspace = true parking_lot.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["time"] } diff --git a/crates/prover/zisk/src/sdk/local.rs b/crates/prover/zisk/src/sdk/local.rs index 248eefe2..994bf95d 100644 --- a/crates/prover/zisk/src/sdk/local.rs +++ b/crates/prover/zisk/src/sdk/local.rs @@ -9,6 +9,7 @@ use std::{ use ere_compiler_core::Elf; use ere_prover_core::{Input, ProverResource}; use ere_verifier_zisk::{PUBLIC_VALUES_BYTES, ZiskProgramVk, ZiskProof}; +use once_cell::sync::OnceCell; use parking_lot::{Mutex, MutexGuard}; use tracing::warn; use zisk_common::{Proof, ProofKind, io::ZiskStdin}; @@ -21,6 +22,10 @@ use crate::{ sdk::{framed_stdin, panic_msg}, }; +// Use a shared prover instance to avoid `MpiCtx` get initialized twice, to support multiple +// `ZiskProver` instances creation (e.g. testing different ELFs). +static LOCAL_PROVER: OnceCell> = OnceCell::new(); + struct Config { setup_on_init: bool, unlock_mapped_memory: bool, @@ -54,7 +59,7 @@ impl Config { } pub struct LocalProver { - prover: ZiskProver, + prover: &'static ZiskProver, program: GuestProgram, program_vk: ZiskProgramVk, initialized: Mutex, @@ -63,7 +68,7 @@ pub struct LocalProver { impl LocalProver { pub fn new(elf: Elf, resource: &ProverResource) -> Result { let config = Config::from_env()?; - let prover = build_prover(&config, resource)?; + let prover = LOCAL_PROVER.get_or_try_init(|| build_prover(&config, resource))?; let program = GuestProgram::from_bytes("guest", elf.0); let program_vk = prover @@ -113,11 +118,11 @@ impl LocalProver { match result { Ok(Ok(output)) => Ok((parse_proof(output.get_proof())?, proving_time)), Ok(Err(err)) => { - uninitialize(&self.prover, initialized); + uninitialize(self.prover, initialized); Err(Error::Prove(err)) } Err(panic) => { - uninitialize(&self.prover, initialized); + uninitialize(self.prover, initialized); Err(Error::ProvePanic(panic_msg(panic))) } } From 5de18679ad4b8de21a55a6b55950dadabb0b067e Mon Sep 17 00:00:00 2001 From: han0110 Date: Tue, 5 May 2026 04:28:25 +0000 Subject: [PATCH 12/15] chore: fix typo --- scripts/sdk_installers/install_zisk_sdk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sdk_installers/install_zisk_sdk.sh b/scripts/sdk_installers/install_zisk_sdk.sh index 83735d6a..0d444ac7 100755 --- a/scripts/sdk_installers/install_zisk_sdk.sh +++ b/scripts/sdk_installers/install_zisk_sdk.sh @@ -33,7 +33,7 @@ ensure_tool_installed "cargo" "to pre-build lib-c" if [ -n "$CUDA" ]; then export USE_GPU=true else - export USE_GPU=fasle + export USE_GPU=false fi # Step 1: Download and run the script that installs the ziskup binary itself. From 8a4761aa8c50e2c10fe0571c3fc04bce9d076bd2 Mon Sep 17 00:00:00 2001 From: han0110 Date: Tue, 5 May 2026 04:32:48 +0000 Subject: [PATCH 13/15] chore: refine --- scripts/sdk_installers/install_zisk_sdk.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/sdk_installers/install_zisk_sdk.sh b/scripts/sdk_installers/install_zisk_sdk.sh index 0d444ac7..aaf85df9 100755 --- a/scripts/sdk_installers/install_zisk_sdk.sh +++ b/scripts/sdk_installers/install_zisk_sdk.sh @@ -30,15 +30,11 @@ ensure_tool_installed "bash" "to run the ziskup installer" ensure_tool_installed "rustup" "for managing Rust toolchains (ZisK installs its own)" ensure_tool_installed "cargo" "to pre-build lib-c" -if [ -n "$CUDA" ]; then - export USE_GPU=true -else - export USE_GPU=false -fi - # Step 1: Download and run the script that installs the ziskup binary itself. +# Export USE_GPU to download pre-built cargo-zisk and zisk-worker with or without cuda support. # Export SETUP_KEY=proving-no-consttree to download proving key without doing setup. export ZISK_VERSION="0.17.0" +export USE_GPU=$([ -n "$CUDA" ] && echo true || echo false) export SETUP_KEY=${SETUP_KEY:=proving-no-consttree} curl "https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh" | bash unset SETUP_KEY From 62303edeb6cc7cddc6c3797f467999773540e3c1 Mon Sep 17 00:00:00 2001 From: han0110 Date: Tue, 5 May 2026 07:00:03 +0000 Subject: [PATCH 14/15] feat: compile time check for cuda feature --- crates/prover/zisk/.gitignore | 1 - crates/prover/zisk/build.rs | 22 ++++++++++++++++++++++ crates/prover/zisk/src/error.rs | 3 +++ crates/prover/zisk/src/sdk.rs | 11 ++++++++++- crates/prover/zisk/src/sdk/local.rs | 2 +- 5 files changed, 36 insertions(+), 3 deletions(-) delete mode 100644 crates/prover/zisk/.gitignore create mode 100644 crates/prover/zisk/build.rs diff --git a/crates/prover/zisk/.gitignore b/crates/prover/zisk/.gitignore deleted file mode 100644 index 5538f553..00000000 --- a/crates/prover/zisk/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zisk_prover_server.log \ No newline at end of file diff --git a/crates/prover/zisk/build.rs b/crates/prover/zisk/build.rs new file mode 100644 index 00000000..4be423f8 --- /dev/null +++ b/crates/prover/zisk/build.rs @@ -0,0 +1,22 @@ +use std::{ + env, + path::Path, + process::{self, Command}, +}; + +fn main() { + println!("cargo:rerun-if-env-changed=PATH"); + + if env::var("CARGO_FEATURE_CUDA").is_ok() && !nvcc_exists() { + eprintln!("`cuda` feature requires `nvcc` at /usr/local/cuda/bin/nvcc or on PATH."); + process::exit(1); + } +} + +fn nvcc_exists() -> bool { + Path::new("/usr/local/cuda/bin/nvcc").exists() + || Command::new("nvcc") + .arg("--version") + .status() + .is_ok_and(|status| status.success()) +} diff --git a/crates/prover/zisk/src/error.rs b/crates/prover/zisk/src/error.rs index 9284ba0a..93ef2884 100644 --- a/crates/prover/zisk/src/error.rs +++ b/crates/prover/zisk/src/error.rs @@ -39,6 +39,9 @@ pub enum Error { #[error("Prove panicked: {0}")] ProvePanic(String), + #[error("Enable `cuda` feature to use `ProverResource::Gpu`")] + CudaFeatureDisabled, + // Cluster #[error(transparent)] Cluster(#[from] ere_cluster_client_zisk::Error), diff --git a/crates/prover/zisk/src/sdk.rs b/crates/prover/zisk/src/sdk.rs index dacadecf..7cc67253 100644 --- a/crates/prover/zisk/src/sdk.rs +++ b/crates/prover/zisk/src/sdk.rs @@ -28,6 +28,7 @@ enum Backend { } pub struct ZiskSdk { + resource: ProverResource, backend: Backend, rom: ZiskRom, } @@ -67,7 +68,11 @@ impl ZiskSdk { } }; - Ok(Self { backend, rom }) + Ok(Self { + resource, + backend, + rom, + }) } pub fn program_vk(&self) -> ZiskProgramVk { @@ -101,6 +106,10 @@ impl ZiskSdk { } pub fn prove(&self, input: &Input) -> Result<(PublicValues, ZiskProof, Duration), Error> { + if cfg!(not(feature = "cuda")) && self.resource == ProverResource::Gpu { + return Err(Error::CudaFeatureDisabled); + } + let (proof, proving_time) = match &self.backend { Backend::Local(local) => local.prove(input)?, Backend::Cluster { diff --git a/crates/prover/zisk/src/sdk/local.rs b/crates/prover/zisk/src/sdk/local.rs index 994bf95d..ca59f3d6 100644 --- a/crates/prover/zisk/src/sdk/local.rs +++ b/crates/prover/zisk/src/sdk/local.rs @@ -131,7 +131,7 @@ impl LocalProver { fn build_prover(config: &Config, resource: &ProverResource) -> Result, Error> { let mut opts = BackendProverOpts::default(); - if matches!(resource, ProverResource::Gpu) { + if cfg!(feature = "cuda") && matches!(resource, ProverResource::Gpu) { opts = opts.gpu(); } if config.minimal_memory { From 1810ac4e0ccbc8690e742edbe966c48bd52d7c88 Mon Sep 17 00:00:00 2001 From: han0110 Date: Tue, 5 May 2026 14:38:02 +0000 Subject: [PATCH 15/15] feat: add cycle-scope feature in ere-platform-zisk --- crates/platform/zisk/Cargo.toml | 2 ++ crates/platform/zisk/src/platform.rs | 36 +++++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/platform/zisk/Cargo.toml b/crates/platform/zisk/Cargo.toml index 3dfaf886..8b0e5b9b 100644 --- a/crates/platform/zisk/Cargo.toml +++ b/crates/platform/zisk/Cargo.toml @@ -21,6 +21,8 @@ zisk-embedded-alloc = ["ziskos/zisk-embedded-alloc"] zisk-embedded-dlmalloc-alloc = ["ziskos/zisk-embedded-dlmalloc-alloc"] zisk-embedded-talc-alloc = ["ziskos/zisk-embedded-talc-alloc"] zisk-embedded-tlfs-alloc = ["ziskos/zisk-embedded-tlfs-alloc"] +# NOTE: This enables `cycle_scope_*` to emit profile syscalls, the generated ELF can NOT be proved by ASM prover. +cycle-scope = [] [lints] workspace = true diff --git a/crates/platform/zisk/src/platform.rs b/crates/platform/zisk/src/platform.rs index abef6115..378958ee 100644 --- a/crates/platform/zisk/src/platform.rs +++ b/crates/platform/zisk/src/platform.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use core::ops::Deref; use ere_platform_core::{LengthPrefixedStdin, Platform}; @@ -33,22 +35,28 @@ impl Platform for ZiskPlatform { } fn cycle_scope_start(_name: &str) { - // FIXME: Uncomment when ZisK support profile opcode in program setup - // #[cfg(all(target_os = "zkvm", target_vendor = "zisk"))] - // ziskos::ziskos_syscall!( - // ziskos::SYSCALL_PROFILE_ID, - // ziskos::PROFILE_REPORT_START_COST_ID, - // &_name as *const &str as usize - // ); + // NOTE: If the profile syscall is emitted, the ELF can NOT be proved by ASM prover. + #[cfg(all( + feature = "cycle-scope", + all(target_os = "zkvm", target_vendor = "zisk") + ))] + ziskos::ziskos_syscall!( + ziskos::SYSCALL_PROFILE_ID, + ziskos::PROFILE_REPORT_START_COST_ID, + &_name as *const &str as usize + ); } fn cycle_scope_end(_name: &str) { - // FIXME: Uncomment when ZisK support profile opcode in program setup - // #[cfg(all(target_os = "zkvm", target_vendor = "zisk"))] - // ziskos::ziskos_syscall!( - // ziskos::SYSCALL_PROFILE_ID, - // ziskos::PROFILE_REPORT_END_COST_ID, - // &_name as *const &str as usize - // ) + // NOTE: If the profile syscall is emitted, the ELF can NOT be proved by ASM prover. + #[cfg(all( + feature = "cycle-scope", + all(target_os = "zkvm", target_vendor = "zisk") + ))] + ziskos::ziskos_syscall!( + ziskos::SYSCALL_PROFILE_ID, + ziskos::PROFILE_REPORT_END_COST_ID, + &_name as *const &str as usize + ) } }