Skip to content

Commit 42221c9

Browse files
committed
fix
1 parent 6b4c106 commit 42221c9

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", tag =
2424
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2", features = ["scroll", "rkyv"] }
2525
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2" }
2626
sbv-core = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2", features = ["scroll"] }
27-
axiom-sdk = { git = "https://github.com/axiom-crypto/axiom-api-cli.git", branch = "feat/upload-exe-raw" }
27+
axiom-sdk = { git = "https://github.com/axiom-crypto/axiom-api-cli.git", tag = "v1.0.9" }
2828

2929
alloy = { version = "1", default-features = false }
3030
alloy-primitives = { version = "1.4.1", default-features = false, features = ["tiny-keccak"] }

crates/prover-bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tokio = { workspace = true, features = ["full"] }
2626
async-trait = "0.1"
2727
clap = { version = "4.5", features = ["derive"] }
2828
url = { version = "2.5.4", features = ["serde"] }
29+
tempfile = "3.24"
2930

3031
[features]
3132
default = []

crates/prover-bin/src/prover/axiom.rs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::zk_circuits_handler::universal::UniversalHandler;
22
use async_trait::async_trait;
33
use axiom_sdk::{
4-
AxiomConfig, AxiomSdk, ProofType as AxiomProofType, SaveOption,
4+
AxiomSdk, ProofType as AxiomProofType,
55
build::BuildSdk,
66
input::Input as AxiomInput,
77
prove::{ProveArgs, ProveSdk},
@@ -23,17 +23,22 @@ use scroll_zkvm_types::{
2323
proof::{OpenVmEvmProof, OpenVmVersionedVmStarkProof, ProofEnum},
2424
};
2525
use serde::{Deserialize, Serialize};
26-
use std::{collections::HashMap, fs::File, path::Path};
26+
use std::{collections::HashMap, fs::File, io::Write, path::Path};
27+
use tempfile::NamedTempFile;
2728
use tracing::Level;
2829

2930
#[derive(Debug, Clone, Serialize, Deserialize)]
3031
pub struct AxiomProverConfig {
31-
#[serde(rename = "axiom_api_key")]
32-
pub api_key: String,
32+
pub axiom: AxiomConfig,
3333
pub sdk_config: SdkConfig,
34+
}
35+
36+
#[derive(Debug, Clone, Serialize, Deserialize)]
37+
pub struct AxiomConfig {
38+
pub api_key: String,
3439
// vk to program mapping
35-
#[serde(rename = "axiom_programs")]
3640
pub programs: HashMap<String, AxiomProgram>,
41+
pub num_gpus: Option<usize>,
3742
}
3843

3944
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -110,9 +115,9 @@ impl AxiomProver {
110115
config_id: Option<String>,
111116
req: impl FnOnce(AxiomSdk) -> eyre::Result<R> + Send + 'static,
112117
) -> eyre::Result<R> {
113-
let api_key = self.config.api_key.clone();
118+
let api_key = self.config.axiom.api_key.clone();
114119
tokio::task::spawn_blocking(move || {
115-
let config = AxiomConfig {
120+
let config = axiom_sdk::AxiomConfig {
116121
api_key: Some(api_key),
117122
config_id,
118123
..Default::default()
@@ -130,6 +135,7 @@ impl AxiomProver {
130135
let vk = hex::encode(vk);
131136
debug!(vk = %vk);
132137
self.config
138+
.axiom
133139
.programs
134140
.get(vk.as_str())
135141
.cloned()
@@ -146,8 +152,13 @@ impl AxiomProver {
146152
let prover_task: ProvingTask = prover_task.into();
147153

148154
let program = self.get_program(&prover_task.vk)?;
155+
let num_gpus = self.config.axiom.num_gpus;
156+
157+
let mut input_file = NamedTempFile::new()?;
158+
let input = prover_task.build_openvm_input();
159+
serde_json::to_writer(&mut input_file, &input)?;
160+
input_file.flush()?;
149161

150-
let input = serde_json::to_value(prover_task.build_openvm_input())?;
151162
let proof_type = if req.proof_type == ProofType::Bundle {
152163
AxiomProofType::Evm
153164
} else {
@@ -165,9 +176,9 @@ impl AxiomProver {
165176
.make_axiom_request(Some(program.config_id), move |sdk| {
166177
sdk.generate_new_proof(ProveArgs {
167178
program_id: Some(program.program_id.clone()),
168-
input: Some(AxiomInput::Value(input)),
179+
input: Some(AxiomInput::FilePath(input_file.path().to_path_buf())),
169180
proof_type: Some(proof_type),
170-
num_gpus: Some(4),
181+
num_gpus,
171182
priority: None,
172183
})
173184
})
@@ -208,11 +219,13 @@ impl AxiomProver {
208219

209220
let axiom_proof_type: AxiomProofType = status.proof_type.parse()?;
210221
let proof = if status.state == "Succeeded" {
211-
Some(sdk.get_generated_proof(
222+
let file = NamedTempFile::new()?;
223+
sdk.get_generated_proof(
212224
&status.id,
213225
&axiom_proof_type,
214-
SaveOption::DoNotSave,
215-
)?)
226+
Some(file.path().to_path_buf()),
227+
)?;
228+
Some(file)
216229
} else {
217230
None
218231
};
@@ -296,14 +309,14 @@ impl AxiomProver {
296309
}
297310
}
298311

299-
if let Some(proof_bytes) = proof {
312+
if let Some(proof_file) = proof {
300313
let proof = match proof_type {
301314
ProofType::Bundle => {
302-
let proof: OpenVmEvmProof = serde_json::from_slice(&proof_bytes)?;
315+
let proof: OpenVmEvmProof = serde_json::from_reader(proof_file)?;
303316
ProofEnum::Evm(proof.into())
304317
}
305318
_ => {
306-
let proof: OpenVmVersionedVmStarkProof = serde_json::from_slice(&proof_bytes)?;
319+
let proof: OpenVmVersionedVmStarkProof = serde_json::from_reader(proof_file)?;
307320
ProofEnum::Stark(proof.try_into()?)
308321
}
309322
};

0 commit comments

Comments
 (0)